<ol>
<li><p>I believe you can use either at this stage. The marker and the flag show let the client decipher which scheme is being used and interpret appropriately.</p></li>
<li><p>lockTime sets when the transaction is valid from. 0x00 is from the first block, 0x11 is from a later block. You can continue to use 0x00 if you wish. <a href="https://bitcoin.org/en/glossary/locktime" rel="nofollow noreferrer">https://bitcoin.org/en/glossary/locktime</a>. Most transactions are published with a locktime in the past so that they are immediately mined.</p></li>
<li><p>The sequence number: <a href="https://bitcoin.org/en/glossary/sequence-number" rel="nofollow noreferrer">https://bitcoin.org/en/glossary/sequence-number</a></p></li>
<li><p>The stack items depend on the type of transaction. See the examples in bip 141. For example the witness for p2WPKH nested in BIP16 P2SH is "signature" "pubkey"</p></li>
</ol>

CC BY-SA 3.0
2018-01-23T06:30:30.620Z
2018-01-23T06:30:30.620Z
 mynt
<p>I'm trying to grasp some of the concepts presented in <a href="https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#Native_P2WPKH" rel="nofollow noreferrer">BIP 143</a>. These are the things I'm stuck on:</p>

<p>(1) A new hash format is presented. This new format is used to create a hash, which when signed with a private key, acts as a signature for an input. If my transaction contains a mix of input types (e.g. P2PKH and P2WPKH, for example), and I'm signing the P2PKH input, do I still use the original hash format that was used in the past or shall I use this new format? It appears the new format is only used when signing the P2WPKH inputs, correct?</p>

<p>(2) In the past, I've always set lockTime to 0x00. Why is it set to 0x11 in the BIP 143 example?</p>

<p>(3) In the past, I've always set sequenceNumber to 0xffffffff. Why is is set to 0xeeffffff in the BIP 143 example?</p>

<p>(4)I can't quite figure out the format of the witness section. Clearly, there should be one entry for each input. And for the P2PKH input it's just set to zero. But what comes next? According to <a href="https://bitcoincore.org/en/segwit_wallet_dev/" rel="nofollow noreferrer">this</a>, each entry consists of an integer indicating the number of "stack items for the corresponding txIn", and then each stack item consists of a size indicator and the payload of the stack item. But what are the stack items and what is their order? Presumably this is where I'd put my input script and signature, right?</p>

<segregated-witness><signature><locktime><sequence><bip143>
Understanding BIP 143 [hash computation, lockTime, sequence number, witness format]
Festus Martingale
# Understanding BIP 143 [hash computation, lockTime, sequence number, witness format]

(Asked by: username_0 on 2018-01-23)

I'm trying to grasp some of the concepts presented in [BIP 143](https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#Native_P2WPKH). These are the things I'm stuck on:

(1) A new hash format is presented. This new format is used to create a hash, which when signed with a private key, acts as a signature for an input. If my transaction contains a mix of input types (e.g. P2PKH and P2WPKH, for example), and I'm signing the P2PKH input, do I still use the original hash format that was used in the past or shall I use this new format? It appears the new format is only used when signing the P2WPKH inputs, correct?

(2) In the past, I've always set lockTime to 0x00. Why is it set to 0x11 in the BIP 143 example?

(3) In the past, I've always set sequenceNumber to 0xffffffff. Why is is set to 0xeeffffff in the BIP 143 example?

(4)I can't quite figure out the format of the witness section. Clearly, there should be one entry for each input. And for the P2PKH input it's just set to zero. But what comes next? According to [this](https://bitcoincore.org/en/segwit_wallet_dev/), each entry consists of an integer indicating the number of "stack items for the corresponding txIn", and then each stack item consists of a size indicator and the payload of the stack item. But what are the stack items and what is their order? Presumably this is where I'd put my input script and signature, right?

**Tags:** segregated-witness, signature, locktime, sequence, bip143


---

## 1 answers

### Answer by username_1 on 2018-01-23. Score: 1 | Accepted answer

1. I believe you can use either at this stage. The marker and the flag show let the client decipher which scheme is being used and interpret appropriately.
2. lockTime sets when the transaction is valid from. 0x00 is from the first block, 0x11 is from a later block. You can continue to use 0x00 if you wish. <https://bitcoin.org/en/glossary/locktime>. Most transactions are published with a locktime in the past so that they are immediately mined.
3. The sequence number: <https://bitcoin.org/en/glossary/sequence-number>
4. The stack items depend on the type of transaction. See the examples in bip 141. For example the witness for p2WPKH nested in BIP16 P2SH is "signature" "pubkey"


---

