mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-17 15:21:30 +02:00
continue renaming tx and block ids to hashes
This commit is contained in:
+40
-40
@@ -666,12 +666,12 @@ namespace monero {
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get a wallet transaction by id.
|
||||
// * Get a wallet transaction by hash.
|
||||
// *
|
||||
// * @param tx_id is an id of a transaction to get
|
||||
// * @param tx_hash is a hash of a transaction to get
|
||||
// * @return monero_tx_wallet is the identified transactions
|
||||
// */
|
||||
// public monero_tx_wallet getTx(string tx_id);
|
||||
// public monero_tx_wallet getTx(string tx_hash);
|
||||
|
||||
/**
|
||||
* Get all wallet transactions. Wallet transactions contain one or more
|
||||
@@ -684,12 +684,12 @@ namespace monero {
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get wallet transactions by id.
|
||||
// * Get wallet transactions by hash.
|
||||
// *
|
||||
// * @param tx_ids are ids of transactions to get
|
||||
// * @param tx_hashes are hashes of transactions to get
|
||||
// * @return the identified transactions
|
||||
// */
|
||||
// public List<monero_tx_wallet> get_txs(Collection<string> tx_ids);
|
||||
// public List<monero_tx_wallet> get_txs(Collection<string> tx_hashes);
|
||||
|
||||
/**
|
||||
* Get wallet transactions. Wallet transactions contain one or more
|
||||
@@ -708,15 +708,15 @@ namespace monero {
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as get_txs(request) but collects missing tx ids instead of throwing an error.
|
||||
* Same as get_txs(request) but collects missing tx hashes instead of throwing an error.
|
||||
* This method is separated because WebAssembly does not support exception handling.
|
||||
*
|
||||
* @param request filters query results (optional)
|
||||
* @param missing_tx_ids are populated with requested tx ids that are not part of the wallet
|
||||
* @param missing_tx_hashes are populated with requested tx hashes that are not part of the wallet
|
||||
* @return wallet transactions per the request
|
||||
*/
|
||||
virtual vector<shared_ptr<monero_tx_wallet>> get_txs(const monero_tx_query& query, vector<string>& missing_tx_ids) const {
|
||||
throw runtime_error("get_txs(query, missing_tx_ids) not supported");
|
||||
virtual vector<shared_ptr<monero_tx_wallet>> get_txs(const monero_tx_query& query, vector<string>& missing_tx_hashes) const {
|
||||
throw runtime_error("get_txs(query, missing_tx_hashes) not supported");
|
||||
}
|
||||
|
||||
// /**
|
||||
@@ -901,7 +901,7 @@ namespace monero {
|
||||
* Relay a transaction previously created without relaying.
|
||||
*
|
||||
* @param txMetadata is transaction metadata previously created without relaying
|
||||
* @return string is the id of the relayed tx
|
||||
* @return string is the hash of the relayed tx
|
||||
*/
|
||||
virtual string relay_tx(const string& tx_metadata) {
|
||||
throw runtime_error("relay_tx() not supported");
|
||||
@@ -911,7 +911,7 @@ namespace monero {
|
||||
* Relay a previously created transaction.
|
||||
*
|
||||
* @param tx is the transaction to relay
|
||||
* @return the id of the relayed tx
|
||||
* @return the hash of the relayed tx
|
||||
*/
|
||||
virtual string relay_tx(const monero_tx_wallet& tx) {
|
||||
throw runtime_error("relay_tx() not supported");
|
||||
@@ -921,7 +921,7 @@ namespace monero {
|
||||
* Relay transactions previously created without relaying.
|
||||
*
|
||||
* @param tx_metadatas are transaction metadata previously created without relaying
|
||||
* @return the ids of the relayed txs
|
||||
* @return the hashes of the relayed txs
|
||||
*/
|
||||
virtual vector<string> relay_txs(const vector<string>& tx_metadatas) {
|
||||
throw runtime_error("relay_txs() not supported");
|
||||
@@ -931,7 +931,7 @@ namespace monero {
|
||||
* Relay previously created transactions.
|
||||
*
|
||||
* @param txs are the transactions to relay
|
||||
* @return the ids of the relayed txs
|
||||
* @return the hashes of the relayed txs
|
||||
*/
|
||||
virtual vector<string> relay_txs(const vector<shared_ptr<monero_tx_wallet>>& txs) {
|
||||
throw runtime_error("relay_txs() not supported");
|
||||
@@ -1135,89 +1135,89 @@ namespace monero {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a transaction's secret key from its id.
|
||||
* Get a transaction's secret key from its hash.
|
||||
*
|
||||
* @param tx_id is the transaction's id
|
||||
* @param tx_hash is the transaction's hash
|
||||
* @return is the transaction's secret key
|
||||
*/
|
||||
virtual string get_tx_key(const string& tx_id) const {
|
||||
virtual string get_tx_key(const string& tx_hash) const {
|
||||
throw runtime_error("get_tx_key() not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a transaction in the blockchain with its secret key.
|
||||
*
|
||||
* @param tx_id specifies the transaction to check
|
||||
* @param tx_hash specifies the transaction to check
|
||||
* @param txKey is the transaction's secret key
|
||||
* @param address is the destination public address of the transaction
|
||||
* @return the result of the check
|
||||
*/
|
||||
virtual shared_ptr<monero_check_tx> check_tx_key(const string& tx_id, const string& txKey, const string& address) const {
|
||||
virtual shared_ptr<monero_check_tx> check_tx_key(const string& tx_hash, const string& txKey, const string& address) const {
|
||||
throw runtime_error("check_tx_key() not supported");
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Get a transaction signature to prove it.
|
||||
// *
|
||||
// * @param tx_id specifies the transaction to prove
|
||||
// * @param tx_hash specifies the transaction to prove
|
||||
// * @param address is the destination public address of the transaction
|
||||
// * @return the transaction signature
|
||||
// */
|
||||
// string get_tx_proof(const string& tx_id, const string& address) const;
|
||||
// string get_tx_proof(const string& tx_hash, const string& address) const;
|
||||
|
||||
/**
|
||||
* Get a transaction signature to prove it.
|
||||
*
|
||||
* @param tx_id specifies the transaction to prove
|
||||
* @param tx_hash specifies the transaction to prove
|
||||
* @param address is the destination public address of the transaction
|
||||
* @param message is a message to include with the signature to further authenticate the proof (optional)
|
||||
* @return the transaction signature
|
||||
*/
|
||||
virtual string get_tx_proof(const string& tx_id, const string& address, const string& message) const {
|
||||
virtual string get_tx_proof(const string& tx_hash, const string& address, const string& message) const {
|
||||
throw runtime_error("get_tx_proof() not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Prove a transaction by checking its signature.
|
||||
*
|
||||
* @param tx_id specifies the transaction to prove
|
||||
* @param tx_hash specifies the transaction to prove
|
||||
* @param address is the destination public address of the transaction
|
||||
* @param message is a message included with the signature to further authenticate the proof (optional)
|
||||
* @param signature is the transaction signature to confirm
|
||||
* @return the result of the check
|
||||
*/
|
||||
virtual shared_ptr<monero_check_tx> check_tx_proof(const string& tx_id, const string& address, const string& message, const string& signature) const {
|
||||
virtual shared_ptr<monero_check_tx> check_tx_proof(const string& tx_hash, const string& address, const string& message, const string& signature) const {
|
||||
throw runtime_error("check_tx_proof() not supported");
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Generate a signature to prove a spend. Unlike proving a transaction, it does not require the destination public address.
|
||||
// *
|
||||
// * @param tx_id specifies the transaction to prove
|
||||
// * @param tx_hash specifies the transaction to prove
|
||||
// * @return the transaction signature
|
||||
// */
|
||||
// string get_spend_proof(const string& tx_id) const;
|
||||
// string get_spend_proof(const string& tx_hash) const;
|
||||
|
||||
/**
|
||||
* Generate a signature to prove a spend. Unlike proving a transaction, it does not require the destination public address.
|
||||
*
|
||||
* @param tx_id specifies the transaction to prove
|
||||
* @param tx_hash specifies the transaction to prove
|
||||
* @param message is a message to include with the signature to further authenticate the proof (optional)
|
||||
* @return the transaction signature
|
||||
*/
|
||||
virtual string get_spend_proof(const string& tx_id, const string& message) const {
|
||||
virtual string get_spend_proof(const string& tx_hash, const string& message) const {
|
||||
throw runtime_error("get_spend_proof() not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Prove a spend using a signature. Unlike proving a transaction, it does not require the destination public address.
|
||||
*
|
||||
* @param tx_id specifies the transaction to prove
|
||||
* @param tx_hash specifies the transaction to prove
|
||||
* @param message is a message included with the signature to further authenticate the proof (optional)
|
||||
* @param signature is the transaction signature to confirm
|
||||
* @return true if the signature is good, false otherwise
|
||||
*/
|
||||
virtual bool check_spend_proof(const string& tx_id, const string& message, const string& signature) const {
|
||||
virtual bool check_spend_proof(const string& tx_hash, const string& message, const string& signature) const {
|
||||
throw runtime_error("check_spend_proof() not supported");
|
||||
}
|
||||
|
||||
@@ -1258,40 +1258,40 @@ namespace monero {
|
||||
/**
|
||||
* Get a transaction note.
|
||||
*
|
||||
* @param tx_id specifies the transaction to get the note of
|
||||
* @param tx_hash specifies the transaction to get the note of
|
||||
* @return the tx note
|
||||
*/
|
||||
virtual string get_tx_note(const string& tx_id) const {
|
||||
virtual string get_tx_note(const string& tx_hash) const {
|
||||
throw runtime_error("get_tx_note() not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get notes for multiple transactions.
|
||||
*
|
||||
* @param tx_ids identify the transactions to get notes for
|
||||
* @param tx_hashes identify the transactions to get notes for
|
||||
* @preturns notes for the transactions
|
||||
*/
|
||||
virtual vector<string> get_tx_notes(const vector<string>& tx_ids) const {
|
||||
virtual vector<string> get_tx_notes(const vector<string>& tx_hashes) const {
|
||||
throw runtime_error("get_tx_notes() not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a note for a specific transaction.
|
||||
*
|
||||
* @param tx_id specifies the transaction
|
||||
* @param tx_hash specifies the transaction
|
||||
* @param note specifies the note
|
||||
*/
|
||||
virtual void set_tx_note(const string& tx_id, const string& note) {
|
||||
virtual void set_tx_note(const string& tx_hash, const string& note) {
|
||||
throw runtime_error("set_tx_note() not supported");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set notes for multiple transactions.
|
||||
*
|
||||
* @param tx_ids specify the transactions to set notes for
|
||||
* @param tx_hashes specify the transactions to set notes for
|
||||
* @param notes are the notes to set for the transactions
|
||||
*/
|
||||
virtual void set_tx_notes(const vector<string>& tx_ids, const vector<string>& notes) {
|
||||
virtual void set_tx_notes(const vector<string>& tx_hashes, const vector<string>& notes) {
|
||||
throw runtime_error("set_tx_notes() not supported");
|
||||
}
|
||||
|
||||
@@ -1530,7 +1530,7 @@ namespace monero {
|
||||
* Submit signed multisig transactions as represented by a hex string.
|
||||
*
|
||||
* @param signed_multisig_tx_hex is the signed multisig hex returned from signMultisigTxs()
|
||||
* @return the resulting transaction ids
|
||||
* @return the resulting transaction hashes
|
||||
*/
|
||||
virtual vector<string> submit_multisig_tx_hex(const string& signed_multisig_tx_hex) {
|
||||
throw runtime_error("submit_multisig_tx_hex() not supported");
|
||||
|
||||
@@ -362,12 +362,12 @@ namespace monero {
|
||||
* when sent from/to same account #4500
|
||||
*
|
||||
* @param tx is the transaction to merge into the existing txs
|
||||
* @param tx_map maps tx ids to txs
|
||||
* @param tx_map maps tx hashes to txs
|
||||
* @param block_map maps block heights to blocks
|
||||
* @param skip_if_absent specifies if the tx should not be added if it doesn't already exist
|
||||
*/
|
||||
void merge_tx(const shared_ptr<monero_tx_wallet>& tx, map<string, shared_ptr<monero_tx_wallet>>& tx_map, map<uint64_t, shared_ptr<monero_block>>& block_map, bool skip_if_absent) {
|
||||
if (tx->m_hash == boost::none) throw runtime_error("Tx id is not initialized");
|
||||
if (tx->m_hash == boost::none) throw runtime_error("Tx hash is not initialized");
|
||||
|
||||
// if tx doesn't exist, add it (unless skipped)
|
||||
map<string, shared_ptr<monero_tx_wallet>>::const_iterator tx_iter = tx_map.find(*tx->m_hash);
|
||||
@@ -1430,17 +1430,17 @@ namespace monero {
|
||||
}
|
||||
txs = queried_txs;
|
||||
|
||||
// verify all specified tx ids found
|
||||
// verify all specified tx hashes found
|
||||
if (!_query->m_tx_hashes.empty()) {
|
||||
for (const string& tx_id : _query->m_tx_hashes) {
|
||||
for (const string& tx_hash : _query->m_tx_hashes) {
|
||||
bool found = false;
|
||||
for (const shared_ptr<monero_tx_wallet>& tx : txs) {
|
||||
if (tx_id == *tx->m_hash) {
|
||||
if (tx_hash == *tx->m_hash) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) throw runtime_error("Tx not found in wallet: " + tx_id);
|
||||
if (!found) throw runtime_error("Tx not found in wallet: " + tx_hash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1450,11 +1450,11 @@ namespace monero {
|
||||
if (*tx->m_is_confirmed && tx->m_block == boost::none) return get_txs(*_query);
|
||||
}
|
||||
|
||||
// otherwise order txs if tx ids given then return
|
||||
// otherwise order txs if tx hashes given then return
|
||||
if (!_query->m_tx_hashes.empty()) {
|
||||
vector<shared_ptr<monero_tx_wallet>> ordered_txs;
|
||||
for (const string& tx_id : _query->m_tx_hashes) {
|
||||
map<string, shared_ptr<monero_tx_wallet>>::const_iterator tx_iter = tx_map.find(tx_id);
|
||||
for (const string& tx_hash : _query->m_tx_hashes) {
|
||||
map<string, shared_ptr<monero_tx_wallet>>::const_iterator tx_iter = tx_map.find(tx_hash);
|
||||
ordered_txs.push_back(tx_iter->second);
|
||||
}
|
||||
txs = ordered_txs;
|
||||
@@ -1790,7 +1790,7 @@ namespace monero {
|
||||
MTRACE("relay_txs()");
|
||||
|
||||
// relay each metadata as a tx
|
||||
vector<string> tx_ids;
|
||||
vector<string> tx_hashes;
|
||||
for (const auto& txMetadata : tx_metadatas) {
|
||||
|
||||
// parse tx metadata hex
|
||||
@@ -1816,12 +1816,12 @@ namespace monero {
|
||||
throw runtime_error("Failed to commit tx");
|
||||
}
|
||||
|
||||
// collect resulting id
|
||||
tx_ids.push_back(epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(ptx.tx)));
|
||||
// collect resulting hash
|
||||
tx_hashes.push_back(epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(ptx.tx)));
|
||||
}
|
||||
|
||||
// return relayed tx ids
|
||||
return tx_ids;
|
||||
// return relayed tx hashes
|
||||
return tx_hashes;
|
||||
}
|
||||
|
||||
vector<string> monero_wallet_core::relay_txs(const vector<shared_ptr<monero_tx_wallet>>& txs) {
|
||||
@@ -1903,16 +1903,16 @@ namespace monero {
|
||||
list<uint64_t> tx_fees;
|
||||
string multisig_tx_hex;
|
||||
string unsigned_tx_hex;
|
||||
list<string> tx_ids;
|
||||
list<string> tx_hashes;
|
||||
list<string> tx_blobs;
|
||||
list<string> tx_metadatas;
|
||||
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_hex, unsigned_tx_hex, m_do_not_relay, tx_ids, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, err)) {
|
||||
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_hex, unsigned_tx_hex, m_do_not_relay, tx_hashes, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, err)) {
|
||||
throw runtime_error("need to handle error filling response!"); // TODO
|
||||
}
|
||||
|
||||
// build sent txs from results // TODO: break this into separate utility function
|
||||
vector<shared_ptr<monero_tx_wallet>> txs;
|
||||
auto tx_ids_iter = tx_ids.begin();
|
||||
auto tx_hashes_iter = tx_hashes.begin();
|
||||
auto tx_keys_iter = tx_keys.begin();
|
||||
auto tx_amounts_iter = tx_amounts.begin();
|
||||
auto tx_fees_iter = tx_fees.begin();
|
||||
@@ -1923,7 +1923,7 @@ namespace monero {
|
||||
// init tx with outgoing transfer from filled values
|
||||
shared_ptr<monero_tx_wallet> tx = make_shared<monero_tx_wallet>();
|
||||
txs.push_back(tx);
|
||||
tx->m_hash = *tx_ids_iter;
|
||||
tx->m_hash = *tx_hashes_iter;
|
||||
tx->m_key = *tx_keys_iter;
|
||||
tx->m_fee = *tx_fees_iter;
|
||||
tx->m_full_hex = *tx_blobs_iter;
|
||||
@@ -1955,7 +1955,7 @@ namespace monero {
|
||||
tx_keys_iter++;
|
||||
tx_amounts_iter++;
|
||||
tx_fees_iter++;
|
||||
tx_ids_iter++;
|
||||
tx_hashes_iter++;
|
||||
tx_blobs_iter++;
|
||||
tx_metadatas_iter++;
|
||||
}
|
||||
@@ -2079,16 +2079,16 @@ namespace monero {
|
||||
list<uint64_t> tx_fees;
|
||||
string multisig_tx_hex;
|
||||
string unsigned_tx_hex;
|
||||
list<string> tx_ids;
|
||||
list<string> tx_hashes;
|
||||
list<string> tx_blobs;
|
||||
list<string> tx_metadatas;
|
||||
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_hex, unsigned_tx_hex, do_not_relay, tx_ids, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, err)) {
|
||||
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_hex, unsigned_tx_hex, do_not_relay, tx_hashes, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, err)) {
|
||||
throw runtime_error("need to handle error filling response!"); // TODO
|
||||
}
|
||||
|
||||
// build sent txs from results // TODO: break this into separate utility function
|
||||
vector<shared_ptr<monero_tx_wallet>> txs;
|
||||
auto tx_ids_iter = tx_ids.begin();
|
||||
auto tx_hashes_iter = tx_hashes.begin();
|
||||
auto tx_keys_iter = tx_keys.begin();
|
||||
auto tx_amounts_iter = tx_amounts.begin();
|
||||
auto tx_fees_iter = tx_fees.begin();
|
||||
@@ -2099,7 +2099,7 @@ namespace monero {
|
||||
// init tx with outgoing transfer from filled values
|
||||
shared_ptr<monero_tx_wallet> tx = make_shared<monero_tx_wallet>();
|
||||
txs.push_back(tx);
|
||||
tx->m_hash = *tx_ids_iter;
|
||||
tx->m_hash = *tx_hashes_iter;
|
||||
tx->m_is_locked = true;
|
||||
tx->m_is_outgoing = true;
|
||||
tx->m_key = *tx_keys_iter;
|
||||
@@ -2132,7 +2132,7 @@ namespace monero {
|
||||
tx_keys_iter++;
|
||||
tx_amounts_iter++;
|
||||
tx_fees_iter++;
|
||||
tx_ids_iter++;
|
||||
tx_hashes_iter++;
|
||||
tx_blobs_iter++;
|
||||
tx_metadatas_iter++;
|
||||
}
|
||||
@@ -2197,16 +2197,16 @@ namespace monero {
|
||||
list<uint64_t> tx_fees;
|
||||
string multisig_tx_hex;
|
||||
string unsigned_tx_hex;
|
||||
list<string> tx_ids;
|
||||
list<string> tx_hashes;
|
||||
list<string> tx_blobs;
|
||||
list<string> tx_metadatas;
|
||||
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_hex, unsigned_tx_hex, m_do_not_relay, tx_ids, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, err)) {
|
||||
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_hex, unsigned_tx_hex, m_do_not_relay, tx_hashes, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, err)) {
|
||||
throw runtime_error("need to handle error filling response!"); // TODO: return err message
|
||||
}
|
||||
|
||||
// build sent txs from results // TODO: use common utility with send_split() to avoid code duplication
|
||||
vector<shared_ptr<monero_tx_wallet>> txs;
|
||||
auto tx_ids_iter = tx_ids.begin();
|
||||
auto tx_hashes_iter = tx_hashes.begin();
|
||||
auto tx_keys_iter = tx_keys.begin();
|
||||
auto tx_amounts_iter = tx_amounts.begin();
|
||||
auto tx_fees_iter = tx_fees.begin();
|
||||
@@ -2217,7 +2217,7 @@ namespace monero {
|
||||
// init tx with outgoing transfer from filled values
|
||||
shared_ptr<monero_tx_wallet> tx = make_shared<monero_tx_wallet>();
|
||||
txs.push_back(tx);
|
||||
tx->m_hash = *tx_ids_iter;
|
||||
tx->m_hash = *tx_hashes_iter;
|
||||
tx->m_is_outgoing = true;
|
||||
tx->m_key = *tx_keys_iter;
|
||||
tx->m_fee = *tx_fees_iter;
|
||||
@@ -2250,7 +2250,7 @@ namespace monero {
|
||||
tx_keys_iter++;
|
||||
tx_amounts_iter++;
|
||||
tx_fees_iter++;
|
||||
tx_ids_iter++;
|
||||
tx_hashes_iter++;
|
||||
tx_blobs_iter++;
|
||||
tx_metadatas_iter++;
|
||||
}
|
||||
@@ -2283,17 +2283,17 @@ namespace monero {
|
||||
list<uint64_t> tx_fees;
|
||||
string multisig_tx_hex;
|
||||
string unsigned_tx_hex;
|
||||
list<string> tx_ids;
|
||||
list<string> tx_hashes;
|
||||
list<string> tx_blobs;
|
||||
list<string> tx_metadatas;
|
||||
epee::json_rpc::error er;
|
||||
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_hex, unsigned_tx_hex, do_not_relay, tx_ids, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, er)) {
|
||||
if (!fill_response(m_w2.get(), ptx_vector, get_tx_keys, tx_keys, tx_amounts, tx_fees, multisig_tx_hex, unsigned_tx_hex, do_not_relay, tx_hashes, get_tx_hex, tx_blobs, get_tx_metadata, tx_metadatas, er)) {
|
||||
throw runtime_error("need to handle error filling response!"); // TODO: return err message
|
||||
}
|
||||
|
||||
// build sent txs from results // TODO: use common utility with send_split() to avoid code duplication
|
||||
vector<shared_ptr<monero_tx_wallet>> txs;
|
||||
auto tx_ids_iter = tx_ids.begin();
|
||||
auto tx_hashes_iter = tx_hashes.begin();
|
||||
auto tx_keys_iter = tx_keys.begin();
|
||||
auto tx_amounts_iter = tx_amounts.begin();
|
||||
auto tx_fees_iter = tx_fees.begin();
|
||||
@@ -2304,7 +2304,7 @@ namespace monero {
|
||||
// init tx with outgoing transfer from filled values
|
||||
shared_ptr<monero_tx_wallet> tx = make_shared<monero_tx_wallet>();
|
||||
txs.push_back(tx);
|
||||
tx->m_hash = *tx_ids_iter;
|
||||
tx->m_hash = *tx_hashes_iter;
|
||||
tx->m_is_outgoing = true;
|
||||
tx->m_key = *tx_keys_iter;
|
||||
tx->m_fee = *tx_fees_iter;
|
||||
@@ -2332,7 +2332,7 @@ namespace monero {
|
||||
tx_keys_iter++;
|
||||
tx_amounts_iter++;
|
||||
tx_fees_iter++;
|
||||
tx_ids_iter++;
|
||||
tx_hashes_iter++;
|
||||
tx_blobs_iter++;
|
||||
tx_metadatas_iter++;
|
||||
}
|
||||
@@ -2536,48 +2536,48 @@ namespace monero {
|
||||
return m_w2->verify(msg, info.address, signature);
|
||||
}
|
||||
|
||||
string monero_wallet_core::get_tx_key(const string& tx_id) const {
|
||||
string monero_wallet_core::get_tx_key(const string& tx_hash) const {
|
||||
MTRACE("monero_wallet_core::get_tx_key()");
|
||||
|
||||
// validate and parse tx id hash
|
||||
crypto::hash tx_hash;
|
||||
if (!epee::string_tools::hex_to_pod(tx_id, tx_hash)) {
|
||||
throw runtime_error("TX ID has invalid format");
|
||||
// validate and parse tx hash
|
||||
crypto::hash _tx_hash;
|
||||
if (!epee::string_tools::hex_to_pod(tx_hash, _tx_hash)) {
|
||||
throw runtime_error("TX hash has invalid format");
|
||||
}
|
||||
|
||||
// get tx key and additional keys
|
||||
crypto::secret_key txKey;
|
||||
crypto::secret_key _tx_key;
|
||||
std::vector<crypto::secret_key> additional_tx_keys;
|
||||
if (!m_w2->get_tx_key(tx_hash, txKey, additional_tx_keys)) {
|
||||
if (!m_w2->get_tx_key(_tx_hash, _tx_key, additional_tx_keys)) {
|
||||
throw runtime_error("No tx secret key is stored for this tx");
|
||||
}
|
||||
|
||||
// build and return tx key with additional keys
|
||||
epee::wipeable_string s;
|
||||
s += epee::to_hex::wipeable_string(txKey);
|
||||
s += epee::to_hex::wipeable_string(_tx_key);
|
||||
for (size_t i = 0; i < additional_tx_keys.size(); ++i) {
|
||||
s += epee::to_hex::wipeable_string(additional_tx_keys[i]);
|
||||
}
|
||||
return std::string(s.data(), s.size());
|
||||
}
|
||||
|
||||
shared_ptr<monero_check_tx> monero_wallet_core::check_tx_key(const string& tx_id, const string& txKey, const string& address) const {
|
||||
shared_ptr<monero_check_tx> monero_wallet_core::check_tx_key(const string& tx_hash, const string& tx_key, const string& address) const {
|
||||
MTRACE("monero_wallet_core::check_tx_key()");
|
||||
|
||||
// validate and parse tx id
|
||||
crypto::hash tx_hash;
|
||||
if (!epee::string_tools::hex_to_pod(tx_id, tx_hash)) {
|
||||
throw runtime_error("TX ID has invalid format");
|
||||
// validate and parse tx hash
|
||||
crypto::hash _tx_hash;
|
||||
if (!epee::string_tools::hex_to_pod(tx_hash, _tx_hash)) {
|
||||
throw runtime_error("TX hash has invalid format");
|
||||
}
|
||||
|
||||
// validate and parse tx key
|
||||
epee::wipeable_string tx_key_str = txKey;
|
||||
epee::wipeable_string tx_key_str = tx_key;
|
||||
if (tx_key_str.size() < 64 || tx_key_str.size() % 64) {
|
||||
throw runtime_error("Tx key has invalid format");
|
||||
}
|
||||
const char *data = tx_key_str.data();
|
||||
crypto::secret_key tx_key;
|
||||
if (!epee::wipeable_string(data, 64).hex_to_pod(unwrap(unwrap(tx_key)))) {
|
||||
crypto::secret_key _tx_key;
|
||||
if (!epee::wipeable_string(data, 64).hex_to_pod(unwrap(unwrap(_tx_key)))) {
|
||||
throw runtime_error("Tx key has invalid format");
|
||||
}
|
||||
|
||||
@@ -2602,7 +2602,7 @@ namespace monero {
|
||||
uint64_t received_amount;
|
||||
bool in_tx_pool;
|
||||
uint64_t num_confirmations;
|
||||
m_w2->check_tx_key(tx_hash, tx_key, additional_tx_keys, info.address, received_amount, in_tx_pool, num_confirmations);
|
||||
m_w2->check_tx_key(_tx_hash, _tx_key, additional_tx_keys, info.address, received_amount, in_tx_pool, num_confirmations);
|
||||
shared_ptr<monero_check_tx> checkTx = make_shared<monero_check_tx>();
|
||||
checkTx->m_is_good = true; // check is good if we get this far
|
||||
checkTx->m_received_amount = received_amount;
|
||||
@@ -2611,12 +2611,12 @@ namespace monero {
|
||||
return checkTx;
|
||||
}
|
||||
|
||||
string monero_wallet_core::get_tx_proof(const string& tx_id, const string& address, const string& message) const {
|
||||
string monero_wallet_core::get_tx_proof(const string& tx_hash, const string& address, const string& message) const {
|
||||
|
||||
// validate and parse tx id hash
|
||||
crypto::hash tx_hash;
|
||||
if (!epee::string_tools::hex_to_pod(tx_id, tx_hash)) {
|
||||
throw runtime_error("TX ID has invalid format");
|
||||
// validate and parse tx hash
|
||||
crypto::hash _tx_hash;
|
||||
if (!epee::string_tools::hex_to_pod(tx_hash, _tx_hash)) {
|
||||
throw runtime_error("TX hash has invalid format");
|
||||
}
|
||||
|
||||
// validate and parse address
|
||||
@@ -2626,16 +2626,16 @@ namespace monero {
|
||||
}
|
||||
|
||||
// get tx proof
|
||||
return m_w2->get_tx_proof(tx_hash, info.address, info.is_subaddress, message);
|
||||
return m_w2->get_tx_proof(_tx_hash, info.address, info.is_subaddress, message);
|
||||
}
|
||||
|
||||
shared_ptr<monero_check_tx> monero_wallet_core::check_tx_proof(const string& tx_id, const string& address, const string& message, const string& signature) const {
|
||||
shared_ptr<monero_check_tx> monero_wallet_core::check_tx_proof(const string& tx_hash, const string& address, const string& message, const string& signature) const {
|
||||
MTRACE("monero_wallet_core::check_tx_proof()");
|
||||
|
||||
// validate and parse tx id
|
||||
crypto::hash tx_hash;
|
||||
if (!epee::string_tools::hex_to_pod(tx_id, tx_hash)) {
|
||||
throw runtime_error("TX ID has invalid format");
|
||||
// validate and parse tx hash
|
||||
crypto::hash _tx_hash;
|
||||
if (!epee::string_tools::hex_to_pod(tx_hash, _tx_hash)) {
|
||||
throw runtime_error("TX hash has invalid format");
|
||||
}
|
||||
|
||||
// validate and parse address
|
||||
@@ -2649,7 +2649,7 @@ namespace monero {
|
||||
uint64_t received_amount;
|
||||
bool in_tx_pool;
|
||||
uint64_t num_confirmations;
|
||||
checkTx->m_is_good = m_w2->check_tx_proof(tx_hash, info.address, info.is_subaddress, message, signature, received_amount, in_tx_pool, num_confirmations);
|
||||
checkTx->m_is_good = m_w2->check_tx_proof(_tx_hash, info.address, info.is_subaddress, message, signature, received_amount, in_tx_pool, num_confirmations);
|
||||
if (checkTx->m_is_good) {
|
||||
checkTx->m_received_amount = received_amount;
|
||||
checkTx->m_in_tx_pool = in_tx_pool;
|
||||
@@ -2658,30 +2658,30 @@ namespace monero {
|
||||
return checkTx;
|
||||
}
|
||||
|
||||
string monero_wallet_core::get_spend_proof(const string& tx_id, const string& message) const {
|
||||
string monero_wallet_core::get_spend_proof(const string& tx_hash, const string& message) const {
|
||||
MTRACE("monero_wallet_core::get_spend_proof()");
|
||||
|
||||
// validate and parse tx id
|
||||
crypto::hash tx_hash;
|
||||
if (!epee::string_tools::hex_to_pod(tx_id, tx_hash)) {
|
||||
throw runtime_error("TX ID has invalid format");
|
||||
// validate and parse tx hash
|
||||
crypto::hash _tx_hash;
|
||||
if (!epee::string_tools::hex_to_pod(tx_hash, _tx_hash)) {
|
||||
throw runtime_error("TX hash has invalid format");
|
||||
}
|
||||
|
||||
// return spend proof signature
|
||||
return m_w2->get_spend_proof(tx_hash, message);
|
||||
return m_w2->get_spend_proof(_tx_hash, message);
|
||||
}
|
||||
|
||||
bool monero_wallet_core::check_spend_proof(const string& tx_id, const string& message, const string& signature) const {
|
||||
bool monero_wallet_core::check_spend_proof(const string& tx_hash, const string& message, const string& signature) const {
|
||||
MTRACE("monero_wallet_core::check_spend_proof()");
|
||||
|
||||
// validate and parse tx id
|
||||
crypto::hash tx_hash;
|
||||
if (!epee::string_tools::hex_to_pod(tx_id, tx_hash)) {
|
||||
throw runtime_error("TX ID has invalid format");
|
||||
// validate and parse tx hash
|
||||
crypto::hash _tx_hash;
|
||||
if (!epee::string_tools::hex_to_pod(tx_hash, _tx_hash)) {
|
||||
throw runtime_error("TX hash has invalid format");
|
||||
}
|
||||
|
||||
// check spend proof
|
||||
return m_w2->check_spend_proof(tx_hash, message, signature);
|
||||
return m_w2->check_spend_proof(_tx_hash, message, signature);
|
||||
}
|
||||
|
||||
string monero_wallet_core::get_reserve_proof_wallet(const string& message) const {
|
||||
@@ -2718,38 +2718,38 @@ namespace monero {
|
||||
return checkReserve;
|
||||
}
|
||||
|
||||
string monero_wallet_core::get_tx_note(const string& tx_id) const {
|
||||
string monero_wallet_core::get_tx_note(const string& tx_hash) const {
|
||||
MTRACE("monero_wallet_core::get_tx_note()");
|
||||
cryptonote::blobdata tx_blob;
|
||||
if (!epee::string_tools::parse_hexstr_to_binbuff(tx_id, tx_blob) || tx_blob.size() != sizeof(crypto::hash)) {
|
||||
throw runtime_error("TX ID has invalid format");
|
||||
if (!epee::string_tools::parse_hexstr_to_binbuff(tx_hash, tx_blob) || tx_blob.size() != sizeof(crypto::hash)) {
|
||||
throw runtime_error("TX hash has invalid format");
|
||||
}
|
||||
crypto::hash tx_hash = *reinterpret_cast<const crypto::hash*>(tx_blob.data());
|
||||
return m_w2->get_tx_note(tx_hash);
|
||||
crypto::hash _tx_hash = *reinterpret_cast<const crypto::hash*>(tx_blob.data());
|
||||
return m_w2->get_tx_note(_tx_hash);
|
||||
}
|
||||
|
||||
vector<string> monero_wallet_core::get_tx_notes(const vector<string>& tx_ids) const {
|
||||
vector<string> monero_wallet_core::get_tx_notes(const vector<string>& tx_hashes) const {
|
||||
MTRACE("monero_wallet_core::get_tx_notes()");
|
||||
vector<string> notes;
|
||||
for (const auto& tx_id : tx_ids) notes.push_back(get_tx_note(tx_id));
|
||||
for (const auto& tx_hash : tx_hashes) notes.push_back(get_tx_note(tx_hash));
|
||||
return notes;
|
||||
}
|
||||
|
||||
void monero_wallet_core::set_tx_note(const string& tx_id, const string& note) {
|
||||
void monero_wallet_core::set_tx_note(const string& tx_hash, const string& note) {
|
||||
MTRACE("monero_wallet_core::set_tx_note()");
|
||||
cryptonote::blobdata tx_blob;
|
||||
if (!epee::string_tools::parse_hexstr_to_binbuff(tx_id, tx_blob) || tx_blob.size() != sizeof(crypto::hash)) {
|
||||
throw runtime_error("TX ID has invalid format");
|
||||
if (!epee::string_tools::parse_hexstr_to_binbuff(tx_hash, tx_blob) || tx_blob.size() != sizeof(crypto::hash)) {
|
||||
throw runtime_error("TX hash has invalid format");
|
||||
}
|
||||
crypto::hash tx_hash = *reinterpret_cast<const crypto::hash*>(tx_blob.data());
|
||||
m_w2->set_tx_note(tx_hash, note);
|
||||
crypto::hash _tx_hash = *reinterpret_cast<const crypto::hash*>(tx_blob.data());
|
||||
m_w2->set_tx_note(_tx_hash, note);
|
||||
}
|
||||
|
||||
void monero_wallet_core::set_tx_notes(const vector<string>& tx_ids, const vector<string>& notes) {
|
||||
void monero_wallet_core::set_tx_notes(const vector<string>& tx_hashes, const vector<string>& notes) {
|
||||
MTRACE("monero_wallet_core::set_tx_notes()");
|
||||
if (tx_ids.size() != notes.size()) throw runtime_error("Different amount of txids and notes");
|
||||
for (int i = 0; i < tx_ids.size(); i++) {
|
||||
set_tx_note(tx_ids[i], notes[i]);
|
||||
if (tx_hashes.size() != notes.size()) throw runtime_error("Different amount of txids and notes");
|
||||
for (int i = 0; i < tx_hashes.size(); i++) {
|
||||
set_tx_note(tx_hashes[i], notes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3148,19 +3148,19 @@ namespace monero {
|
||||
}
|
||||
|
||||
// commit the transactions
|
||||
vector<string> tx_ids;
|
||||
vector<string> tx_hashes;
|
||||
try {
|
||||
for (auto& pending_tx : signed_multisig_tx_set.m_ptx) {
|
||||
m_w2->commit_tx(pending_tx);
|
||||
tx_ids.push_back(epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(pending_tx.tx)));
|
||||
tx_hashes.push_back(epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(pending_tx.tx)));
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
string msg = string("Failed to submit multisig tx: ") + e.what();
|
||||
throw runtime_error(msg);
|
||||
}
|
||||
|
||||
// return the resulting tx ids
|
||||
return tx_ids;
|
||||
// return the resulting tx hashes
|
||||
return tx_hashes;
|
||||
}
|
||||
|
||||
void monero_wallet_core::save() {
|
||||
|
||||
@@ -222,19 +222,19 @@ namespace monero {
|
||||
monero_tx_set parse_tx_set(const monero_tx_set& tx_set);
|
||||
string sign(const string& msg) const;
|
||||
bool verify(const string& msg, const string& address, const string& signature) const;
|
||||
string get_tx_key(const string& tx_id) const;
|
||||
shared_ptr<monero_check_tx> check_tx_key(const string& tx_id, const string& txKey, const string& address) const;
|
||||
string get_tx_proof(const string& tx_id, const string& address, const string& message) const;
|
||||
shared_ptr<monero_check_tx> check_tx_proof(const string& tx_id, const string& address, const string& message, const string& signature) const;
|
||||
string get_spend_proof(const string& tx_id, const string& message) const;
|
||||
bool check_spend_proof(const string& tx_id, const string& message, const string& signature) const;
|
||||
string get_tx_key(const string& tx_hash) const;
|
||||
shared_ptr<monero_check_tx> check_tx_key(const string& tx_hash, const string& txKey, const string& address) const;
|
||||
string get_tx_proof(const string& tx_hash, const string& address, const string& message) const;
|
||||
shared_ptr<monero_check_tx> check_tx_proof(const string& tx_hash, const string& address, const string& message, const string& signature) const;
|
||||
string get_spend_proof(const string& tx_hash, const string& message) const;
|
||||
bool check_spend_proof(const string& tx_hash, const string& message, const string& signature) const;
|
||||
string get_reserve_proof_wallet(const string& message) const;
|
||||
string get_reserve_proof_account(uint32_t account_idx, uint64_t amount, const string& message) const;
|
||||
shared_ptr<monero_check_reserve> check_reserve_proof(const string& address, const string& message, const string& signature) const;
|
||||
string get_tx_note(const string& tx_id) const;
|
||||
vector<string> get_tx_notes(const vector<string>& tx_ids) const;
|
||||
void set_tx_note(const string& tx_id, const string& note);
|
||||
void set_tx_notes(const vector<string>& tx_ids, const vector<string>& notes);
|
||||
string get_tx_note(const string& tx_hash) const;
|
||||
vector<string> get_tx_notes(const vector<string>& tx_hashes) const;
|
||||
void set_tx_note(const string& tx_hash, const string& note);
|
||||
void set_tx_notes(const vector<string>& tx_hashes, const vector<string>& notes);
|
||||
vector<monero_address_book_entry> get_address_book_entries(const vector<uint64_t>& indices) const;
|
||||
uint64_t add_address_book_entry(const string& address, const string& description, const string& payment_id = "");
|
||||
void edit_address_book_entry(uint64_t index, bool set_address, const string& address, bool set_description, const string& description, bool set_payment_id = false, const string& payment_id = "");
|
||||
|
||||
@@ -202,7 +202,7 @@ namespace monero {
|
||||
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
//if (key == string("id")) tx->m_hash = it->second.data();
|
||||
//if (key == string("hash")) tx->m_hash = it->second.data();
|
||||
if (key == string("isLocked")) tx_wallet->m_is_locked = it->second.get_value<bool>();
|
||||
// TODO: deserialize other fields
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ int main(int argc, const char* argv[]) {
|
||||
monero_account account = wallet_restored->get_account(1, true); // get account with subaddresses
|
||||
uint64_t unlocked_account_balance = account.m_unlocked_balance.get(); // get boost::optional value
|
||||
|
||||
// query a transaction by id
|
||||
// query a transaction by hash
|
||||
monero_tx_query tx_query;
|
||||
tx_query.m_id = "314a0f1375db31cea4dac4e0a51514a6282b43792269b3660166d4d2b46437ca";
|
||||
tx_query.m_hash = "314a0f1375db31cea4dac4e0a51514a6282b43792269b3660166d4d2b46437ca";
|
||||
shared_ptr<monero_tx_wallet> tx = wallet_restored->get_txs(tx_query)[0];
|
||||
for (const shared_ptr<monero_incoming_transfer> in_transfer : tx->m_incoming_transfers) {
|
||||
uint64_t in_amount = in_transfer->m_amount.get();
|
||||
@@ -90,7 +90,7 @@ int main(int argc, const char* argv[]) {
|
||||
struct : monero_wallet_listener {
|
||||
void on_output_received(const monero_output_wallet& output) {
|
||||
cout << "Wallet received funds!" << endl;
|
||||
string tx_id = output.m_tx->m_id.get();
|
||||
string tx_hash = output.m_tx->m_hash.get();
|
||||
int account_index = output.m_account_index.get();
|
||||
int subaddress_index = output.m_subaddress_index.get();
|
||||
OUTPUT_RECEIVED = true;
|
||||
|
||||
Reference in New Issue
Block a user