| 547 | } |
| 548 | |
| 549 | struct bitcoin_tx *bitcoin_tx_with_psbt(const tal_t *ctx, struct wally_psbt *psbt TAKES) |
| 550 | { |
| 551 | size_t locktime; |
| 552 | |
| 553 | if (!taken(psbt)) |
| 554 | psbt = clone_psbt(tmpctx, psbt); |
| 555 | |
| 556 | wally_psbt_get_locktime(psbt, &locktime); |
| 557 | struct bitcoin_tx *tx = bitcoin_tx(ctx, chainparams, |
| 558 | psbt->num_inputs, |
| 559 | psbt->num_outputs, |
| 560 | locktime); |
| 561 | wally_tx_free(tx->wtx); |
| 562 | |
| 563 | psbt_finalize(psbt); |
| 564 | tx->wtx = psbt_final_tx(tx, psbt); |
| 565 | if (!tx->wtx) { |
| 566 | tal_wally_start(); |
| 567 | if (wally_psbt_extract(psbt, WALLY_PSBT_EXTRACT_NON_FINAL, &tx->wtx) != WALLY_OK) { |
| 568 | tx->wtx = NULL; |
| 569 | } |
| 570 | tal_wally_end_onto(tx, tx->wtx, struct wally_tx); |
| 571 | if (!tx->wtx) |
| 572 | return tal_free(tx); |
| 573 | } |
| 574 | |
| 575 | tal_free(tx->psbt); |
| 576 | tx->psbt = tal_steal(tx, psbt); |
| 577 | |
| 578 | return tx; |
| 579 | } |
| 580 | |
| 581 | struct bitcoin_tx *clone_bitcoin_tx(const tal_t *ctx, |
| 582 | const struct bitcoin_tx *tx) |
no test coverage detected