| 1288 | } |
| 1289 | |
| 1290 | void CWallet::transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t mempool_sequence) { |
| 1291 | LOCK(cs_wallet); |
| 1292 | auto it = mapWallet.find(tx->GetHash()); |
| 1293 | if (it != mapWallet.end()) { |
| 1294 | RefreshMempoolStatus(it->second, chain()); |
| 1295 | } |
| 1296 | // Handle transactions that were removed from the mempool because they |
| 1297 | // conflict with transactions in a newly connected block. |
| 1298 | if (reason == MemPoolRemovalReason::CONFLICT) { |
| 1299 | // Trigger external -walletnotify notifications for these transactions. |
| 1300 | // Set Status::UNCONFIRMED instead of Status::CONFLICTED for a few reasons: |
| 1301 | // |
| 1302 | // 1. The transactionRemovedFromMempool callback does not currently |
| 1303 | // provide the conflicting block's hash and height, and for backwards |
| 1304 | // compatibility reasons it may not be not safe to store conflicted |
| 1305 | // wallet transactions with a null block hash. See |
| 1306 | // https://github.com/bitcoin/bitcoin/pull/18600#discussion_r420195993. |
| 1307 | // 2. For most of these transactions, the wallet's internal conflict |
| 1308 | // detection in the blockConnected handler will subsequently call |
| 1309 | // MarkConflicted and update them with CONFLICTED status anyway. This |
| 1310 | // applies to any wallet transaction that has inputs spent in the |
| 1311 | // block, or that has ancestors in the wallet with inputs spent by |
| 1312 | // the block. |
| 1313 | // 3. Longstanding behavior since the sync implementation in |
| 1314 | // https://github.com/bitcoin/bitcoin/pull/9371 and the prior sync |
| 1315 | // implementation before that was to mark these transactions |
| 1316 | // unconfirmed rather than conflicted. |
| 1317 | // |
| 1318 | // Nothing described above should be seen as an unchangeable requirement |
| 1319 | // when improving this code in the future. The wallet's heuristics for |
| 1320 | // distinguishing between conflicted and unconfirmed transactions are |
| 1321 | // imperfect, and could be improved in general, see |
| 1322 | // https://github.com/bitcoin-core/bitcoin-devwiki/wiki/Wallet-Transaction-Conflict-Tracking |
| 1323 | SyncTransaction(tx, TxStateInactive{}); |
| 1324 | } |
| 1325 | } |
| 1326 | |
| 1327 | void CWallet::blockConnected(const CBlock& block, int height) |
| 1328 | { |
no test coverage detected