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

Function funding_transaction_established

plugins/spender/openchannel.c:616–660  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

614 */
615
616static struct command_result *
617funding_transaction_established(struct multifundchannel_command *mfc)
618{
619 /* Elements requires a fee output. */
620 /* FIXME: v2 on liquid */
621 psbt_elements_normalize_fees(mfc->psbt);
622
623 /* Generate the TXID. */
624 mfc->txid = tal(mfc, struct bitcoin_txid);
625 psbt_txid(NULL, mfc->psbt, mfc->txid, NULL);
626 plugin_log(mfc->cmd->plugin, LOG_DBG,
627 "mfc %"PRIu64": funding tx %s",
628 mfc->id,
629 fmt_bitcoin_txid(tmpctx, mfc->txid));
630
631 /* If all we've got is v2 destinations, we're just waiting
632 * for all of our peers to send us their sigs.
633 * Let's check if we've gotten them yet */
634 if (dest_count(mfc, FUND_CHANNEL) == 0)
635 return check_sigs_ready(mfc);
636
637 /* For any v1 destination, we need to update the destination
638 * outnum with the correct outnum on the now-known
639 * funding transaction */
640 for (size_t i = 0; i < tal_count(mfc->destinations); i++) {
641 struct multifundchannel_destination *dest;
642 if (is_v2(&mfc->destinations[i]))
643 continue;
644
645 dest = &mfc->destinations[i];
646 dest->outnum = mfc->psbt->num_outputs;
647 for (size_t j = 0; j < mfc->psbt->num_outputs; j++) {
648 if (memeq(dest->funding_script,
649 tal_bytelen(dest->funding_script),
650 mfc->psbt->outputs[j].script,
651 mfc->psbt->outputs[j].script_len))
652 dest->outnum = j;
653 }
654 if (dest->outnum == mfc->psbt->num_outputs)
655 abort();
656 assert(dest->outnum < mfc->psbt->num_outputs);
657 }
658
659 return perform_fundchannel_complete(mfc);
660}
661
662static struct command_result *
663openchannel_update_returned(struct multifundchannel_destination *dest)

Callers 1

Calls 11

psbt_txidFunction · 0.85
fmt_bitcoin_txidFunction · 0.85
dest_countFunction · 0.85
check_sigs_readyFunction · 0.85
is_v2Function · 0.85
memeqFunction · 0.85
tal_bytelenFunction · 0.85
abortFunction · 0.85
plugin_logFunction · 0.50

Tested by

no test coverage detected