Branch data Line data Source code
# 1 : : // Copyright (c) 2016-2020 The Bitcoin Core developers # 2 : : // Distributed under the MIT software license, see the accompanying # 3 : : // file COPYING or http://www.opensource.org/licenses/mit-license.php. # 4 : : # 5 : : #include <policy/rbf.h> # 6 : : #include <util/rbf.h> # 7 : : # 8 : : RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool) # 9 : 43378 : { # 10 : 43378 : AssertLockHeld(pool.cs); # 11 : : # 12 : 43378 : CTxMemPool::setEntries setAncestors; # 13 : : # 14 : : // First check the transaction itself. # 15 [ + + ]: 43378 : if (SignalsOptInRBF(tx)) { # 16 : 227 : return RBFTransactionState::REPLACEABLE_BIP125; # 17 : 227 : } # 18 : : # 19 : : // If this transaction is not in our mempool, then we can't be sure # 20 : : // we will know about all its inputs. # 21 [ + + ]: 43151 : if (!pool.exists(tx.GetHash())) { # 22 : 442 : return RBFTransactionState::UNKNOWN; # 23 : 442 : } # 24 : : # 25 : : // If all the inputs have nSequence >= maxint-1, it still might be # 26 : : // signaled for RBF if any unconfirmed parents have signaled. # 27 : 42709 : uint64_t noLimit = std::numeric_limits<uint64_t>::max(); # 28 : 42709 : std::string dummy; # 29 : 42709 : CTxMemPoolEntry entry = *pool.mapTx.find(tx.GetHash()); # 30 : 42709 : pool.CalculateMemPoolAncestors(entry, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false); # 31 : : # 32 [ + + ]: 2000562 : for (CTxMemPool::txiter it : setAncestors) { # 33 [ + + ]: 2000562 : if (SignalsOptInRBF(it->GetTx())) { # 34 : 5 : return RBFTransactionState::REPLACEABLE_BIP125; # 35 : 5 : } # 36 : 2000562 : } # 37 : 42709 : return RBFTransactionState::FINAL; # 38 : 42709 : } # 39 : : # 40 : : RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction& tx) # 41 : 0 : { # 42 : : // If we don't have a local mempool we can only check the transaction itself. # 43 [ # # ]: 0 : return SignalsOptInRBF(tx) ? RBFTransactionState::REPLACEABLE_BIP125 : RBFTransactionState::UNKNOWN; # 44 : 0 : }