mirror of
https://github.com/monero-project/monero.git
synced 2024-12-22 19:49:30 +00:00
wallet_api: add scanTransactions function
This commit is contained in:
parent
97271b7d20
commit
de2f0d0102
3 changed files with 44 additions and 0 deletions
|
@ -1280,6 +1280,42 @@ bool WalletImpl::importOutputs(const string &filename)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool WalletImpl::scanTransactions(const std::vector<std::string> &txids)
|
||||
{
|
||||
if (txids.empty())
|
||||
{
|
||||
setStatusError(string(tr("Failed to scan transactions: no transaction ids provided.")));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Parse and dedup args
|
||||
std::unordered_set<crypto::hash> txids_u;
|
||||
for (const auto &s : txids)
|
||||
{
|
||||
crypto::hash txid;
|
||||
if (!epee::string_tools::hex_to_pod(s, txid))
|
||||
{
|
||||
setStatusError(string(tr("Invalid txid specified: ")) + s);
|
||||
return false;
|
||||
}
|
||||
txids_u.insert(txid);
|
||||
}
|
||||
std::vector<crypto::hash> txids_v(txids_u.begin(), txids_u.end());
|
||||
|
||||
try
|
||||
{
|
||||
m_wallet->scan_tx(txids_v);
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
LOG_ERROR("Failed to scan transaction: " << e.what());
|
||||
setStatusError(string(tr("Failed to scan transaction: ")) + e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WalletImpl::addSubaddressAccount(const std::string& label)
|
||||
{
|
||||
m_wallet->add_subaddress_account(label);
|
||||
|
|
|
@ -169,6 +169,7 @@ public:
|
|||
bool importKeyImages(const std::string &filename) override;
|
||||
bool exportOutputs(const std::string &filename, bool all = false) override;
|
||||
bool importOutputs(const std::string &filename) override;
|
||||
bool scanTransactions(const std::vector<std::string> &txids) override;
|
||||
|
||||
virtual void disposeTransaction(PendingTransaction * t) override;
|
||||
virtual uint64_t estimateTransactionFee(const std::vector<std::pair<std::string, uint64_t>> &destinations,
|
||||
|
|
|
@ -927,6 +927,13 @@ struct Wallet
|
|||
*/
|
||||
virtual bool importOutputs(const std::string &filename) = 0;
|
||||
|
||||
/*!
|
||||
* \brief scanTransactions - scan a list of transaction ids, this operation may reveal the txids to the remote node and affect your privacy
|
||||
* \param txids - list of transaction ids
|
||||
* \return - true on success
|
||||
*/
|
||||
virtual bool scanTransactions(const std::vector<std::string> &txids) = 0;
|
||||
|
||||
virtual TransactionHistory * history() = 0;
|
||||
virtual AddressBook * addressBook() = 0;
|
||||
virtual Subaddress * subaddress() = 0;
|
||||
|
|
Loading…
Reference in a new issue