I'm trying to grasp some of the concepts presented in BIP 143. 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, 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?

1 Answer 1

  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"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.