make tx keys available to the user

They are also stored in the cache file, to be retrieved using
a new get_tx_key command.
This commit is contained in:
moneromooo-monero
2015-08-19 20:59:44 +01:00
parent 776b4fc91a
commit 6c995710d8
8 changed files with 77 additions and 10 deletions

View File

@@ -120,6 +120,7 @@ namespace tools
cryptonote::tx_destination_entry change_dts;
std::list<transfer_container::iterator> selected_transfers;
std::string key_images;
crypto::secret_key tx_key;
};
struct keys_file_data
@@ -251,6 +252,9 @@ namespace tools
if(ver < 7)
return;
a & m_payments;
if(ver < 8)
return;
a & m_tx_keys;
}
/*!
@@ -278,6 +282,8 @@ namespace tools
bool always_confirm_transfers() const { return m_always_confirm_transfers; }
void always_confirm_transfers(bool always) { m_always_confirm_transfers = always; }
bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key) const;
private:
/*!
* \brief Stores wallet information to wallet file.
@@ -316,6 +322,7 @@ namespace tools
std::vector<crypto::hash> m_blockchain;
std::atomic<uint64_t> m_local_bc_height; //temporary workaround
std::unordered_map<crypto::hash, unconfirmed_transfer_details> m_unconfirmed_txs;
std::unordered_map<crypto::hash, crypto::secret_key> m_tx_keys;
transfer_container m_transfers;
payment_container m_payments;
@@ -334,7 +341,7 @@ namespace tools
bool m_always_confirm_transfers;
};
}
BOOST_CLASS_VERSION(tools::wallet2, 7)
BOOST_CLASS_VERSION(tools::wallet2, 8)
namespace boost
{
@@ -565,7 +572,8 @@ namespace tools
splitted_dsts.push_back(cryptonote::tx_destination_entry(dust, dust_policy.addr_for_dust));
}
bool r = cryptonote::construct_tx(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time);
crypto::secret_key tx_key;
bool r = cryptonote::construct_tx(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);
@@ -584,7 +592,7 @@ namespace tools
ptx.tx = tx;
ptx.change_dts = change_dts;
ptx.selected_transfers = selected_transfers;
ptx.tx_key = tx_key;
}