| 1433 | } |
| 1434 | |
| 1435 | void CWallet::transactionAddedToMempool(const CTransactionRef& tx) { |
| 1436 | LOCK(cs_wallet); |
| 1437 | SyncTransaction(tx, TxStateInMempool{}); |
| 1438 | |
| 1439 | auto it = mapWallet.find(tx->GetHash()); |
| 1440 | if (it != mapWallet.end()) { |
| 1441 | RefreshMempoolStatus(it->second, chain()); |
| 1442 | } |
| 1443 | |
| 1444 | const Txid& txid = tx->GetHash(); |
| 1445 | |
| 1446 | for (const CTxIn& tx_in : tx->vin) { |
| 1447 | // For each wallet transaction spending this prevout.. |
| 1448 | for (auto range = mapTxSpends.equal_range(tx_in.prevout); range.first != range.second; range.first++) { |
| 1449 | const Txid& spent_id = range.first->second; |
| 1450 | // Skip the recently added tx |
| 1451 | if (spent_id == txid) continue; |
| 1452 | RecursiveUpdateTxState(/*batch=*/nullptr, spent_id, [&txid](CWalletTx& wtx) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { |
| 1453 | return wtx.mempool_conflicts.insert(txid).second ? TxUpdate::CHANGED : TxUpdate::UNCHANGED; |
| 1454 | }); |
| 1455 | } |
| 1456 | |
| 1457 | } |
| 1458 | |
| 1459 | if (tx->version == TRUC_VERSION) { |
| 1460 | // Unconfirmed TRUC transactions are only allowed a 1-parent-1-child topology. |
| 1461 | // For any unconfirmed v3 parents (there should be a maximum of 1 except in reorgs), |
| 1462 | // record this child so the wallet doesn't try to spend any other outputs |
| 1463 | for (const CTxIn& tx_in : tx->vin) { |
| 1464 | auto parent_it = mapWallet.find(tx_in.prevout.hash); |
| 1465 | if (parent_it != mapWallet.end()) { |
| 1466 | CWalletTx& parent_wtx = parent_it->second; |
| 1467 | if (parent_wtx.isUnconfirmed()) { |
| 1468 | parent_wtx.truc_child_in_mempool = tx->GetHash(); |
| 1469 | // Even though these siblings do not spend the same utxos, they can't |
| 1470 | // be present in the mempool at the same time because of TRUC policy rules |
| 1471 | UpdateTrucSiblingConflicts(parent_wtx, txid, /*add_conflict=*/true); |
| 1472 | } |
| 1473 | } |
| 1474 | } |
| 1475 | } |
| 1476 | } |
| 1477 | |
| 1478 | void CWallet::transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason) { |
| 1479 | LOCK(cs_wallet); |
no test coverage detected