Extracting the constant makes it possible to attach documentation to it.
Also, rework the docs for the other “sequence constants”.
Extracting the constant makes it possible to attach documentation to it.
Also, rework the docs for the other “sequence constants”.
93+ /**
94+ * If this flag is set, CTxIn::nSequence is NOT interpreted as a
95+ * relative lock-time.
96+ * It skips SequenceLocks() for any input that has it set (BIP 68).
97+ * It fails OP_CHECKSEQUENCEVERIFY/CheckSequence() for any input that has
98+ * it set (BIP 112).
You are using the same language here as for BIP65 timelocks, whereas in this case it’s “local” (if an input needs both satisfy a BIP112 timelock and its nSequence has the disable flag) while in the other it’s “global” (if any input of the spending transaction has a BIP65 timelock and any other input has its nSequence set to SEQUENCE_FINAL).
I don’t have a better suggestion. Just a nit that it might be confusing to someone only from these comments.
Sorry, can you explain this a bit better? Both OP_CHECKLOCKTIMEVERIFY
and OP_CHECKSEQUENCEVERIFY
are evaluated in a local context of the input.
Sure, the whole transaction fails “globally”, if any input is invalid, but this is true for both opcodes as well.
IsFinalTx()
returned true
if any input’s nSequence
was set to SEQUENCE_FINAL
… And of course didn’t double check before posting this confusing comment.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
88+ static const uint32_t MAX_SEQUENCE_NONFINAL{SEQUENCE_FINAL - 1};
89
90- /* Below flags apply in the context of BIP 68*/
91- /* If this flag set, CTxIn::nSequence is NOT interpreted as a
92- * relative lock-time. */
93+ // Below flags apply in the context of BIP 68. BIP 68 requires the tx
I see this is from BIP 68, but it could be better (may propose some fixups to the BIP), plus add a newline to denote that this comment applies to the next four sections of doxygen docs + constants
0 * disables nLockTime. */
1 static const uint32_t SEQUENCE_FINAL = 0xffffffff;
2
3- /* Below flags apply in the context of BIP 68*/
4+ /* The following flags apply in the context of BIP 68: */
5+
6 /* If this flag set, CTxIn::nSequence is NOT interpreted as a
7 * relative lock-time. */
Concept ACK. Another replacement to consider:
0diff --git a/src/util/rbf.h b/src/util/rbf.h
1index a957617389..33a38dad88 100644
2--- a/src/util/rbf.h
3+++ b/src/util/rbf.h
4@@ -13,11 +13,12 @@ static constexpr uint32_t MAX_BIP125_RBF_SEQUENCE{0xfffffffd};
5
6 /** Check whether the sequence numbers on this transaction are signaling opt-in to replace-by-fee,
7 * according to BIP 125. Allow opt-out of transaction replacement by setting nSequence >
8- * MAX_BIP125_RBF_SEQUENCE (SEQUENCE_FINAL-2) on all inputs.
9+ * MAX_BIP125_RBF_SEQUENCE (SEQUENCE_FINAL - 2) on all inputs.
10 *
11-* SEQUENCE_FINAL-1 is picked to still allow use of nLockTime by non-replaceable transactions. All
12-* inputs rather than just one is for the sake of multi-party protocols, where we don't want a single
13-* party to be able to disable replacement by opting out in their own input. */
14+* CTxIn::MAX_SEQUENCE_NONFINAL (SEQUENCE_FINAL - 1) is picked to still allow use
15+* of nLockTime by non-replaceable transactions. Using all inputs rather than just one
16+* is for the sake of multi-party protocols, where we don't want a single party
17+* to be able to disable replacement by opting out in their own input. */
18 bool SignalsOptInRBF(const CTransaction& tx);
19
20 #endif // BITCOIN_UTIL_RBF_H
Also: s/All inputs/Using all inputs/
Another replacement to consider:
The goal of this pull was to document consensus rules. If policy is documented, I am wondering if the following diff should also be applied:
0diff --git a/src/util/rbf.h b/src/util/rbf.h
1index a957617389..fc1fbb60de 100644
2--- a/src/util/rbf.h
3+++ b/src/util/rbf.h
4@@ -9,6 +9,11 @@
5
6 class CTransaction;
7
8+/**
9+ * This is the maximum sequence number that enables all of: BIP 125,
10+ * nLockTime and OP_CHECKLOCKTIMEVERIFY (BIP 65).
11+ * It has SEQUENCE_LOCKTIME_DISABLE_FLAG set (BIP 68/112).
12+ */
13 static constexpr uint32_t MAX_BIP125_RBF_SEQUENCE{0xfffffffd};
14
15 /** Check whether the sequence numbers on this transaction are signaling opt-in to replace-by-fee,
If policy is documented, I am wondering if the following diff should also be applied
SGTM