2021-01-07 19:35:47 +01:00
|
|
|
#ifndef LIGHTNING_PLUGINS_OFFERS_H
|
|
|
|
#define LIGHTNING_PLUGINS_OFFERS_H
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
struct command_result;
|
|
|
|
struct command;
|
2024-07-17 05:23:24 +02:00
|
|
|
struct onion_message;
|
2024-07-17 05:23:00 +02:00
|
|
|
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;
|
2024-07-17 05:23:25 +02:00
|
|
|
/* Basis for invoice path_secrets */
|
2024-07-17 05:23:00 +02:00
|
|
|
extern struct secret invoicesecret_base;
|
2024-07-17 05:23:25 +02:00
|
|
|
/* Base for offers path_secrets */
|
|
|
|
extern struct secret offerblinding_base;
|
2024-08-01 02:03:36 +02:00
|
|
|
/* Base for node aliases for invoice requests */
|
|
|
|
extern struct secret nodealias_base;
|
2024-07-17 11:06:11 +02:00
|
|
|
/* --dev-invoice-bpath-scid */
|
|
|
|
extern bool dev_invoice_bpath_scid;
|
2024-07-17 11:07:11 +02:00
|
|
|
/* --dev-invoice-internal-scid */
|
|
|
|
extern struct short_channel_id *dev_invoice_internal_scid;
|
2024-07-17 05:23:25 +02:00
|
|
|
/* This is me. */
|
|
|
|
extern struct pubkey id;
|
2021-01-07 19:35:47 +01:00
|
|
|
|
2024-07-17 05:23:24 +02:00
|
|
|
/* Helper to send a reply (connecting if required), and discard result */
|
2021-01-07 19:35:47 +01:00
|
|
|
struct command_result *WARN_UNUSED_RESULT
|
|
|
|
send_onion_reply(struct command *cmd,
|
2022-10-17 02:44:39 +02:00
|
|
|
struct blinded_path *reply_path,
|
|
|
|
struct tlv_onionmsg_tlv *payload);
|
2024-07-17 05:23:00 +02:00
|
|
|
|
2024-07-17 05:23:24 +02:00
|
|
|
/* Helper to send an onion message */
|
|
|
|
#define inject_onionmessage(cmd, omsg, success, fail, arg) \
|
|
|
|
inject_onionmessage_((cmd), (omsg), \
|
|
|
|
typesafe_cb_preargs(struct command_result *, void *, \
|
|
|
|
(success), (arg), \
|
|
|
|
struct command *, \
|
|
|
|
const char *, \
|
2024-11-07 02:27:37 +01:00
|
|
|
const char *, \
|
2024-07-17 05:23:24 +02:00
|
|
|
const jsmntok_t *), \
|
|
|
|
typesafe_cb_preargs(struct command_result *, void *, \
|
|
|
|
(fail), (arg), \
|
|
|
|
struct command *, \
|
|
|
|
const char *, \
|
2024-11-07 02:27:37 +01:00
|
|
|
const char *, \
|
2024-07-17 05:23:24 +02:00
|
|
|
const jsmntok_t *), \
|
|
|
|
(arg))
|
|
|
|
|
|
|
|
struct command_result *
|
|
|
|
inject_onionmessage_(struct command *cmd,
|
|
|
|
const struct onion_message *omsg,
|
|
|
|
struct command_result *(*cb)(struct command *command,
|
2024-11-07 02:27:37 +01:00
|
|
|
const char *method,
|
2024-07-17 05:23:24 +02:00
|
|
|
const char *buf,
|
|
|
|
const jsmntok_t *result,
|
|
|
|
void *arg),
|
|
|
|
struct command_result *(*errcb)(struct command *command,
|
2024-11-07 02:27:37 +01:00
|
|
|
const char *method,
|
2024-07-17 05:23:24 +02:00
|
|
|
const char *buf,
|
|
|
|
const jsmntok_t *result,
|
|
|
|
void *arg),
|
|
|
|
void *arg);
|
|
|
|
|
2024-07-17 05:23:00 +02:00
|
|
|
/* Get the (latest) gossmap */
|
|
|
|
struct gossmap *get_gossmap(struct plugin *plugin);
|
2024-07-17 11:02:11 +02:00
|
|
|
|
|
|
|
/* Get the best (private) channel */
|
|
|
|
struct chaninfo {
|
|
|
|
struct pubkey id;
|
|
|
|
struct amount_msat capacity, htlc_min, htlc_max;
|
|
|
|
u32 feebase, feeppm, cltv;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Calls listpeerchannels, then cb with best peer (if any!) which has needed_feature */
|
|
|
|
struct command_result *find_best_peer_(struct command *cmd,
|
|
|
|
int needed_feature,
|
|
|
|
struct command_result *(*cb)(struct command *,
|
|
|
|
const struct chaninfo *,
|
|
|
|
void *),
|
|
|
|
void *arg);
|
|
|
|
|
|
|
|
#define find_best_peer(cmd, needed_feature, cb, arg) \
|
|
|
|
find_best_peer_((cmd), (needed_feature), \
|
|
|
|
typesafe_cb_preargs(struct command_result *, void *, \
|
|
|
|
(cb), (arg), \
|
|
|
|
struct command *, \
|
|
|
|
const struct chaninfo *), \
|
|
|
|
(arg))
|
|
|
|
|
2021-01-07 19:35:47 +01:00
|
|
|
#endif /* LIGHTNING_PLUGINS_OFFERS_H */
|