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

Function recurrence_invreq_metadata

plugins/fetchinvoice.c:857–879  ·  view source on GitHub ↗

BOLT #12: * - MUST set `invreq_metadata` to an unpredictable series of bytes. */ Derive metadata (and thus temp key) from offer data and label * as payer_id must be same for all recurring payments. */

Source from the content-addressed store, hash-verified

855/* Derive metadata (and thus temp key) from offer data and label
856 * as payer_id must be same for all recurring payments. */
857static u8 *recurrence_invreq_metadata(const tal_t *ctx,
858 const struct tlv_invoice_request *invreq,
859 const struct secret *nodealias_base,
860 const char *rec_label)
861{
862 struct sha256 offer_id, tweak;
863 u8 *tweak_input;
864
865 /* Use "offer_id || label" as tweak input */
866 invreq_offer_id(invreq, &offer_id);
867 tweak_input = tal_arr(tmpctx, u8,
868 sizeof(offer_id) + strlen(rec_label));
869 memcpy(tweak_input, &offer_id, sizeof(offer_id));
870 memcpy(tweak_input + sizeof(offer_id),
871 rec_label,
872 strlen(rec_label));
873
874 bolt12_alias_tweak(nodealias_base,
875 tweak_input,
876 tal_bytelen(tweak_input),
877 &tweak);
878 return (u8 *)tal_dup(invreq, struct sha256, &tweak);
879}
880
881static struct command_result *param_bip353(struct command *cmd, const char *name,
882 const char *buffer, const jsmntok_t *tok,

Callers 2

json_fetchinvoiceFunction · 0.85

Calls 3

invreq_offer_idFunction · 0.85
bolt12_alias_tweakFunction · 0.85
tal_bytelenFunction · 0.85

Tested by

no test coverage detected