Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wallet_api: add scanTransactions function #8356

Merged
merged 1 commit into from
Jul 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/wallet/api/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
selsta marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
txids_u.insert(txid);
}
std::vector<crypto::hash> txids_v(txids_u.begin(), txids_u.end());
selsta marked this conversation as resolved.
Show resolved Hide resolved

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);
Expand Down
1 change: 1 addition & 0 deletions src/wallet/api/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class WalletImpl : public Wallet
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,
Expand Down
7 changes: 7 additions & 0 deletions src/wallet/api/wallet2_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
selsta marked this conversation as resolved.
Show resolved Hide resolved
*/
virtual bool scanTransactions(const std::vector<std::string> &txids) = 0;

virtual TransactionHistory * history() = 0;
virtual AddressBook * addressBook() = 0;
virtual Subaddress * subaddress() = 0;
Expand Down