feat: track shielded send txids via z_viewtransaction

Extract txids from completed z_sendmany operations and store in
send_txids_ so pure shielded sends are discoverable. The network
thread includes them in the enrichment set, calls z_viewtransaction,
caches results in viewtx_cache_, and removes them from send_txids_.
This commit is contained in:
dan_s
2026-03-25 11:06:09 -05:00
parent f02c965929
commit 30fc5da520
3 changed files with 34 additions and 2 deletions

View File

@@ -437,6 +437,9 @@ void App::refreshData()
// Snapshot viewtx cache for the worker thread
auto viewtxCacheSnap = viewtx_cache_;
// Snapshot send txids so the worker can include them in enrichment
auto sendTxidsSnap = send_txids_;
// Single consolidated worker task — all RPC calls happen back-to-back
// on a single thread with no inter-task queue overhead.
worker_->post([this, doAddresses, doPeers, doEncrypt, doTransactions,
@@ -444,7 +447,8 @@ void App::refreshData()
fullyEnriched = std::move(fullyEnriched),
cachedConfirmedTxns = std::move(cachedConfirmedTxns),
cachedConfirmedIds = std::move(cachedConfirmedIds),
viewtxCacheSnap = std::move(viewtxCacheSnap)]() -> rpc::RPCWorker::MainCb {
viewtxCacheSnap = std::move(viewtxCacheSnap),
sendTxidsSnap = std::move(sendTxidsSnap)]() -> rpc::RPCWorker::MainCb {
// ================================================================
// Phase 1: Balance + blockchain info
// ================================================================
@@ -596,6 +600,13 @@ void App::refreshData()
}
}
// Include txids from completed z_sendmany operations so that
// pure shielded sends (which don't appear in listtransactions
// or z_listreceivedbyaddress) are discoverable.
for (const auto& txid : sendTxidsSnap) {
knownTxids.insert(txid);
}
// Phase 3c: detect shielded sends via z_viewtransaction
// Check the in-memory viewtx cache first; only make RPC calls
// for txids we haven't seen before.
@@ -858,6 +869,8 @@ void App::refreshData()
// Merge new z_viewtransaction results into the persistent cache
for (auto& [txid, entry] : newViewTxEntries) {
viewtx_cache_[txid] = std::move(entry);
// Once cached, no need to keep in send_txids_
send_txids_.erase(txid);
}
// Rebuild confirmed transaction cache: txns with >= 10