MCPcopy Create free account
hub / github.com/ElementsProject/lightning / bitcoin_tx_with_psbt

Function bitcoin_tx_with_psbt

bitcoin/tx.c:549–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

547}
548
549struct 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
581struct bitcoin_tx *clone_bitcoin_tx(const tal_t *ctx,
582 const struct bitcoin_tx *tx)

Callers 6

inflight_set_last_txFunction · 0.85
unreserve_get_resultFunction · 0.85
db_col_psbt_to_txFunction · 0.85

Calls 7

takenFunction · 0.85
clone_psbtFunction · 0.85
psbt_finalizeFunction · 0.85
psbt_final_txFunction · 0.85
tal_wally_startFunction · 0.85
tal_freeFunction · 0.85
bitcoin_txFunction · 0.70

Tested by

no test coverage detected