@@ -94,6 +94,16 @@ static void UpdateWalletSetting(interfaces::Chain& chain,
94
94
}
95
95
}
96
96
97
+ /* *
98
+ * Refresh mempool status so the wallet is in an internally consistent state and
99
+ * immediately knows the transaction's status: Whether it can be considered
100
+ * trusted and is eligible to be abandoned ...
101
+ */
102
+ static void RefreshMempoolStatus (CWalletTx& tx, interfaces::Chain& chain)
103
+ {
104
+ tx.fInMempool = chain.isInMempool (tx.GetHash ());
105
+ }
106
+
97
107
bool AddWallet (const std::shared_ptr<CWallet>& wallet)
98
108
{
99
109
LOCK (cs_wallets);
@@ -788,10 +798,7 @@ bool CWallet::MarkReplaced(const uint256& originalHash, const uint256& newHash)
788
798
wtx.mapValue [" replaced_by_txid" ] = newHash.ToString ();
789
799
790
800
// Refresh mempool status without waiting for transactionRemovedFromMempool
791
- // notification so the wallet is in an internally consistent state and
792
- // immediately knows the old transaction should not be considered trusted
793
- // and is eligible to be abandoned
794
- wtx.fInMempool = chain ().isInMempool (originalHash);
801
+ RefreshMempoolStatus (wtx, chain ());
795
802
796
803
WalletBatch batch (GetDatabase ());
797
804
@@ -1191,15 +1198,15 @@ void CWallet::transactionAddedToMempool(const CTransactionRef& tx, uint64_t memp
1191
1198
1192
1199
auto it = mapWallet.find (tx->GetHash ());
1193
1200
if (it != mapWallet.end ()) {
1194
- it->second . fInMempool = true ;
1201
+ RefreshMempoolStatus ( it->second , chain ()) ;
1195
1202
}
1196
1203
}
1197
1204
1198
1205
void CWallet::transactionRemovedFromMempool (const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) {
1199
1206
LOCK (cs_wallet);
1200
1207
auto it = mapWallet.find (tx->GetHash ());
1201
1208
if (it != mapWallet.end ()) {
1202
- it->second . fInMempool = false ;
1209
+ RefreshMempoolStatus ( it->second , chain ()) ;
1203
1210
}
1204
1211
// Handle transactions that were removed from the mempool because they
1205
1212
// conflict with transactions in a newly connected block.
0 commit comments