Skip to content

Commit 095b917

Browse files
committed
Avoid using sizes on non-fixed-width types to derive protocol constants.
Thanks to awemany for pointing this out.
1 parent 0b01935 commit 095b917

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
@@ -2723,7 +2723,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
27232723
// to avoid conflicting with other possible uses of nSequence,
27242724
// and in the spirit of "smallest possible change from prior
27252725
// behavior."
2726-
const uint32_t nSequence = coin_control.signalRbf ? MAX_BIP125_RBF_SEQUENCE : (std::numeric_limits<unsigned int>::max() - 1);
2726+
const uint32_t nSequence = coin_control.signalRbf ? MAX_BIP125_RBF_SEQUENCE : (CTxIn::SEQUENCE_FINAL - 1);
27272727
for (const auto& coin : setCoins)
27282728
txNew.vin.push_back(CTxIn(coin.outpoint,CScript(),
27292729
nSequence));

0 commit comments

Comments
 (0)