| 117 | } |
| 118 | |
| 119 | int main(int argc, const char *argv[]) |
| 120 | { |
| 121 | common_setup(argv[0]); |
| 122 | chainparams = chainparams_for_network("bitcoin"); |
| 123 | |
| 124 | struct bitcoin_tx *tx; |
| 125 | |
| 126 | tx = bitcoin_tx_from_hex(NULL, extended_tx, strlen(extended_tx)); |
| 127 | assert(tx); |
| 128 | |
| 129 | /* Canonical results from Nichola Dorier's |
| 130 | * http://n.bitcoin.ninja/checktx |
| 131 | * With much thanks! |
| 132 | */ |
| 133 | assert(tx->wtx->num_inputs == 1); |
| 134 | assert(tx->wtx->num_outputs == 1); |
| 135 | |
| 136 | reverse_bytes(tx->wtx->inputs[0].txhash, |
| 137 | sizeof(tx->wtx->inputs[0].txhash)); |
| 138 | hexeq(tx->wtx->inputs[0].txhash, sizeof(tx->wtx->inputs[0].txhash), |
| 139 | "1db36e1306dfc810ea63f0cf866d475cce4e9261a5e8d1581f0d1dc485f4beb5"); |
| 140 | assert(tx->wtx->inputs[0].index == 0); |
| 141 | |
| 142 | /* This is a p2sh-p2wpkh: */ |
| 143 | /* ScriptSig is push of "version 0 + hash of pubkey" */ |
| 144 | hexeq(tx->wtx->inputs[0].script, tx->wtx->inputs[0].script_len, |
| 145 | "16" "00" "144aa38e396e1394fb45cbf83f48d1464fbc9f498f"); |
| 146 | |
| 147 | /* Witness with 2 items */ |
| 148 | assert(tx->wtx->inputs[0].witness); |
| 149 | assert(tx->wtx->inputs[0].witness->num_items == 2); |
| 150 | |
| 151 | hexeq(tx->wtx->inputs[0].witness->items[0].witness, |
| 152 | tx->wtx->inputs[0].witness->items[0].witness_len, |
| 153 | "3045022100f2abf9e9cf238c66533af93f23937eae8ac01fb6f105a00ab71dbe" |
| 154 | "fb9637dc9502205c1ac745829b3f6889607961f5d817dfa0c8f52bdda12e837c" |
| 155 | "4f7b162f6db8a701"); |
| 156 | hexeq(tx->wtx->inputs[0].witness->items[1].witness, |
| 157 | tx->wtx->inputs[0].witness->items[1].witness_len, |
| 158 | "0204096eb817f7efb414ef4d3d8be39dd04374256d3b054a322d4a6ee22736d0" |
| 159 | "3b"); |
| 160 | |
| 161 | tal_free(tx); |
| 162 | common_shutdown(); |
| 163 | return 0; |
| 164 | } |
nothing calls this directly
no test coverage detected