| 535 | } |
| 536 | |
| 537 | struct bitcoin_tx *bitcoin_tx_with_psbt(const tal_t *ctx, struct wally_psbt *psbt STEALS) |
| 538 | { |
| 539 | struct bitcoin_tx *tx = bitcoin_tx(ctx, chainparams, |
| 540 | psbt->tx->num_inputs, |
| 541 | psbt->tx->num_outputs, |
| 542 | psbt->tx->locktime); |
| 543 | wally_tx_free(tx->wtx); |
| 544 | |
| 545 | psbt_finalize(psbt); |
| 546 | tx->wtx = psbt_final_tx(tx, psbt); |
| 547 | if (!tx->wtx) { |
| 548 | tal_wally_start(); |
| 549 | if (wally_tx_clone_alloc(psbt->tx, 0, &tx->wtx) != WALLY_OK) |
| 550 | tx->wtx = NULL; |
| 551 | tal_wally_end_onto(tx, tx->wtx, struct wally_tx); |
| 552 | if (!tx->wtx) |
| 553 | return tal_free(tx); |
| 554 | } |
| 555 | |
| 556 | tal_free(tx->psbt); |
| 557 | tx->psbt = tal_steal(tx, psbt); |
| 558 | |
| 559 | return tx; |
| 560 | } |
| 561 | |
| 562 | static struct wally_tx *pull_wtx(const tal_t *ctx, |
| 563 | const u8 **cursor, |
no test coverage detected