MCPcopy Create free account
hub / github.com/ElementsProject/elements / HasNoNewUnconfirmed

Function HasNoNewUnconfirmed

src/policy/rbf.cpp:78–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78std::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
110std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries& ancestors,
111 const std::set<uint256>& direct_conflicts,

Callers 1

ReplacementChecksMethod · 0.85

Calls 7

GetTxMethod · 0.80
countMethod · 0.80
insertMethod · 0.45
sizeMethod · 0.45
existsMethod · 0.45
ToStringMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected