| 76 | } |
| 77 | |
| 78 | std::optional<std::string> HasNoNewUnconfirmed(const CTransaction& tx, |
| 79 | const CTxMemPool& pool, |
| 80 | const CTxMemPool::setEntries& iters_conflicting) |
| 81 | { |
| 82 | AssertLockHeld(pool.cs); |
| 83 | std::set<uint256> parents_of_conflicts; |
| 84 | for (const auto& mi : iters_conflicting) { |
| 85 | for (const CTxIn& txin : mi->GetTx().vin) { |
| 86 | parents_of_conflicts.insert(txin.prevout.hash); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | for (unsigned int j = 0; j < tx.vin.size(); j++) { |
| 91 | // BIP125 Rule #2: We don't want to accept replacements that require low feerate junk to be |
| 92 | // mined first. Ideally we'd keep track of the ancestor feerates and make the decision |
| 93 | // based on that, but for now requiring all new inputs to be confirmed works. |
| 94 | // |
| 95 | // Note that if you relax this to make RBF a little more useful, this may break the |
| 96 | // CalculateMempoolAncestors RBF relaxation which subtracts the conflict count/size from the |
| 97 | // descendant limit. |
| 98 | if (!parents_of_conflicts.count(tx.vin[j].prevout.hash)) { |
| 99 | // Rather than check the UTXO set - potentially expensive - it's cheaper to just check |
| 100 | // if the new input refers to a tx that's in the mempool. |
| 101 | if (pool.exists(GenTxid::Txid(tx.vin[j].prevout.hash))) { |
| 102 | return strprintf("replacement %s adds unconfirmed input, idx %d", |
| 103 | tx.GetHash().ToString(), j); |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | return std::nullopt; |
| 108 | } |
| 109 | |
| 110 | std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries& ancestors, |
| 111 | const std::set<uint256>& direct_conflicts, |