Browse Source
This fixes block parsing on testnet; specifically, non-standard tx versions. We hit a type bug in libwally (wallt_get_secp_context()) which I had to work around for the moment, and the updated libsecp adds an optional hash function arg to the ECDH function. Fixes: #2563 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>pr-2587
Rusty Russell
6 years ago
committed by
Christian Decker
14 changed files with 122 additions and 16 deletions
@ -0,0 +1,98 @@ |
|||
#include "../block.c" |
|||
#include "../pullpush.c" |
|||
#include "../shadouble.c" |
|||
#include "../tx.c" |
|||
#include "../varint.c" |
|||
#include <assert.h> |
|||
|
|||
static const char block[] = |
|||
"00a09265c15bea24321eecadb27ddf660035ac1f2b450ec03b973e17310f000" |
|||
"0000000008a0ee58ded5de949325ebc99583e3ca84f96a6597465c611685413" |
|||
"f50f0ead7eafdc6a5c00013f1a3580194903010000000001010000000000000" |
|||
"000000000000000000000000000000000000000000000000000ffffffff2703" |
|||
"9985161a4d696e656420627920416e74506f6f6c2094000103208efc8ad9030" |
|||
"00000101f0100ffffffff02d2545402000000001976a9144afc312d452c9c49" |
|||
"9fb8662728b19ac0cd3ea68888ac0000000000000000266a24aa21a9ed08b1d" |
|||
"c37da139ccd00803738db33e05331819736b3336352dc6e2fa74f1fd67b0120" |
|||
"000000000000000000000000000000000000000000000000000000000000000" |
|||
"00000000001000000019b1a8eaec64d596296c3abe9af09cce1dc09996a9ad0" |
|||
"84aaef0e4f79eb13f1e400000000fd5e0100483045022100b16d81821baf80d" |
|||
"6af47afea73cbd3f013bf4905c87ba896ed6e545dd00edd3a0220043262bf51" |
|||
"fe21b22b74a3ed148396077da75969e76b5fd647cda138f323634d014830450" |
|||
"22100a2b86c9e21b5b8ff0b185e42274bfe1ef6c8d4ec6e43c174bfdac360b6" |
|||
"8ac2b80220440a60482cfccd5c384c7d62e16e03a86295224b3ef82fb6f7d29" |
|||
"42657a4b330014cc95241048aa0d470b7a9328889c84ef0291ed30346986e22" |
|||
"558e80c3ae06199391eae21308a00cdcfb34febc0ea9c80dfd16b01f26c7ec6" |
|||
"7593cb8ab474aca8fa1d7029d4104cf54956634c4d0bdaf00e6b1871c089b7a" |
|||
"892d0fecc077f03b91e8d4d146861b0a4fdd237891a9819c878984d4b123f6f" |
|||
"e92d9bbc05873a1bb4fe510145bf369410471843c33b2971e4944c73d4500ab" |
|||
"d6f61f7edf9ec919c408cbe12a6c9132d2cb8ebed8253322760d5ec6081165e" |
|||
"0ab68900683de503f1544f03816d47fec699a53aeffffffff02707712000000" |
|||
"00001976a9147e1d98594b7b8417ed905904bad4d0de0217ee0288acc9a20a0" |
|||
"20000000017a9145629021f7668d4ec310ac5e99701a6d6cf95eb8f87000000" |
|||
"0003000000046113feede7973b484e4b8605d4f8cf2d498c98cef1a30898eb2" |
|||
"5e0958805031c000000006a47304402207afc3e15fc3c3657981cd4e0cf8afc" |
|||
"2c62bf37efa7f92eef669d1b4ec0701c93022057bbcb4bb3b5b7b7341d708e8" |
|||
"bf62975013f658c29fcd22482307b4ee8e223b3012103585914f7d7e37df12b" |
|||
"df0171503922c86ea2c9f09d4f20c40660a74c883687adffffffff6d2663970" |
|||
"ee08fbbf1dd9a30ba71ef1bc196cba2b9f6a19db1af4c7995003e8500000000" |
|||
"6b483045022100906fd4411926dca316ba7127e7072bd0691481883811856ff" |
|||
"81e4f9c526ec08e022005afc833c37cec7b87c58a8eec66704a0ed277f8e497" |
|||
"f7512b9cefae3d50d3db012103585914f7d7e37df12bdf0171503922c86ea2c" |
|||
"9f09d4f20c40660a74c883687adffffffff8356393fa3711040b67f221f1246" |
|||
"4ea09a770381130b4070bf8514307decba18010000006a47304402200657e98" |
|||
"4c480a37e2d73534d8314e2a73d315cb2934ad47a84d1ca9f5304332702206b" |
|||
"212bb3ec549c39dca2f5e7ba5f8ba6020f5d4a975433a2334ceb8ff2f040590" |
|||
"12103585914f7d7e37df12bdf0171503922c86ea2c9f09d4f20c40660a74c88" |
|||
"3687adffffffffca9dd5661fc8caf4e5e75aa218c29a004a1d18a6461c493ef" |
|||
"7c29e9cb77b54c9010000006b483045022100da7635fdaa91d5c293915802b4" |
|||
"d02a044cd64548b8c23bfaaeec47d25d6039df022053927423c4d29c9a30458" |
|||
"a837b6715ff50a3a2f5e97268cf606d9a52a30fa486012103585914f7d7e37d" |
|||
"f12bdf0171503922c86ea2c9f09d4f20c40660a74c883687adffffffff02404" |
|||
"20f00000000001976a914a2fdc4acc57254d6922607cd02b4826bb458528288" |
|||
"ac0eb82500000000001976a914e05655a7d90b01ba874d81beff57ee09610ca" |
|||
"3ce88ac00000000"; |
|||
|
|||
STRUCTEQ_DEF(sha256_double, 0, sha); |
|||
|
|||
int main(void) |
|||
{ |
|||
struct bitcoin_blkid prev; |
|||
struct sha256_double merkle; |
|||
struct bitcoin_txid txid, expected_txid; |
|||
struct bitcoin_block *b; |
|||
|
|||
setup_locale(); |
|||
b = bitcoin_block_from_hex(NULL, block, strlen(block)); |
|||
|
|||
assert(b); |
|||
assert(b->hdr.version == CPU_TO_LE32(0x6592a000)); |
|||
bitcoin_blkid_from_hex("0000000000000f31173e973bc00e452b1fac350066df7db2adec1e3224ea5bc1", strlen("0000000000000f31173e973bc00e452b1fac350066df7db2adec1e3224ea5bc1"), &prev); |
|||
assert(bitcoin_blkid_eq(&prev, &b->hdr.prev_hash)); |
|||
hex_decode("8a0ee58ded5de949325ebc99583e3ca84f96a6597465c611685413f50f0ead7e", strlen("8a0ee58ded5de949325ebc99583e3ca84f96a6597465c611685413f50f0ead7e"), &merkle, sizeof(merkle)); |
|||
assert(sha256_double_eq(&merkle, &b->hdr.merkle_hash)); |
|||
assert(b->hdr.timestamp == CPU_TO_LE32(1550507183)); |
|||
assert(b->hdr.nonce == CPU_TO_LE32(1226407989)); |
|||
|
|||
assert(tal_count(b->tx) == 3); |
|||
bitcoin_txid(b->tx[0], &txid); |
|||
bitcoin_txid_from_hex("14d86acd2158acd1f59ab77ab251e3f5073db905a7b2aed25d3ba7780c3d790c", |
|||
strlen("14d86acd2158acd1f59ab77ab251e3f5073db905a7b2aed25d3ba7780c3d790c"), |
|||
&expected_txid); |
|||
assert(bitcoin_txid_eq(&txid, &expected_txid)); |
|||
|
|||
bitcoin_txid(b->tx[1], &txid); |
|||
bitcoin_txid_from_hex("c261a53121cc9841f843e2e6e0cff337e4f3c5eee788c982a0bffe771ce69919", |
|||
strlen("c261a53121cc9841f843e2e6e0cff337e4f3c5eee788c982a0bffe771ce69919"), |
|||
&expected_txid); |
|||
assert(bitcoin_txid_eq(&txid, &expected_txid)); |
|||
|
|||
bitcoin_txid(b->tx[2], &txid); |
|||
bitcoin_txid_from_hex("80cea306607b708a03a1854520729da884e4317b7b51f3d4a622f88176f5e034", |
|||
strlen("80cea306607b708a03a1854520729da884e4317b7b51f3d4a622f88176f5e034"), |
|||
&expected_txid); |
|||
assert(bitcoin_txid_eq(&txid, &expected_txid)); |
|||
|
|||
tal_free(b); |
|||
return 0; |
|||
} |
@ -1 +1 @@ |
|||
Subproject commit c51bca3379545e1aaaa78a25cc2b73e589a6ad79 |
|||
Subproject commit f27740564955e9a63d2946bdb0099622c0977b6e |
Loading…
Reference in new issue