aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/api/wallet.cpp140
-rw-r--r--src/wallet/api/wallet.h3
-rw-r--r--src/wallet/api/wallet_manager.cpp149
-rw-r--r--src/wallet/api/wallet_manager.h1
-rw-r--r--src/wallet/wallet2.cpp349
-rw-r--r--src/wallet/wallet2.h4
-rw-r--r--src/wallet/wallet2_api.h16
-rw-r--r--src/wallet/wallet_rpc_server.cpp161
-rw-r--r--src/wallet/wallet_rpc_server.h8
-rw-r--r--src/wallet/wallet_rpc_server_commands_defs.h108
-rw-r--r--src/wallet/wallet_rpc_server_error_codes.h2
11 files changed, 770 insertions, 171 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp
index 8e747d16b..db8911042 100644
--- a/src/wallet/api/wallet.cpp
+++ b/src/wallet/api/wallet.cpp
@@ -1385,24 +1385,148 @@ std::string WalletImpl::getUserNote(const std::string &txid) const
return m_wallet->get_tx_note(htxid);
}
-std::string WalletImpl::getTxKey(const std::string &txid) const
+std::string WalletImpl::getTxKey(const std::string &txid_str) const
{
- cryptonote::blobdata txid_data;
- if(!epee::string_tools::parse_hexstr_to_binbuff(txid, txid_data) || txid_data.size() != sizeof(crypto::hash))
+ crypto::hash txid;
+ if(!epee::string_tools::hex_to_pod(txid_str, txid))
{
- return "";
+ m_status = Status_Error;
+ m_errorString = tr("Failed to parse txid");
+ return "";
}
- const crypto::hash htxid = *reinterpret_cast<const crypto::hash*>(txid_data.data());
crypto::secret_key tx_key;
std::vector<crypto::secret_key> additional_tx_keys;
- if (m_wallet->get_tx_key(htxid, tx_key, additional_tx_keys))
+ if (m_wallet->get_tx_key(txid, tx_key, additional_tx_keys))
{
- return epee::string_tools::pod_to_hex(tx_key);
+ m_status = Status_Ok;
+ std::ostringstream oss;
+ oss << epee::string_tools::pod_to_hex(tx_key);
+ for (size_t i = 0; i < additional_tx_keys.size(); ++i)
+ oss << epee::string_tools::pod_to_hex(additional_tx_keys[i]);
+ return oss.str();
}
else
{
- return "";
+ m_status = Status_Error;
+ m_errorString = tr("no tx keys found for this txid");
+ return "";
+ }
+}
+
+bool WalletImpl::checkTxKey(const std::string &txid_str, std::string tx_key_str, const std::string &address_str, uint64_t &received, bool &in_pool, uint64_t &confirmations)
+{
+ crypto::hash txid;
+ if (!epee::string_tools::hex_to_pod(txid_str, txid))
+ {
+ m_status = Status_Error;
+ m_errorString = tr("Failed to parse txid");
+ return false;
+ }
+
+ crypto::secret_key tx_key;
+ std::vector<crypto::secret_key> additional_tx_keys;
+ if (!epee::string_tools::hex_to_pod(tx_key_str.substr(0, 64), tx_key))
+ {
+ m_status = Status_Error;
+ m_errorString = tr("Failed to parse tx key");
+ return false;
+ }
+ tx_key_str = tx_key_str.substr(64);
+ while (!tx_key_str.empty())
+ {
+ additional_tx_keys.resize(additional_tx_keys.size() + 1);
+ if (!epee::string_tools::hex_to_pod(tx_key_str.substr(0, 64), additional_tx_keys.back()))
+ {
+ m_status = Status_Error;
+ m_errorString = tr("Failed to parse tx key");
+ return false;
+ }
+ tx_key_str = tx_key_str.substr(64);
+ }
+
+ cryptonote::address_parse_info info;
+ if (!cryptonote::get_account_address_from_str(info, m_wallet->testnet(), address_str))
+ {
+ m_status = Status_Error;
+ m_errorString = tr("Failed to parse address");
+ return false;
+ }
+
+ try
+ {
+ m_wallet->check_tx_key(txid, tx_key, additional_tx_keys, info.address, received, in_pool, confirmations);
+ m_status = Status_Ok;
+ return true;
+ }
+ catch (const std::exception &e)
+ {
+ m_status = Status_Error;
+ m_errorString = e.what();
+ return false;
+ }
+}
+
+std::string WalletImpl::getTxProof(const std::string &txid_str, const std::string &address_str, const std::string &message, std::string &error_str) const
+{
+ crypto::hash txid;
+ if (!epee::string_tools::hex_to_pod(txid_str, txid))
+ {
+ m_status = Status_Error;
+ m_errorString = tr("Failed to parse txid");
+ return "";
+ }
+
+ cryptonote::address_parse_info info;
+ if (!cryptonote::get_account_address_from_str(info, m_wallet->testnet(), address_str))
+ {
+ m_status = Status_Error;
+ m_errorString = tr("Failed to parse address");
+ return "";
+ }
+
+ try
+ {
+ m_status = Status_Ok;
+ return m_wallet->get_tx_proof(txid, info.address, info.is_subaddress, message, error_str);
+ }
+ catch (const std::exception &e)
+ {
+ m_status = Status_Error;
+ m_errorString = e.what();
+ return "";
+ }
+}
+
+bool WalletImpl::checkTxProof(const std::string &txid_str, const std::string &address_str, const std::string &message, const std::string &signature, bool &good, uint64_t &received, bool &in_pool, uint64_t &confirmations)
+{
+ crypto::hash txid;
+ if (!epee::string_tools::hex_to_pod(txid_str, txid))
+ {
+ m_status = Status_Error;
+ m_errorString = tr("Failed to parse txid");
+ return false;
+ }
+
+ cryptonote::address_parse_info info;
+ if (!cryptonote::get_account_address_from_str(info, m_wallet->testnet(), address_str))
+ {
+ m_status = Status_Error;
+ m_errorString = tr("Failed to parse address");
+ return false;
+ }
+
+ try
+ {
+ good = m_wallet->check_tx_proof(txid, info.address, info.is_subaddress, message, signature, received, in_pool, confirmations);
+ m_status = Status_Ok;
+ return true;
+ }
+ catch (const std::exception &e)
+ {
+ m_status = Status_Error;
+ m_errorString = e.what();
+ return false;
}
}
diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h
index 051eda3ba..ecf540f22 100644
--- a/src/wallet/api/wallet.h
+++ b/src/wallet/api/wallet.h
@@ -137,6 +137,9 @@ public:
virtual bool setUserNote(const std::string &txid, const std::string &note);
virtual std::string getUserNote(const std::string &txid) const;
virtual std::string getTxKey(const std::string &txid) const;
+ virtual bool checkTxKey(const std::string &txid, std::string tx_key, const std::string &address, uint64_t &received, bool &in_pool, uint64_t &confirmations);
+ virtual std::string getTxProof(const std::string &txid, const std::string &address, const std::string &message, std::string &error_str) const;
+ virtual bool checkTxProof(const std::string &txid, const std::string &address, const std::string &message, const std::string &signature, bool &good, uint64_t &received, bool &in_pool, uint64_t &confirmations);
virtual std::string signMessage(const std::string &message);
virtual bool verifySignedMessage(const std::string &message, const std::string &address, const std::string &signature) const;
virtual void startRefresh();
diff --git a/src/wallet/api/wallet_manager.cpp b/src/wallet/api/wallet_manager.cpp
index 2326f54d3..ee69ec028 100644
--- a/src/wallet/api/wallet_manager.cpp
+++ b/src/wallet/api/wallet_manager.cpp
@@ -189,155 +189,6 @@ bool WalletManagerImpl::connected(uint32_t *version) const
return true;
}
-bool WalletManagerImpl::checkPayment(const std::string &address_text, const std::string &txid_text, const std::string &txkey_text, const std::string &daemon_address, uint64_t &received, uint64_t &height, std::string &error) const
-{
- error = "";
- cryptonote::blobdata txid_data;
- if(!epee::string_tools::parse_hexstr_to_binbuff(txid_text, txid_data) || txid_data.size() != sizeof(crypto::hash))
- {
- error = tr("failed to parse txid");
- return false;
- }
- crypto::hash txid = *reinterpret_cast<const crypto::hash*>(txid_data.data());
-
- if (txkey_text.size() < 64 || txkey_text.size() % 64)
- {
- error = tr("failed to parse tx key");
- return false;
- }
- crypto::secret_key tx_key;
- cryptonote::blobdata tx_key_data;
- if(!epee::string_tools::parse_hexstr_to_binbuff(txkey_text, tx_key_data) || tx_key_data.size() != sizeof(crypto::hash))
- {
- error = tr("failed to parse tx key");
- return false;
- }
- tx_key = *reinterpret_cast<const crypto::secret_key*>(tx_key_data.data());
-
- bool testnet = address_text[0] != '4';
- cryptonote::address_parse_info info;
- if(!cryptonote::get_account_address_from_str(info, testnet, address_text))
- {
- error = tr("failed to parse address");
- return false;
- }
-
- cryptonote::COMMAND_RPC_GET_TRANSACTIONS::request req;
- cryptonote::COMMAND_RPC_GET_TRANSACTIONS::response res;
- req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txid));
- if (!connect_and_invoke(m_daemonAddress, "/gettransactions", req, res) ||
- (res.txs.size() != 1 && res.txs_as_hex.size() != 1))
- {
- error = tr("failed to get transaction from daemon");
- return false;
- }
- cryptonote::blobdata tx_data;
- bool ok;
- if (res.txs.size() == 1)
- ok = epee::string_tools::parse_hexstr_to_binbuff(res.txs.front().as_hex, tx_data);
- else
- ok = epee::string_tools::parse_hexstr_to_binbuff(res.txs_as_hex.front(), tx_data);
- if (!ok)
- {
- error = tr("failed to parse transaction from daemon");
- return false;
- }
- crypto::hash tx_hash, tx_prefix_hash;
- cryptonote::transaction tx;
- if (!cryptonote::parse_and_validate_tx_from_blob(tx_data, tx, tx_hash, tx_prefix_hash))
- {
- error = tr("failed to validate transaction from daemon");
- return false;
- }
- if (tx_hash != txid)
- {
- error = tr("failed to get the right transaction from daemon");
- return false;
- }
-
- crypto::key_derivation derivation;
- if (!crypto::generate_key_derivation(info.address.m_view_public_key, tx_key, derivation))
- {
- error = tr("failed to generate key derivation from supplied parameters");
- return false;
- }
-
- received = 0;
- try {
- for (size_t n = 0; n < tx.vout.size(); ++n)
- {
- if (typeid(cryptonote::txout_to_key) != tx.vout[n].target.type())
- continue;
- const cryptonote::txout_to_key tx_out_to_key = boost::get<cryptonote::txout_to_key>(tx.vout[n].target);
- crypto::public_key pubkey;
- derive_public_key(derivation, n, info.address.m_spend_public_key, pubkey);
- if (pubkey == tx_out_to_key.key)
- {
- uint64_t amount;
- if (tx.version == 1)
- {
- amount = tx.vout[n].amount;
- }
- else
- {
- try
- {
- rct::key Ctmp;
- //rct::key amount_key = rct::hash_to_scalar(rct::scalarmultKey(rct::pk2rct(address.m_view_public_key), rct::sk2rct(tx_key)));
- crypto::key_derivation derivation;
- bool r = crypto::generate_key_derivation(info.address.m_view_public_key, tx_key, derivation);
- if (!r)
- {
- LOG_ERROR("Failed to generate key derivation to decode rct output " << n);
- amount = 0;
- }
- else
- {
- crypto::secret_key scalar1;
- crypto::derivation_to_scalar(derivation, n, scalar1);
- rct::ecdhTuple ecdh_info = tx.rct_signatures.ecdhInfo[n];
- rct::ecdhDecode(ecdh_info, rct::sk2rct(scalar1));
- rct::key C = tx.rct_signatures.outPk[n].mask;
- rct::addKeys2(Ctmp, ecdh_info.mask, ecdh_info.amount, rct::H);
- if (rct::equalKeys(C, Ctmp))
- amount = rct::h2d(ecdh_info.amount);
- else
- amount = 0;
- }
- }
- catch (...) { amount = 0; }
- }
- received += amount;
- }
- }
- }
- catch(const std::exception &e)
- {
- LOG_ERROR("error: " << e.what());
- error = std::string(tr("error: ")) + e.what();
- return false;
- }
-
- if (received > 0)
- {
- LOG_PRINT_L1(get_account_address_as_str(testnet, info.is_subaddress, info.address) << " " << tr("received") << " " << cryptonote::print_money(received) << " " << tr("in txid") << " " << txid);
- }
- else
- {
- LOG_PRINT_L1(get_account_address_as_str(testnet, info.is_subaddress, info.address) << " " << tr("received nothing in txid") << " " << txid);
- }
- if (res.txs.front().in_pool)
- {
- height = 0;
- }
- else
- {
- height = res.txs.front().block_height;
- }
-
- return true;
-}
-
uint64_t WalletManagerImpl::blockchainHeight() const
{
cryptonote::COMMAND_RPC_GET_INFO::request ireq;
diff --git a/src/wallet/api/wallet_manager.h b/src/wallet/api/wallet_manager.h
index 8455f0f16..5772eda05 100644
--- a/src/wallet/api/wallet_manager.h
+++ b/src/wallet/api/wallet_manager.h
@@ -55,7 +55,6 @@ public:
std::string errorString() const;
void setDaemonAddress(const std::string &address);
bool connected(uint32_t *version = NULL) const;
- bool checkPayment(const std::string &address, const std::string &txid, const std::string &txkey, const std::string &daemon_address, uint64_t &received, uint64_t &height, std::string &error) const;
uint64_t blockchainHeight() const;
uint64_t blockchainTargetHeight() const;
uint64_t networkDifficulty() const;
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 07601af3d..c4124a677 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -6210,6 +6210,355 @@ bool wallet2::get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, s
return true;
}
+void wallet2::check_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations)
+{
+ crypto::key_derivation derivation;
+ THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(address.m_view_public_key, tx_key, derivation), error::wallet_internal_error,
+ "Failed to generate key derivation from supplied parameters");
+
+ std::vector<crypto::key_derivation> additional_derivations;
+ additional_derivations.resize(additional_tx_keys.size());
+ for (size_t i = 0; i < additional_tx_keys.size(); ++i)
+ THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(address.m_view_public_key, additional_tx_keys[i], additional_derivations[i]), error::wallet_internal_error,
+ "Failed to generate key derivation from supplied parameters");
+
+ check_tx_key_helper(txid, derivation, additional_derivations, address, received, in_pool, confirmations);
+}
+
+void wallet2::check_tx_key_helper(const crypto::hash &txid, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations)
+{
+ COMMAND_RPC_GET_TRANSACTIONS::request req;
+ COMMAND_RPC_GET_TRANSACTIONS::response res;
+ req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txid));
+ m_daemon_rpc_mutex.lock();
+ bool ok = epee::net_utils::invoke_http_json("/gettransactions", req, res, m_http_client);
+ m_daemon_rpc_mutex.unlock();
+ THROW_WALLET_EXCEPTION_IF(!ok || (res.txs.size() != 1 && res.txs_as_hex.size() != 1),
+ error::wallet_internal_error, "Failed to get transaction from daemon");
+
+ cryptonote::blobdata tx_data;
+ if (res.txs.size() == 1)
+ ok = string_tools::parse_hexstr_to_binbuff(res.txs.front().as_hex, tx_data);
+ else
+ ok = string_tools::parse_hexstr_to_binbuff(res.txs_as_hex.front(), tx_data);
+ THROW_WALLET_EXCEPTION_IF(!ok, error::wallet_internal_error, "Failed to parse transaction from daemon");
+
+ crypto::hash tx_hash, tx_prefix_hash;
+ cryptonote::transaction tx;
+ THROW_WALLET_EXCEPTION_IF(!cryptonote::parse_and_validate_tx_from_blob(tx_data, tx, tx_hash, tx_prefix_hash), error::wallet_internal_error,
+ "Failed to validate transaction from daemon");
+ THROW_WALLET_EXCEPTION_IF(tx_hash != txid, error::wallet_internal_error,
+ "Failed to get the right transaction from daemon");
+ THROW_WALLET_EXCEPTION_IF(!additional_derivations.empty() && additional_derivations.size() != tx.vout.size(), error::wallet_internal_error,
+ "The size of additional derivations is wrong");
+
+ received = 0;
+ for (size_t n = 0; n < tx.vout.size(); ++n)
+ {
+ const cryptonote::txout_to_key* const out_key = boost::get<cryptonote::txout_to_key>(std::addressof(tx.vout[n].target));
+ if (!out_key)
+ continue;
+
+ crypto::public_key derived_out_key;
+ derive_public_key(derivation, n, address.m_spend_public_key, derived_out_key);
+ bool found = out_key->key == derived_out_key;
+ crypto::key_derivation found_derivation = derivation;
+ if (!found && !additional_derivations.empty())
+ {
+ derive_public_key(additional_derivations[n], n, address.m_spend_public_key, derived_out_key);
+ found = out_key->key == derived_out_key;
+ found_derivation = additional_derivations[n];
+ }
+
+ if (found)
+ {
+ uint64_t amount;
+ if (tx.version == 1 || tx.rct_signatures.type == rct::RCTTypeNull)
+ {
+ amount = tx.vout[n].amount;
+ }
+ else
+ {
+ crypto::secret_key scalar1;
+ crypto::derivation_to_scalar(found_derivation, n, scalar1);
+ rct::ecdhTuple ecdh_info = tx.rct_signatures.ecdhInfo[n];
+ rct::ecdhDecode(ecdh_info, rct::sk2rct(scalar1));
+ const rct::key C = tx.rct_signatures.outPk[n].mask;
+ rct::key Ctmp;
+ rct::addKeys2(Ctmp, ecdh_info.mask, ecdh_info.amount, rct::H);
+ if (rct::equalKeys(C, Ctmp))
+ amount = rct::h2d(ecdh_info.amount);
+ else
+ amount = 0;
+ }
+ received += amount;
+ }
+ }
+
+ in_pool = res.txs.front().in_pool;
+ confirmations = (uint64_t)-1;
+ if (!in_pool)
+ {
+ std::string err;
+ uint64_t bc_height = get_daemon_blockchain_height(err);
+ if (err.empty())
+ confirmations = bc_height - (res.txs.front().block_height + 1);
+ }
+}
+
+std::string wallet2::get_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message, std::string &error_str)
+{
+ error_str = "";
+ // determine if the address is found in the subaddress hash table (i.e. whether the proof is outbound or inbound)
+ const bool is_out = m_subaddresses.count(address.m_spend_public_key) == 0;
+
+ std::string prefix_data((const char*)&txid, sizeof(crypto::hash));
+ prefix_data += message;
+ crypto::hash prefix_hash;
+ crypto::cn_fast_hash(prefix_data.data(), prefix_data.size(), prefix_hash);
+
+ std::vector<crypto::public_key> shared_secret;
+ std::vector<crypto::signature> sig;
+ std::string sig_str;
+ if (is_out)
+ {
+ crypto::secret_key tx_key;
+ std::vector<crypto::secret_key> additional_tx_keys;
+ if (!get_tx_key(txid, tx_key, additional_tx_keys))
+ {
+ error_str = tr("Tx secret key wasn't found in the wallet file.");
+ return {};
+ }
+
+ const size_t num_sigs = 1 + additional_tx_keys.size();
+ shared_secret.resize(num_sigs);
+ sig.resize(num_sigs);
+
+ shared_secret[0] = rct::rct2pk(rct::scalarmultKey(rct::pk2rct(address.m_view_public_key), rct::sk2rct(tx_key)));
+ crypto::public_key tx_pub_key;
+ if (is_subaddress)
+ {
+ tx_pub_key = rct2pk(rct::scalarmultKey(rct::pk2rct(address.m_spend_public_key), rct::sk2rct(tx_key)));
+ crypto::generate_tx_proof(prefix_hash, tx_pub_key, address.m_view_public_key, address.m_spend_public_key, shared_secret[0], tx_key, sig[0]);
+ }
+ else
+ {
+ crypto::secret_key_to_public_key(tx_key, tx_pub_key);
+ crypto::generate_tx_proof(prefix_hash, tx_pub_key, address.m_view_public_key, boost::none, shared_secret[0], tx_key, sig[0]);
+ }
+ for (size_t i = 1; i < num_sigs; ++i)
+ {
+ shared_secret[i] = rct::rct2pk(rct::scalarmultKey(rct::pk2rct(address.m_view_public_key), rct::sk2rct(additional_tx_keys[i - 1])));
+ if (is_subaddress)
+ {
+ tx_pub_key = rct2pk(rct::scalarmultKey(rct::pk2rct(address.m_spend_public_key), rct::sk2rct(additional_tx_keys[i - 1])));
+ crypto::generate_tx_proof(prefix_hash, tx_pub_key, address.m_view_public_key, address.m_spend_public_key, shared_secret[i], additional_tx_keys[i - 1], sig[i]);
+ }
+ else
+ {
+ crypto::secret_key_to_public_key(additional_tx_keys[i - 1], tx_pub_key);
+ crypto::generate_tx_proof(prefix_hash, tx_pub_key, address.m_view_public_key, boost::none, shared_secret[i], additional_tx_keys[i - 1], sig[i]);
+ }
+ }
+ sig_str = std::string("OutProofV1");
+ }
+ else
+ {
+ // fetch tx pubkey from the daemon
+ COMMAND_RPC_GET_TRANSACTIONS::request req;
+ COMMAND_RPC_GET_TRANSACTIONS::response res;
+ req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txid));
+ m_daemon_rpc_mutex.lock();
+ bool ok = net_utils::invoke_http_json("/gettransactions", req, res, m_http_client);
+ m_daemon_rpc_mutex.unlock();
+ THROW_WALLET_EXCEPTION_IF(!ok || (res.txs.size() != 1 && res.txs_as_hex.size() != 1),
+ error::wallet_internal_error, "Failed to get transaction from daemon");
+
+ cryptonote::blobdata tx_data;
+ if (res.txs.size() == 1)
+ ok = string_tools::parse_hexstr_to_binbuff(res.txs.front().as_hex, tx_data);
+ else
+ ok = string_tools::parse_hexstr_to_binbuff(res.txs_as_hex.front(), tx_data);
+ THROW_WALLET_EXCEPTION_IF(!ok, error::wallet_internal_error, "Failed to parse transaction from daemon");
+
+ crypto::hash tx_hash, tx_prefix_hash;
+ cryptonote::transaction tx;
+ THROW_WALLET_EXCEPTION_IF(!cryptonote::parse_and_validate_tx_from_blob(tx_data, tx, tx_hash, tx_prefix_hash), error::wallet_internal_error,
+ "Failed to validate transaction from daemon");
+ THROW_WALLET_EXCEPTION_IF(tx_hash != txid, error::wallet_internal_error, "Failed to get the right transaction from daemon");
+
+ crypto::public_key tx_pub_key = get_tx_pub_key_from_extra(tx);
+ THROW_WALLET_EXCEPTION_IF(tx_pub_key == null_pkey, error::wallet_internal_error, "Tx pubkey was not found");
+
+ std::vector<crypto::public_key> additional_tx_pub_keys = get_additional_tx_pub_keys_from_extra(tx);
+ const size_t num_sigs = 1 + additional_tx_pub_keys.size();
+ shared_secret.resize(num_sigs);
+ sig.resize(num_sigs);
+
+ const crypto::secret_key& a = m_account.get_keys().m_view_secret_key;
+ shared_secret[0] = rct::rct2pk(rct::scalarmultKey(rct::pk2rct(tx_pub_key), rct::sk2rct(a)));
+ if (is_subaddress)
+ {
+ crypto::generate_tx_proof(prefix_hash, address.m_view_public_key, tx_pub_key, address.m_spend_public_key, shared_secret[0], a, sig[0]);
+ }
+ else
+ {
+ crypto::generate_tx_proof(prefix_hash, address.m_view_public_key, tx_pub_key, boost::none, shared_secret[0], a, sig[0]);
+ }
+ for (size_t i = 1; i < num_sigs; ++i)
+ {
+ shared_secret[i] = rct::rct2pk(rct::scalarmultKey(rct::pk2rct(additional_tx_pub_keys[i - 1]), rct::sk2rct(a)));
+ if (is_subaddress)
+ {
+ crypto::generate_tx_proof(prefix_hash, address.m_view_public_key, additional_tx_pub_keys[i - 1], address.m_spend_public_key, shared_secret[i], a, sig[i]);
+ }
+ else
+ {
+ crypto::generate_tx_proof(prefix_hash, address.m_view_public_key, additional_tx_pub_keys[i - 1], boost::none, shared_secret[i], a, sig[i]);
+ }
+ }
+ sig_str = std::string("InProofV1");
+ }
+ const size_t num_sigs = shared_secret.size();
+
+ // check if this address actually received any funds
+ crypto::key_derivation derivation;
+ THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(shared_secret[0], rct::rct2sk(rct::I), derivation), error::wallet_internal_error, "Failed to generate key derivation");
+ std::vector<crypto::key_derivation> additional_derivations(num_sigs - 1);
+ for (size_t i = 1; i < num_sigs; ++i)
+ THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(shared_secret[i], rct::rct2sk(rct::I), additional_derivations[i - 1]), error::wallet_internal_error, "Failed to generate key derivation");
+ uint64_t received;
+ bool in_pool;
+ uint64_t confirmations;
+ check_tx_key_helper(txid, derivation, additional_derivations, address, received, in_pool, confirmations);
+ if (!received)
+ {
+ error_str = tr("No funds received in this tx.");
+ return {};
+ }
+
+ // concatenate all signature strings
+ for (size_t i = 0; i < num_sigs; ++i)
+ sig_str +=
+ tools::base58::encode(std::string((const char *)&shared_secret[i], sizeof(crypto::public_key))) +
+ tools::base58::encode(std::string((const char *)&sig[i], sizeof(crypto::signature)));
+ return sig_str;
+}
+
+bool wallet2::check_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message, const std::string &sig_str, uint64_t &received, bool &in_pool, uint64_t &confirmations)
+{
+ const bool is_out = sig_str.substr(0, 3) == "Out";
+ const std::string header = is_out ? "OutProofV1" : "InProofV1";
+ const size_t header_len = header.size();
+ THROW_WALLET_EXCEPTION_IF(sig_str.size() < header_len || sig_str.substr(0, header_len) != header, error::wallet_internal_error,
+ "Signature header check error");
+
+ // decode base58
+ std::vector<crypto::public_key> shared_secret(1);
+ std::vector<crypto::signature> sig(1);
+ const size_t pk_len = tools::base58::encode(std::string((const char *)&shared_secret[0], sizeof(crypto::public_key))).size();
+ const size_t sig_len = tools::base58::encode(std::string((const char *)&sig[0], sizeof(crypto::signature))).size();
+ const size_t num_sigs = (sig_str.size() - header_len) / (pk_len + sig_len);
+ THROW_WALLET_EXCEPTION_IF(sig_str.size() != header_len + num_sigs * (pk_len + sig_len), error::wallet_internal_error,
+ "Wrong signature size");
+ shared_secret.resize(num_sigs);
+ sig.resize(num_sigs);
+ for (size_t i = 0; i < num_sigs; ++i)
+ {
+ std::string pk_decoded;
+ std::string sig_decoded;
+ const size_t offset = header_len + i * (pk_len + sig_len);
+ THROW_WALLET_EXCEPTION_IF(!tools::base58::decode(sig_str.substr(offset, pk_len), pk_decoded), error::wallet_internal_error,
+ "Signature decoding error");
+ THROW_WALLET_EXCEPTION_IF(!tools::base58::decode(sig_str.substr(offset + pk_len, sig_len), sig_decoded), error::wallet_internal_error,
+ "Signature decoding error");
+ THROW_WALLET_EXCEPTION_IF(sizeof(crypto::public_key) != pk_decoded.size() || sizeof(crypto::signature) != sig_decoded.size(), error::wallet_internal_error,
+ "Signature decoding error");
+ memcpy(&shared_secret[i], pk_decoded.data(), sizeof(crypto::public_key));
+ memcpy(&sig[i], sig_decoded.data(), sizeof(crypto::signature));
+ }
+
+ // fetch tx pubkey from the daemon
+ COMMAND_RPC_GET_TRANSACTIONS::request req;
+ COMMAND_RPC_GET_TRANSACTIONS::response res;
+ req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txid));
+ m_daemon_rpc_mutex.lock();
+ bool ok = net_utils::invoke_http_json("/gettransactions", req, res, m_http_client);
+ m_daemon_rpc_mutex.unlock();
+ THROW_WALLET_EXCEPTION_IF(!ok || (res.txs.size() != 1 && res.txs_as_hex.size() != 1),
+ error::wallet_internal_error, "Failed to get transaction from daemon");
+
+ cryptonote::blobdata tx_data;
+ if (res.txs.size() == 1)
+ ok = string_tools::parse_hexstr_to_binbuff(res.txs.front().as_hex, tx_data);
+ else
+ ok = string_tools::parse_hexstr_to_binbuff(res.txs_as_hex.front(), tx_data);
+ THROW_WALLET_EXCEPTION_IF(!ok, error::wallet_internal_error, "Failed to parse transaction from daemon");
+
+ crypto::hash tx_hash, tx_prefix_hash;
+ cryptonote::transaction tx;
+ THROW_WALLET_EXCEPTION_IF(!cryptonote::parse_and_validate_tx_from_blob(tx_data, tx, tx_hash, tx_prefix_hash), error::wallet_internal_error,
+ "Failed to validate transaction from daemon");
+ THROW_WALLET_EXCEPTION_IF(tx_hash != txid, error::wallet_internal_error, "Failed to get the right transaction from daemon");
+
+ crypto::public_key tx_pub_key = get_tx_pub_key_from_extra(tx);
+ THROW_WALLET_EXCEPTION_IF(tx_pub_key == null_pkey, error::wallet_internal_error, "Tx pubkey was not found");
+
+ std::vector<crypto::public_key> additional_tx_pub_keys = get_additional_tx_pub_keys_from_extra(tx);
+ THROW_WALLET_EXCEPTION_IF(additional_tx_pub_keys.size() + 1 != num_sigs, error::wallet_internal_error, "Signature size mismatch with additional tx pubkeys");
+
+ std::string prefix_data((const char*)&txid, sizeof(crypto::hash));
+ prefix_data += message;
+ crypto::hash prefix_hash;
+ crypto::cn_fast_hash(prefix_data.data(), prefix_data.size(), prefix_hash);
+
+ // check signature
+ std::vector<int> good_signature(num_sigs, 0);
+ if (is_out)
+ {
+ good_signature[0] = is_subaddress ?
+ crypto::check_tx_proof(prefix_hash, tx_pub_key, address.m_view_public_key, address.m_spend_public_key, shared_secret[0], sig[0]) :
+ crypto::check_tx_proof(prefix_hash, tx_pub_key, address.m_view_public_key, boost::none, shared_secret[0], sig[0]);
+
+ for (size_t i = 0; i < additional_tx_pub_keys.size(); ++i)
+ {
+ good_signature[i + 1] = is_subaddress ?
+ crypto::check_tx_proof(prefix_hash, additional_tx_pub_keys[i], address.m_view_public_key, address.m_spend_public_key, shared_secret[i + 1], sig[i + 1]) :
+ crypto::check_tx_proof(prefix_hash, additional_tx_pub_keys[i], address.m_view_public_key, boost::none, shared_secret[i + 1], sig[i + 1]);
+ }
+ }
+ else
+ {
+ good_signature[0] = is_subaddress ?
+ crypto::check_tx_proof(prefix_hash, address.m_view_public_key, tx_pub_key, address.m_spend_public_key, shared_secret[0], sig[0]) :
+ crypto::check_tx_proof(prefix_hash, address.m_view_public_key, tx_pub_key, boost::none, shared_secret[0], sig[0]);
+
+ for (size_t i = 0; i < additional_tx_pub_keys.size(); ++i)
+ {
+ good_signature[i + 1] = is_subaddress ?
+ crypto::check_tx_proof(prefix_hash, address.m_view_public_key, additional_tx_pub_keys[i], address.m_spend_public_key, shared_secret[i + 1], sig[i + 1]) :
+ crypto::check_tx_proof(prefix_hash, address.m_view_public_key, additional_tx_pub_keys[i], boost::none, shared_secret[i + 1], sig[i + 1]);
+ }
+ }
+
+ if (std::any_of(good_signature.begin(), good_signature.end(), [](int i) { return i > 0; }))
+ {
+ // obtain key derivation by multiplying scalar 1 to the shared secret
+ crypto::key_derivation derivation;
+ if (good_signature[0])
+ THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(shared_secret[0], rct::rct2sk(rct::I), derivation), error::wallet_internal_error, "Failed to generate key derivation");
+
+ std::vector<crypto::key_derivation> additional_derivations(num_sigs - 1);
+ for (size_t i = 1; i < num_sigs; ++i)
+ if (good_signature[i])
+ THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(shared_secret[i], rct::rct2sk(rct::I), additional_derivations[i - 1]), error::wallet_internal_error, "Failed to generate key derivation");
+
+ check_tx_key_helper(txid, derivation, additional_derivations, address, received, in_pool, confirmations);
+ return true;
+ }
+ return false;
+}
+
std::string wallet2::get_wallet_file() const
{
return m_wallet_file;
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index 6e01d4e28..cff10fa11 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -684,6 +684,10 @@ namespace tools
uint32_t get_confirm_backlog_threshold() const { return m_confirm_backlog_threshold; };
bool get_tx_key(const crypto::hash &txid, crypto::secret_key &tx_key, std::vector<crypto::secret_key> &additional_tx_keys) const;
+ void check_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations);
+ void check_tx_key_helper(const crypto::hash &txid, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations);
+ std::string get_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message, std::string &error_str);
+ bool check_tx_proof(const crypto::hash &txid, const cryptonote::account_public_address &address, bool is_subaddress, const std::string &message, const std::string &sig_str, uint64_t &received, bool &in_pool, uint64_t &confirmations);
/*!
* \brief GUI Address book get/store
diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h
index 432c820cb..8d6b2ffa9 100644
--- a/src/wallet/wallet2_api.h
+++ b/src/wallet/wallet2_api.h
@@ -700,6 +700,9 @@ struct Wallet
*/
virtual std::string getUserNote(const std::string &txid) const = 0;
virtual std::string getTxKey(const std::string &txid) const = 0;
+ virtual bool checkTxKey(const std::string &txid, std::string tx_key, const std::string &address, uint64_t &received, bool &in_pool, uint64_t &confirmations) = 0;
+ virtual std::string getTxProof(const std::string &txid, const std::string &address, const std::string &message, std::string &error_str) const = 0;
+ virtual bool checkTxProof(const std::string &txid, const std::string &address, const std::string &message, const std::string &signature, bool &good, uint64_t &received, bool &in_pool, uint64_t &confirmations) = 0;
/*
* \brief signMessage - sign a message with the spend private key
@@ -819,19 +822,6 @@ struct WalletManager
*/
virtual std::vector<std::string> findWallets(const std::string &path) = 0;
- /*!
- * \brief checkPayment - checks a payment was made using a txkey
- * \param address - the address the payment was sent to
- * \param txid - the transaction id for that payment
- * \param txkey - the transaction's secret key
- * \param daemon_address - the address (host and port) to the daemon to request transaction data
- * \param received - if succesful, will hold the amount of monero received
- * \param height - if succesful, will hold the height of the transaction (0 if only in the pool)
- * \param error - if unsuccesful, will hold an error string with more information about the error
- * \return - true is succesful, false otherwise
- */
- virtual bool checkPayment(const std::string &address, const std::string &txid, const std::string &txkey, const std::string &daemon_address, uint64_t &received, uint64_t &height, std::string &error) const = 0;
-
//! returns verbose error string regarding last error;
virtual std::string errorString() const = 0;
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index 7846231c2..cf404543c 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -624,6 +624,8 @@ namespace tools
if (req.get_tx_key)
{
res.tx_key = epee::string_tools::pod_to_hex(ptx_vector.back().tx_key);
+ for (const crypto::secret_key& additional_tx_key : ptx_vector.back().additional_tx_keys)
+ res.tx_key += epee::string_tools::pod_to_hex(additional_tx_key);
}
res.fee = ptx_vector.back().fee;
@@ -686,6 +688,8 @@ namespace tools
if (req.get_tx_keys)
{
res.tx_key_list.push_back(epee::string_tools::pod_to_hex(ptx.tx_key));
+ for (const crypto::secret_key& additional_tx_key : ptx.additional_tx_keys)
+ res.tx_key_list.back() += epee::string_tools::pod_to_hex(additional_tx_key);
}
// Compute amount leaving wallet in tx. By convention dests does not include change outputs
ptx_amount = 0;
@@ -1397,6 +1401,163 @@ namespace tools
res.value = m_wallet->get_attribute(req.key);
return true;
}
+ bool wallet_rpc_server::on_get_tx_key(const wallet_rpc::COMMAND_RPC_GET_TX_KEY::request& req, wallet_rpc::COMMAND_RPC_GET_TX_KEY::response& res, epee::json_rpc::error& er)
+ {
+ if (!m_wallet) return not_open(er);
+
+ crypto::hash txid;
+ if (!epee::string_tools::hex_to_pod(req.txid, txid))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_TXID;
+ er.message = "TX ID has invalid format";
+ return false;
+ }
+
+ crypto::secret_key tx_key;
+ std::vector<crypto::secret_key> additional_tx_keys;
+ if (!m_wallet->get_tx_key(txid, tx_key, additional_tx_keys))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_NO_TXKEY;
+ er.message = "No tx secret key is stored for this tx";
+ return false;
+ }
+
+ std::ostringstream oss;
+ oss << epee::string_tools::pod_to_hex(tx_key);
+ for (size_t i = 0; i < additional_tx_keys.size(); ++i)
+ oss << epee::string_tools::pod_to_hex(additional_tx_keys[i]);
+ res.tx_key = oss.str();
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
+ bool wallet_rpc_server::on_check_tx_key(const wallet_rpc::COMMAND_RPC_CHECK_TX_KEY::request& req, wallet_rpc::COMMAND_RPC_CHECK_TX_KEY::response& res, epee::json_rpc::error& er)
+ {
+ if (!m_wallet) return not_open(er);
+
+ crypto::hash txid;
+ if (!epee::string_tools::hex_to_pod(req.txid, txid))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_TXID;
+ er.message = "TX ID has invalid format";
+ return false;
+ }
+
+ std::string tx_key_str = req.tx_key;
+ crypto::secret_key tx_key;
+ if (!epee::string_tools::hex_to_pod(tx_key_str.substr(0, 64), tx_key))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_KEY;
+ er.message = "Tx key has invalid format";
+ return false;
+ }
+ tx_key_str = tx_key_str.substr(64);
+ std::vector<crypto::secret_key> additional_tx_keys;
+ while (!tx_key_str.empty())
+ {
+ additional_tx_keys.resize(additional_tx_keys.size() + 1);
+ if (!epee::string_tools::hex_to_pod(tx_key_str.substr(0, 64), additional_tx_keys.back()))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_KEY;
+ er.message = "Tx key has invalid format";
+ return false;
+ }
+ tx_key_str = tx_key_str.substr(64);
+ }
+
+ cryptonote::address_parse_info info;
+ if(!get_account_address_from_str(info, m_wallet->testnet(), req.address))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_ADDRESS;
+ er.message = "Invalid address";
+ return false;
+ }
+
+ try
+ {
+ m_wallet->check_tx_key(txid, tx_key, additional_tx_keys, info.address, res.received, res.in_pool, res.confirmations);
+ }
+ catch (const std::exception &e)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = e.what();
+ return false;
+ }
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
+ bool wallet_rpc_server::on_get_tx_proof(const wallet_rpc::COMMAND_RPC_GET_TX_PROOF::request& req, wallet_rpc::COMMAND_RPC_GET_TX_PROOF::response& res, epee::json_rpc::error& er)
+ {
+ if (!m_wallet) return not_open(er);
+
+ crypto::hash txid;
+ if (!epee::string_tools::hex_to_pod(req.txid, txid))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_TXID;
+ er.message = "TX ID has invalid format";
+ return false;
+ }
+
+ cryptonote::address_parse_info info;
+ if(!get_account_address_from_str(info, m_wallet->testnet(), req.address))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_ADDRESS;
+ er.message = "Invalid address";
+ return false;
+ }
+
+ try
+ {
+ res.signature = m_wallet->get_tx_proof(txid, info.address, info.is_subaddress, req.message, er.message);
+ if (res.signature.empty())
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ return false;
+ }
+ }
+ catch (const std::exception &e)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = e.what();
+ return false;
+ }
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
+ bool wallet_rpc_server::on_check_tx_proof(const wallet_rpc::COMMAND_RPC_CHECK_TX_PROOF::request& req, wallet_rpc::COMMAND_RPC_CHECK_TX_PROOF::response& res, epee::json_rpc::error& er)
+ {
+ if (!m_wallet) return not_open(er);
+
+ crypto::hash txid;
+ if (!epee::string_tools::hex_to_pod(req.txid, txid))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_TXID;
+ er.message = "TX ID has invalid format";
+ return false;
+ }
+
+ cryptonote::address_parse_info info;
+ if(!get_account_address_from_str(info, m_wallet->testnet(), req.address))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_WRONG_ADDRESS;
+ er.message = "Invalid address";
+ return false;
+ }
+
+ try
+ {
+ uint64_t received;
+ bool in_pool;
+ uint64_t confirmations;
+ res.good = m_wallet->check_tx_proof(txid, info.address, info.is_subaddress, req.message, req.signature, res.received, res.in_pool, res.confirmations);
+ }
+ catch (const std::exception &e)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
+ er.message = e.what();
+ return false;
+ }
+ return true;
+ }
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_get_transfers(const wallet_rpc::COMMAND_RPC_GET_TRANSFERS::request& req, wallet_rpc::COMMAND_RPC_GET_TRANSFERS::response& res, epee::json_rpc::error& er)
{
diff --git a/src/wallet/wallet_rpc_server.h b/src/wallet/wallet_rpc_server.h
index 36a853a1a..87e442bae 100644
--- a/src/wallet/wallet_rpc_server.h
+++ b/src/wallet/wallet_rpc_server.h
@@ -93,6 +93,10 @@ namespace tools
MAP_JON_RPC_WE("get_tx_notes", on_get_tx_notes, wallet_rpc::COMMAND_RPC_GET_TX_NOTES)
MAP_JON_RPC_WE("set_attribute", on_set_attribute, wallet_rpc::COMMAND_RPC_SET_ATTRIBUTE)
MAP_JON_RPC_WE("get_attribute", on_get_attribute, wallet_rpc::COMMAND_RPC_GET_ATTRIBUTE)
+ MAP_JON_RPC_WE("get_tx_key", on_get_tx_key, wallet_rpc::COMMAND_RPC_GET_TX_KEY)
+ MAP_JON_RPC_WE("check_tx_key", on_check_tx_key, wallet_rpc::COMMAND_RPC_CHECK_TX_KEY)
+ MAP_JON_RPC_WE("get_tx_proof", on_get_tx_proof, wallet_rpc::COMMAND_RPC_GET_TX_PROOF)
+ MAP_JON_RPC_WE("check_tx_proof", on_check_tx_proof, wallet_rpc::COMMAND_RPC_CHECK_TX_PROOF)
MAP_JON_RPC_WE("get_transfers", on_get_transfers, wallet_rpc::COMMAND_RPC_GET_TRANSFERS)
MAP_JON_RPC_WE("get_transfer_by_txid", on_get_transfer_by_txid, wallet_rpc::COMMAND_RPC_GET_TRANSFER_BY_TXID)
MAP_JON_RPC_WE("sign", on_sign, wallet_rpc::COMMAND_RPC_SIGN)
@@ -140,6 +144,10 @@ namespace tools
bool on_get_tx_notes(const wallet_rpc::COMMAND_RPC_GET_TX_NOTES::request& req, wallet_rpc::COMMAND_RPC_GET_TX_NOTES::response& res, epee::json_rpc::error& er);
bool on_set_attribute(const wallet_rpc::COMMAND_RPC_SET_ATTRIBUTE::request& req, wallet_rpc::COMMAND_RPC_SET_ATTRIBUTE::response& res, epee::json_rpc::error& er);
bool on_get_attribute(const wallet_rpc::COMMAND_RPC_GET_ATTRIBUTE::request& req, wallet_rpc::COMMAND_RPC_GET_ATTRIBUTE::response& res, epee::json_rpc::error& er);
+ bool on_get_tx_key(const wallet_rpc::COMMAND_RPC_GET_TX_KEY::request& req, wallet_rpc::COMMAND_RPC_GET_TX_KEY::response& res, epee::json_rpc::error& er);
+ bool on_check_tx_key(const wallet_rpc::COMMAND_RPC_CHECK_TX_KEY::request& req, wallet_rpc::COMMAND_RPC_CHECK_TX_KEY::response& res, epee::json_rpc::error& er);
+ bool on_get_tx_proof(const wallet_rpc::COMMAND_RPC_GET_TX_PROOF::request& req, wallet_rpc::COMMAND_RPC_GET_TX_PROOF::response& res, epee::json_rpc::error& er);
+ bool on_check_tx_proof(const wallet_rpc::COMMAND_RPC_CHECK_TX_PROOF::request& req, wallet_rpc::COMMAND_RPC_CHECK_TX_PROOF::response& res, epee::json_rpc::error& er);
bool on_get_transfers(const wallet_rpc::COMMAND_RPC_GET_TRANSFERS::request& req, wallet_rpc::COMMAND_RPC_GET_TRANSFERS::response& res, epee::json_rpc::error& er);
bool on_get_transfer_by_txid(const wallet_rpc::COMMAND_RPC_GET_TRANSFER_BY_TXID::request& req, wallet_rpc::COMMAND_RPC_GET_TRANSFER_BY_TXID::response& res, epee::json_rpc::error& er);
bool on_sign(const wallet_rpc::COMMAND_RPC_SIGN::request& req, wallet_rpc::COMMAND_RPC_SIGN::response& res, epee::json_rpc::error& er);
diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h
index 9bcc5138a..2e7c7c76f 100644
--- a/src/wallet/wallet_rpc_server_commands_defs.h
+++ b/src/wallet/wallet_rpc_server_commands_defs.h
@@ -828,6 +828,114 @@ namespace wallet_rpc
};
};
+ struct COMMAND_RPC_GET_TX_KEY
+ {
+ struct request
+ {
+ std::string txid;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(txid)
+ END_KV_SERIALIZE_MAP()
+ };
+
+ struct response
+ {
+ std::string tx_key;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(tx_key)
+ END_KV_SERIALIZE_MAP()
+ };
+ };
+
+ struct COMMAND_RPC_CHECK_TX_KEY
+ {
+ struct request
+ {
+ std::string txid;
+ std::string tx_key;
+ std::string address;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(txid)
+ KV_SERIALIZE(tx_key)
+ KV_SERIALIZE(address)
+ END_KV_SERIALIZE_MAP()
+ };
+
+ struct response
+ {
+ uint64_t received;
+ bool in_pool;
+ uint64_t confirmations;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(received)
+ KV_SERIALIZE(in_pool)
+ KV_SERIALIZE(confirmations)
+ END_KV_SERIALIZE_MAP()
+ };
+ };
+
+ struct COMMAND_RPC_GET_TX_PROOF
+ {
+ struct request
+ {
+ std::string txid;
+ std::string address;
+ std::string message;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(txid)
+ KV_SERIALIZE(address)
+ KV_SERIALIZE(message)
+ END_KV_SERIALIZE_MAP()
+ };
+
+ struct response
+ {
+ std::string signature;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(signature)
+ END_KV_SERIALIZE_MAP()
+ };
+ };
+
+ struct COMMAND_RPC_CHECK_TX_PROOF
+ {
+ struct request
+ {
+ std::string txid;
+ std::string address;
+ std::string message;
+ std::string signature;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(txid)
+ KV_SERIALIZE(address)
+ KV_SERIALIZE(message)
+ KV_SERIALIZE(signature)
+ END_KV_SERIALIZE_MAP()
+ };
+
+ struct response
+ {
+ bool good;
+ uint64_t received;
+ bool in_pool;
+ uint64_t confirmations;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(good)
+ KV_SERIALIZE(received)
+ KV_SERIALIZE(in_pool)
+ KV_SERIALIZE(confirmations)
+ END_KV_SERIALIZE_MAP()
+ };
+ };
+
struct transfer_entry
{
std::string txid;
diff --git a/src/wallet/wallet_rpc_server_error_codes.h b/src/wallet/wallet_rpc_server_error_codes.h
index e74e9110b..74f2999b6 100644
--- a/src/wallet/wallet_rpc_server_error_codes.h
+++ b/src/wallet/wallet_rpc_server_error_codes.h
@@ -54,3 +54,5 @@
#define WALLET_RPC_ERROR_CODE_WALLET_ALREADY_EXISTS -21
#define WALLET_RPC_ERROR_CODE_INVALID_PASSWORD -22
#define WALLET_RPC_ERROR_CODE_NO_WALLET_DIR -23
+#define WALLET_RPC_ERROR_CODE_NO_TXKEY -24
+#define WALLET_RPC_ERROR_CODE_WRONG_KEY -25