aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/wallet2.cpp21
-rw-r--r--src/wallet/wallet2.h13
-rw-r--r--src/wallet/wallet_rpc_server.cpp39
-rw-r--r--src/wallet/wallet_rpc_server_commands_defs.h35
4 files changed, 101 insertions, 7 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index a6c9faa80..ef77f68c3 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -1258,6 +1258,7 @@ bool wallet2::clear()
m_unconfirmed_txs.clear();
m_payments.clear();
m_tx_keys.clear();
+ m_amount_keys.clear();
m_confirmed_txs.clear();
m_local_bc_height = 1;
return true;
@@ -2343,7 +2344,10 @@ void wallet2::commit_tx(pending_tx& ptx)
}
add_unconfirmed_tx(ptx.tx, amount_in, dests, payment_id, ptx.change_dts.amount);
if (store_tx_info())
+ {
m_tx_keys.insert(std::make_pair(txid, ptx.tx_key));
+ m_amount_keys.insert(std::make_pair(txid, ptx.amount_keys));
+ }
LOG_PRINT_L2("transaction " << txid << " generated ok and sent to daemon, key_images: [" << ptx.key_images << "]");
@@ -2753,7 +2757,8 @@ void wallet2::transfer_selected(const std::vector<cryptonote::tx_destination_ent
}
crypto::secret_key tx_key;
- bool r = cryptonote::construct_tx_and_get_tx_key(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key);
+ std::vector<crypto::secret_key> amount_keys;
+ bool r = cryptonote::construct_tx_and_get_tx_keys(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key, amount_keys);
THROW_WALLET_EXCEPTION_IF(!r, error::tx_not_constructed, sources, splitted_dsts, unlock_time, m_testnet);
THROW_WALLET_EXCEPTION_IF(upper_transaction_size_limit <= get_object_blobsize(tx), error::tx_too_big, tx, upper_transaction_size_limit);
@@ -2780,6 +2785,7 @@ void wallet2::transfer_selected(const std::vector<cryptonote::tx_destination_ent
ptx.change_dts = change_dts;
ptx.selected_transfers = selected_transfers;
ptx.tx_key = tx_key;
+ ptx.amount_keys = amount_keys;
ptx.dests = dsts;
}
@@ -2972,7 +2978,8 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
dsts.push_back(change_dts);
crypto::secret_key tx_key;
- bool r = cryptonote::construct_tx_and_get_tx_key(m_account.get_keys(), sources, dsts, extra, tx, unlock_time, tx_key, true);
+ std::vector<crypto::secret_key> amount_keys;
+ bool r = cryptonote::construct_tx_and_get_tx_keys(m_account.get_keys(), sources, dsts, extra, tx, unlock_time, tx_key, amount_keys, true);
THROW_WALLET_EXCEPTION_IF(!r, error::tx_not_constructed, sources, dsts, unlock_time, m_testnet);
THROW_WALLET_EXCEPTION_IF(upper_transaction_size_limit <= get_object_blobsize(tx), error::tx_too_big, tx, upper_transaction_size_limit);
@@ -2993,6 +3000,7 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
ptx.change_dts = change_dts;
ptx.selected_transfers = selected_transfers;
ptx.tx_key = tx_key;
+ ptx.amount_keys = amount_keys;
ptx.dests = dsts;
}
@@ -3645,7 +3653,8 @@ void wallet2::transfer_from(const std::vector<size_t> &outs, size_t num_outputs,
}
crypto::secret_key tx_key;
- bool r = cryptonote::construct_tx_and_get_tx_key(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key);
+ std::vector<crypto::secret_key> amount_keys;
+ bool r = cryptonote::construct_tx_and_get_tx_keys(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key, amount_keys);
THROW_WALLET_EXCEPTION_IF(!r, error::tx_not_constructed, sources, splitted_dsts, unlock_time, m_testnet);
THROW_WALLET_EXCEPTION_IF(upper_transaction_size_limit <= get_object_blobsize(tx), error::tx_too_big, tx, upper_transaction_size_limit);
@@ -3665,6 +3674,7 @@ void wallet2::transfer_from(const std::vector<size_t> &outs, size_t num_outputs,
ptx.change_dts = change_dts;
ptx.selected_transfers = selected_transfers;
ptx.tx_key = tx_key;
+ ptx.amount_keys = amount_keys;
ptx.dests = dsts;
}
@@ -3911,12 +3921,15 @@ std::vector<wallet2::pending_tx> wallet2::create_unmixable_sweep_transactions(bo
}
}
-bool wallet2::get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key) const
+bool wallet2::get_tx_keys(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &amount_keys) const
{
const std::unordered_map<crypto::hash, crypto::secret_key>::const_iterator i = m_tx_keys.find(txid);
if (i == m_tx_keys.end())
return false;
tx_key = i->second;
+ const std::unordered_map<crypto::hash, std::vector<crypto::secret_key>>::const_iterator j = m_amount_keys.find(txid);
+ if (j != m_amount_keys.end())
+ amount_keys = j->second;
return true;
}
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index ca9d9fb70..c45b64822 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -161,6 +161,7 @@ namespace tools
std::list<transfer_container::iterator> selected_transfers;
std::string key_images;
crypto::secret_key tx_key;
+ std::vector<crypto::secret_key> amount_keys;
std::vector<cryptonote::tx_destination_entry> dests;
};
@@ -351,6 +352,9 @@ namespace tools
if(ver < 13)
return;
a & m_unconfirmed_payments;
+ if(ver < 14)
+ return;
+ a & m_amount_keys;
}
/*!
@@ -386,7 +390,7 @@ namespace tools
bool auto_refresh() const { return m_auto_refresh; }
void auto_refresh(bool r) { m_auto_refresh = r; }
- bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key) const;
+ bool get_tx_keys(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &amount_keys) const;
bool use_fork_rules(uint8_t version);
@@ -464,6 +468,7 @@ namespace tools
std::unordered_map<crypto::hash, confirmed_transfer_details> m_confirmed_txs;
std::unordered_map<crypto::hash, payment_details> m_unconfirmed_payments;
std::unordered_map<crypto::hash, crypto::secret_key> m_tx_keys;
+ std::unordered_map<crypto::hash, std::vector<crypto::secret_key>> m_amount_keys;
transfer_container m_transfers;
payment_container m_payments;
@@ -491,7 +496,7 @@ namespace tools
uint64_t m_refresh_from_block_height;
};
}
-BOOST_CLASS_VERSION(tools::wallet2, 13)
+BOOST_CLASS_VERSION(tools::wallet2, 14)
BOOST_CLASS_VERSION(tools::wallet2::transfer_details, 2)
BOOST_CLASS_VERSION(tools::wallet2::payment_details, 1)
BOOST_CLASS_VERSION(tools::wallet2::unconfirmed_transfer_details, 4)
@@ -795,7 +800,8 @@ namespace tools
}
crypto::secret_key tx_key;
- bool r = cryptonote::construct_tx_and_get_tx_key(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key);
+ std::vector<crypto::secret_key> amount_keys;
+ bool r = cryptonote::construct_tx_and_get_tx_keys(m_account.get_keys(), sources, splitted_dsts, extra, tx, unlock_time, tx_key, amount_keys);
THROW_WALLET_EXCEPTION_IF(!r, error::tx_not_constructed, sources, splitted_dsts, unlock_time, m_testnet);
THROW_WALLET_EXCEPTION_IF(upper_transaction_size_limit <= get_object_blobsize(tx), error::tx_too_big, tx, upper_transaction_size_limit);
@@ -821,6 +827,7 @@ namespace tools
ptx.change_dts = change_dts;
ptx.selected_transfers = selected_transfers;
ptx.tx_key = tx_key;
+ ptx.amount_keys = amount_keys;
ptx.dests = dsts;
}
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index 9bcc26077..7d00dde08 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -254,7 +254,16 @@ namespace tools
// populate response with tx hash
res.tx_hash = epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(ptx_vector.back().tx));
if (req.get_tx_key)
+ {
res.tx_key = epee::string_tools::pod_to_hex(ptx_vector.back().tx_key);
+ if (ptx_vector.back().tx.version > 1)
+ {
+ for (const auto &i: ptx_vector.back().amount_keys)
+ {
+ res.amount_keys.push_back(epee::string_tools::pod_to_hex(i));
+ }
+ }
+ }
return true;
}
catch (const tools::error::daemon_busy& e)
@@ -317,7 +326,17 @@ namespace tools
{
res.tx_hash_list.push_back(epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(ptx.tx)));
if (req.get_tx_keys)
+ {
res.tx_key_list.push_back(epee::string_tools::pod_to_hex(ptx.tx_key));
+ res.amount_key_list.push_back(wallet_rpc::COMMAND_RPC_TRANSFER_SPLIT::key_list());
+ if (ptx.tx.version > 1)
+ {
+ for (const auto &i: ptx.amount_keys)
+ {
+ res.amount_key_list.back().keys.push_back(epee::string_tools::pod_to_hex(i));
+ }
+ }
+ }
}
return true;
@@ -363,7 +382,17 @@ namespace tools
{
res.tx_hash_list.push_back(epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(ptx.tx)));
if (req.get_tx_keys)
+ {
res.tx_key_list.push_back(epee::string_tools::pod_to_hex(ptx.tx_key));
+ res.amount_key_list.push_back(wallet_rpc::COMMAND_RPC_SWEEP_DUST::key_list());
+ if (ptx.tx.version > 1)
+ {
+ for (const auto &i: ptx.amount_keys)
+ {
+ res.amount_key_list.back().keys.push_back(epee::string_tools::pod_to_hex(i));
+ }
+ }
+ }
}
return true;
@@ -422,7 +451,17 @@ namespace tools
{
res.tx_hash_list.push_back(epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(ptx.tx)));
if (req.get_tx_keys)
+ {
res.tx_key_list.push_back(epee::string_tools::pod_to_hex(ptx.tx_key));
+ res.amount_key_list.push_back(wallet_rpc::COMMAND_RPC_SWEEP_ALL::key_list());
+ if (ptx.tx.version > 1)
+ {
+ for (const auto &i: ptx.amount_keys)
+ {
+ res.amount_key_list.back().keys.push_back(epee::string_tools::pod_to_hex(i));
+ }
+ }
+ }
}
return true;
diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h
index d7f01d9ee..ea92a028e 100644
--- a/src/wallet/wallet_rpc_server_commands_defs.h
+++ b/src/wallet/wallet_rpc_server_commands_defs.h
@@ -132,10 +132,12 @@ namespace wallet_rpc
{
std::string tx_hash;
std::string tx_key;
+ std::list<std::string> amount_keys;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tx_hash)
KV_SERIALIZE(tx_key)
+ KV_SERIALIZE(amount_keys)
END_KV_SERIALIZE_MAP()
};
};
@@ -165,14 +167,25 @@ namespace wallet_rpc
END_KV_SERIALIZE_MAP()
};
+ struct key_list
+ {
+ std::list<std::string> keys;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(keys)
+ END_KV_SERIALIZE_MAP()
+ };
+
struct response
{
std::list<std::string> tx_hash_list;
std::list<std::string> tx_key_list;
+ std::list<key_list> amount_key_list;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tx_hash_list)
KV_SERIALIZE(tx_key_list)
+ KV_SERIALIZE(amount_key_list)
END_KV_SERIALIZE_MAP()
};
};
@@ -190,14 +203,25 @@ namespace wallet_rpc
END_KV_SERIALIZE_MAP()
};
+ struct key_list
+ {
+ std::list<std::string> keys;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(keys)
+ END_KV_SERIALIZE_MAP()
+ };
+
struct response
{
std::list<std::string> tx_hash_list;
std::list<std::string> tx_key_list;
+ std::list<key_list> amount_key_list;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tx_hash_list)
KV_SERIALIZE(tx_key_list)
+ KV_SERIALIZE(amount_key_list)
END_KV_SERIALIZE_MAP()
};
};
@@ -225,14 +249,25 @@ namespace wallet_rpc
END_KV_SERIALIZE_MAP()
};
+ struct key_list
+ {
+ std::list<std::string> keys;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(keys)
+ END_KV_SERIALIZE_MAP()
+ };
+
struct response
{
std::list<std::string> tx_hash_list;
std::list<std::string> tx_key_list;
+ std::list<key_list> amount_key_list;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tx_hash_list)
KV_SERIALIZE(tx_key_list)
+ KV_SERIALIZE(amount_key_list)
END_KV_SERIALIZE_MAP()
};
};