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

Function openchannel2_signed_deserialize

lightningd/dual_open_control.c:876–917  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

874}
875
876static bool
877openchannel2_signed_deserialize(struct openchannel2_psbt_payload *payload,
878 const char *buffer, const jsmntok_t *toks)
879{
880 struct subd *dualopend = payload->dualopend;
881 struct wally_psbt *psbt;
882
883 if (!hook_extract_psbt(NULL, dualopend, buffer,
884 toks, "openchannel2_sign",
885 false, &psbt))
886 return false;
887
888 /* We require the PSBT to meet certain criteria such as
889 * extra, proprietary fields (`serial_id`s) or
890 * to have a `redeemscripts` iff the inputs are P2SH.
891 *
892 * Since this is externally provided, we confirm that
893 * they've done the right thing / haven't lost any required info.
894 */
895 if (!psbt_has_required_fields(psbt))
896 fatal("Plugin supplied PSBT that's missing required fields. %s",
897 type_to_string(tmpctx, struct wally_psbt, psbt));
898
899 /* Verify that inputs/outputs are the same. Note that this is a
900 * 'de minimus' check -- we just look at serial_ids. If you've
901 * totally managled the data here but left the serial_ids intact,
902 * you'll get a failure back from the peer when you send
903 * commitment sigs */
904 if (psbt_contribs_changed(payload->psbt, psbt))
905 fatal("Plugin must not change psbt input/output set. "
906 "orig: %s. updated: %s",
907 type_to_string(tmpctx, struct wally_psbt,
908 payload->psbt),
909 type_to_string(tmpctx, struct wally_psbt,
910 psbt));
911
912 if (payload->psbt)
913 tal_free(payload->psbt);
914
915 payload->psbt = tal_steal(payload, psbt);
916 return true;
917}
918
919static void
920openchannel2_sign_hook_cb(struct openchannel2_psbt_payload *payload STEALS)

Callers

nothing calls this directly

Calls 6

hook_extract_psbtFunction · 0.85
psbt_has_required_fieldsFunction · 0.85
psbt_contribs_changedFunction · 0.85
tal_freeFunction · 0.85
fatalFunction · 0.70
type_to_stringClass · 0.50

Tested by

no test coverage detected