offers: encapsulate globals in plugin_get_data()
What changed, and why it matters
This commit is a straightforward internal code cleanup in the Core Lightning 'offers' plugin. It moves several global variables into a single per-plugin data structure and provides a helper function to access them. There is no change to user-facing behavior, no bug fix, and no security-related change described in the commit or diff.
No security action required. Treat as normal refactoring/technical-debt cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors the offers plugin to use plugin_get_data() for storing plugin state (node ID, configuration flags, secret bases, gossmap pointer) instead of file-scope global variables. It introduces struct offers_data in offers.h, adds get_offers_data(), and updates all call sites in fetchinvoice.c, offers.c, offers_inv_hook.c, offers_invreq_hook.c, and offers_offer.c to retrieve state via the helper. A test stub for plugin_get_data_ is also added. The change is purely structural and does not alter logic, parsing, cryptography, or access control.
Changed components
plugins/offers.cplugins/offers.hplugins/fetchinvoice.cplugins/offers_inv_hook.cplugins/offers_invreq_hook.cplugins/offers_offer.cplugins/test/run-decode_guess_type.cInspect captured patch +120 / −85
diff --git a/plugins/fetchinvoice.c b/plugins/fetchinvoice.c
index 7a71eb44..848f3504 100644
--- a/plugins/fetchinvoice.c
+++ b/plugins/fetchinvoice.c
@@ -585,6 +585,7 @@ static struct command_result *establish_path_fail(struct command *cmd,
static struct command_result *try_establish(struct command *cmd,
struct establishing_paths *epaths)
{
+ const struct offers_data *od = get_offers_data(cmd->plugin);
struct pubkey target;
if (epaths->sent->direct_dest) {
@@ -605,8 +606,8 @@ static struct command_result *try_establish(struct command *cmd,
epaths->sent->issuer_key = &bpath->path[tal_count(bpath->path)-1]->blinded_node_id;
}
- return establish_onion_path(cmd, get_gossmap(cmd->plugin), &id, &target,
- disable_connect,
+ return establish_onion_path(cmd, get_gossmap(cmd->plugin), &od->id, &target,
+ od->disable_connect,
establish_path_done,
establish_path_fail,
epaths);
@@ -815,15 +816,16 @@ static struct command_result *param_dev_reply_path(struct command *cmd, const ch
return NULL;
}
-static bool payer_key(const u8 *public_tweak, size_t public_tweak_len,
+static bool payer_key(const struct offers_data *od,
+ const u8 *public_tweak, size_t public_tweak_len,
struct pubkey *key)
{
struct sha256 tweakhash;
- bolt12_alias_tweak(&nodealias_base, public_tweak, public_tweak_len,
+ bolt12_alias_tweak(&od->nodealias_base, public_tweak, public_tweak_len,
&tweakhash);
- *key = id;
+ *key = od->id;
return secp256k1_ec_pubkey_tweak_add(secp256k1_ctx,
&key->pubkey,
tweakhash.u.u8) == 1;
@@ -836,6 +838,7 @@ static bool payer_key(const u8 *public_tweak, size_t public_tweak_len,
* as payer_id must be same for all recurring payments. */
static u8 *recurrence_invreq_metadata(const tal_t *ctx,
const struct tlv_invoice_request *invreq,
+ const struct secret *nodealias_base,
const char *rec_label)
{
struct sha256 offer_id, tweak;
@@ -850,7 +853,7 @@ static u8 *recurrence_invreq_metadata(const tal_t *ctx,
rec_label,
strlen(rec_label));
- bolt12_alias_tweak(&nodealias_base,
+ bolt12_alias_tweak(nodealias_base,
tweak_input,
tal_bytelen(tweak_input),
&tweak);
@@ -897,6 +900,7 @@ struct command_result *json_fetchinvoice(struct command *cmd,
const char *buffer,
const jsmntok_t *params)
{
+ const struct offers_data *od = get_offers_data(cmd->plugin);
struct amount_msat *msat;
const char *rec_label, *payer_note;
u8 *payer_metadata;
@@ -1054,7 +1058,9 @@ struct command_result *json_fetchinvoice(struct command *cmd,
"needs recurrence_label");
invreq->invreq_metadata
- = recurrence_invreq_metadata(invreq, invreq, rec_label);
+ = recurrence_invreq_metadata(invreq, invreq,
+ &od->nodealias_base,
+ rec_label);
} else {
/* BOLT-recurrence #12:
* - otherwise:
@@ -1088,7 +1094,7 @@ struct command_result *json_fetchinvoice(struct command *cmd,
/* We derive transient payer_id from invreq_metadata */
invreq->invreq_payer_id = tal(invreq, struct pubkey);
- if (!payer_key(invreq->invreq_metadata,
+ if (!payer_key(od, invreq->invreq_metadata,
tal_bytelen(invreq->invreq_metadata),
invreq->invreq_payer_id)) {
/* Doesn't happen! */
@@ -1146,6 +1152,7 @@ struct command_result *json_cancelrecurringinvoice(struct command *cmd,
const char *buffer,
const jsmntok_t *params)
{
+ const struct offers_data *od = get_offers_data(cmd->plugin);
const char *rec_label, *payer_note;
struct out_req *req;
struct tlv_invoice_request *invreq;
@@ -1220,11 +1227,13 @@ struct command_result *json_cancelrecurringinvoice(struct command *cmd,
}
invreq->invreq_metadata
- = recurrence_invreq_metadata(invreq, invreq, rec_label);
+ = recurrence_invreq_metadata(invreq, invreq,
+ &od->nodealias_base,
+ rec_label);
/* We derive transient payer_id from invreq_metadata */
invreq->invreq_payer_id = tal(invreq, struct pubkey);
- if (!payer_key(invreq->invreq_metadata,
+ if (!payer_key(od, invreq->invreq_metadata,
tal_bytelen(invreq->invreq_metadata),
invreq->invreq_payer_id)) {
/* Doesn't happen! */
@@ -1530,6 +1539,7 @@ struct command_result *json_sendinvoice(struct command *cmd,
const char *buffer,
const jsmntok_t *params)
{
+ const struct offers_data *od = get_offers_data(cmd->plugin);
struct amount_msat *msat;
u32 *timeout;
struct sent *sent = tal(cmd, struct sent);
@@ -1602,7 +1612,7 @@ struct command_result *json_sendinvoice(struct command *cmd,
* - MUST set `invoice_node_id` to the final `blinded_node_id` on the path it received the invoice request
*/
sent->inv->invoice_node_id = tal(sent->inv, struct pubkey);
- sent->inv->invoice_node_id->pubkey = id.pubkey;
+ sent->inv->invoice_node_id->pubkey = od->id.pubkey;
/* BOLT #12:
* - if the expiry for accepting payment is not 7200 seconds
diff --git a/plugins/offers.c b/plugins/offers.c
index 8e847ab5..26686920 100644
--- a/plugins/offers.c
+++ b/plugins/offers.c
@@ -32,36 +32,31 @@
#define HEADER_LEN crypto_secretstream_xchacha20poly1305_HEADERBYTES
#define ABYTES crypto_secretstream_xchacha20poly1305_ABYTES
-struct pubkey id;
-u32 blockheight;
-u16 cltv_final;
-bool disable_connect;
-bool dev_invoice_bpath_scid;
-struct short_channel_id *dev_invoice_internal_scid;
-struct secret invoicesecret_base;
-struct secret offerblinding_base;
-struct secret nodealias_base;
-static struct gossmap *global_gossmap;
-
-static void init_gossmap(struct plugin *plugin)
+struct offers_data *get_offers_data(struct plugin *plugin)
{
- global_gossmap
- = notleak_with_children(gossmap_load(plugin,
- GOSSIP_STORE_FILENAME,
- plugin_gossmap_logcb,
- plugin));
- if (!global_gossmap)
+ return plugin_get_data(plugin, struct offers_data);
+}
+
+static void init_gossmap(struct plugin *plugin,
+ struct offers_data *od)
+{
+ od->global_gossmap_ = gossmap_load(plugin,
+ GOSSIP_STORE_FILENAME,
+ plugin_gossmap_logcb,
+ plugin);
+ if (!od->global_gossmap_)
plugin_err(plugin, "Could not load gossmap %s: %s",
GOSSIP_STORE_FILENAME, strerror(errno));
}
struct gossmap *get_gossmap(struct plugin *plugin)
{
- if (!global_gossmap)
- init_gossmap(plugin);
+ struct offers_data *od = get_offers_data(plugin);
+ if (!od->global_gossmap_)
+ init_gossmap(plugin, od);
else
- gossmap_refresh(global_gossmap);
- return global_gossmap;
+ gossmap_refresh(od->global_gossmap_);
+ return od->global_gossmap_;
}
/* BOLT #12:
@@ -71,6 +66,7 @@ struct gossmap *get_gossmap(struct plugin *plugin)
*/
bool we_want_blinded_path(struct plugin *plugin, bool for_payment)
{
+ const struct offers_data *od = get_offers_data(plugin);
struct node_id local_nodeid;
const struct gossmap_node *node;
const u8 *nannounce;
@@ -82,7 +78,7 @@ bool we_want_blinded_path(struct plugin *plugin, bool for_payment)
u8 rgb_color[3], alias[32];
struct tlv_node_ann_tlvs *na_tlvs;
- node_id_from_pubkey(&local_nodeid, &id);
+ node_id_from_pubkey(&local_nodeid, &od->id);
node = gossmap_find_node(gossmap, &local_nodeid);
if (!node)
@@ -237,6 +233,7 @@ send_onion_reply(struct command *cmd,
struct blinded_path *reply_path,
struct tlv_onionmsg_tlv *payload)
{
+ const struct offers_data *od = get_offers_data(cmd->plugin);
struct onion_reply *onion_reply;
onion_reply = tal(cmd, struct onion_reply);
@@ -253,8 +250,8 @@ send_onion_reply(struct command *cmd,
}
return establish_onion_path(cmd, get_gossmap(cmd->plugin),
- &id, &onion_reply->reply_path->first_node_id.pubkey,
- disable_connect,
+ &od->id, &onion_reply->reply_path->first_node_id.pubkey,
+ od->disable_connect,
send_onion_reply_after_established,
send_onion_reply_not_established,
onion_reply);
@@ -433,8 +430,9 @@ static struct command_result *block_added_notify(struct command *cmd,
const char *buf,
const jsmntok_t *params)
{
+ struct offers_data *od = get_offers_data(cmd->plugin);
const char *err = json_scan(cmd, buf, params, "{block_added:{height:%}}",
- JSON_SCAN(json_to_u32, &blockheight));
+ JSON_SCAN(json_to_u32, &od->blockheight));
if (err)
plugin_err(cmd->plugin, "Failed to parse block_added (%.*s): %s",
json_tok_full_len(params),
@@ -1620,34 +1618,36 @@ static const char *init(struct command *init_cmd,
const char *buf UNUSED,
const jsmntok_t *config UNUSED)
{
+ struct offers_data *od = get_offers_data(init_cmd->plugin);
+
rpc_scan(init_cmd, "getinfo",
take(json_out_obj(NULL, NULL, NULL)),
- "{id:%}", JSON_SCAN(json_to_pubkey, &id));
+ "{id:%}", JSON_SCAN(json_to_pubkey, &od->id));
rpc_scan(init_cmd, "getchaininfo",
take(json_out_obj(NULL, "last_height", NULL)),
- "{headercount:%}", JSON_SCAN(json_to_u32, &blockheight));
+ "{headercount:%}", JSON_SCAN(json_to_u32, &od->blockheight));
rpc_scan(init_cmd, "listconfigs",
take(json_out_obj(NULL, NULL, NULL)),
"{configs:"
"{cltv-final:{value_int:%}}}",
- JSON_SCAN(json_to_u16, &cltv_final));
+ JSON_SCAN(json_to_u16, &od->cltv_final));
rpc_scan(init_cmd, "makesecret",
take(json_out_obj(NULL, "string", BOLT12_ID_BASE_STRING)),
"{secret:%}",
- JSON_SCAN(json_to_secret, &invoicesecret_base));
+ JSON_SCAN(json_to_secret, &od->invoicesecret_base));
rpc_scan(init_cmd, "makesecret",
take(json_out_obj(NULL, "string", "offer-blinded-path")),
"{secret:%}",
- JSON_SCAN(json_to_secret, &offerblinding_base));
+ JSON_SCAN(json_to_secret, &od->offerblinding_base));
rpc_scan(init_cmd, "makesecret",
take(json_out_obj(NULL, "string", NODE_ALIAS_BASE_STRING)),
"{secret:%}",
- JSON_SCAN(json_to_secret, &nodealias_base));
+ JSON_SCAN(json_to_secret, &od->nodealias_base));
return NULL;
}
@@ -1708,22 +1708,28 @@ static bool scid_jsonfmt(struct plugin *plugin, struct json_stream *js, const ch
int main(int argc, char *argv[])
{
setup_locale();
+ struct offers_data *od = tal(NULL, struct offers_data);
+
+ od->disable_connect = false;
+ od->dev_invoice_bpath_scid = false;
+ od->dev_invoice_internal_scid = NULL;
+ od->global_gossmap_ = NULL;
/* We deal in UTC; mktime() uses local time */
setenv("TZ", "", 1);
- plugin_main(argv, init, NULL, PLUGIN_RESTARTABLE, true, NULL,
+ plugin_main(argv, init, take(od), PLUGIN_RESTARTABLE, true, NULL,
commands, ARRAY_SIZE(commands),
notifications, ARRAY_SIZE(notifications),
hooks, ARRAY_SIZE(hooks),
NULL, 0,
plugin_option("fetchinvoice-noconnect", "flag",
"Don't try to connect directly to fetch/pay an invoice.",
- flag_option, flag_jsonfmt, &disable_connect),
+ flag_option, flag_jsonfmt, &od->disable_connect),
plugin_option_dev("dev-invoice-bpath-scid", "flag",
"Use short_channel_id instead of pubkey when creating a blinded payment path",
- flag_option, flag_jsonfmt, &dev_invoice_bpath_scid),
+ flag_option, flag_jsonfmt, &od->dev_invoice_bpath_scid),
plugin_option_dev("dev-invoice-internal-scid", "string",
"Use short_channel_id instead of pubkey when creating a blinded payment path",
- scid_option, scid_jsonfmt, &dev_invoice_internal_scid),
+ scid_option, scid_jsonfmt, &od->dev_invoice_internal_scid),
NULL);
}
diff --git a/plugins/offers.h b/plugins/offers.h
index b7be946f..fef29c60 100644
--- a/plugins/offers.h
+++ b/plugins/offers.h
@@ -7,26 +7,31 @@ struct command;
struct onion_message;
struct plugin;
-/* This is me. */
-extern struct pubkey id;
-/* --fetchinvoice-noconnect */
-extern bool disable_connect;
-/* --cltv-final */
-extern u16 cltv_final;
-/* Current header_count */
-extern u32 blockheight;
-/* Basis for invoice path_secrets */
-extern struct secret invoicesecret_base;
-/* Base for offers path_secrets */
-extern struct secret offerblinding_base;
-/* Base for node aliases for invoice requests */
-extern struct secret nodealias_base;
-/* --dev-invoice-bpath-scid */
-extern bool dev_invoice_bpath_scid;
-/* --dev-invoice-internal-scid */
-extern struct short_channel_id *dev_invoice_internal_scid;
-/* This is me. */
-extern struct pubkey id;
+/* plugin_data for this plugin */
+struct offers_data {
+ /* This is me. */
+ struct pubkey id;
+ /* --fetchinvoice-noconnect */
+ bool disable_connect;
+ /* --cltv-final */
+ u16 cltv_final;
+ /* Current header_count */
+ u32 blockheight;
+ /* Basis for invoice path_secrets */
+ struct secret invoicesecret_base;
+ /* Base for offers path_secrets */
+ struct secret offerblinding_base;
+ /* Base for node aliases for invoice requests */
+ struct secret nodealias_base;
+ /* --dev-invoice-bpath-scid */
+ bool dev_invoice_bpath_scid;
+ /* --dev-invoice-internal-scid */
+ struct short_channel_id *dev_invoice_internal_scid;
+ /* Use get_gossmap() to access this! */
+ struct gossmap *global_gossmap_;
+};
+
+struct offers_data *get_offers_data(struct plugin *plugin);
/* Helper to send a reply (connecting if required), and discard result */
struct command_result *WARN_UNUSED_RESULT
diff --git a/plugins/offers_inv_hook.c b/plugins/offers_inv_hook.c
index b1f859d4..9de434c8 100644
--- a/plugins/offers_inv_hook.c
+++ b/plugins/offers_inv_hook.c
@@ -218,6 +218,7 @@ struct command_result *handle_invoice(struct command *cmd,
struct blinded_path *reply_path STEALS,
const struct secret *secret)
{
+ const struct offers_data *od = get_offers_data(cmd->plugin);
size_t len = tal_count(invbin);
struct inv *inv = tal(cmd, struct inv);
struct out_req *req;
@@ -243,7 +244,7 @@ struct command_result *handle_invoice(struct command *cmd,
invoice_invreq_id(inv->inv, &invreq_id_nopath);
inv->inv->invreq_paths = invreq_paths;
- path_secret = bolt12_path_id(tmpctx, &offerblinding_base, &invreq_id_nopath);
+ path_secret = bolt12_path_id(tmpctx, &od->offerblinding_base, &invreq_id_nopath);
if (!memeq(path_secret, tal_count(path_secret),
secret, sizeof(*secret))) {
if (command_dev_apis(cmd))
diff --git a/plugins/offers_invreq_hook.c b/plugins/offers_invreq_hook.c
index 8588ed25..3e6b0338 100644
--- a/plugins/offers_invreq_hook.c
+++ b/plugins/offers_invreq_hook.c
@@ -260,6 +260,8 @@ static struct command_result *found_best_peer(struct command *cmd,
const struct chaninfo *best,
struct invreq *ir)
{
+ struct offers_data *od = get_offers_data(cmd->plugin);
+
/* BOLT #12:
* - MUST include `invoice_paths` containing one or more paths to the node.
* - MUST specify `invoice_paths` in order of most-preferred to
@@ -282,11 +284,11 @@ static struct command_result *found_best_peer(struct command *cmd,
/* Make a small 1-hop path to us */
ids = tal_arr(tmpctx, struct pubkey, 2);
ids[0] = best->id;
- ids[1] = id;
+ ids[1] = od->id;
/* This does nothing unless dev_invoice_internal_scid is set */
scids = tal_arrz(tmpctx, struct short_channel_id *, 2);
- scids[1] = dev_invoice_internal_scid;
+ scids[1] = od->dev_invoice_internal_scid;
/* Make basic tlvs, add payment restrictions */
etlvs = new_encdata_tlvs(tmpctx, ids,
@@ -306,9 +308,9 @@ static struct command_result *found_best_peer(struct command *cmd,
* - MUST set `invoice_relative_expiry`
*/
if (ir->inv->invoice_relative_expiry)
- base = blockheight + *ir->inv->invoice_relative_expiry / 600;
+ base = od->blockheight + *ir->inv->invoice_relative_expiry / 600;
else
- base = blockheight + 7200 / 600;
+ base = od->blockheight + 7200 / 600;
/* BOLT #4:
* - MUST set `encrypted_data_tlv.payment_constraints`
@@ -326,12 +328,12 @@ static struct command_result *found_best_peer(struct command *cmd,
* payments fail in practice! We add 1008 (half the max possible) */
etlvs[0]->payment_constraints = tal(etlvs[0],
struct tlv_encrypted_data_tlv_payment_constraints);
- etlvs[0]->payment_constraints->max_cltv_expiry = 1008 + base + best->cltv + cltv_final;
+ etlvs[0]->payment_constraints->max_cltv_expiry = 1008 + base + best->cltv + od->cltv_final;
etlvs[0]->payment_constraints->htlc_minimum_msat = best->htlc_min.millisatoshis; /* Raw: tlv */
/* So we recognize this payment */
etlvs[1]->path_id = bolt12_path_id(etlvs[1],
- &invoicesecret_base,
+ &od->invoicesecret_base,
ir->inv->invoice_payment_hash);
ir->inv->invoice_paths = tal_arr(ir->inv, struct blinded_path *, 1);
@@ -342,7 +344,7 @@ static struct command_result *found_best_peer(struct command *cmd,
/* If they tell us to use scidd for first point, grab
* a channel from node (must exist, it's public) */
- if (dev_invoice_bpath_scid) {
+ if (od->dev_invoice_bpath_scid) {
struct gossmap *gossmap = get_gossmap(cmd->plugin);
struct node_id best_nodeid;
const struct gossmap_node *n;
@@ -366,7 +368,7 @@ static struct command_result *found_best_peer(struct command *cmd,
ir->inv->invoice_blindedpay[0] = tal(ir->inv->invoice_blindedpay, struct blinded_payinfo);
ir->inv->invoice_blindedpay[0]->fee_base_msat = best->feebase;
ir->inv->invoice_blindedpay[0]->fee_proportional_millionths = best->feeppm;
- ir->inv->invoice_blindedpay[0]->cltv_expiry_delta = best->cltv + cltv_final;
+ ir->inv->invoice_blindedpay[0]->cltv_expiry_delta = best->cltv + od->cltv_final;
ir->inv->invoice_blindedpay[0]->htlc_minimum_msat = best->htlc_min;
ir->inv->invoice_blindedpay[0]->htlc_maximum_msat = best->htlc_max;
ir->inv->invoice_blindedpay[0]->features = NULL;
@@ -809,6 +811,7 @@ static struct command_result *listoffers_done(struct command *cmd,
const jsmntok_t *result,
struct invreq *ir)
{
+ const struct offers_data *od = get_offers_data(cmd->plugin);
const jsmntok_t *arr = json_get_member(buf, result, "offers");
const jsmntok_t *offertok, *activetok, *b12tok;
bool active;
@@ -851,7 +854,7 @@ static struct command_result *listoffers_done(struct command *cmd,
ir->invreq->offer_paths = NULL;
invreq_offer_id(ir->invreq, &offer_id);
ir->invreq->offer_paths = offer_paths;
- bolt12_path_secret(&offerblinding_base, &offer_id,
+ bolt12_path_secret(&od->offerblinding_base, &offer_id,
&blinding_path_secret);
if (!secret_eq_consttime(ir->secret, &blinding_path_secret)) {
/* You used the wrong blinded path for invreq */
diff --git a/plugins/offers_offer.c b/plugins/offers_offer.c
index 8bad8249..c6c2acbd 100644
--- a/plugins/offers_offer.c
+++ b/plugins/offers_offer.c
@@ -255,6 +255,8 @@ static struct command_result *found_best_peer(struct command *cmd,
const struct chaninfo *best,
struct offer_info *offinfo)
{
+ const struct offers_data *od = get_offers_data(cmd->plugin);
+
/* BOLT #12:
* - if it is connected only by private channels:
* - MUST include `offer_paths` containing one or more paths to the node from
@@ -275,11 +277,11 @@ static struct command_result *found_best_peer(struct command *cmd,
/* Make a small 1-hop path to us */
ids = tal_arr(tmpctx, struct pubkey, 2);
ids[0] = best->id;
- ids[1] = id;
+ ids[1] = od->id;
/* So we recognize this */
/* We can check this when they try to take up offer. */
- bolt12_path_secret(&offerblinding_base, &offer_id,
+ bolt12_path_secret(&od->offerblinding_base, &offer_id,
&blinding_path_secret);
offinfo->offer->offer_paths = tal_arr(offinfo->offer, struct blinded_path *, 1);
@@ -352,6 +354,7 @@ static struct command_result *param_paths(struct command *cmd, const char *name,
{
size_t i;
const jsmntok_t *t;
+ const struct offers_data *od = get_offers_data(cmd->plugin);
if (tok->type != JSMN_ARRAY)
return command_fail_badparam(cmd, name, buffer, tok, "Must be array");
@@ -394,7 +397,7 @@ static struct command_result *param_paths(struct command *cmd, const char *name,
"invalid pubkey");
}
}
- if (j == t->size - 1 && !pubkey_eq(&pk, &id))
+ if (j == t->size - 1 && !pubkey_eq(&pk, &od->id))
return command_fail_badparam(cmd, name, buffer, p,
"final pubkey must be this node");
(*paths)[i]->path[j] = pk;
@@ -407,6 +410,7 @@ struct command_result *json_offer(struct command *cmd,
const char *buffer,
const jsmntok_t *params)
{
+ const struct offers_data *od = get_offers_data(cmd->plugin);
const char *desc, *issuer;
struct tlv_offer *offer;
struct offer_info *offinfo = tal(cmd, struct offer_info);
@@ -527,7 +531,7 @@ struct command_result *json_offer(struct command *cmd,
* - MUST set `offer_issuer_id` to the node's public key to request the
* invoice from.
*/
- offer->offer_issuer_id = tal_dup(offer, struct pubkey, &id);
+ offer->offer_issuer_id = tal_dup(offer, struct pubkey, &od->id);
/* Now rest of offer will not change: we use pathless offer to create secret. */
if (paths) {
@@ -537,7 +541,7 @@ struct command_result *json_offer(struct command *cmd,
offer_offer_id(offer, &offer_id);
/* We can check this when they try to take up offer. */
- bolt12_path_secret(&offerblinding_base, &offer_id,
+ bolt12_path_secret(&od->offerblinding_base, &offer_id,
&blinding_path_secret);
offer->offer_paths = tal_arr(offer, struct blinded_path *, tal_count(paths));
@@ -599,6 +603,8 @@ static struct command_result *found_best_peer_invrequest(struct command *cmd,
const struct chaninfo *best,
struct invrequest_data *irdata)
{
+ const struct offers_data *od = get_offers_data(cmd->plugin);
+
if (!best) {
/* FIXME: Make this a warning in the result! */
plugin_log(cmd->plugin, LOG_UNUSUAL,
@@ -623,11 +629,11 @@ static struct command_result *found_best_peer_invrequest(struct command *cmd,
/* Make a small 1-hop path to us */
ids = tal_arr(tmpctx, struct pubkey, 2);
ids[0] = best->id;
- ids[1] = id;
+ ids[1] = od->id;
/* So we recognize this */
/* We can check this when they try to take up invoice_request. */
- bolt12_path_secret(&offerblinding_base, &invreq_id,
+ bolt12_path_secret(&od->offerblinding_base, &invreq_id,
&blinding_path_secret);
plugin_log(cmd->plugin, LOG_DBG,
@@ -650,6 +656,7 @@ struct command_result *json_invoicerequest(struct command *cmd,
const char *buffer,
const jsmntok_t *params)
{
+ const struct offers_data *od = get_offers_data(cmd->plugin);
const char *desc, *issuer, *label;
struct tlv_invoice_request *invreq;
struct amount_msat *msat;
@@ -715,7 +722,7 @@ struct command_result *json_invoicerequest(struct command *cmd,
* - MUST set `invreq_payer_id` (as it would set `offer_issuer_id` for an offer).
*/
/* FIXME: Allow invoicerequests using aliases! */
- invreq->invreq_payer_id = tal_dup(invreq, struct pubkey, &id);
+ invreq->invreq_payer_id = tal_dup(invreq, struct pubkey, &od->id);
/* BOLT #12:
* - if it supports bolt12 invoice request features:
diff --git a/plugins/test/run-decode_guess_type.c b/plugins/test/run-decode_guess_type.c
index 25000cc4..8b3782a7 100644
--- a/plugins/test/run-decode_guess_type.c
+++ b/plugins/test/run-decode_guess_type.c
@@ -174,6 +174,9 @@ void plugin_err(struct plugin *p UNNEEDED, const char *fmt UNNEEDED, ...)
/* Generated stub for plugin_feature_set */
const struct feature_set *plugin_feature_set(const struct plugin *p UNNEEDED)
{ fprintf(stderr, "plugin_feature_set called!\n"); abort(); }
+/* Generated stub for plugin_get_data_ */
+void *plugin_get_data_(struct plugin *plugin UNNEEDED)
+{ fprintf(stderr, "plugin_get_data_ called!\n"); abort(); }
/* Generated stub for plugin_gossmap_logcb */
void plugin_gossmap_logcb(struct plugin *plugin UNNEEDED,
enum log_level level UNNEEDED,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.