| 33 | } |
| 34 | |
| 35 | int main(int argc, const char *argv[]) |
| 36 | { |
| 37 | common_setup(argv[0]); |
| 38 | chainparams = chainparams_for_network("bitcoin"); |
| 39 | |
| 40 | struct bitcoin_tx *tx; |
| 41 | |
| 42 | tx = bitcoin_tx_from_hex(NULL, extended_tx, strlen(extended_tx)); |
| 43 | assert(tx); |
| 44 | |
| 45 | /* Canonical results from Nichola Dorier's |
| 46 | * http://n.bitcoin.ninja/checktx |
| 47 | * With much thanks! |
| 48 | */ |
| 49 | assert(tx->wtx->num_inputs == 1); |
| 50 | assert(tx->wtx->num_outputs == 1); |
| 51 | |
| 52 | reverse_bytes(tx->wtx->inputs[0].txhash, |
| 53 | sizeof(tx->wtx->inputs[0].txhash)); |
| 54 | hexeq(tx->wtx->inputs[0].txhash, sizeof(tx->wtx->inputs[0].txhash), |
| 55 | "1db36e1306dfc810ea63f0cf866d475cce4e9261a5e8d1581f0d1dc485f4beb5"); |
| 56 | assert(tx->wtx->inputs[0].index == 0); |
| 57 | |
| 58 | /* This is a p2sh-p2wpkh: */ |
| 59 | /* ScriptSig is push of "version 0 + hash of pubkey" */ |
| 60 | hexeq(tx->wtx->inputs[0].script, tx->wtx->inputs[0].script_len, |
| 61 | "16" "00" "144aa38e396e1394fb45cbf83f48d1464fbc9f498f"); |
| 62 | |
| 63 | /* Witness with 2 items */ |
| 64 | assert(tx->wtx->inputs[0].witness); |
| 65 | assert(tx->wtx->inputs[0].witness->num_items == 2); |
| 66 | |
| 67 | hexeq(tx->wtx->inputs[0].witness->items[0].witness, |
| 68 | tx->wtx->inputs[0].witness->items[0].witness_len, |
| 69 | "3045022100f2abf9e9cf238c66533af93f23937eae8ac01fb6f105a00ab71dbe" |
| 70 | "fb9637dc9502205c1ac745829b3f6889607961f5d817dfa0c8f52bdda12e837c" |
| 71 | "4f7b162f6db8a701"); |
| 72 | hexeq(tx->wtx->inputs[0].witness->items[1].witness, |
| 73 | tx->wtx->inputs[0].witness->items[1].witness_len, |
| 74 | "0204096eb817f7efb414ef4d3d8be39dd04374256d3b054a322d4a6ee22736d0" |
| 75 | "3b"); |
| 76 | |
| 77 | tal_free(tx); |
| 78 | common_shutdown(); |
| 79 | return 0; |
| 80 | } |
nothing calls this directly
no test coverage detected