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

Function openchannel_hook_final

lightningd/opening_control.c:720–766  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

718}
719
720static void
721openchannel_hook_final(struct openchannel_hook_payload *payload STEALS)
722{
723 struct subd *openingd = payload->openingd;
724 const u8 *our_upfront_shutdown_script = payload->our_upfront_shutdown_script;
725 const char *errmsg = payload->errmsg;
726 struct uncommitted_channel* uc = payload->uc;
727 u32 *upfront_shutdown_script_wallet_index;
728
729 /* We want to free this, whatever happens. */
730 tal_steal(tmpctx, payload);
731
732 /* If openingd went away, don't send it anything! */
733 if (!openingd)
734 return;
735
736 tal_del_destructor2(openingd, openchannel_payload_remove_openingd, payload);
737
738 if (!errmsg) {
739 /* Plugins accepted the offer, cancel any of our
740 * funder-side commands. */
741 opening_funder_failed_cancel_commands(uc,
742 "Have in-progress "
743 "`open_channel` from "
744 "peer");
745 uc->got_offer = true;
746 }
747
748 /* Determine the wallet index for our_upfront_shutdown_script,
749 * NULL if not found. */
750 u32 found_wallet_index;
751 if (wallet_can_spend(payload->openingd->ld->wallet,
752 our_upfront_shutdown_script,
753 tal_bytelen(our_upfront_shutdown_script),
754 &found_wallet_index, NULL)) {
755 upfront_shutdown_script_wallet_index = tal(tmpctx, u32);
756 *upfront_shutdown_script_wallet_index = found_wallet_index;
757 } else
758 upfront_shutdown_script_wallet_index = NULL;
759
760 subd_send_msg(openingd,
761 take(towire_openingd_got_offer_reply(NULL, errmsg,
762 our_upfront_shutdown_script,
763 upfront_shutdown_script_wallet_index,
764 payload->uc->reserve,
765 payload->uc->minimum_depth)));
766}
767
768static bool
769openchannel_hook_deserialize(struct openchannel_hook_payload *payload,

Callers 1

Calls 4

wallet_can_spendFunction · 0.85
tal_bytelenFunction · 0.85
subd_send_msgFunction · 0.70

Tested by

no test coverage detected