Bitcoin Forum
February 11, 2026, 02:10:32 PM *
News: Community awards 2025
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Understanding transaction structure  (Read 165 times)
hmbdofficial (OP)
Member
**
Online Online

Activity: 98
Merit: 20


View Profile
February 06, 2026, 02:12:26 PM
Merited by pooya87 (2), vapourminer (1), Mia Chloe (1), stwenhao (1)
 #1

Hi trying to understand the technical part of the transactions and it was necessary that I start with the transactions structure but during the course of studying I got some questions I wasn’t really clear with. and I believe I could get some help here I don’t know if I could upload images to make my questions clearer
1. what are the two bytes makers and flag that is always put at the beginning of a Segwit transaction and why are they always 00, 01?
2. In a standard transaction what does the sequence number field represent? And what value is commonly use today to enable by fee?
3.why can a transaction with nLocktime field set to a feature block height still have inputs with sequence  =0xFFFFFFFF?
stwenhao
Hero Member
*****
Offline Offline

Activity: 610
Merit: 1538


View Profile
February 06, 2026, 02:43:16 PM
Merited by pooya87 (5), ABCbits (2), vapourminer (1), Mia Chloe (1)
 #2

Quote
what are the two bytes makers and flag that is always put at the beginning of a Segwit transaction and why are they always 00, 01?
It simply means "zero inputs, one output" in the old format. And then, old decoders mark it as invalid, if some transaction has zero inputs.

So, the first zero is needed, to simply crash the old decoders, because there is a format they cannot fully understand. Which means, that if the new format is accidentally passed to the old decoders, then it will crash. All old decoders should receive a transaction without any witness, in the old format.

And later, the "01" is just the version of the encoding, which is set to one, and can be incremented in the future, if needed.

Quote
In a standard transaction what does the sequence number field represent?
The number of replacement. In a naive implementation, where transaction version was below 0x00000002, you could start from 0x00000000, then make it 0x00000001, and replace some transaction 2^32 times. In transaction versions equal or greater than 0x00000002, this field is used by BIP-68.

Quote
why can a transaction with nLocktime field set to a feature block height still have inputs with sequence  =0xFFFFFFFF?
Because when all inputs have sequence equal to 0xffffffff, then locktime is ignored, and can be set to anything.

Proof of Work puzzle in mainnet, testnet4 and signet.
hmbdofficial (OP)
Member
**
Online Online

Activity: 98
Merit: 20


View Profile
February 06, 2026, 03:32:49 PM
Merited by stwenhao (1)
 #3

Quote
what are the two bytes makers and flag that is always put at the beginning of a Segwit transaction and why are they always 00, 01?
It simply means "zero inputs, one output" in the old format. And then, old decoders mark it as invalid, if some transaction has zero inputs.

So, the first zero is needed, to simply crash the old decoders, because there is a format they cannot fully understand. Which means, that if the new format is accidentally passed to the old decoders, then it will crash. All old decoders should receive a transaction without any witness, in the old format.

And later, the "01" is just the version of the encoding, which is set to one, and can be incremented in the future, if needed.

Quote
In a standard transaction what does the sequence number field represent?
The number of replacement. In a naive implementation, where transaction version was below 0x00000002, you could start from 0x00000000, then make it 0x00000001, and replace some transaction 2^32 times. In transaction versions equal or greater than 0x00000002, this field is used by BIP-68.

Quote
why can a transaction with nLocktime field set to a feature block height still have inputs with sequence  =0xFFFFFFFF?
Because when all inputs have sequence equal to 0xffffffff, then locktime is ignored, and can be set to anything.
Sorry  just needed to add this to my question I’m just curious to know what is actually placed in the scriptsig field of a transaction with a pay to witness public key hash (P2WPKH) input in Segwit transaction?
stwenhao
Hero Member
*****
Offline Offline

Activity: 610
Merit: 1538


View Profile
February 06, 2026, 05:11:50 PM
Merited by vapourminer (1)
 #4

Quote
what is actually placed in the scriptsig field of a transaction with a pay to witness public key hash (P2WPKH) input in Segwit transaction?
Nothing. Because from the legacy perspective, Segwit is just some push on the stack, so nothing is needed in legacy part of scriptSig for Segwit inputs. Which is also why changing witness data does not change transaction ID, because it is calculated only from legacy parts, to make things compatible with the old nodes.

Proof of Work puzzle in mainnet, testnet4 and signet.
hmbdofficial (OP)
Member
**
Online Online

