How many bytes long should nSequence be?

0

When I look at the following raw transaction from: https://blockstream.info/tx/a175425ee2f3c01acc97ef32ab1082db14eaa94e5af4c54f02f3b01dec72558e?expand

020000000001018e5572ec1db0f3024fc5f45a4ea9ea14db8210ab32ef97cc1ac0f3e25e4275a100000000**00cf050000**01d2ddbc0000000000160014b82d832b2e5c0d80c771b06ce0da50fbccf12f3e0347304402204a54d94068512c22847cc07fa85f2b93feaf758411920a9b20ce9b85831e8aa5022005924cb82c331c5173e21477a4d8298eb25c0d967ace065b883455f2537c3d0a01004d632103f96d73ffe138690f032e97408af933a71782ad27a28df66a750b48c56b2d7fa96702cf05b275210304f332f50363cd01b679d9fb50fb8691fb0fb638737867bd02f06850c6191a2268ac00000000

When I parse it manually, specifically at this section: a100000000**00cf050000**01...

a1 is the last byte of the input tx (in little endian),

00000000 is the output index (4-bytes),

and at the end the 01 is the tx_out_count.

But that would make the sequence number 00cf050000, which is longer than 4 bytes? What am I missing here?

Darius

Posted 2019-11-10T18:02:15.347

Reputation: 103

Answers

1

The sequence number is always 4 bytes, it is a fixed size, little endian, 32 bit integer which makes it always 4 bytes.

What you are missing is the scriptSig. The scriptSig always begins with the size of the script (as a compact size unsigned integer). If the scriptSig is empty, then the size must still be there to say that it is a 0 length byte. So the first byte of your "sequence" is actually the length byte for the scriptSig that says it is of length 0.

Andrew Chow

Posted 2019-11-10T18:02:15.347

Reputation: 40 910