| 10 | #include <util/rbf.h> |
| 11 | |
| 12 | RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool) |
| 13 | { |
| 14 | AssertLockHeld(pool.cs); |
| 15 | |
| 16 | CTxMemPool::setEntries ancestors; |
| 17 | |
| 18 | // First check the transaction itself. |
| 19 | if (SignalsOptInRBF(tx)) { |
| 20 | return RBFTransactionState::REPLACEABLE_BIP125; |
| 21 | } |
| 22 | |
| 23 | // If this transaction is not in our mempool, then we can't be sure |
| 24 | // we will know about all its inputs. |
| 25 | if (!pool.exists(GenTxid::Txid(tx.GetHash()))) { |
| 26 | return RBFTransactionState::UNKNOWN; |
| 27 | } |
| 28 | |
| 29 | // If all the inputs have nSequence >= maxint-1, it still might be |
| 30 | // signaled for RBF if any unconfirmed parents have signaled. |
| 31 | uint64_t noLimit = std::numeric_limits<uint64_t>::max(); |
| 32 | std::string dummy; |
| 33 | CTxMemPoolEntry entry = *pool.mapTx.find(tx.GetHash()); |
| 34 | pool.CalculateMemPoolAncestors(entry, ancestors, noLimit, noLimit, noLimit, noLimit, dummy, false); |
| 35 | |
| 36 | for (CTxMemPool::txiter it : ancestors) { |
| 37 | if (SignalsOptInRBF(it->GetTx())) { |
| 38 | return RBFTransactionState::REPLACEABLE_BIP125; |
| 39 | } |
| 40 | } |
| 41 | return RBFTransactionState::FINAL; |
| 42 | } |
| 43 | |
| 44 | RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction& tx) |
| 45 | { |