| 68 | } |
| 69 | |
| 70 | struct wally_psbt *new_psbt(const tal_t *ctx, const struct wally_tx *wtx) |
| 71 | { |
| 72 | struct wally_psbt *psbt; |
| 73 | int wally_err; |
| 74 | |
| 75 | psbt = init_psbt(ctx, wtx->num_inputs, wtx->num_outputs); |
| 76 | |
| 77 | tal_wally_start(); |
| 78 | /* Set directly: avoids psbt checks for non-NULL scripts/witnesses */ |
| 79 | wally_err = wally_tx_clone_alloc(wtx, 0, &psbt->tx); |
| 80 | assert(wally_err == WALLY_OK); |
| 81 | /* Inputs/outs are pre-allocated above, 'add' them as empty dummies */ |
| 82 | psbt->num_inputs = wtx->num_inputs; |
| 83 | psbt->num_outputs = wtx->num_outputs; |
| 84 | |
| 85 | for (size_t i = 0; i < wtx->num_inputs; i++) { |
| 86 | /* add these scripts + witnesses to the psbt */ |
| 87 | if (wtx->inputs[i].script) { |
| 88 | wally_err = |
| 89 | wally_psbt_input_set_final_scriptsig(&psbt->inputs[i], |
| 90 | wtx->inputs[i].script, |
| 91 | wtx->inputs[i].script_len); |
| 92 | assert(wally_err == WALLY_OK); |
| 93 | } |
| 94 | if (wtx->inputs[i].witness) { |
| 95 | wally_err = |
| 96 | wally_psbt_input_set_final_witness(&psbt->inputs[i], |
| 97 | wtx->inputs[i].witness); |
| 98 | assert(wally_err == WALLY_OK); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | tal_wally_end(psbt); |
| 103 | return psbt; |
| 104 | } |
| 105 | |
| 106 | bool psbt_is_finalized(const struct wally_psbt *psbt) |
| 107 | { |
no test coverage detected