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

Function psbt_txid

bitcoin/psbt.c:775–810  ·  view source on GitHub ↗

This only works on a non-final psbt because we're ALL SEGWIT! */

Source from the content-addressed store, hash-verified

773
774/* This only works on a non-final psbt because we're ALL SEGWIT! */
775void psbt_txid(const tal_t *ctx,
776 const struct wally_psbt *psbt, struct bitcoin_txid *txid,
777 struct wally_tx **wtx)
778{
779 struct wally_tx *tx;
780
781 /* You can *almost* take txid of global tx. But @niftynei thought
782 * about this far more than me and pointed out that P2SH
783 * inputs would not be represented, so here we go. */
784 tal_wally_start();
785 wally_tx_clone_alloc(psbt->tx, 0, &tx);
786
787 for (size_t i = 0; i < tx->num_inputs; i++) {
788 if (psbt->inputs[i].final_scriptsig) {
789 wally_tx_set_input_script(tx, i,
790 psbt->inputs[i].final_scriptsig,
791 psbt->inputs[i].final_scriptsig_len);
792 } else if (psbt->inputs[i].redeem_script) {
793 u8 *script;
794
795 /* P2SH requires push of the redeemscript, from libwally src */
796 script = tal_arr(tmpctx, u8, 0);
797 script_push_bytes(&script,
798 psbt->inputs[i].redeem_script,
799 psbt->inputs[i].redeem_script_len);
800 wally_tx_set_input_script(tx, i, script, tal_bytelen(script));
801 }
802 }
803 tal_wally_end_onto(ctx, tx, struct wally_tx);
804
805 wally_txid(tx, txid);
806 if (wtx)
807 *wtx = tx;
808 else
809 wally_tx_free(tx);
810}
811
812struct amount_sat psbt_compute_fee(const struct wally_psbt *psbt)
813{

Callers 12

json_openchannel_signedFunction · 0.85
signpsbt_doneFunction · 0.85
finish_txprepareFunction · 0.85
collect_sigsFunction · 0.85
handle_send_tx_sigsFunction · 0.85
accepter_commitsFunction · 0.85
opener_commitsFunction · 0.85
rbf_wrap_upFunction · 0.85

Calls 4

tal_wally_startFunction · 0.85
tal_bytelenFunction · 0.85
wally_txidFunction · 0.85
script_push_bytesFunction · 0.70

Tested by

no test coverage detected