2

what is the purpose of that 02 in this P2WPKH transaction :

01000000
0001
01
d6f3994ab779ac849996a6235699ced672fa4b8334f825a2f1fcb4081c5b0c62
00000000
00
ffffffff
02
1027000000000000
16
00140429fc6e543ff7b4b75d0c6a60013c125827aa66
5716040000000000
16
00145951ac8720b1865ba633d19eaa6473afae7c46b3


02  -----> WHAT IS THE PURPOSE OF THIS?


483045022100b826e4123a66ab38f2e5f4ede2c50c1ce93bbfbdbdc2997a6e1ff09fe964349d022060a14f272ba521ec71f022922a855bda8827b7262ca181df755fdf42f656cc97012102e2ae4b9e9d86f03d511c4716ce3af351428201f2ff0378d00c7e097fbbbcb95
000000000

1 Answer 1

2

It is the number of witness items in the witness stack of input #0 of the transaction.

See BIP144 for the serialization format used by segwit transactions:

the only witness objects type supported are script witnesses which consist of a stack of byte arrays. It is encoded as a var_int item count followed by each item encoded as a var_int length followed by a string of bytes. Each txin has its own script witness. The number of script witnesses is not explicitly encoded as it is implied by txin_count. Empty script witnesses are encoded as a zero byte. The order of the script witnesses follows the same order as the associated txins.

3
  • thanks for anwsering, this is the transaction : mempool.space/tx/… where is the witness item? i'm new to bitcoin btw. is the signature and public key which two items?
    – user148205
    Feb 7 at 20:59
  • The first witness item of this input has length 0x48 (and comprises the 0x48 following bytes 30450221...cc9701). The second witness item has length 0x21 (and comprises the 0x21 following bytes 02e2ae4b...fbbbcb95). It's a P2WPKH spend, so exactly two witness items are expected: an ECDSA signature and a public key, in that order. Feb 7 at 21:04
  • Got It, Thank You.
    – user148205
    Feb 7 at 21:09

Your Answer

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