diff --git a/src/validationinterface.h b/src/validationinterface.h --- a/src/validationinterface.h +++ b/src/validationinterface.h @@ -105,7 +105,7 @@ * * Called on a background thread. */ - virtual void TransactionAddedToMempool(const CTransactionRef &ptxn) {} + virtual void TransactionAddedToMempool(const CTransactionRef &tx) {} /** * Notifies listeners of a transaction leaving mempool. * @@ -138,7 +138,7 @@ * * Called on a background thread. */ - virtual void TransactionRemovedFromMempool(const CTransactionRef &ptx, + virtual void TransactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason) {} /** * Notifies listeners of a block being connected. diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -203,25 +203,25 @@ fInitialDownload); } -void CMainSignals::TransactionAddedToMempool(const CTransactionRef &ptx) { - auto event = [ptx, this] { +void CMainSignals::TransactionAddedToMempool(const CTransactionRef &tx) { + auto event = [tx, this] { m_internals->Iterate([&](CValidationInterface &callbacks) { - callbacks.TransactionAddedToMempool(ptx); + callbacks.TransactionAddedToMempool(tx); }); }; ENQUEUE_AND_LOG_EVENT(event, "%s: txid=%s", __func__, - ptx->GetHash().ToString()); + tx->GetHash().ToString()); } -void CMainSignals::TransactionRemovedFromMempool(const CTransactionRef &ptx, +void CMainSignals::TransactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason) { - auto event = [ptx, reason, this] { + auto event = [tx, reason, this] { m_internals->Iterate([&](CValidationInterface &callbacks) { - callbacks.TransactionRemovedFromMempool(ptx, reason); + callbacks.TransactionRemovedFromMempool(tx, reason); }); }; ENQUEUE_AND_LOG_EVENT(event, "%s: txid=%s", __func__, - ptx->GetHash().ToString()); + tx->GetHash().ToString()); } void CMainSignals::BlockConnected(const std::shared_ptr &pblock, diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1086,7 +1086,7 @@ std::optional max_height, const WalletRescanReserver &reserver, bool fUpdate); - void transactionRemovedFromMempool(const CTransactionRef &ptx, + void transactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason) override; void ReacceptWalletTransactions() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); void ResendWalletTransactions(); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1213,23 +1213,22 @@ MarkInputsDirty(ptx); } -void CWallet::transactionAddedToMempool(const CTransactionRef &ptx) { +void CWallet::transactionAddedToMempool(const CTransactionRef &tx) { LOCK(cs_wallet); - CWalletTx::Confirmation confirm(CWalletTx::Status::UNCONFIRMED, - /* block_height */ 0, BlockHash(), - /* nIndex */ 0); - SyncTransaction(ptx, confirm); - auto it = mapWallet.find(ptx->GetId()); + SyncTransaction(tx, {CWalletTx::Status::UNCONFIRMED, /* block_height */ 0, + BlockHash(), /* nIndex */ 0}); + + auto it = mapWallet.find(tx->GetId()); if (it != mapWallet.end()) { it->second.fInMempool = true; } } -void CWallet::transactionRemovedFromMempool(const CTransactionRef &ptx, +void CWallet::transactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason) { LOCK(cs_wallet); - auto it = mapWallet.find(ptx->GetId()); + auto it = mapWallet.find(tx->GetId()); if (it != mapWallet.end()) { it->second.fInMempool = false; } @@ -1261,7 +1260,7 @@ // distinguishing between conflicted and unconfirmed transactions are // imperfect, and could be improved in general, see // https://github.com/bitcoin-core/bitcoin-devwiki/wiki/Wallet-Transaction-Conflict-Tracking - SyncTransaction(ptx, + SyncTransaction(tx, {CWalletTx::Status::UNCONFIRMED, /* block height */ 0, BlockHash(), /* index */ 0}); } @@ -1274,9 +1273,8 @@ m_last_block_processed_height = height; m_last_block_processed = block_hash; for (size_t index = 0; index < block.vtx.size(); index++) { - CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, height, - block_hash, index); - SyncTransaction(block.vtx[index], confirm); + SyncTransaction(block.vtx[index], {CWalletTx::Status::CONFIRMED, height, + block_hash, int(index)}); transactionRemovedFromMempool(block.vtx[index], MemPoolRemovalReason::BLOCK); } @@ -1293,10 +1291,9 @@ m_last_block_processed_height = height - 1; m_last_block_processed = block.hashPrevBlock; for (const CTransactionRef &ptx : block.vtx) { - CWalletTx::Confirmation confirm(CWalletTx::Status::UNCONFIRMED, - /* block_height */ 0, BlockHash(), - /* nIndex */ 0); - SyncTransaction(ptx, confirm); + SyncTransaction(ptx, + {CWalletTx::Status::UNCONFIRMED, /* block_height */ 0, + BlockHash(), /* nIndex */ 0}); } } @@ -1899,7 +1896,10 @@ CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, block_height, block_hash, posInBlock); - SyncTransaction(block.vtx[posInBlock], confirm, fUpdate); + SyncTransaction(block.vtx[posInBlock], + {CWalletTx::Status::CONFIRMED, block_height, + block_hash, int(posInBlock)}, + fUpdate); } // scan succeeded, record block as most recent successfully // scanned