update to monero core v0.16.0.0 nitrogen nebula

remove is_rct on submit tx result
only incoming transfers have num_suggested_confirmations
update docs
add to readme: git checkout tags/v0.16.0.0 for monero-core
This commit is contained in:
woodser
2020-05-28 14:05:15 -04:00
parent 94cf7dc869
commit 9342a67dde
21 changed files with 209 additions and 221 deletions
+2 -2
View File
@@ -319,8 +319,8 @@ namespace monero {
else if (key == std::string("prunedHex")) tx->m_pruned_hex = it->second.data();
else if (key == std::string("prunableHex")) tx->m_prunable_hex = it->second.data();
else if (key == std::string("prunableHash")) tx->m_prunable_hash = it->second.data();
else if (key == std::string("size")) throw std::runtime_error("size deserialization not implemented");
else if (key == std::string("weight")) throw std::runtime_error("weight deserialization not implemented");
else if (key == std::string("size")) tx->m_size = it->second.get_value<uint64_t>();
else if (key == std::string("weight")) tx->m_weight = it->second.get_value<uint64_t>();
else if (key == std::string("inputs")) throw std::runtime_error("inputs deserializationn not implemented");
else if (key == std::string("outputs")) throw std::runtime_error("outputs deserializationn not implemented");
else if (key == std::string("outputIndices")) throw std::runtime_error("m_output_indices deserialization not implemented");
+32 -35
View File
@@ -234,11 +234,6 @@ namespace monero {
outgoing_transfer->m_amount = amount;
}
// compute m_num_suggested_confirmations TODO monero core: this logic is based on wallet_rpc_server.cpp:87 but it should be encapsulated in wallet2
uint64_t block_reward = m_w2.get_last_block_reward();
if (block_reward == 0) outgoing_transfer->m_num_suggested_confirmations = 0;
else outgoing_transfer->m_num_suggested_confirmations = (*outgoing_transfer->m_amount + block_reward - 1) / block_reward;
// return pointer to new tx
return tx;
}
@@ -339,11 +334,6 @@ namespace monero {
outgoing_transfer->m_amount = amount;
}
// compute num_suggested_confirmations TODO monero core: this logic is based on wallet_rpc_server.cpp:87 but it should be encapsulated in wallet2
uint64_t block_reward = m_w2.get_last_block_reward();
if (block_reward == 0) outgoing_transfer->m_num_suggested_confirmations = 0;
else outgoing_transfer->m_num_suggested_confirmations = (*outgoing_transfer->m_amount + block_reward - 1) / block_reward;
// return pointer to new tx
return tx;
}
@@ -622,7 +612,7 @@ namespace monero {
//------------------------------------------------------------------------------------------------------------------------------
template<typename Ts, typename Tu>
bool fill_response(wallet2* m_w2, std::vector<tools::wallet2::pending_tx> &ptx_vector,
bool get_tx_key, Ts& tx_key, Tu &amount, Tu &fee, std::string &multisig_txset, std::string &unsigned_txset, bool do_not_relay,
bool get_tx_key, Ts& tx_key, Tu &amount, Tu &fee, Tu &weight, std::string &multisig_txset, std::string &unsigned_txset, bool do_not_relay,
Ts &tx_hash, bool get_tx_hex, Ts &tx_blob, bool get_tx_metadata, Ts &tx_metadata, epee::json_rpc::error &er)
{
for (const auto & ptx : ptx_vector)
@@ -637,6 +627,7 @@ namespace monero {
// Compute amount leaving wallet in tx. By convention dests does not include change outputs
fill(amount, total_amount(ptx));
fill(fee, ptx.fee);
fill(weight, cryptonote::get_transaction_weight(ptx.tx));
}
if (m_w2->multisig())
@@ -720,7 +711,7 @@ namespace monero {
m_sync_end_height = boost::none;
}
void on_new_block(uint64_t height, const cryptonote::block& cn_block) {
void on_new_block(uint64_t height, const cryptonote::block& cn_block) override {
if (m_wallet.get_listeners().empty()) return;
// ignore notifications before sync start height, irrelevant to clients
@@ -740,7 +731,7 @@ namespace monero {
}
}
void on_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& cn_tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index) {
void on_unconfirmed_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& cn_tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index) override {
if (m_wallet.get_listeners().empty()) return;
// create library tx
@@ -763,7 +754,7 @@ namespace monero {
tx.reset();
}
void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& cn_tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index, uint64_t unlock_time) {
void on_money_received(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& cn_tx, uint64_t amount, const cryptonote::subaddress_index& subaddr_index, bool is_change, uint64_t unlock_time) override {
if (m_wallet.get_listeners().empty()) return;
// create native library tx
@@ -792,7 +783,7 @@ namespace monero {
tx.reset();
}
void on_money_spent(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& cn_tx_in, uint64_t amount, const cryptonote::transaction& cn_tx_out, const cryptonote::subaddress_index& subaddr_index) {
void on_money_spent(uint64_t height, const crypto::hash &txid, const cryptonote::transaction& cn_tx_in, uint64_t amount, const cryptonote::transaction& cn_tx_out, const cryptonote::subaddress_index& subaddr_index) override {
if (m_wallet.get_listeners().empty()) return;
if (&cn_tx_in != &cn_tx_out) throw std::runtime_error("on_money_spent() in tx is different than out tx");
@@ -819,23 +810,11 @@ namespace monero {
monero_utils::free(block);
output.reset();
tx.reset();
// TODO **: to notify or not to notify?
// std::string tx_hash = epee::string_tools::pod_to_hex(txid);
// LOG_PRINT_L3(__FUNCTION__ << ": money spent. height: " << height
// << ", tx: " << tx_hash
// << ", amount: " << print_money(amount)
// << ", idx: " << subaddr_index);
// // do not signal on sent tx if wallet is not syncronized completely
// if (m_listener && m_wallet->synchronized()) {
// m_listener->moneySpent(tx_hash, amount);
// m_listener->updated();
// }
}
private:
monero_wallet_core& m_wallet; // wallet to provide context for notifications
tools::wallet2& m_w2; // internal wallet implementation to listen to
monero_wallet_core& m_wallet; // wallet to provide context for notifications
tools::wallet2& m_w2; // internal wallet implementation to listen to
boost::optional<uint64_t> m_sync_start_height;
boost::optional<uint64_t> m_sync_end_height;
};
@@ -1664,12 +1643,13 @@ namespace monero {
std::list<std::string> tx_keys;
std::list<uint64_t> tx_amounts;
std::list<uint64_t> tx_fees;
std::list<uint64_t> tx_weights;
std::string multisig_tx_hex;
std::string unsigned_tx_hex;
std::list<std::string> tx_hashes;
std::list<std::string> tx_blobs;
std::list<std::string> tx_metadatas;
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_hex, unsigned_tx_hex, !relay, tx_hashes, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, err)) {
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, tx_weights, multisig_tx_hex, unsigned_tx_hex, !relay, tx_hashes, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, err)) {
throw std::runtime_error("need to handle error filling response!"); // TODO
}
@@ -1679,6 +1659,7 @@ namespace monero {
auto tx_keys_iter = tx_keys.begin();
auto tx_amounts_iter = tx_amounts.begin();
auto tx_fees_iter = tx_fees.begin();
auto tx_weights_iter = tx_weights.begin();
auto tx_blobs_iter = tx_blobs.begin();
auto tx_metadatas_iter = tx_metadatas.begin();
while (tx_fees_iter != tx_fees.end()) {
@@ -1689,6 +1670,7 @@ namespace monero {
tx->m_hash = *tx_hashes_iter;
tx->m_key = *tx_keys_iter;
tx->m_fee = *tx_fees_iter;
tx->m_weight = *tx_weights_iter;
tx->m_full_hex = *tx_blobs_iter;
tx->m_metadata = *tx_metadatas_iter;
std::shared_ptr<monero_outgoing_transfer> out_transfer = std::make_shared<monero_outgoing_transfer>();
@@ -1846,12 +1828,13 @@ namespace monero {
std::list<std::string> tx_keys;
std::list<uint64_t> tx_amounts;
std::list<uint64_t> tx_fees;
std::list<uint64_t> tx_weights;
std::string multisig_tx_hex;
std::string unsigned_tx_hex;
std::list<std::string> tx_hashes;
std::list<std::string> tx_blobs;
std::list<std::string> tx_metadatas;
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_hex, unsigned_tx_hex, !relay, tx_hashes, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, err)) {
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, tx_weights, multisig_tx_hex, unsigned_tx_hex, !relay, tx_hashes, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, err)) {
throw std::runtime_error("need to handle error filling response!"); // TODO
}
@@ -1861,6 +1844,7 @@ namespace monero {
auto tx_keys_iter = tx_keys.begin();
auto tx_amounts_iter = tx_amounts.begin();
auto tx_fees_iter = tx_fees.begin();
auto tx_weights_iter = tx_weights.begin();
auto tx_blobs_iter = tx_blobs.begin();
auto tx_metadatas_iter = tx_metadatas.begin();
while (tx_fees_iter != tx_fees.end()) {
@@ -1873,6 +1857,7 @@ namespace monero {
tx->m_is_outgoing = true;
tx->m_key = *tx_keys_iter;
tx->m_fee = *tx_fees_iter;
tx->m_weight = *tx_weights_iter;
tx->m_full_hex = *tx_blobs_iter;
tx->m_metadata = *tx_metadatas_iter;
std::shared_ptr<monero_outgoing_transfer> out_transfer = std::make_shared<monero_outgoing_transfer>();
@@ -1966,12 +1951,13 @@ namespace monero {
std::list<std::string> tx_keys;
std::list<uint64_t> tx_amounts;
std::list<uint64_t> tx_fees;
std::list<uint64_t> tx_weights;
std::string multisig_tx_hex;
std::string unsigned_tx_hex;
std::list<std::string> tx_hashes;
std::list<std::string> tx_blobs;
std::list<std::string> tx_metadatas;
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_hex, unsigned_tx_hex, !relay, tx_hashes, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, err)) {
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, tx_weights, multisig_tx_hex, unsigned_tx_hex, !relay, tx_hashes, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, err)) {
throw std::runtime_error("need to handle error filling response!"); // TODO: return err message
}
@@ -1981,6 +1967,7 @@ namespace monero {
auto tx_keys_iter = tx_keys.begin();
auto tx_amounts_iter = tx_amounts.begin();
auto tx_fees_iter = tx_fees.begin();
auto tx_weights_iter = tx_weights.begin();
auto tx_blobs_iter = tx_blobs.begin();
auto tx_metadatas_iter = tx_metadatas.begin();
while (tx_fees_iter != tx_fees.end()) {
@@ -1992,6 +1979,7 @@ namespace monero {
tx->m_is_outgoing = true;
tx->m_key = *tx_keys_iter;
tx->m_fee = *tx_fees_iter;
tx->m_weight = *tx_weights_iter;
tx->m_full_hex = *tx_blobs_iter;
tx->m_metadata = *tx_metadatas_iter;
std::shared_ptr<monero_outgoing_transfer> out_transfer = std::make_shared<monero_outgoing_transfer>();
@@ -2053,13 +2041,14 @@ namespace monero {
std::list<std::string> tx_keys;
std::list<uint64_t> tx_amounts;
std::list<uint64_t> tx_fees;
std::list<uint64_t> tx_weights;
std::string multisig_tx_hex;
std::string unsigned_tx_hex;
std::list<std::string> tx_hashes;
std::list<std::string> tx_blobs;
std::list<std::string> tx_metadatas;
epee::json_rpc::error er;
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_hex, unsigned_tx_hex, !relay, tx_hashes, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, er)) {
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, tx_weights, multisig_tx_hex, unsigned_tx_hex, !relay, tx_hashes, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, er)) {
throw std::runtime_error("need to handle error filling response!"); // TODO: return err message
}
@@ -2069,6 +2058,7 @@ namespace monero {
auto tx_keys_iter = tx_keys.begin();
auto tx_amounts_iter = tx_amounts.begin();
auto tx_fees_iter = tx_fees.begin();
auto tx_weights_iter = tx_weights.begin();
auto tx_blobs_iter = tx_blobs.begin();
auto tx_metadatas_iter = tx_metadatas.begin();
while (tx_fees_iter != tx_fees.end()) {
@@ -2080,6 +2070,7 @@ namespace monero {
tx->m_is_outgoing = true;
tx->m_key = *tx_keys_iter;
tx->m_fee = *tx_fees_iter;
tx->m_weight = *tx_weights_iter;
tx->m_full_hex = *tx_blobs_iter;
tx->m_metadata = *tx_metadatas_iter;
std::shared_ptr<monero_outgoing_transfer> out_transfer = std::make_shared<monero_outgoing_transfer>();
@@ -2622,14 +2613,20 @@ namespace monero {
if (indices.empty()) {
uint64_t idx = 0;
for (const auto &w2_entry: w2_entries) {
monero_address_book_entry entry(idx++, cryptonote::get_account_address_as_str(m_w2->nettype(), w2_entry.m_is_subaddress, w2_entry.m_address), w2_entry.m_description, epee::string_tools::pod_to_hex(w2_entry.m_payment_id));
std::string address;
if (w2_entry.m_has_payment_id) address = cryptonote::get_account_integrated_address_as_str(m_w2->nettype(), w2_entry.m_address, w2_entry.m_payment_id);
else address = get_account_address_as_str(m_w2->nettype(), w2_entry.m_is_subaddress, w2_entry.m_address);
monero_address_book_entry entry(idx++, address, w2_entry.m_description);
entries.push_back(entry);
}
} else {
for (uint64_t idx : indices) {
if (idx >= w2_entries.size()) throw std::runtime_error("Index out of range: " + std::to_string(idx));
const auto &w2_entry = w2_entries[idx];
monero_address_book_entry entry(idx++, cryptonote::get_account_address_as_str(m_w2->nettype(), w2_entry.m_is_subaddress, w2_entry.m_address), w2_entry.m_description, epee::string_tools::pod_to_hex(w2_entry.m_payment_id));
std::string address;
if (w2_entry.m_has_payment_id) address = cryptonote::get_account_integrated_address_as_str(m_w2->nettype(), w2_entry.m_address, w2_entry.m_payment_id);
else address = get_account_address_as_str(m_w2->nettype(), w2_entry.m_is_subaddress, w2_entry.m_address);
monero_address_book_entry entry(idx++, address, w2_entry.m_description);
entries.push_back(entry);
}
}
+4 -7
View File
@@ -621,7 +621,6 @@ namespace monero {
rapidjson::Value value_num(rapidjson::kNumberType);
if (m_amount != boost::none) monero_utils::addJsonMember("amount", m_amount.get(), allocator, root, value_num);
if (m_account_index != boost::none) monero_utils::addJsonMember("accountIndex", m_account_index.get(), allocator, root, value_num);
if (m_num_suggested_confirmations != boost::none) monero_utils::addJsonMember("numSuggestedConfirmations", m_num_suggested_confirmations.get(), allocator, root, value_num);
// return root
return root;
@@ -641,7 +640,6 @@ namespace monero {
tgt->m_tx = src->m_tx; // reference parent tx by default
tgt->m_amount = src->m_amount;
tgt->m_account_index = src->m_account_index;
tgt->m_num_suggested_confirmations = src->m_num_suggested_confirmations;
return tgt;
}
@@ -658,14 +656,11 @@ namespace monero {
// otherwise merge transfer fields
m_account_index = gen_utils::reconcile(m_account_index, other->m_account_index, "acountIndex");
// TODO monero core: failed m_tx in pool (after testUpdateLockedDifferentAccounts()) causes non-originating saved wallets to return duplicate incoming transfers but one has amount/m_num_suggested_confirmations of 0
// TODO monero core: failed m_tx in pool (after testUpdateLockedDifferentAccounts()) causes non-originating saved wallets to return duplicate incoming transfers but one has amount of 0
if (m_amount != boost::none && other->m_amount != boost::none && *m_amount != *other->m_amount && (*m_amount == 0 || *other->m_amount == 0)) {
m_account_index = gen_utils::reconcile(m_account_index, other->m_account_index, boost::none, boost::none, true, "acountIndex");
m_num_suggested_confirmations = gen_utils::reconcile(m_num_suggested_confirmations, other->m_num_suggested_confirmations, boost::none, boost::none, true, "m_num_suggested_confirmations");
MWARNING("WARNING: failed tx in pool causes non-originating wallets to return duplicate incoming transfers but with one amount/m_num_suggested_confirmations of 0");
throw std::runtime_error("failed tx in pool causes non-originating wallets to return duplicate incoming transfers but with one amount/m_num_suggested_confirmations of 0");
} else {
m_amount = gen_utils::reconcile(m_amount, other->m_amount, "transfer amount");
m_num_suggested_confirmations = gen_utils::reconcile(m_num_suggested_confirmations, other->m_num_suggested_confirmations, boost::none, boost::none, false, "m_num_suggested_confirmations");
}
}
@@ -679,6 +674,7 @@ namespace monero {
// set num values
rapidjson::Value value_num(rapidjson::kNumberType);
if (m_subaddress_index != boost::none) monero_utils::addJsonMember("subaddressIndex", m_subaddress_index.get(), allocator, root, value_num);
if (m_num_suggested_confirmations != boost::none) monero_utils::addJsonMember("numSuggestedConfirmations", m_num_suggested_confirmations.get(), allocator, root, value_num);
// set std::string values
rapidjson::Value value_str(rapidjson::kStringType);
@@ -708,6 +704,7 @@ namespace monero {
monero_transfer::merge(self, other);
m_subaddress_index = gen_utils::reconcile(m_subaddress_index, other->m_subaddress_index, "incoming transfer m_subaddress_index");
m_address = gen_utils::reconcile(m_address, other->m_address);
m_num_suggested_confirmations = gen_utils::reconcile(m_num_suggested_confirmations, other->m_num_suggested_confirmations, boost::none, boost::none, false, "m_num_suggested_confirmations");
}
// ----------------------- MONERO OUTGOING TRANSFER -------------------------
+2 -1
View File
@@ -131,7 +131,6 @@ namespace monero {
std::shared_ptr<monero_tx_wallet> m_tx;
boost::optional<uint64_t> m_amount;
boost::optional<uint32_t> m_account_index;
boost::optional<uint64_t> m_num_suggested_confirmations;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr<monero_transfer>& transfer);
@@ -150,6 +149,7 @@ namespace monero {
struct monero_incoming_transfer : public monero_transfer {
boost::optional<uint32_t> m_subaddress_index;
boost::optional<std::string> m_address;
boost::optional<uint64_t> m_num_suggested_confirmations;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
std::shared_ptr<monero_incoming_transfer> copy(const std::shared_ptr<monero_transfer>& src, const std::shared_ptr<monero_transfer>& tgt) const;
@@ -452,6 +452,7 @@ namespace monero {
boost::optional<std::string> m_payment_id;
monero_address_book_entry() {}
monero_address_book_entry(uint64_t index, const std::string& address, const std::string& description) : m_index(index), m_address(address), m_description(description) {}
monero_address_book_entry(uint64_t index, const std::string& address, const std::string& description, const std::string& payment_id) : m_index(index), m_address(address), m_description(description), m_payment_id(payment_id) {}
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
};