Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BIP-112: Mempool-only CHECKSEQUENCEVERIFY #7524

Merged
merged 3 commits into from
Feb 16, 2016

Conversation

btcdrak
Copy link
Contributor

@btcdrak btcdrak commented Feb 12, 2016

Replace NOP3 with CHECKSEQUENCEVERIFY (BIP-112)

The BIP text is at https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki

This PR follows on from #6564 and is rebased (with #7184 which has been merged top master) so can now be tested directly.

Functional test scripts by @ajtowns can be found at https://github.com/ajtowns/op_csv-test

For reviewers please note that #6564 remained unchanged for several months. The list of reviews in #6564 were as follows:

@morcos
Copy link
Contributor

morcos commented Feb 12, 2016

My comment remains that I would prefer VerifyLockTime not be encapsulated for reuse for nLockTime and nSequence checks.

@btcdrak
Copy link
Contributor Author

btcdrak commented Feb 13, 2016

@morcos @petertodd I agree the encapsulation hampers readability. I propose something like 2fcd56f.

@NicolasDorier
Copy link
Contributor

ACK 2fcd56f

@instagibbs
Copy link
Member

utACK btcdrak@2fcd56f

maaku and others added 2 commits February 14, 2016 11:29
- Replace NOP3 with CHECKSEQUENCEVERIFY (BIP112)
  <nSequence> CHECKSEQUENCEVERIFY -> <nSequence>
- Fails if txin.nSequence < nSequence, allowing funds of a txout to be locked for a number of blocks or a duration of time after its inclusion in a block.
- Pull most of CheckLockTime() out into VerifyLockTime(), a local function that will be reused for CheckSequence()
- Add bitwise AND operator to CScriptNum
- Enable CHECKSEQUENCEVERIFY as a standard script verify flag
- Transactions that fail CSV verification will be rejected from the mempool, making it easy to test the feature. However blocks containing "invalid" CSV-using transactions will still be accepted; this is *not* the soft-fork required to actually enable CSV for production use.
For the sake of a little repetition, make code more readable.
@btcdrak
Copy link
Contributor Author

btcdrak commented Feb 14, 2016

I've squashed to two commits. 53e53a3 corresponds to the state of #6564 as per OP and c3c3752 (was 2fcd56f) addresses request from @morcos and @petertodd.

Previous branch state for verification checksequenceverify_2fcd56f.

(txToSequenceMasked < CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG && nSequenceMasked < CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG) ||
(txToSequenceMasked >= CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG && nSequenceMasked >= CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG)
))
return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This return false here seems to come out of the blue, which could make people misread the code and introduce bugs. I'd suggest adding the )) to the line before it, or surrounding with {}.

@laanwj
Copy link
Member

laanwj commented Feb 16, 2016

utACK 2fcd56f

This if statement is a little obtuse and using braces here
improves readability.
@laanwj laanwj merged commit a381076 into bitcoin:master Feb 16, 2016
laanwj added a commit that referenced this pull request Feb 16, 2016
a381076 Code style fix. (BtcDrak)
c3c3752 Separate CheckLockTime() and CheckSequence() logic (BtcDrak)
53e53a3 BIP112: Implement CHECKSEQUENCEVERIFY (Mark Friedenbach)
@btcdrak btcdrak deleted the checksequenceverify branch December 3, 2016 10:52
wqking added a commit to wqking-misc/Phore that referenced this pull request Apr 26, 2018
wqking added a commit to wqking-misc/Phore that referenced this pull request Apr 26, 2018
… txOut is empty, the function CheckTransaction in Phore rejects empty txOut while Bitcoin doesn't.
meyer9 pushed a commit to phoreproject/Phore that referenced this pull request Jun 16, 2018
meyer9 pushed a commit to phoreproject/Phore that referenced this pull request Jun 16, 2018
… txOut is empty, the function CheckTransaction in Phore rejects empty txOut while Bitcoin doesn't.
meyer9 pushed a commit to phoreproject/Phore that referenced this pull request Jun 16, 2018
meyer9 pushed a commit to phoreproject/Phore that referenced this pull request Jun 16, 2018
… txOut is empty, the function CheckTransaction in Phore rejects empty txOut while Bitcoin doesn't.
meyer9 pushed a commit to phoreproject/Phore that referenced this pull request Jul 4, 2018
meyer9 pushed a commit to phoreproject/Phore that referenced this pull request Jul 4, 2018
… txOut is empty, the function CheckTransaction in Phore rejects empty txOut while Bitcoin doesn't.
wqking added a commit to wqking-misc/SocialSend that referenced this pull request Apr 4, 2021
# Conflicts:
#	src/script/interpreter.cpp
#	src/script/interpreter.h
#	src/script/script.h
wqking added a commit to wqking-misc/SocialSend that referenced this pull request Apr 4, 2021
…ause the txOut is empty, the function CheckTransaction in Phore rejects empty txOut while Bitcoin doesn't.
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants