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

Function openchannel_hook_final

lightningd/opening_control.c:670–716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

668}
669
670static void
671openchannel_hook_final(struct openchannel_hook_payload *payload STEALS)
672{
673 struct subd *openingd = payload->openingd;
674 const u8 *our_upfront_shutdown_script = payload->our_upfront_shutdown_script;
675 const char *errmsg = payload->errmsg;
676 struct uncommitted_channel* uc = payload->uc;
677 u32 *upfront_shutdown_script_wallet_index;
678
679 /* We want to free this, whatever happens. */
680 tal_steal(tmpctx, payload);
681
682 /* If openingd went away, don't send it anything! */
683 if (!openingd)
684 return;
685
686 tal_del_destructor2(openingd, openchannel_payload_remove_openingd, payload);
687
688 if (!errmsg) {
689 /* Plugins accepted the offer, cancel any of our
690 * funder-side commands. */
691 opening_funder_failed_cancel_commands(uc,
692 "Have in-progress "
693 "`open_channel` from "
694 "peer");
695 uc->got_offer = true;
696 }
697
698 /* Determine the wallet index for our_upfront_shutdown_script,
699 * NULL if not found. */
700 u32 found_wallet_index;
701 bool is_p2sh;
702 if (wallet_can_spend(payload->openingd->ld->wallet,
703 our_upfront_shutdown_script,
704 &found_wallet_index,
705 &is_p2sh)) {
706 upfront_shutdown_script_wallet_index = tal(tmpctx, u32);
707 *upfront_shutdown_script_wallet_index = found_wallet_index;
708 } else
709 upfront_shutdown_script_wallet_index = NULL;
710
711 subd_send_msg(openingd,
712 take(towire_openingd_got_offer_reply(NULL, errmsg,
713 our_upfront_shutdown_script,
714 upfront_shutdown_script_wallet_index,
715 payload->uc->reserve)));
716}
717
718static bool
719openchannel_hook_deserialize(struct openchannel_hook_payload *payload,

Callers 1

Calls 3

wallet_can_spendFunction · 0.85
subd_send_msgFunction · 0.70

Tested by

no test coverage detected