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

Function funding_transaction_established

plugins/spender/openchannel.c:606–651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 11

psbt_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
type_to_stringClass · 0.50

Tested by

no test coverage detected