mirror of
https://github.com/monero-project/monero.git
synced 2025-05-25 16:10:55 -04:00
wallet: only return tx keys via RPC if requested
To get the tx keys returned via RPC, set the "get_tx_key" or "get_tx_keys" request field to true (defaults to false).
This commit is contained in:
parent
32077d3810
commit
d91eb8c7b4
6 changed files with 36 additions and 11 deletions
|
@ -540,6 +540,9 @@ bool wallet2::store_keys(const std::string& keys_file_name, const std::string& p
|
|||
value2.SetInt(m_always_confirm_transfers ? 1 :0);
|
||||
json.AddMember("always_confirm_transfers", value2, json.GetAllocator());
|
||||
|
||||
value2.SetInt(m_store_tx_keys ? 1 :0);
|
||||
json.AddMember("store_tx_keys", value2, json.GetAllocator());
|
||||
|
||||
// Serialize the JSON object
|
||||
rapidjson::StringBuffer buffer;
|
||||
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
||||
|
@ -620,6 +623,7 @@ void wallet2::load_keys(const std::string& keys_file_name, const std::string& pa
|
|||
m_watch_only = false;
|
||||
}
|
||||
m_always_confirm_transfers = json.HasMember("always_confirm_transfers") && (json["always_confirm_transfers"].GetInt() != 0);
|
||||
m_store_tx_keys = json.HasMember("store_tx_keys") && (json["store_tx_keys"].GetInt() != 0);
|
||||
}
|
||||
|
||||
const cryptonote::account_keys& keys = m_account.get_keys();
|
||||
|
@ -1325,7 +1329,8 @@ void wallet2::commit_tx(pending_tx& ptx)
|
|||
|
||||
txid = get_transaction_hash(ptx.tx);
|
||||
add_unconfirmed_tx(ptx.tx, ptx.change_dts.amount);
|
||||
m_tx_keys.insert(std::make_pair(txid, ptx.tx_key));
|
||||
if (store_tx_keys())
|
||||
m_tx_keys.insert(std::make_pair(txid, ptx.tx_key));
|
||||
|
||||
LOG_PRINT_L2("transaction " << txid << " generated ok and sent to daemon, key_images: [" << ptx.key_images << "]");
|
||||
|
||||
|
@ -1578,7 +1583,7 @@ void wallet2::transfer_selected(const std::vector<cryptonote::tx_destination_ent
|
|||
}
|
||||
|
||||
crypto::secret_key tx_key;
|
||||
bool r = cryptonote::construct_tx(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key);
|
||||
bool r = cryptonote::construct_tx_and_get_tx_key(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key);
|
||||
THROW_WALLET_EXCEPTION_IF(!r, error::tx_not_constructed, sources, splitted_dsts, unlock_time, m_testnet);
|
||||
THROW_WALLET_EXCEPTION_IF(m_upper_transaction_size_limit <= get_object_blobsize(tx), error::tx_too_big, tx, m_upper_transaction_size_limit);
|
||||
|
||||
|
@ -1925,7 +1930,7 @@ void wallet2::transfer_dust(size_t num_outputs, uint64_t unlock_time, uint64_t n
|
|||
std::to_string(dust) + ", dust_threshold = " + std::to_string(dust_policy.dust_threshold));
|
||||
|
||||
crypto::secret_key tx_key;
|
||||
bool r = cryptonote::construct_tx(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key);
|
||||
bool r = cryptonote::construct_tx_and_get_tx_key(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key);
|
||||
THROW_WALLET_EXCEPTION_IF(!r, error::tx_not_constructed, sources, splitted_dsts, unlock_time, m_testnet);
|
||||
THROW_WALLET_EXCEPTION_IF(m_upper_transaction_size_limit <= get_object_blobsize(tx), error::tx_too_big, tx, m_upper_transaction_size_limit);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue