| 59 | } |
| 60 | |
| 61 | int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script, |
| 62 | const u8 *wscript, struct amount_sat amount) |
| 63 | { |
| 64 | size_t i = tx->wtx->num_outputs; |
| 65 | struct wally_tx_output *output; |
| 66 | struct wally_psbt_output *psbt_out; |
| 67 | int ret; |
| 68 | const struct chainparams *chainparams = tx->chainparams; |
| 69 | assert(i < tx->wtx->outputs_allocation_len); |
| 70 | |
| 71 | assert(tx->wtx != NULL); |
| 72 | assert(chainparams); |
| 73 | |
| 74 | output = wally_tx_output(NULL, script, amount); |
| 75 | assert(output); |
| 76 | tal_wally_start(); |
| 77 | ret = wally_tx_add_output(tx->wtx, output); |
| 78 | assert(ret == WALLY_OK); |
| 79 | tal_wally_end(tx->wtx); |
| 80 | |
| 81 | psbt_out = psbt_add_output(tx->psbt, output, i); |
| 82 | if (wscript) { |
| 83 | tal_wally_start(); |
| 84 | ret = wally_psbt_output_set_witness_script(psbt_out, |
| 85 | wscript, |
| 86 | tal_bytelen(wscript)); |
| 87 | assert(ret == WALLY_OK); |
| 88 | tal_wally_end(tx->psbt); |
| 89 | } |
| 90 | |
| 91 | wally_tx_output_free(output); |
| 92 | bitcoin_tx_output_set_amount(tx, i, amount); |
| 93 | |
| 94 | return i; |
| 95 | } |
| 96 | |
| 97 | bool elements_wtx_output_is_fee(const struct wally_tx *tx, int outnum) |
| 98 | { |
no test coverage detected