blocktools
blocktools copied to clipboard
Added support to Segregated Witness (BIP144)
Hi, I'm studying bitcoin to create a parser with C++ for my thesis and I'm using this parser to doing testing the data for my parser.
I have opened this issue https://github.com/tenthirtyone/blocktools/issues/17 and this pull-request fix it.
I added the support to the Segregation Witness (BIP144), is the new type of the transaction but I not add the support to the deserialize new type of the script (BIP143) but my pull-request is a soft fork so it still decodes the scripts not witness
This is the official reference
Also, this is the example of the end file blk01231.dat
==================== No. 3165 Transaction ====================
Tx Version: 1
Inputs: 2
Prev. Tx Hash: 1972743790d9d2963089d838311e185c523a9c3269712cf06737f25e1ca57f65
Tx Out Index: 0
Script Length: 35
Sequence: ffffffff
Prev. Tx Hash: 60b031317b4a5174a3fb07a606e38c4faedb1456caa3d7ca23354ac53399ac1c
Tx Out Index: 0
Script Length: 35
Sequence: ffffffff
Outputs: 6
Value: 4209263976 Satoshi
Script Len: 23
Pubkey OP_CODE: OP_HASH160 Bytes:20 tail_op_code:OP_EQUAL
Pure Pubkey: 82e7e273ec4e0dff2590e50d5fec2ebc665cd1f7
ScriptPubkey: a91482e7e273ec4e0dff2590e50d5fec2ebc665cd1f787
Value: 5108824 Satoshi
Script Len: 23
Pubkey OP_CODE: OP_HASH160 Bytes:20 tail_op_code:OP_EQUAL
Pure Pubkey: 62eb8dcf0ef509201a5a294adb7a5f819d17fa00
ScriptPubkey: a91462eb8dcf0ef509201a5a294adb7a5f819d17fa0087
Value: 1300000 Satoshi
Script Len: 25
Pubkey OP_CODE: OP_DUP OP_HASH160 Bytes:20 tail_op_code:OP_EQUALVERIFY OP_CHECKSIG
PubkeyHash: 7eb91e48b5be5011536dc3e3c0a6d9858c8baabb
ScriptPubkey: 76a9147eb91e48b5be5011536dc3e3c0a6d9858c8baabb88ac
Value: 3078237 Satoshi
Script Len: 23
Pubkey OP_CODE: OP_HASH160 Bytes:20 tail_op_code:OP_EQUAL
Pure Pubkey: 69f376e9a2cc565ebaa5c64d118b9e6239563a5f
ScriptPubkey: a91469f376e9a2cc565ebaa5c64d118b9e6239563a5f87
Value: 14193601 Satoshi
Script Len: 25
Pubkey OP_CODE: OP_DUP OP_HASH160 Bytes:20 tail_op_code:OP_EQUALVERIFY OP_CHECKSIG
PubkeyHash: 02309d612cada70f7d9d030b52d230583cdb4ef3
ScriptPubkey: 76a91402309d612cada70f7d9d030b52d230583cdb4ef388ac
Value: 1700000 Satoshi
Script Len: 25
Pubkey OP_CODE: OP_DUP OP_HASH160 Bytes:20 tail_op_code:OP_EQUALVERIFY OP_CHECKSIG
PubkeyHash: 65ea0f3cc8b0f97cd6f793e0532ac233c4854cda
ScriptPubkey: 76a91465ea0f3cc8b0f97cd6f793e0532ac233c4854cda88ac
====================|> Input transaction witness <|====================
Dimension script: 3
====================|> Input transaction witness <|====================
Dimension script: 3
Lock Time: 0
==================== No. 3166 Transaction ====================
Tx Version: 1
Inputs: 9
Prev. Tx Hash: 663e55096f26d574db000ceee1ca9553ab78332e004e1002d8418ae248b4db79
Tx Out Index: 1f
Script Length: 106
Sequence: ffffffff
Prev. Tx Hash: 35cab85edf09a6ae5f9b72369d28b7a949b7854903c5ab99b7178daa953f2b69
Tx Out Index: 1
Script Length: 106
Sequence: ffffffff
Prev. Tx Hash: bf138e99fc1faf2adbaada8927b6bbc953c4e74a81757c8f0476236f9a9bf052
Tx Out Index: 0
Script Length: 23
Sequence: ffffffff
Prev. Tx Hash: 0c664fdf906c94a1d5964bd4005e2342406823471955b41f6794070ffedbe542
Tx Out Index: 1
Script Length: 107
Sequence: ffffffff
Prev. Tx Hash: fc6eb3d13a9d76986cab8401fe528961853f30e2775c6b26f6801b22d4569250
Tx Out Index: 0
Script Length: 107
Sequence: ffffffff
Prev. Tx Hash: 0731e413cd1f1b09e1908a7fb4e2097c3b78928c27a276d2653249c51b9d5393
Tx Out Index: 1
Script Length: 106
Sequence: ffffffff
Prev. Tx Hash: e6cfe953dace7edd9ec7dc3fa90c9a0b79710285df5158c4ad4401e4948d2888
Tx Out Index: 30
Script Length: 107
Sequence: ffffffff
Prev. Tx Hash: e8c3f1ea0eebf1fea2b71f246a84ea333b7cdc1c60111b3c4875a560f21d3d65
Tx Out Index: 12
Script Length: 105
Sequence: ffffffff
Prev. Tx Hash: 1c1d3d10dcdc1d1f499745db0f758e13e296aa882820ffa58cd324e261c02ce6
Tx Out Index: 1
Script Length: 23
Sequence: ffffffff
Outputs: 1
Value: 911021218 Satoshi
Script Len: 23
Pubkey OP_CODE: OP_HASH160 Bytes:20 tail_op_code:OP_EQUAL
Pure Pubkey: 5070222ce20355fa52799fc2b2fdca5bc0ade065
ScriptPubkey: a9145070222ce20355fa52799fc2b2fdca5bc0ade06587
====================|> Input transaction witness <|====================
Dimension script: 0
====================|> Input transaction witness <|====================
Dimension script: 0
====================|> Input transaction witness <|====================
Dimension script: 2
====================|> Input transaction witness <|====================
Dimension script: 0
====================|> Input transaction witness <|====================
Dimension script: 0
====================|> Input transaction witness <|====================
Dimension script: 0
====================|> Input transaction witness <|====================
Dimension script: 0
====================|> Input transaction witness <|====================
Dimension script: 0
====================|> Input transaction witness <|====================
Dimension script: 2
Lock Time: 0
==================== No. 3167 Transaction ====================
Tx Version: 1
Inputs: 1
Prev. Tx Hash: 0678d0a4c6b168c13b8b0a47aee2a2727bd97d6087822ac9abd4cb5310c8b306
Tx Out Index: 1
Script Length: 107
Script: 3045022100cfcedec577e2ccc4538ed719d52ee880c3eca86be5edae0c6bb0a3056d71562e02205b7e85059d15b26fc4ee1657072dc6070d5f960d9d64aef5a0b0ad88a2368e8801
InPubkey: 026b005650374684ee6397b9cb53b2d8507d59b89ef1530f3d850d82f5ff9fefed
Sequence: fffffffe
Outputs: 2
Value: 258600 Satoshi
Script Len: 25
Pubkey OP_CODE: OP_DUP OP_HASH160 Bytes:20 tail_op_code:OP_EQUALVERIFY OP_CHECKSIG
PubkeyHash: 1d840a5edd1b34388fbb8eb7e53ec0018a72533d
ScriptPubkey: 76a9141d840a5edd1b34388fbb8eb7e53ec0018a72533d88ac
Value: 596600 Satoshi
Script Len: 25
Pubkey OP_CODE: OP_DUP OP_HASH160 Bytes:20 tail_op_code:OP_EQUALVERIFY OP_CHECKSIG
PubkeyHash: b01814e27a0e05a6aac8506d1ea6ed3f5cfc3d2b
ScriptPubkey: 76a914b01814e27a0e05a6aac8506d1ea6ed3f5cfc3d2b88ac
Lock Time: 517866
#### end of all 3168 transactins
####################Block counter No. 169####################
####################Block counter No. 170####################
Reached End of Field
Parsed 170 blocks
This is the last previous hash raw tx founded