Merge pull request #6102

b328de6b wallet_rpc_server: add tx weight in transfer commands responses (moneromooo-monero)
This commit is contained in:
Alexander Blair 2020-02-06 00:32:47 -08:00
commit 756f06cd83
No known key found for this signature in database
GPG key ID: C64552D877C32479
3 changed files with 18 additions and 7 deletions

View file

@ -863,7 +863,7 @@ namespace tools
//------------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------------
template<typename Ts, typename Tu> template<typename Ts, typename Tu>
bool wallet_rpc_server::fill_response(std::vector<tools::wallet2::pending_tx> &ptx_vector, bool wallet_rpc_server::fill_response(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) 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) for (const auto & ptx : ptx_vector)
@ -878,6 +878,7 @@ namespace tools
// Compute amount leaving wallet in tx. By convention dests does not include change outputs // Compute amount leaving wallet in tx. By convention dests does not include change outputs
fill(amount, total_amount(ptx)); fill(amount, total_amount(ptx));
fill(fee, ptx.fee); fill(fee, ptx.fee);
fill(weight, cryptonote::get_transaction_weight(ptx.tx));
} }
if (m_wallet->multisig()) if (m_wallet->multisig())
@ -963,7 +964,7 @@ namespace tools
return false; return false;
} }
return fill_response(ptx_vector, req.get_tx_key, res.tx_key, res.amount, res.fee, res.multisig_txset, res.unsigned_txset, req.do_not_relay, return fill_response(ptx_vector, req.get_tx_key, res.tx_key, res.amount, res.fee, res.weight, res.multisig_txset, res.unsigned_txset, req.do_not_relay,
res.tx_hash, req.get_tx_hex, res.tx_blob, req.get_tx_metadata, res.tx_metadata, er); res.tx_hash, req.get_tx_hex, res.tx_blob, req.get_tx_metadata, res.tx_metadata, er);
} }
catch (const std::exception& e) catch (const std::exception& e)
@ -1009,7 +1010,7 @@ namespace tools
return false; return false;
} }
return fill_response(ptx_vector, req.get_tx_keys, res.tx_key_list, res.amount_list, res.fee_list, res.multisig_txset, res.unsigned_txset, req.do_not_relay, return fill_response(ptx_vector, req.get_tx_keys, res.tx_key_list, res.amount_list, res.fee_list, res.weight_list, res.multisig_txset, res.unsigned_txset, req.do_not_relay,
res.tx_hash_list, req.get_tx_hex, res.tx_blob_list, req.get_tx_metadata, res.tx_metadata_list, er); res.tx_hash_list, req.get_tx_hex, res.tx_blob_list, req.get_tx_metadata, res.tx_metadata_list, er);
} }
catch (const std::exception& e) catch (const std::exception& e)
@ -1373,7 +1374,7 @@ namespace tools
{ {
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_unmixable_sweep_transactions(); std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_unmixable_sweep_transactions();
return fill_response(ptx_vector, req.get_tx_keys, res.tx_key_list, res.amount_list, res.fee_list, res.multisig_txset, res.unsigned_txset, req.do_not_relay, return fill_response(ptx_vector, req.get_tx_keys, res.tx_key_list, res.amount_list, res.fee_list, res.weight_list, res.multisig_txset, res.unsigned_txset, req.do_not_relay,
res.tx_hash_list, req.get_tx_hex, res.tx_blob_list, req.get_tx_metadata, res.tx_metadata_list, er); res.tx_hash_list, req.get_tx_hex, res.tx_blob_list, req.get_tx_metadata, res.tx_metadata_list, er);
} }
catch (const std::exception& e) catch (const std::exception& e)
@ -1420,7 +1421,7 @@ namespace tools
uint32_t priority = m_wallet->adjust_priority(req.priority); uint32_t priority = m_wallet->adjust_priority(req.priority);
std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_all(req.below_amount, dsts[0].addr, dsts[0].is_subaddress, req.outputs, mixin, req.unlock_time, priority, extra, req.account_index, req.subaddr_indices); std::vector<wallet2::pending_tx> ptx_vector = m_wallet->create_transactions_all(req.below_amount, dsts[0].addr, dsts[0].is_subaddress, req.outputs, mixin, req.unlock_time, priority, extra, req.account_index, req.subaddr_indices);
return fill_response(ptx_vector, req.get_tx_keys, res.tx_key_list, res.amount_list, res.fee_list, res.multisig_txset, res.unsigned_txset, req.do_not_relay, return fill_response(ptx_vector, req.get_tx_keys, res.tx_key_list, res.amount_list, res.fee_list, res.weight_list, res.multisig_txset, res.unsigned_txset, req.do_not_relay,
res.tx_hash_list, req.get_tx_hex, res.tx_blob_list, req.get_tx_metadata, res.tx_metadata_list, er); res.tx_hash_list, req.get_tx_hex, res.tx_blob_list, req.get_tx_metadata, res.tx_metadata_list, er);
} }
catch (const std::exception& e) catch (const std::exception& e)
@ -1495,7 +1496,7 @@ namespace tools
return false; return false;
} }
return fill_response(ptx_vector, req.get_tx_key, res.tx_key, res.amount, res.fee, res.multisig_txset, res.unsigned_txset, req.do_not_relay, return fill_response(ptx_vector, req.get_tx_key, res.tx_key, res.amount, res.fee, res.weight, res.multisig_txset, res.unsigned_txset, req.do_not_relay,
res.tx_hash, req.get_tx_hex, res.tx_blob, req.get_tx_metadata, res.tx_metadata, er); res.tx_hash, req.get_tx_hex, res.tx_blob, req.get_tx_metadata, res.tx_metadata, er);
} }
catch (const std::exception& e) catch (const std::exception& e)