Activity: 98
Merit: 20


View Profile
February 06, 2026, 05:41:38 PM
 #5

Quote
what is actually placed in the scriptsig field of a transaction with a pay to witness public key hash (P2WPKH) input in Segwit transaction?
Nothing. Because from the legacy perspective, Segwit is just some push on the stack, so nothing is needed in legacy part of scriptSig for Segwit inputs. Which is also why changing witness data does not change transaction ID, because it is calculated only from legacy parts, to make things compatible with the old nodes.
I get it now..and if I get your explanation right which you say “changing witness data does not change transaction ID” because it is calculated from the legacy part with nothing on the scriptsig field for Segwit transaction is actually what fixes  transaction malleability right because the signature i.e the witness is not part of the transaction ID again
Mia Chloe
Legendary
*
Online Online

Activity: 980
Merit: 2058


Contact me for your designs...


View Profile
February 06, 2026, 07:11:38 PM
Merited by vapourminer (1)
 #6

~snip
Nice question I must say. I can barely remember but I think In Bitcoin SegWit BIP141 the marker 0x00 and flag 0x01 appear after the version field because 0x00 is an invalid legacy input count. while 0x01 indicates the presence of witness data and is fixed by consensus.

The nSequence field before now actually controlled replacement and today is mainly used for Replace By Fee and BIP68 where any value 0xFFFFFFFE opts into RBF and 0xFFFFFFFF marks an input as final. However a transaction can actually set nLockTime to a future block height and yet still use nSequence = 0xFFFFFFFF because  locktime is only enforced when at least one input has a non final sequence if not  the locktime field is just ignored.

███████████████████████████
███████▄████████████▄██████
████████▄████████▄████████
███▀█████▀▄███▄▀█████▀███
█████▀█▀▄██▀▀▀██▄▀█▀█████
███████▄███████████▄███████
███████████████████████████
███████▀███████████▀███████
████▄██▄▀██▄▄▄██▀▄██▄████
████▄████▄▀███▀▄████▄████
██▄███▀▀█▀██████▀█▀███▄███
██▀█▀████████████████▀█▀███
███████████████████████████
.
.Duelbits PREDICT..
█████████████████████████
█████████████████████████
███████████▀▀░░░░▀▀██████
██████████░░▄████▄░░████
█████████░░████████░░████
█████████░░████████░░████
█████████▄▀██████▀▄████
████████▀▀░░░▀▀▀▀░░▄█████
██████▀░░░░██▄▄▄▄████████
████▀░░░░▄███████████████
█████▄▄█████████████████
█████████████████████████
█████████████████████████
.
.WHERE EVERYTHING IS A MARKET..
█████
██
██







██
██
██████
Will Bitcoin hit $200,000
before January 1st 2027?

    No @1.15         Yes @6.00    
█████
██
██







██
██
██████

  CHECK MORE > 
hmbdofficial (OP)
Member
**
Online Online

Activity: 98
Merit: 20


View Profile
Today at 12:25:29 PM
 #7

I actually created this tread to be my reference point of my technical journey as though I will be asking more questions as I move on with my technical learning.  I hope I’m not breaking any rule here. And I will be more glad to get straight forward explanations with simplest term.

Q. So today I read about transaction layer cryptography and I was wondering how the Schnorr signature (BIP 340) used in the taproot changes the witness data as compared to the ECDSA signatures used in legacy and Segwit transactions.
hd49728
Legendary
*
Offline Offline

Activity: 2730
Merit: 1290



View Profile
Today at 02:02:35 PM
Merited by vapourminer (1)
 #8

Hi trying to understand the technical part of the transactions and it was necessary that I start with the transactions structure
I can not explain things in your questions for you as I am not too technical but this note of Hongchao on Anatomy of Bitcoin's Raw Transactions can help you, I really hope so.

I see that the note has information on Segwit transaction, Lock time so I guess it can help answering your curious questions.
Quote
The following byte 01 represents the number of transaction inputs, which means that this particular transaction contains exactly one transaction input.

The following byte 02 represents the number of transaction outputs. As the number suggests, there are two outputs in this particular transaction.

e3b50700 is the locktime of the transaction, which dictates the block number or timestamp until which the transaction is locked.


Lock time (learnmeabitcoin.com)


██████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
██████████████████████
.SHUFFLE.COM..███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
█████████████████████
████████████████████
██████████████████████
████████████████████
██████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
██████████████████████
██████████████████████
██████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
███████████████████████
.
...Next Generation Crypto Casino...
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!