summa-tx / bitcoin-spv

utilities for Bitcoin SPV proof verification on (many!) other chains
Other
171 stars 46 forks source link

Feature Request: Programmatically create Bitcoin Stateless SPV Proofs without running a bcoin full node #152

Open GandalfTheBrown opened 4 years ago

GandalfTheBrown commented 4 years ago

Hi! It would be really helpful to have library functions that query one of the block explorers and parse the transaction data to generate SPV proofs in the format discussed in the SPV Proof CLI readme (copied below) without having to run a bcoin full node.

{ "version": "01000000", "vin": "0168fe12339c9eb3ceaf21899b775a53dc10901f88f57ba7b360bbd285fe1b8731000000006a47304402206f33a57c88e473a26eca617c21aa9545101b18df83b127bc485bf0fea1a831b702204d56bc0e39fa14ff254d0677f46c3f7f26f6dea8e6a9c5ba90aace3c8476f1d401210396dd84815a4f121bf29b882c283ec1cd8b5bfa92773008a79cb44d981821a399ffffffff", "vout": "0230182b00000000001976a91452ada19e1305964e80a1a1cbbafea97f6b632fae88aca7ec3703000000001976a914f9da3787e63ad9261517a6d4d9dabd2cf40fb80988ac", "locktime": "00000000", "tx_id": "fff0d18db9f52e6bff445c26cb8bb9658882c8045997a74be26003225713e762", "tx_id_le": "62e71357220360e24ba7975904c8828865b98bcb265c44ff6b2ef5b98dd1f0ff", "index": 6, "confirming_header": { "raw": "00e0002074859a363c5a885b262722d5c5c5cd912e2cd1a53d0c0c000000000000000000a0c7ea544dcc99af8af5415d4293856da7c07f9f1a3b145d2498b39bf5fa5e36fbd1d45dd1201617d64b8b4c", "hash": "00000000000000000003e7124509796d4f15ef47fedc71c79cea60d1ff503410", "hash_le": "103450ffd160ea9cc771dcfe47ef154f6d79094512e703000000000000000000", "height": 604596, "prevhash": "0000000000000000000c0c3da5d12c2e91cdc5c5d52227265b885a3c369a8574", "prevhash_le": "74859a363c5a885b262722d5c5c5cd912e2cd1a53d0c0c000000000000000000", "merkle_root": "365efaf59bb398245d143b1a9f7fc0a76d8593425d41f58aaf99cc4d54eac7a0", "merkle_root_le": "a0c7ea544dcc99af8af5415d4293856da7c07f9f1a3b145d2498b39bf5fa5e36" }, "intermediate_nodes": "c7ca43c16c6a587c3554d45a1c0d56e801ef2dc929fae3cc95bb604b3f566de1f6e9750121695b84989ba819f6cea180315f8a3ae71d644f1bb90379577dbc6d7167faee2d76d172fcec41469346d3d731a901fa86e71528a8569a414ef42ed5585623d28015eb91eb1dda03615196918e49e5f1ff0ef22974..." }

prestwich commented 4 years ago

This should be relatively easy to put together using the blockstream esplora api (docs here)

@GandalfTheBrown note that recently the *_le fields were dropped, and all fields were changed to be LE by default