View file

@ -257,7 +257,7 @@ namespace tools
template<typename Ts, typename Tu> template<typename Ts, typename Tu>
bool fill_response(std::vector<tools::wallet2::pending_tx> &ptx_vector, bool fill_response(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); Ts &tx_hash, bool get_tx_hex, Ts &tx_blob, bool get_tx_metadata, Ts &tx_metadata, epee::json_rpc::error &er);
bool validate_transfer(const std::list<wallet_rpc::transfer_destination>& destinations, const std::string& payment_id, std::vector<cryptonote::tx_destination_entry>& dsts, std::vector<uint8_t>& extra, bool at_least_one_destination, epee::json_rpc::error& er); bool validate_transfer(const std::list<wallet_rpc::transfer_destination>& destinations, const std::string& payment_id, std::vector<cryptonote::tx_destination_entry>& dsts, std::vector<uint8_t>& extra, bool at_least_one_destination, epee::json_rpc::error& er);

View file

@ -490,6 +490,7 @@ namespace wallet_rpc
std::string tx_key; std::string tx_key;
uint64_t amount; uint64_t amount;
uint64_t fee; uint64_t fee;
uint64_t weight;
std::string tx_blob; std::string tx_blob;
std::string tx_metadata; std::string tx_metadata;
std::string multisig_txset; std::string multisig_txset;
@ -500,6 +501,7 @@ namespace wallet_rpc
KV_SERIALIZE(tx_key) KV_SERIALIZE(tx_key)
KV_SERIALIZE(amount) KV_SERIALIZE(amount)
KV_SERIALIZE(fee) KV_SERIALIZE(fee)
KV_SERIALIZE(weight)
KV_SERIALIZE(tx_blob) KV_SERIALIZE(tx_blob)
KV_SERIALIZE(tx_metadata) KV_SERIALIZE(tx_metadata)
KV_SERIALIZE(multisig_txset) KV_SERIALIZE(multisig_txset)
@ -556,6 +558,7 @@ namespace wallet_rpc
std::list<std::string> tx_key_list; std::list<std::string> tx_key_list;
std::list<uint64_t> amount_list; std::list<uint64_t> amount_list;
std::list<uint64_t> fee_list; std::list<uint64_t> fee_list;
std::list<uint64_t> weight_list;
std::list<std::string> tx_blob_list; std::list<std::string> tx_blob_list;
std::list<std::string> tx_metadata_list; std::list<std::string> tx_metadata_list;
std::string multisig_txset; std::string multisig_txset;
@ -566,6 +569,7 @@ namespace wallet_rpc
KV_SERIALIZE(tx_key_list) KV_SERIALIZE(tx_key_list)
KV_SERIALIZE(amount_list) KV_SERIALIZE(amount_list)
KV_SERIALIZE(fee_list) KV_SERIALIZE(fee_list)
KV_SERIALIZE(weight_list)
KV_SERIALIZE(tx_blob_list) KV_SERIALIZE(tx_blob_list)
KV_SERIALIZE(tx_metadata_list) KV_SERIALIZE(tx_metadata_list)
KV_SERIALIZE(multisig_txset) KV_SERIALIZE(multisig_txset)
@ -729,6 +733,7 @@ namespace wallet_rpc
std::list<std::string> tx_key_list; std::list<std::string> tx_key_list;
std::list<uint64_t> amount_list; std::list<uint64_t> amount_list;
std::list<uint64_t> fee_list; std::list<uint64_t> fee_list;
std::list<uint64_t> weight_list;
std::list<std::string> tx_blob_list; std::list<std::string> tx_blob_list;
std::list<std::string> tx_metadata_list; std::list<std::string> tx_metadata_list;
std::string multisig_txset; std::string multisig_txset;
@ -739,6 +744,7 @@ namespace wallet_rpc
KV_SERIALIZE(tx_key_list) KV_SERIALIZE(tx_key_list)
KV_SERIALIZE(amount_list) KV_SERIALIZE(amount_list)
KV_SERIALIZE(fee_list) KV_SERIALIZE(fee_list)
KV_SERIALIZE(weight_list)
KV_SERIALIZE(tx_blob_list) KV_SERIALIZE(tx_blob_list)
KV_SERIALIZE(tx_metadata_list) KV_SERIALIZE(tx_metadata_list)
KV_SERIALIZE(multisig_txset) KV_SERIALIZE(multisig_txset)
@ -799,6 +805,7 @@ namespace wallet_rpc
std::list<std::string> tx_key_list; std::list<std::string> tx_key_list;
std::list<uint64_t> amount_list; std::list<uint64_t> amount_list;
std::list<uint64_t> fee_list; std::list<uint64_t> fee_list;
std::list<uint64_t> weight_list;
std::list<std::string> tx_blob_list; std::list<std::string> tx_blob_list;
std::list<std::string> tx_metadata_list; std::list<std::string> tx_metadata_list;
std::string multisig_txset; std::string multisig_txset;
@ -809,6 +816,7 @@ namespace wallet_rpc
KV_SERIALIZE(tx_key_list) KV_SERIALIZE(tx_key_list)
KV_SERIALIZE(amount_list) KV_SERIALIZE(amount_list)
KV_SERIALIZE(fee_list) KV_SERIALIZE(fee_list)
KV_SERIALIZE(weight_list)
KV_SERIALIZE(tx_blob_list) KV_SERIALIZE(tx_blob_list)
KV_SERIALIZE(tx_metadata_list) KV_SERIALIZE(tx_metadata_list)
KV_SERIALIZE(multisig_txset) KV_SERIALIZE(multisig_txset)
@ -856,6 +864,7 @@ namespace wallet_rpc
std::string tx_key; std::string tx_key;
uint64_t amount; uint64_t amount;
uint64_t fee; uint64_t fee;
uint64_t weight;
std::string tx_blob; std::string tx_blob;
std::string tx_metadata; std::string tx_metadata;
std::string multisig_txset; std::string multisig_txset;
@ -866,6 +875,7 @@ namespace wallet_rpc
KV_SERIALIZE(tx_key) KV_SERIALIZE(tx_key)
KV_SERIALIZE(amount) KV_SERIALIZE(amount)
KV_SERIALIZE(fee) KV_SERIALIZE(fee)
KV_SERIALIZE(weight)
KV_SERIALIZE(tx_blob) KV_SERIALIZE(tx_blob)
KV_SERIALIZE(tx_metadata) KV_SERIALIZE(tx_metadata)
KV_SERIALIZE(multisig_txset) KV_SERIALIZE(multisig_txset)