support scan_txs() to scan txs by id

This commit is contained in:
woodser
2022-08-21 09:13:07 -04:00
parent 00f90f5a44
commit 7376b1b126
3 changed files with 28 additions and 0 deletions
+9
View File
@@ -475,6 +475,15 @@ namespace monero {
throw std::runtime_error("stop_syncing() not supported");
}
/**
* Scan transactions by their hash/id.
*
* @param txHashes - tx hashes to scan
*/
virtual void scan_txs(const std::vector<std::string>& tx_hashes) {
throw std::runtime_error("scan_txs() not supported");
}
/**
* Rescan the blockchain for spent outputs.
*
+18
View File
@@ -1492,6 +1492,24 @@ namespace monero {
m_w2->stop();
}
void monero_wallet_full::scan_txs(const std::vector<std::string>& tx_ids) {
MTRACE("scan_txs()");
if (!m_is_connected) throw std::runtime_error("Wallet is not connected to daemon");
// convert string ids to crypto hashes
std::vector<crypto::hash> tx_hashes;
std::vector<std::string>::const_iterator i = tx_ids.begin();
while (i != tx_ids.end()) {
cryptonote::blobdata tx_hash_blob;
if (!epee::string_tools::parse_hexstr_to_binbuff(*i++, tx_hash_blob) || tx_hash_blob.size() != sizeof(crypto::hash)) throw std::runtime_error("TX ID has invalid format");
crypto::hash tx_hash = *reinterpret_cast<const crypto::hash*>(tx_hash_blob.data());
tx_hashes.push_back(tx_hash);
}
// scan txs
m_w2->scan_tx(tx_hashes);
}
void monero_wallet_full::rescan_spent() {
MTRACE("rescan_spent()");
if (!m_is_connected) throw std::runtime_error("Wallet is not connected to daemon");
+1
View File
@@ -206,6 +206,7 @@ namespace monero {
monero_sync_result sync(uint64_t start_height, monero_wallet_listener& listener) override;
void start_syncing(uint64_t sync_period_in_ms) override;
void stop_syncing() override;
void scan_txs(const std::vector<std::string>& tx_hashes) override;
void rescan_spent() override;
void rescan_blockchain() override;
uint64_t get_balance() const override;