| 579 | } |
| 580 | |
| 581 | struct bitcoin_tx *clone_bitcoin_tx(const tal_t *ctx, |
| 582 | const struct bitcoin_tx *tx) |
| 583 | { |
| 584 | struct bitcoin_tx *newtx; |
| 585 | |
| 586 | if (taken(tx)) |
| 587 | return cast_const(struct bitcoin_tx *, tal_steal(ctx, tx)); |
| 588 | |
| 589 | newtx = tal(ctx, struct bitcoin_tx); |
| 590 | |
| 591 | newtx->chainparams = tx->chainparams; |
| 592 | |
| 593 | tal_wally_start(); |
| 594 | if (wally_tx_clone_alloc(tx->wtx, 0, &newtx->wtx) != WALLY_OK) |
| 595 | newtx->wtx = NULL; |
| 596 | tal_wally_end_onto(newtx, newtx->wtx, struct wally_tx); |
| 597 | if (!newtx->wtx) |
| 598 | return tal_free(newtx); |
| 599 | |
| 600 | newtx->psbt = clone_psbt(newtx, tx->psbt); |
| 601 | tal_add_destructor(newtx, bitcoin_tx_destroy); |
| 602 | return newtx; |
| 603 | } |
| 604 | |
| 605 | static struct wally_tx *pull_wtx(const tal_t *ctx, |
| 606 | const u8 **cursor, |
no test coverage detected