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

Function openchannel2_hook_deserialize

lightningd/dual_open_control.c:719–850  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

717
718
719static bool
720openchannel2_hook_deserialize(struct openchannel2_payload *payload,
721 const char *buffer,
722 const jsmntok_t *toks)
723{
724 const u8 *shutdown_script;
725 const char *err;
726 struct subd *dualopend = payload->dualopend;
727
728 /* If our daemon died, we're done */
729 if (!dualopend) {
730 openchannel2_hook_cb(payload);
731 return false;
732 }
733
734 const jsmntok_t *t_result = json_get_member(buffer, toks, "result");
735 if (!t_result)
736 fatal("Plugin returned an invalid response to the"
737 " openchannel2 hook: %.*s",
738 json_tok_full_len(toks),
739 json_tok_full(buffer, toks));
740
741 if (json_tok_streq(buffer, t_result, "reject")) {
742 /* Should not have set any other fields if 'reject'ing */
743 if (json_get_member(buffer, toks, "close_to"))
744 fatal("Plugin rejected openchannel2 but"
745 " also set close_to");
746 if (json_get_member(buffer, toks, "psbt"))
747 fatal("Plugin rejected openchannel2 but"
748 " also set `psbt`");
749 if (json_get_member(buffer, toks, "our_funding_msat"))
750 fatal("Plugin rejected openchannel2 but"
751 " also set `our_funding_psbt`");
752
753 const jsmntok_t *t_errmsg = json_get_member(buffer, toks,
754 "error_message");
755
756 if (t_errmsg)
757 payload->err_msg = json_strdup(payload,
758 buffer, t_errmsg);
759 else
760 payload->err_msg = "";
761
762 openchannel2_hook_cb(payload);
763 return false;
764 } else if (!json_tok_streq(buffer, t_result, "continue"))
765 fatal("Plugin returned an invalid response to the"
766 " openchannel2 hook: %.*s",
767 json_tok_full_len(toks),
768 json_tok_full(buffer, toks));
769
770 if (!hook_extract_psbt(payload, dualopend, buffer, toks,
771 "openchannel2", true, &payload->psbt))
772 return false;
773
774 shutdown_script =
775 hook_extract_shutdown_script(dualopend, buffer, toks);
776 if (shutdown_script && payload->our_shutdown_scriptpubkey)

Callers

nothing calls this directly

Calls 15

openchannel2_hook_cbFunction · 0.85
json_get_memberFunction · 0.85
json_tok_streqFunction · 0.85
hook_extract_psbtFunction · 0.85
tal_freeFunction · 0.85
psbt_add_serialsFunction · 0.85
psbt_has_required_fieldsFunction · 0.85
fmt_wally_psbtFunction · 0.85
hook_extract_amountFunction · 0.85

Tested by

no test coverage detected