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

Function openchannel2_hook_deserialize

lightningd/dual_open_control.c:682–811  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

680
681
682static bool
683openchannel2_hook_deserialize(struct openchannel2_payload *payload,
684 const char *buffer,
685 const jsmntok_t *toks)
686{
687 const u8 *shutdown_script;
688 const char *err;
689 struct subd *dualopend = payload->dualopend;
690
691 /* If our daemon died, we're done */
692 if (!dualopend) {
693 openchannel2_hook_cb(payload);
694 return false;
695 }
696
697 const jsmntok_t *t_result = json_get_member(buffer, toks, "result");
698 if (!t_result)
699 fatal("Plugin returned an invalid response to the"
700 " openchannel2 hook: %.*s",
701 json_tok_full_len(toks),
702 json_tok_full(buffer, toks));
703
704 if (json_tok_streq(buffer, t_result, "reject")) {
705 /* Should not have set any other fields if 'reject'ing */
706 if (json_get_member(buffer, toks, "close_to"))
707 fatal("Plugin rejected openchannel2 but"
708 " also set close_to");
709 if (json_get_member(buffer, toks, "psbt"))
710 fatal("Plugin rejected openchannel2 but"
711 " also set `psbt`");
712 if (json_get_member(buffer, toks, "our_funding_msat"))
713 fatal("Plugin rejected openchannel2 but"
714 " also set `our_funding_psbt`");
715
716 const jsmntok_t *t_errmsg = json_get_member(buffer, toks,
717 "error_message");
718
719 if (t_errmsg)
720 payload->err_msg = json_strdup(payload,
721 buffer, t_errmsg);
722 else
723 payload->err_msg = "";
724
725 openchannel2_hook_cb(payload);
726 return false;
727 } else if (!json_tok_streq(buffer, t_result, "continue"))
728 fatal("Plugin returned an invalid response to the"
729 " openchannel2 hook: %.*s",
730 json_tok_full_len(toks),
731 json_tok_full(buffer, toks));
732
733 if (!hook_extract_psbt(payload, dualopend, buffer, toks,
734 "openchannel2", true, &payload->psbt))
735 return false;
736
737 shutdown_script =
738 hook_extract_shutdown_script(dualopend, buffer, toks);
739 if (shutdown_script && payload->our_shutdown_scriptpubkey)

Callers

nothing calls this directly

Calls 15

openchannel2_hook_cbFunction · 0.85
hook_extract_psbtFunction · 0.85
tal_freeFunction · 0.85
psbt_add_serialsFunction · 0.85
psbt_has_required_fieldsFunction · 0.85
hook_extract_amountFunction · 0.85
amount_sat_zeroFunction · 0.85
fatalFunction · 0.70
json_get_memberFunction · 0.50

Tested by

no test coverage detected