1
1
mirror of https://github.com/wader/fq.git synced 2024-11-23 00:57:15 +03:00

Merge pull request #671 from Rogach/pr/bitcoin-tx-witness-items

bitcoin: fix witness item structs
This commit is contained in:
Mattias Wadman 2023-05-15 15:17:47 +02:00 committed by GitHub
commit aa6723603e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 64 additions and 2 deletions

View File

@ -89,8 +89,10 @@ func decodeBitcoinTranscation(d *decode.D) any {
witnessSize := d.FieldUintFn("witness_size", decodeVarInt)
d.FieldArray("items", func(d *decode.D) {
for j := uint64(0); j < witnessSize; j++ {
itemSize := d.FieldUintFn("item_size", decodeVarInt)
d.FieldRawLen("item", int64(itemSize)*8)
d.FieldStruct("item", func(d *decode.D) {
itemSize := d.FieldUintFn("item_size", decodeVarInt)
d.FieldRawLen("item", int64(itemSize)*8)
})
}
})
})

BIN
format/bitcoin/testdata/tx_b941ddad.dat vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,60 @@
$ fq -d bitcoin_transaction dv tx_b941ddad.dat
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: tx_b941ddad.dat (bitcoin_transaction) 0x0-0x166.7 (359)
0x000|02 00 00 00 |.... | version: 2 0x0-0x3.7 (4)
0x000| 00 | . | marker: 0 0x4-0x4.7 (1)
0x000| 01 | . | flag: 1 0x5-0x5.7 (1)
0x000| 01 | . | input_count: 1 0x6-0x6.7 (1)
| | | inputs[0:1]: 0x7-0x2f.7 (41)
| | | [0]{}: input 0x7-0x2f.7 (41)
0x000| 05 89 f2 e6 c0 7d 7c d7 d0| .....}|..| txid: "1efe0f1537ddd0b2f94d93b56d14f30f570b7495cfbf6cd..." (raw bits) 0x7-0x26.7 (32)
0x010|6c bf cf 95 74 0b 57 0f f3 14 6d b5 93 4d f9 b2|l...t.W...m..M..|
0x020|d0 dd 37 15 0f fe 1e |..7.... |
0x020| 00 00 00 00 | .... | vout: 0 0x27-0x2a.7 (4)
0x020| 00 | . | scriptsig_size: 0 0x2b-0x2b.7 (1)
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| scriptsig[0:1]: (bitcoin_script) 0x2c-NA (0)
| | | [0]: raw bits gap0 0x2c-NA (0)
0x020| fd ff ff ff| ....| sequence: 0xfffffffd 0x2c-0x2f.7 (4)
0x030|02 |. | output_count: 2 0x30-0x30.7 (1)
| | | outputs[0:2]: 0x31-0x7a.7 (74)
| | | [0]{}: output 0x31-0x5b.7 (43)
0x030| 22 02 00 00 00 00 00 00 | "....... | value: 546 0x31-0x38.7 (8)
0x030| 22 | " | scriptpub_size: 34 0x39-0x39.7 (1)
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| scriptpub[0:2]: (bitcoin_script) 0x3a-0x5b.7 (34)
| | | [0]{}: opcode 0x3a-0x3a.7 (1)
0x030| 51 | Q | op: "true" (81) 0x3a-0x3a.7 (1)
| | | [1]{}: opcode 0x3b-0x5b.7 (33)
0x030| 20 | | op: "pushself" (32) 0x3b-0x3b.7 (1)
0x030| 3f 8a 96 81| ?...| arg: raw bits 0x3c-0x5b.7 (32)
0x040|00 68 97 35 eb 2f 34 44 ec 60 99 e5 59 1f 64 e4|.h.5./4D.`..Y.d.|
0x050|8b 13 f6 7e 03 b9 5c e7 55 ef d9 47 |...~..\.U..G |
| | | [1]{}: output 0x5c-0x7a.7 (31)
0x050| 36 06 00 00| 6...| value: 1590 0x5c-0x63.7 (8)
0x060|00 00 00 00 |.... |
0x060| 16 | . | scriptpub_size: 22 0x64-0x64.7 (1)
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef| scriptpub[0:2]: (bitcoin_script) 0x65-0x7a.7 (22)
| | | [0]{}: opcode 0x65-0x65.7 (1)
0x060| 00 | . | op: "false" (0) 0x65-0x65.7 (1)
| | | [1]{}: opcode 0x66-0x7a.7 (21)
0x060| 14 | . | op: "pushself" (20) 0x66-0x66.7 (1)
0x060| 1a 62 ac 2b 8c 21 3c 14 df| .b.+.!<..| arg: raw bits 0x67-0x7a.7 (20)
0x070|ab c9 d7 5b 67 18 dd ca 3f 8e 16 |...[g...?.. |
| | | witnesses[0:1]: 0x7b-0x162.7 (232)
| | | [0]{}: witness 0x7b-0x162.7 (232)
0x070| 03 | . | witness_size: 3 0x7b-0x7b.7 (1)
| | | items[0:3]: 0x7c-0x162.7 (231)
| | | [0]{}: item 0x7c-0xbc.7 (65)
0x070| 40 | @ | item_size: 64 0x7c-0x7c.7 (1)
0x070| f7 2d d2| .-.| item: raw bits 0x7d-0xbc.7 (64)
0x080|3c 02 8d 3f ae cd e7 40 01 a4 ae 83 f7 10 28 68|<..?...@......(h|
* |until 0xbc.7 (64) | |
| | | [1]{}: item 0xbd-0x140.7 (132)
0x0b0| 83 | . | item_size: 131 0xbd-0xbd.7 (1)
0x0b0| 20 11| .| item: raw bits 0xbe-0x140.7 (131)
0x0c0|7f 69 22 57 b2 33 12 33 b5 70 5c e9 c6 82 be 87|.i"W.3.3.p\.....|
* |until 0x140.7 (131) | |
| | | [2]{}: item 0x141-0x162.7 (34)
0x140| 21 | ! | item_size: 33 0x141-0x141.7 (1)
0x140| c0 11 7f 69 22 57 b2 33 12 33 b5 70 5c e9| ...i"W.3.3.p\.| item: raw bits 0x142-0x162.7 (33)
0x150|c6 82 be 87 19 ff 1b 2b 64 cb ca 29 0b d6 fa eb|.......+d..)....|
0x160|54 42 3e |TB> |
0x160| 00 00 00 00| | ....| | locktime: 0 0x163-0x166.7 (4)