| 45 | } |
| 46 | |
| 47 | struct wally_psbt *new_psbt(const tal_t *ctx, const struct wally_tx *wtx) |
| 48 | { |
| 49 | struct wally_psbt *psbt; |
| 50 | int wally_err; |
| 51 | |
| 52 | psbt = create_psbt(ctx, wtx->num_inputs, wtx->num_outputs, wtx->locktime); |
| 53 | |
| 54 | tal_wally_start(); |
| 55 | |
| 56 | /* locktime and modifiable flags are set in create_psbt */ |
| 57 | wally_psbt_set_tx_version(psbt, wtx->version); |
| 58 | |
| 59 | for (size_t i = 0; i < wtx->num_inputs; i++) { |
| 60 | wally_err = wally_psbt_add_tx_input_at(psbt, i, 0, &wtx->inputs[i]); |
| 61 | assert(wally_err == WALLY_OK); |
| 62 | |
| 63 | /* add these scripts + witnesses to the psbt */ |
| 64 | if (wtx->inputs[i].script) { |
| 65 | wally_err = |
| 66 | wally_psbt_input_set_final_scriptsig(&psbt->inputs[i], |
| 67 | wtx->inputs[i].script, |
| 68 | wtx->inputs[i].script_len); |
| 69 | assert(wally_err == WALLY_OK); |
| 70 | } |
| 71 | if (wtx->inputs[i].witness) { |
| 72 | wally_err = |
| 73 | wally_psbt_input_set_final_witness(&psbt->inputs[i], |
| 74 | wtx->inputs[i].witness); |
| 75 | assert(wally_err == WALLY_OK); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | for (size_t i = 0; i < wtx->num_outputs; i++) { |
| 80 | wally_psbt_add_tx_output_at(psbt, i, 0, &wtx->outputs[i]); |
| 81 | } |
| 82 | |
| 83 | tal_wally_end(psbt); |
| 84 | return psbt; |
| 85 | } |
| 86 | |
| 87 | struct wally_psbt *combine_psbt(const tal_t *ctx, |
| 88 | const struct wally_psbt *psbt0, |
no test coverage detected