Skip to content

Commit 04d395e

Browse files
committed
Merge #10854: Avoid using sizes on non-fixed-width types to derive protocol constants.
095b917 Avoid using sizes on non-fixed-width types to derive protocol constants. (Gregory Maxwell) Pull request description: Thanks to awemany for pointing this out. This replaces #10172 which appears to be abandoned, but uses the constants as requested on that PR. Tree-SHA512: 032c0d75b3aaf807a7d0c7fb8ff5515acc45ad58bd00fe81413f900fe02bad900534a970403b9bb568e132c9eddea6043e958daf625e8acc84375bd41ee2e2ef
2 parents 78f307b + 095b917 commit 04d395e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/validation.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "init.h"
2121
#include "policy/fees.h"
2222
#include "policy/policy.h"
23+
#include "policy/rbf.h"
2324
#include "pow.h"
2425
#include "primitives/block.h"
2526
#include "primitives/transaction.h"
@@ -488,9 +489,9 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
488489
if (!setConflicts.count(ptxConflicting->GetHash()))
489490
{
490491
// Allow opt-out of transaction replacement by setting
491-
// nSequence >= maxint-1 on all inputs.
492+
// nSequence > MAX_BIP125_RBF_SEQUENCE (SEQUENCE_FINAL-2) on all inputs.
492493
//
493-
// maxint-1 is picked to still allow use of nLockTime by
494+
// SEQUENCE_FINAL-1 is picked to still allow use of nLockTime by
494495
// non-replaceable transactions. All inputs rather than just one
495496
// is for the sake of multi-party protocols, where we don't
496497
// want a single party to be able to disable replacement.
@@ -504,7 +505,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
504505
{
505506
for (const CTxIn &_txin : ptxConflicting->vin)
506507
{
507-
if (_txin.nSequence < std::numeric_limits<unsigned int>::max()-1)
508+
if (_txin.nSequence <= MAX_BIP125_RBF_SEQUENCE)
508509
{
509510
fReplacementOptOut = false;
510511
break;

src/wallet/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2739,7 +2739,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
27392739
// to avoid conflicting with other possible uses of nSequence,
27402740
// and in the spirit of "smallest possible change from prior
27412741
// behavior."
2742-
const uint32_t nSequence = coin_control.signalRbf ? MAX_BIP125_RBF_SEQUENCE : (std::numeric_limits<unsigned int>::max() - 1);
2742+
const uint32_t nSequence = coin_control.signalRbf ? MAX_BIP125_RBF_SEQUENCE : (CTxIn::SEQUENCE_FINAL - 1);
27432743
for (const auto& coin : setCoins)
27442744
txNew.vin.push_back(CTxIn(coin.outpoint,CScript(),
27452745
nSequence));

0 commit comments

Comments
 (0)