Skip to content

Conversation

zmanian
Copy link
Contributor

@zmanian zmanian commented Aug 25, 2015

To be effective within the current Bitcoin network, the inputs to a transaction with an nLocktime must be not the standard max value.We set the sequence number of 0 if the value is max.Currently sequence numbers other than MAX_INT32 have no meaning in the Bitcoin protoco but this may change in future BIPS

…ransaction

with an nLocktime must be not the standard max value.

We set the sequence number of 0 if the value is max.

Currently sequence numbers other than MAX_INT32 have no meaning in the Bitcoin protocol
but this may change in future BIPS
@braydonf
Copy link
Contributor

LGTM, with a few thoughts:

  • The expect isn't needed and isn't doing much since the should will error before then.
  • Could be useful to check that the default locktime is being set as expected or not set in the case that the value isn't the max.

@zmanian
Copy link
Contributor Author

zmanian commented Aug 25, 2015

I don't entirely follow your second bullet point?

@braydonf
Copy link
Contributor

Something like this in the second two tests:

var copy = new Transaction(serialized_tx);
copy.inputs[0].sequenceNumber.should.equal(Transaction.Input.DEFAULT_LOCKTIME_SEQNUMBER)

Test that the SequenceNumber is zero

Remove unncessary expect
@zmanian
Copy link
Contributor Author

zmanian commented Aug 27, 2015

My objection to having that test is that this test case doesn't actually that a transaction correctly follows the Bitcoin specifications. It merely handshakes that the code works as currently written.

As I've written the test now, the system tests that a transaction does not have a sequence number that would invalidate the effect of locktime.

But anyway I modified the test cases as requested.

@braydonf
Copy link
Contributor

Sorry, I think there may be some confusion here. The test case that I was thinking should be covered is that "sequenceNumber" is the correct property (which it is), and that when the object is serialized, the property isn't lost, such as would be if the property set was "sequence" instead.

@zmanian
Copy link
Contributor Author

zmanian commented Aug 27, 2015

Ah I get it

@braydonf
Copy link
Contributor

ACK

braydonf pushed a commit that referenced this pull request Aug 28, 2015
Fix SequenceNumber for nLockTime transactions
@braydonf braydonf merged commit 721f54f into bitpay:master Aug 28, 2015
@maraoz
Copy link
Contributor

maraoz commented Aug 28, 2015

Great work @zmanian!

@zmanian zmanian deleted the SetLockTimeSeqNumber branch August 31, 2015 23:22
@braydonf
Copy link
Contributor

braydonf commented Sep 2, 2015

Landed in release 0.13.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants