mirror of
https://github.com/monero-project/monero.git
synced 2024-11-17 16:27:39 +00:00
device: tx_key caching fixed, store recovered txkey
This commit is contained in:
parent
6335509727
commit
64fb0f872a
1 changed files with 11 additions and 3 deletions
|
@ -6118,7 +6118,7 @@ void wallet2::commit_tx(pending_tx& ptx)
|
||||||
amount_in += m_transfers[idx].amount();
|
amount_in += m_transfers[idx].amount();
|
||||||
}
|
}
|
||||||
add_unconfirmed_tx(ptx.tx, amount_in, dests, payment_id, ptx.change_dts.amount, ptx.construction_data.subaddr_account, ptx.construction_data.subaddr_indices);
|
add_unconfirmed_tx(ptx.tx, amount_in, dests, payment_id, ptx.change_dts.amount, ptx.construction_data.subaddr_account, ptx.construction_data.subaddr_indices);
|
||||||
if (store_tx_info())
|
if (store_tx_info() && ptx.tx_key != crypto::null_skey)
|
||||||
{
|
{
|
||||||
m_tx_keys.insert(std::make_pair(txid, ptx.tx_key));
|
m_tx_keys.insert(std::make_pair(txid, ptx.tx_key));
|
||||||
m_additional_tx_keys.insert(std::make_pair(txid, ptx.additional_tx_keys));
|
m_additional_tx_keys.insert(std::make_pair(txid, ptx.additional_tx_keys));
|
||||||
|
@ -6307,7 +6307,7 @@ bool wallet2::sign_tx(unsigned_tx_set &exported_txs, std::vector<wallet2::pendin
|
||||||
// normally, the tx keys are saved in commit_tx, when the tx is actually sent to the daemon.
|
// normally, the tx keys are saved in commit_tx, when the tx is actually sent to the daemon.
|
||||||
// we can't do that here since the tx will be sent from the compromised wallet, which we don't want
|
// we can't do that here since the tx will be sent from the compromised wallet, which we don't want
|
||||||
// to see that info, so we save it here
|
// to see that info, so we save it here
|
||||||
if (store_tx_info())
|
if (store_tx_info() && ptx.tx_key != crypto::null_skey)
|
||||||
{
|
{
|
||||||
const crypto::hash txid = get_transaction_hash(ptx.tx);
|
const crypto::hash txid = get_transaction_hash(ptx.tx);
|
||||||
m_tx_keys.insert(std::make_pair(txid, tx_key));
|
m_tx_keys.insert(std::make_pair(txid, tx_key));
|
||||||
|
@ -10276,6 +10276,8 @@ bool wallet2::get_tx_key_cached(const crypto::hash &txid, crypto::secret_key &tx
|
||||||
if (i == m_tx_keys.end())
|
if (i == m_tx_keys.end())
|
||||||
return false;
|
return false;
|
||||||
tx_key = i->second;
|
tx_key = i->second;
|
||||||
|
if (tx_key == crypto::null_skey)
|
||||||
|
return false;
|
||||||
const auto j = m_additional_tx_keys.find(txid);
|
const auto j = m_additional_tx_keys.find(txid);
|
||||||
if (j != m_additional_tx_keys.end())
|
if (j != m_additional_tx_keys.end())
|
||||||
additional_tx_keys = j->second;
|
additional_tx_keys = j->second;
|
||||||
|
@ -10287,6 +10289,7 @@ bool wallet2::get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, s
|
||||||
bool r = get_tx_key_cached(txid, tx_key, additional_tx_keys);
|
bool r = get_tx_key_cached(txid, tx_key, additional_tx_keys);
|
||||||
if (r)
|
if (r)
|
||||||
{
|
{
|
||||||
|
MDEBUG("tx key cached for txid: " << txid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10347,6 +10350,12 @@ bool wallet2::get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, s
|
||||||
std::vector<crypto::secret_key> tx_keys;
|
std::vector<crypto::secret_key> tx_keys;
|
||||||
dev_cold->get_tx_key(tx_keys, tx_key_data, m_account.get_keys().m_view_secret_key);
|
dev_cold->get_tx_key(tx_keys, tx_key_data, m_account.get_keys().m_view_secret_key);
|
||||||
if (tx_keys.empty())
|
if (tx_keys.empty())
|
||||||
|
{
|
||||||
|
MDEBUG("Empty tx keys for txid: " << txid);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tx_keys[0] == crypto::null_skey)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -10354,7 +10363,6 @@ bool wallet2::get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, s
|
||||||
tx_key = tx_keys[0];
|
tx_key = tx_keys[0];
|
||||||
tx_keys.erase(tx_keys.begin());
|
tx_keys.erase(tx_keys.begin());
|
||||||
additional_tx_keys = tx_keys;
|
additional_tx_keys = tx_keys;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue