Skip to content

Commit

Permalink
add unified-invoices config option and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguida committed Jul 19, 2023
1 parent 19d80e1 commit 13b5b8d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions contrib/startup_regtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ start_nodes() {
funder-fuzz-percent=0
lease-fee-base-sat=2sat
lease-fee-basis=50
unified-invoices
EOF
fi

Expand Down
28 changes: 22 additions & 6 deletions lightningd/invoice.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,8 @@ add_routehints(struct invoice_info *info,
bool *warning_capacity,
bool *warning_deadends,
bool *warning_offline,
bool *warning_private_unused)
bool *warning_private_unused,
bool *warning_fallbacks)
{
const struct chanhints *chanhints = info->chanhints;
bool node_unpublished;
Expand Down Expand Up @@ -797,6 +798,7 @@ add_routehints(struct invoice_info *info,
*warning_offline = false;
*warning_deadends = false;
*warning_private_unused = false;
*warning_fallbacks = info->cmd->ld->unified_invoices && info->b11->fallbacks;
if (amount_msat_greater(needed, avail_capacity)) {
struct amount_msat tot;

Expand Down Expand Up @@ -836,7 +838,8 @@ invoice_complete(struct invoice_info *info,
bool warning_capacity,
bool warning_deadends,
bool warning_offline,
bool warning_private_unused)
bool warning_private_unused,
bool warning_fallbacks)
{
struct json_stream *response;
u64 inv_dbid;
Expand Down Expand Up @@ -907,6 +910,10 @@ invoice_complete(struct invoice_info *info,
json_add_string(response, "warning_private_unused",
"Insufficient incoming capacity, once private channels were excluded (try exposeprivatechannels=true?)");

if (warning_fallbacks)
json_add_string(response, "warning_fallbacks",
"Not tracking on-chain payments for custom fallback addresses");

return command_success(info->cmd, response);
}

Expand All @@ -918,14 +925,15 @@ static void listincoming_done(const char *buffer,
{
struct lightningd *ld = info->cmd->ld;
struct command_result *ret;
bool warning_mpp, warning_capacity, warning_deadends, warning_offline, warning_private_unused;
bool warning_mpp, warning_capacity, warning_deadends, warning_offline, warning_private_unused, warning_fallbacks;

ret = add_routehints(info, buffer, toks,
&warning_mpp,
&warning_capacity,
&warning_deadends,
&warning_offline,
&warning_private_unused);
&warning_private_unused,
&warning_fallbacks);
if (ret)
return;

Expand All @@ -937,7 +945,8 @@ static void listincoming_done(const char *buffer,
warning_capacity,
warning_deadends,
warning_offline,
warning_private_unused);
warning_private_unused,
warning_fallbacks);
db_commit_transaction(ld->wallet->db);
}

Expand Down Expand Up @@ -1110,6 +1119,7 @@ static struct command_result *json_invoice(struct command *cmd,
p_opt_def("cltv", param_number, &cltv,
cmd->ld->config.cltv_final),
p_opt_def("deschashonly", param_bool, &hashonly, false),
// p_opt_def("unified_invoices", param_bool, &hashonly, cmd->ld->unified_invoices),
#if DEVELOPER
p_opt("dev-routes", param_array, &routes),
#endif
Expand All @@ -1131,6 +1141,12 @@ static struct command_result *json_invoice(struct command *cmd,
}

if (fallbacks) {
if (cmd->ld->unified_invoices) {
log_info(cmd->ld->log,
"WARNING: Not tracking on-chain payments "
"for custom fallback addresses"
);
}
size_t i;
const jsmntok_t *t;

Expand Down Expand Up @@ -1193,7 +1209,7 @@ static struct command_result *json_invoice(struct command *cmd,
plugin = find_plugin_for_command(cmd->ld, "listincoming");
if (!plugin) {
return invoice_complete(info, true,
false, false, false, false, false);
false, false, false, false, false, false);
}

req = jsonrpc_request_start(info, "listincoming",
Expand Down
3 changes: 3 additions & 0 deletions lightningd/lightningd.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ struct lightningd {
/* --experimental-upgrade-protocol */
bool experimental_upgrade_protocol;

/* --unified-invoices */
bool unified_invoices;

/* For anchors: how much do we keep for spending close txs? */
struct amount_sat emergency_sat;
};
Expand Down
3 changes: 3 additions & 0 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,9 @@ static void register_opts(struct lightningd *ld)
opt_register_noarg("--experimental-upgrade-protocol",
opt_set_bool, &ld->experimental_upgrade_protocol,
"experimental: allow channel types to be upgraded on reconnect");
opt_register_noarg("--unified-invoices",
opt_set_bool, &ld->unified_invoices,
"emit unified invoices and mark them as paid if payment is received on-chain");
clnopt_witharg("--database-upgrade", OPT_SHOWBOOL,
opt_set_db_upgrade, NULL,
ld,
Expand Down

0 comments on commit 13b5b8d

Please sign in to comment.