mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-10 17:19:15 +01:00
plugins: remove #if DEVELOPER.
And rename dev-only-option `use_shadow` to `dev_use_shadow`. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ef87999f9a
commit
f725edad62
18 changed files with 78 additions and 182 deletions
|
@ -715,7 +715,7 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||
|
||||
def dev_pay(self, bolt11, amount_msat=None, label=None, riskfactor=None,
|
||||
maxfeepercent=None, retry_for=None,
|
||||
maxdelay=None, exemptfee=None, use_shadow=True, exclude=None):
|
||||
maxdelay=None, exemptfee=None, dev_use_shadow=True, exclude=None):
|
||||
"""
|
||||
A developer version of `pay`, with the possibility to deactivate
|
||||
shadow routing (used for testing).
|
||||
|
@ -729,7 +729,7 @@ class LightningRpc(UnixDomainSocketRpc):
|
|||
"retry_for": retry_for,
|
||||
"maxdelay": maxdelay,
|
||||
"exemptfee": exemptfee,
|
||||
"use_shadow": use_shadow,
|
||||
"dev_use_shadow": dev_use_shadow,
|
||||
"exclude": exclude,
|
||||
}
|
||||
return self.call("pay", payload)
|
||||
|
|
|
@ -1366,14 +1366,14 @@ class LightningNode(object):
|
|||
|
||||
def dev_pay(self, bolt11, amount_msat=None, label=None, riskfactor=None,
|
||||
maxfeepercent=None, retry_for=None,
|
||||
maxdelay=None, exemptfee=None, use_shadow=True, exclude=[]):
|
||||
maxdelay=None, exemptfee=None, dev_use_shadow=True, exclude=[]):
|
||||
"""Wrapper for rpc.dev_pay which suppresses the request schema"""
|
||||
# FIXME? dev options are not in schema
|
||||
old_check = self.rpc.check_request_schemas
|
||||
self.rpc.check_request_schemas = False
|
||||
ret = self.rpc.dev_pay(bolt11, amount_msat, label, riskfactor,
|
||||
maxfeepercent, retry_for,
|
||||
maxdelay, exemptfee, use_shadow, exclude)
|
||||
maxdelay, exemptfee, dev_use_shadow, exclude)
|
||||
self.rpc.check_request_schemas = old_check
|
||||
return ret
|
||||
|
||||
|
|
|
@ -63,10 +63,8 @@ struct bitcoind {
|
|||
/* Whether we fake fees (regtest) */
|
||||
bool fake_fees;
|
||||
|
||||
#if DEVELOPER
|
||||
/* Override in case we're developer mode for testing*/
|
||||
bool no_fake_fees;
|
||||
#endif
|
||||
bool dev_no_fake_fees;
|
||||
};
|
||||
|
||||
static struct bitcoind *bitcoind;
|
||||
|
@ -1012,12 +1010,10 @@ static void wait_and_check_bitcoind(struct plugin *p)
|
|||
tal_free(cmd);
|
||||
}
|
||||
|
||||
#if DEVELOPER
|
||||
static void memleak_mark_bitcoind(struct plugin *p, struct htable *memtable)
|
||||
{
|
||||
memleak_scan_obj(memtable, bitcoind);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char *init(struct plugin *p, const char *buffer UNUSED,
|
||||
const jsmntok_t *config UNUSED)
|
||||
|
@ -1026,13 +1022,11 @@ static const char *init(struct plugin *p, const char *buffer UNUSED,
|
|||
|
||||
/* Usually we fake up fees in regtest */
|
||||
if (streq(chainparams->network_name, "regtest"))
|
||||
bitcoind->fake_fees = IFDEV(!bitcoind->no_fake_fees, true);
|
||||
bitcoind->fake_fees = !bitcoind->dev_no_fake_fees;
|
||||
else
|
||||
bitcoind->fake_fees = false;
|
||||
|
||||
#if DEVELOPER
|
||||
plugin_set_memleak_handler(p, memleak_mark_bitcoind);
|
||||
#endif
|
||||
plugin_log(p, LOG_INFORM,
|
||||
"bitcoin-cli initialized and connected to bitcoind.");
|
||||
|
||||
|
@ -1096,9 +1090,7 @@ static struct bitcoind *new_bitcoind(const tal_t *ctx)
|
|||
bitcoind->rpcpass = NULL;
|
||||
bitcoind->rpcconnect = NULL;
|
||||
bitcoind->rpcport = NULL;
|
||||
#if DEVELOPER
|
||||
bitcoind->no_fake_fees = false;
|
||||
#endif
|
||||
bitcoind->dev_no_fake_fees = false;
|
||||
|
||||
return bitcoind;
|
||||
}
|
||||
|
@ -1142,11 +1134,9 @@ int main(int argc, char *argv[])
|
|||
"how long to keep retrying to contact bitcoind"
|
||||
" before fatally exiting",
|
||||
u64_option, &bitcoind->retry_timeout),
|
||||
#if DEVELOPER
|
||||
plugin_option("dev-no-fake-fees",
|
||||
"bool",
|
||||
"Suppress fee faking for regtest",
|
||||
bool_option, &bitcoind->no_fake_fees),
|
||||
#endif /* DEVELOPER */
|
||||
plugin_option_dev("dev-no-fake-fees",
|
||||
"bool",
|
||||
"Suppress fee faking for regtest",
|
||||
bool_option, &bitcoind->dev_no_fake_fees),
|
||||
NULL);
|
||||
}
|
||||
|
|
|
@ -782,13 +782,11 @@ static struct command_result *json_commando_listrunes(struct command *cmd,
|
|||
return forward_command(cmd, buffer, params, "showrunes");
|
||||
}
|
||||
|
||||
#if DEVELOPER
|
||||
static void memleak_mark_globals(struct plugin *p, struct htable *memtable)
|
||||
{
|
||||
memleak_scan_obj(memtable, outgoing_commands);
|
||||
memleak_scan_obj(memtable, incoming_commands);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char *init(struct plugin *p,
|
||||
const char *buf UNUSED, const jsmntok_t *config UNUSED)
|
||||
|
@ -796,9 +794,7 @@ static const char *init(struct plugin *p,
|
|||
outgoing_commands = tal_arr(p, struct commando *, 0);
|
||||
incoming_commands = tal_arr(p, struct commando *, 0);
|
||||
plugin = p;
|
||||
#if DEVELOPER
|
||||
plugin_set_memleak_handler(p, memleak_mark_globals);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -182,15 +182,13 @@ static struct command_result *handle_invreq_response(struct command *cmd,
|
|||
goto badinv;
|
||||
}
|
||||
|
||||
#if DEVELOPER
|
||||
/* Raw send? Just fwd reply. */
|
||||
if (!sent->offer) {
|
||||
if (plugin_developer_mode(cmd->plugin) && !sent->offer) {
|
||||
out = jsonrpc_stream_success(sent->cmd);
|
||||
json_add_string(out, "invoice", invoice_encode(tmpctx, inv));
|
||||
discard_result(command_finished(sent->cmd, out));
|
||||
return command_hook_success(cmd);
|
||||
}
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
/* BOLT-offers #12:
|
||||
* - if the invoice is a response to an `invoice_request`:
|
||||
|
@ -870,56 +868,6 @@ static struct command_result *invreq_done(struct command *cmd,
|
|||
return sendinvreq_after_connect(cmd, NULL, NULL, sent);
|
||||
}
|
||||
|
||||
/* If they hand us the payer secret, we sign it directly, bypassing checks
|
||||
* about periods etc. */
|
||||
static struct command_result *
|
||||
force_payer_secret(struct command *cmd,
|
||||
struct sent *sent,
|
||||
struct tlv_invoice_request *invreq STEALS,
|
||||
const struct secret *payer_secret)
|
||||
{
|
||||
struct sha256 merkle, sha;
|
||||
secp256k1_keypair kp;
|
||||
|
||||
if (secp256k1_keypair_create(secp256k1_ctx, &kp, payer_secret->data) != 1)
|
||||
return command_fail(cmd, LIGHTNINGD, "Bad payer_secret");
|
||||
|
||||
invreq->invreq_payer_id = tal(invreq, struct pubkey);
|
||||
/* Docs say this only happens if arguments are invalid! */
|
||||
if (secp256k1_keypair_pub(secp256k1_ctx,
|
||||
&invreq->invreq_payer_id->pubkey,
|
||||
&kp) != 1)
|
||||
plugin_err(cmd->plugin,
|
||||
"secp256k1_keypair_pub failed on %s?",
|
||||
type_to_string(tmpctx, struct secret, payer_secret));
|
||||
|
||||
/* Re-calculate ->fields */
|
||||
tal_free(invreq->fields);
|
||||
invreq->fields = tlv_make_fields(invreq, tlv_invoice_request);
|
||||
|
||||
sent->invreq = tal_steal(sent, invreq);
|
||||
merkle_tlv(sent->invreq->fields, &merkle);
|
||||
sighash_from_merkle("invoice_request", "signature", &merkle, &sha);
|
||||
|
||||
sent->invreq->signature = tal(invreq, struct bip340sig);
|
||||
if (!secp256k1_schnorrsig_sign32(secp256k1_ctx,
|
||||
sent->invreq->signature->u8,
|
||||
sha.u.u8,
|
||||
&kp,
|
||||
NULL)) {
|
||||
return command_fail(cmd, LIGHTNINGD,
|
||||
"Failed to sign with payer_secret");
|
||||
}
|
||||
|
||||
sent->path = path_to_node(sent, cmd->plugin,
|
||||
sent->invreq->invreq_payer_id);
|
||||
if (!sent->path)
|
||||
return connect_direct(cmd, sent->invreq->offer_node_id,
|
||||
sendinvreq_after_connect, sent);
|
||||
|
||||
return sendinvreq_after_connect(cmd, NULL, NULL, sent);
|
||||
}
|
||||
|
||||
/* Fetches an invoice for this offer, and makes sure it corresponds. */
|
||||
static struct command_result *json_fetchinvoice(struct command *cmd,
|
||||
const char *buffer,
|
||||
|
@ -930,7 +878,6 @@ static struct command_result *json_fetchinvoice(struct command *cmd,
|
|||
struct out_req *req;
|
||||
struct tlv_invoice_request *invreq;
|
||||
struct sent *sent = tal(cmd, struct sent);
|
||||
struct secret *payer_secret = NULL;
|
||||
u32 *timeout;
|
||||
u64 *quantity;
|
||||
u32 *recurrence_counter, *recurrence_start;
|
||||
|
@ -944,9 +891,6 @@ static struct command_result *json_fetchinvoice(struct command *cmd,
|
|||
p_opt("recurrence_label", param_string, &rec_label),
|
||||
p_opt_def("timeout", param_number, &timeout, 60),
|
||||
p_opt("payer_note", param_string, &payer_note),
|
||||
#if DEVELOPER
|
||||
p_opt("payer_secret", param_secret, &payer_secret),
|
||||
#endif
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
|
@ -1058,8 +1002,8 @@ static struct command_result *json_fetchinvoice(struct command *cmd,
|
|||
}
|
||||
|
||||
/* recurrence_label uniquely identifies this series of
|
||||
* payments (unless they supply secret themselves)! */
|
||||
if (!rec_label && !payer_secret)
|
||||
* payments */
|
||||
if (!rec_label)
|
||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"needs recurrence_label");
|
||||
} else {
|
||||
|
@ -1104,11 +1048,6 @@ static struct command_result *json_fetchinvoice(struct command *cmd,
|
|||
strlen(payer_note),
|
||||
0);
|
||||
|
||||
/* They can provide a secret, and we don't assume it's our job
|
||||
* to pay. */
|
||||
if (payer_secret)
|
||||
return force_payer_secret(cmd, sent, invreq, payer_secret);
|
||||
|
||||
/* Make the invoice request (fills in payer_key and payer_info) */
|
||||
req = jsonrpc_request_start(cmd->plugin, cmd, "createinvoicerequest",
|
||||
&invreq_done,
|
||||
|
@ -1470,7 +1409,6 @@ static struct command_result *json_sendinvoice(struct command *cmd,
|
|||
return sign_invoice(cmd, sent);
|
||||
}
|
||||
|
||||
#if DEVELOPER
|
||||
/* This version doesn't do sanity checks! */
|
||||
static struct command_result *param_raw_invreq(struct command *cmd,
|
||||
const char *name,
|
||||
|
@ -1491,9 +1429,9 @@ static struct command_result *param_raw_invreq(struct command *cmd,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static struct command_result *json_rawrequest(struct command *cmd,
|
||||
const char *buffer,
|
||||
const jsmntok_t *params)
|
||||
static struct command_result *json_dev_rawrequest(struct command *cmd,
|
||||
const char *buffer,
|
||||
const jsmntok_t *params)
|
||||
{
|
||||
struct sent *sent = tal(cmd, struct sent);
|
||||
u32 *timeout;
|
||||
|
@ -1519,7 +1457,6 @@ static struct command_result *json_rawrequest(struct command *cmd,
|
|||
|
||||
return sendinvreq_after_connect(cmd, NULL, NULL, sent);
|
||||
}
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
static const struct plugin_command commands[] = {
|
||||
{
|
||||
|
@ -1536,15 +1473,14 @@ static const struct plugin_command commands[] = {
|
|||
NULL,
|
||||
json_sendinvoice,
|
||||
},
|
||||
#if DEVELOPER
|
||||
{
|
||||
"dev-rawrequest",
|
||||
"util",
|
||||
"Send {invreq} to {nodeid}, wait {timeout} (60 seconds by default)",
|
||||
NULL,
|
||||
json_rawrequest,
|
||||
json_dev_rawrequest,
|
||||
.dev_only = true,
|
||||
},
|
||||
#endif /* DEVELOPER */
|
||||
};
|
||||
|
||||
static const char *init(struct plugin *p, const char *buf UNUSED,
|
||||
|
|
|
@ -1458,13 +1458,11 @@ static void tell_lightningd_lease_rates(struct plugin *p,
|
|||
|
||||
}
|
||||
|
||||
#if DEVELOPER
|
||||
static void memleak_mark(struct plugin *p, struct htable *memtable)
|
||||
{
|
||||
memleak_scan_list_head(memtable, &pending_opens);
|
||||
memleak_scan_obj(memtable, current_policy);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char *init(struct plugin *p, const char *b, const jsmntok_t *t)
|
||||
{
|
||||
|
@ -1479,9 +1477,7 @@ static const char *init(struct plugin *p, const char *b, const jsmntok_t *t)
|
|||
if (current_policy->rates)
|
||||
tell_lightningd_lease_rates(p, current_policy->rates);
|
||||
|
||||
#if DEVELOPER
|
||||
plugin_set_memleak_handler(p, memleak_mark);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -250,10 +250,8 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
|
|||
unsigned int *retryfor;
|
||||
struct route_info **hints;
|
||||
struct tlv_field *extra_fields;
|
||||
bool *dev_use_shadow;
|
||||
|
||||
#if DEVELOPER
|
||||
bool *use_shadow;
|
||||
#endif
|
||||
if (!param(cmd, buf, params,
|
||||
p_req("destination", param_node_id, &destination),
|
||||
p_req("amount_msat|msatoshi", param_msat, &msat),
|
||||
|
@ -266,9 +264,7 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
|
|||
p_opt_def("exemptfee", param_msat, &exemptfee, AMOUNT_MSAT(5000)),
|
||||
p_opt("extratlvs", param_extra_tlvs, &extra_fields),
|
||||
p_opt("routehints", param_routehint_array, &hints),
|
||||
#if DEVELOPER
|
||||
p_opt_def("use_shadow", param_bool, &use_shadow, true),
|
||||
#endif
|
||||
p_opt_dev("dev_use_shadow", param_bool, &dev_use_shadow, true),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
|
@ -313,9 +309,7 @@ static struct command_result *json_keysend(struct command *cmd, const char *buf,
|
|||
tal_steal(p, extra_fields);
|
||||
|
||||
payment_mod_exemptfee_get_data(p)->amount = *exemptfee;
|
||||
#if DEVELOPER
|
||||
payment_mod_shadowroute_get_data(p)->use_shadow = *use_shadow;
|
||||
#endif
|
||||
payment_mod_shadowroute_get_data(p)->use_shadow = *dev_use_shadow;
|
||||
p->label = tal_steal(p, label);
|
||||
payment_start(p);
|
||||
/* We're keeping this around now */
|
||||
|
|
|
@ -3032,9 +3032,7 @@ static struct shadow_route_data *shadow_route_init(struct payment *p)
|
|||
if (p->parent != NULL) {
|
||||
pd = payment_mod_shadowroute_get_data(p->parent);
|
||||
d->fuzz_amount = pd->fuzz_amount;
|
||||
#if DEVELOPER
|
||||
d->use_shadow = pd->use_shadow;
|
||||
#endif
|
||||
} else {
|
||||
d->fuzz_amount = true;
|
||||
}
|
||||
|
@ -3204,10 +3202,8 @@ next:
|
|||
static void shadow_route_cb(struct shadow_route_data *d,
|
||||
struct payment *p)
|
||||
{
|
||||
#if DEVELOPER
|
||||
if (!d->use_shadow)
|
||||
return payment_continue(p);
|
||||
#endif
|
||||
|
||||
if (p->step != PAYMENT_STEP_INITIALIZED)
|
||||
return payment_continue(p);
|
||||
|
|
|
@ -398,9 +398,7 @@ struct exemptfee_data {
|
|||
};
|
||||
|
||||
struct shadow_route_data {
|
||||
#if DEVELOPER
|
||||
bool use_shadow;
|
||||
#endif
|
||||
struct payment_constraints constraints;
|
||||
struct node_id destination;
|
||||
struct route_hop *route;
|
||||
|
|
|
@ -920,6 +920,8 @@ handle_getmanifest(struct command *getmanifest_cmd,
|
|||
|
||||
json_array_start(params, "options");
|
||||
for (size_t i = 0; i < tal_count(p->opts); i++) {
|
||||
if (p->opts[i].dev_only && !p->developer)
|
||||
continue;
|
||||
json_object_start(params, NULL);
|
||||
json_add_string(params, "name", p->opts[i].name);
|
||||
json_add_string(params, "type", p->opts[i].type);
|
||||
|
@ -932,6 +934,8 @@ handle_getmanifest(struct command *getmanifest_cmd,
|
|||
|
||||
json_array_start(params, "rpcmethods");
|
||||
for (size_t i = 0; i < p->num_commands; i++) {
|
||||
if (p->commands[i].dev_only && !p->developer)
|
||||
continue;
|
||||
json_object_start(params, NULL);
|
||||
json_add_string(params, "name", p->commands[i].name);
|
||||
json_add_string(params, "usage",
|
||||
|
@ -1888,6 +1892,7 @@ static struct plugin *new_plugin(const tal_t *ctx,
|
|||
o.description = va_arg(ap, const char *);
|
||||
o.handle = va_arg(ap, char *(*)(struct plugin *, const char *str, void *arg));
|
||||
o.arg = va_arg(ap, void *);
|
||||
o.dev_only = va_arg(ap, int); /* bool gets promoted! */
|
||||
o.deprecated = va_arg(ap, int); /* bool gets promoted! */
|
||||
o.dynamic = va_arg(ap, int); /* bool gets promoted! */
|
||||
tal_arr_expand(&p->opts, o);
|
||||
|
|
|
@ -71,6 +71,8 @@ struct plugin_command {
|
|||
const jsmntok_t *params);
|
||||
/* If true, this command *disabled* if allow-deprecated-apis = false */
|
||||
bool deprecated;
|
||||
/* If true, this option requires --developer to be enabled */
|
||||
bool dev_only;
|
||||
};
|
||||
|
||||
/* Create an array of these, one for each --option you support. */
|
||||
|
@ -80,6 +82,8 @@ struct plugin_option {
|
|||
const char *description;
|
||||
char *(*handle)(struct plugin *plugin, const char *str, void *arg);
|
||||
void *arg;
|
||||
/* If true, this option requires --developer to be enabled */
|
||||
bool dev_only;
|
||||
/* If true, this options *disabled* if allow-deprecated-apis = false */
|
||||
bool deprecated;
|
||||
/* If true, allow setting after plugin has initialized */
|
||||
|
@ -409,7 +413,7 @@ static inline void *plugin_option_cb_check(char *(*set)(struct plugin *plugin,
|
|||
bool plugin_developer_mode(const struct plugin *plugin);
|
||||
|
||||
/* Macro to define arguments */
|
||||
#define plugin_option_(name, type, description, set, arg, deprecated, dynamic) \
|
||||
#define plugin_option_(name, type, description, set, arg, dev_only, deprecated, dynamic) \
|
||||
(name), \
|
||||
(type), \
|
||||
(description), \
|
||||
|
@ -418,17 +422,21 @@ bool plugin_developer_mode(const struct plugin *plugin);
|
|||
struct plugin *, \
|
||||
const char *)), \
|
||||
(arg), \
|
||||
(dev_only), \
|
||||
(deprecated), \
|
||||
(dynamic)
|
||||
|
||||
#define plugin_option(name, type, description, set, arg) \
|
||||
plugin_option_((name), (type), (description), (set), (arg), false, false)
|
||||
plugin_option_((name), (type), (description), (set), (arg), false, false, false)
|
||||
|
||||
#define plugin_option_dev(name, type, description, set, arg) \
|
||||
plugin_option_((name), (type), (description), (set), (arg), true, false, false)
|
||||
|
||||
#define plugin_option_dynamic(name, type, description, set, arg) \
|
||||
plugin_option_((name), (type), (description), (set), (arg), false, true)
|
||||
plugin_option_((name), (type), (description), (set), (arg), false, false, true)
|
||||
|
||||
#define plugin_option_deprecated(name, type, description, set, arg) \
|
||||
plugin_option_((name), (type), (description), (set), (arg), true, false)
|
||||
plugin_option_((name), (type), (description), (set), (arg), false, true, false)
|
||||
|
||||
/* Standard helpers */
|
||||
char *u64_option(struct plugin *plugin, const char *arg, u64 *i);
|
||||
|
|
|
@ -77,10 +77,8 @@ struct pay_command {
|
|||
/* Any remaining routehints to try. */
|
||||
struct route_info **routehints;
|
||||
|
||||
#if DEVELOPER
|
||||
/* Disable the use of shadow route ? */
|
||||
/* Disable the use of shadow route ? (--developer allows this) */
|
||||
double use_shadow;
|
||||
#endif
|
||||
|
||||
/* Current node during shadow route calculation. */
|
||||
const char *shadow_dest;
|
||||
|
@ -567,12 +565,10 @@ static struct command_result *json_listpays(struct command *cmd,
|
|||
return send_outreq(cmd->plugin, req);
|
||||
}
|
||||
|
||||
#if DEVELOPER
|
||||
static void memleak_mark_payments(struct plugin *p, struct htable *memtable)
|
||||
{
|
||||
memleak_scan_list_head(memtable, &payments);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char *init(struct plugin *p,
|
||||
const char *buf UNUSED, const jsmntok_t *config UNUSED)
|
||||
|
@ -588,9 +584,7 @@ static const char *init(struct plugin *p,
|
|||
JSON_SCAN(json_to_number, &maxdelay_default),
|
||||
JSON_SCAN(json_to_bool, &exp_offers));
|
||||
|
||||
#if DEVELOPER
|
||||
plugin_set_memleak_handler(p, memleak_mark_payments);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1036,9 +1030,7 @@ static struct command_result *json_pay(struct command *cmd,
|
|||
const struct tlv_invoice *b12;
|
||||
struct out_req *req;
|
||||
struct route_exclusion **exclusions;
|
||||
#if DEVELOPER
|
||||
bool *use_shadow;
|
||||
#endif
|
||||
bool *dev_use_shadow;
|
||||
|
||||
/* If any of the modifiers need to add params to the JSON-RPC call we
|
||||
* would add them to the `param()` call below, and have them be
|
||||
|
@ -1060,9 +1052,7 @@ static struct command_result *json_pay(struct command *cmd,
|
|||
p_opt("exclude", param_route_exclusion_array, &exclusions),
|
||||
p_opt("maxfee", param_msat, &maxfee),
|
||||
p_opt("description", param_escaped_string, &description),
|
||||
#if DEVELOPER
|
||||
p_opt_def("use_shadow", param_bool, &use_shadow, true),
|
||||
#endif
|
||||
p_opt_dev("dev_use_shadow", param_bool, &dev_use_shadow, true),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
|
@ -1262,10 +1252,9 @@ static struct command_result *json_pay(struct command *cmd,
|
|||
|
||||
/* This is an MPP enabled pay command, disable amount fuzzing. */
|
||||
shadow_route->fuzz_amount = false;
|
||||
#if DEVELOPER
|
||||
shadow_route->use_shadow = *use_shadow;
|
||||
tal_free(use_shadow);
|
||||
#endif
|
||||
shadow_route->use_shadow = *dev_use_shadow;
|
||||
tal_free(dev_use_shadow);
|
||||
|
||||
p->label = tal_steal(p, label);
|
||||
list_add_tail(&payments, &p->list);
|
||||
tal_add_destructor(p, destroy_payment);
|
||||
|
|
|
@ -1479,13 +1479,11 @@ static void init_indices(struct plugin *plugin)
|
|||
}
|
||||
}
|
||||
|
||||
#if DEVELOPER
|
||||
static void memleak_mark_tablemap(struct plugin *p, struct htable *memtable)
|
||||
{
|
||||
memleak_ptr(memtable, dbfilename);
|
||||
memleak_scan_strmap(memtable, &tablemap);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char *init(struct plugin *plugin,
|
||||
const char *buf UNUSED, const jsmntok_t *config UNUSED)
|
||||
|
@ -1494,9 +1492,7 @@ static const char *init(struct plugin *plugin,
|
|||
init_tablemap(plugin);
|
||||
init_indices(plugin);
|
||||
|
||||
#if DEVELOPER
|
||||
plugin_set_memleak_handler(plugin, memleak_mark_tablemap);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -600,12 +600,10 @@ done:
|
|||
return command_finished(cmd, js);
|
||||
}
|
||||
|
||||
#if DEVELOPER
|
||||
static void memleak_mark(struct plugin *p, struct htable *memtable)
|
||||
{
|
||||
memleak_scan_obj(memtable, global_gossmap);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char *init(struct plugin *p,
|
||||
const char *buf UNUSED, const jsmntok_t *config UNUSED)
|
||||
|
@ -628,9 +626,7 @@ static const char *init(struct plugin *p,
|
|||
plugin_log(plugin, LOG_DBG,
|
||||
"gossmap ignored %zu channel updates",
|
||||
num_cupdates_rejected);
|
||||
#if DEVELOPER
|
||||
plugin_set_memleak_handler(p, memleak_mark);
|
||||
#endif
|
||||
plugin_set_memleak_handler(p, memleak_mark);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -671,19 +671,15 @@ static const struct plugin_command commands[] = {
|
|||
},
|
||||
};
|
||||
|
||||
#if DEVELOPER
|
||||
static void mark_unreleased_txs(struct plugin *plugin, struct htable *memtable)
|
||||
{
|
||||
memleak_scan_list_head(memtable, &unreleased_txs);
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char *init(struct plugin *p,
|
||||
const char *buf UNUSED, const jsmntok_t *config UNUSED)
|
||||
{
|
||||
#if DEVELOPER
|
||||
plugin_set_memleak_handler(p, mark_unreleased_txs);
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -329,7 +329,7 @@ def test_htlc_out_timeout(node_factory, bitcoind, executor):
|
|||
inv = l2.rpc.invoice(amt, 'test_htlc_out_timeout', 'desc')['bolt11']
|
||||
assert only_one(l2.rpc.listinvoices('test_htlc_out_timeout')['invoices'])['status'] == 'unpaid'
|
||||
|
||||
executor.submit(l1.dev_pay, inv, use_shadow=False)
|
||||
executor.submit(l1.dev_pay, inv, dev_use_shadow=False)
|
||||
|
||||
# l1 will disconnect, and not reconnect.
|
||||
l1.daemon.wait_for_log('dev_disconnect: -WIRE_REVOKE_AND_ACK')
|
||||
|
@ -402,7 +402,7 @@ def test_htlc_in_timeout(node_factory, bitcoind, executor):
|
|||
inv = l2.rpc.invoice(amt, 'test_htlc_in_timeout', 'desc')['bolt11']
|
||||
assert only_one(l2.rpc.listinvoices('test_htlc_in_timeout')['invoices'])['status'] == 'unpaid'
|
||||
|
||||
executor.submit(l1.dev_pay, inv, use_shadow=False)
|
||||
executor.submit(l1.dev_pay, inv, dev_use_shadow=False)
|
||||
|
||||
# l1 will disconnect and not reconnect.
|
||||
l1.daemon.wait_for_log('dev_disconnect: -WIRE_REVOKE_AND_ACK')
|
||||
|
|
|
@ -29,7 +29,7 @@ def test_pay(node_factory):
|
|||
|
||||
inv = l2.rpc.invoice(123000, 'test_pay', 'description')['bolt11']
|
||||
before = int(time.time())
|
||||
details = l1.dev_pay(inv, use_shadow=False)
|
||||
details = l1.dev_pay(inv, dev_use_shadow=False)
|
||||
after = time.time()
|
||||
preimage = details['payment_preimage']
|
||||
assert details['status'] == 'complete'
|
||||
|
@ -44,7 +44,7 @@ def test_pay(node_factory):
|
|||
assert invoice['status'] == 'paid' and invoice['paid_at'] >= before and invoice['paid_at'] <= after
|
||||
|
||||
# Repeat payments are NOPs (if valid): we can hand null.
|
||||
l1.dev_pay(inv, use_shadow=False)
|
||||
l1.dev_pay(inv, dev_use_shadow=False)
|
||||
# This won't work: can't provide an amount (even if correct!)
|
||||
with pytest.raises(RpcError):
|
||||
l1.rpc.pay(inv, 123000)
|
||||
|
@ -62,7 +62,7 @@ def test_pay(node_factory):
|
|||
# Must provide an amount!
|
||||
with pytest.raises(RpcError):
|
||||
l1.rpc.pay(inv2)
|
||||
l1.dev_pay(inv2, random.randint(1000, 999999), use_shadow=False)
|
||||
l1.dev_pay(inv2, random.randint(1000, 999999), dev_use_shadow=False)
|
||||
|
||||
# Should see 6 completed payments
|
||||
assert len(l1.rpc.listsendpays()['payments']) == 6
|
||||
|
@ -95,7 +95,7 @@ def test_pay_amounts(node_factory):
|
|||
assert isinstance(invoice['amount_msat'], Millisatoshi)
|
||||
assert invoice['amount_msat'] == Millisatoshi(123000)
|
||||
|
||||
l1.dev_pay(inv, use_shadow=False)
|
||||
l1.dev_pay(inv, dev_use_shadow=False)
|
||||
|
||||
invoice = only_one(l2.rpc.listinvoices('test_pay_amounts')['invoices'])
|
||||
assert isinstance(invoice['amount_received_msat'], Millisatoshi)
|
||||
|
@ -148,7 +148,7 @@ def test_pay_limits(node_factory):
|
|||
|
||||
# This works, because fee is less than exemptfee.
|
||||
l1.dev_pay(inv['bolt11'], amount_msat=100000, maxfeepercent=0.0001,
|
||||
exemptfee=2000, use_shadow=False)
|
||||
exemptfee=2000, dev_use_shadow=False)
|
||||
status = l1.rpc.call('paystatus', {'bolt11': inv['bolt11']})['pay'][3]['attempts']
|
||||
assert len(status) == 1
|
||||
assert status[0]['strategy'] == "Initial attempt"
|
||||
|
@ -371,13 +371,13 @@ def test_pay_optional_args(node_factory):
|
|||
l1, l2 = node_factory.line_graph(2)
|
||||
|
||||
inv1 = l2.rpc.invoice(123000, 'test_pay', 'desc')['bolt11']
|
||||
l1.dev_pay(inv1, label='desc', use_shadow=False)
|
||||
l1.dev_pay(inv1, label='desc', dev_use_shadow=False)
|
||||
payment1 = l1.rpc.listsendpays(inv1)['payments']
|
||||
assert len(payment1) and payment1[0]['amount_sent_msat'] == 123000
|
||||
assert payment1[0]['label'] == 'desc'
|
||||
|
||||
inv2 = l2.rpc.invoice(321000, 'test_pay2', 'description')['bolt11']
|
||||
l1.dev_pay(inv2, riskfactor=5.0, use_shadow=False)
|
||||
l1.dev_pay(inv2, riskfactor=5.0, dev_use_shadow=False)
|
||||
payment2 = l1.rpc.listsendpays(inv2)['payments']
|
||||
assert(len(payment2) == 1)
|
||||
# The pay plugin uses `sendonion` since 0.9.0 and `lightningd` doesn't
|
||||
|
@ -385,7 +385,7 @@ def test_pay_optional_args(node_factory):
|
|||
# root of a payment tree with the bolt11 invoice).
|
||||
|
||||
anyinv = l2.rpc.invoice('any', 'any_pay', 'desc')['bolt11']
|
||||
l1.dev_pay(anyinv, label='desc', amount_msat=500, use_shadow=False)
|
||||
l1.dev_pay(anyinv, label='desc', amount_msat=500, dev_use_shadow=False)
|
||||
payment3 = l1.rpc.listsendpays(anyinv)['payments']
|
||||
assert len(payment3) == 1
|
||||
assert payment3[0]['label'] == 'desc'
|
||||
|
@ -418,7 +418,7 @@ def test_payment_success_persistence(node_factory, bitcoind, executor):
|
|||
inv1 = l2.rpc.invoice(1000, 'inv1', 'inv1')
|
||||
|
||||
# Fire off a pay request, it'll get interrupted by a restart
|
||||
executor.submit(l1.dev_pay, inv1['bolt11'], use_shadow=False)
|
||||
executor.submit(l1.dev_pay, inv1['bolt11'], dev_use_shadow=False)
|
||||
|
||||
l1.daemon.wait_for_log(r'dev_disconnect: \+WIRE_COMMITMENT_SIGNED')
|
||||
|
||||
|
@ -444,7 +444,7 @@ def test_payment_success_persistence(node_factory, bitcoind, executor):
|
|||
# A duplicate should succeed immediately (nop) and return correct preimage.
|
||||
preimage = l1.dev_pay(
|
||||
inv1['bolt11'],
|
||||
use_shadow=False
|
||||
dev_use_shadow=False
|
||||
)['payment_preimage']
|
||||
assert l1.rpc.dev_rhash(preimage)['rhash'] == inv1['payment_hash']
|
||||
|
||||
|
@ -1806,7 +1806,7 @@ def test_pay_retry(node_factory, bitcoind, executor, chainparams):
|
|||
fut = executor.submit(listpays_nofail, inv['bolt11'])
|
||||
|
||||
# Pay l1->l5 should succeed via straight line (eventually)
|
||||
l1.dev_pay(inv['bolt11'], use_shadow=False)
|
||||
l1.dev_pay(inv['bolt11'], dev_use_shadow=False)
|
||||
|
||||
# This should be OK.
|
||||
fut.result()
|
||||
|
@ -1821,7 +1821,7 @@ def test_pay_retry(node_factory, bitcoind, executor, chainparams):
|
|||
# Finally, fails to find a route.
|
||||
inv = l5.rpc.invoice(10**8, 'test_retry2', 'test_retry2')['bolt11']
|
||||
with pytest.raises(RpcError, match=r'4 attempts'):
|
||||
l1.dev_pay(inv, use_shadow=False)
|
||||
l1.dev_pay(inv, dev_use_shadow=False)
|
||||
|
||||
|
||||
@pytest.mark.developer("needs DEVELOPER=1 otherwise gossip takes 5 minutes!")
|
||||
|
@ -1861,7 +1861,7 @@ def test_pay_routeboost(node_factory, bitcoind):
|
|||
assert only_one(only_one(l1.rpc.decodepay(inv['bolt11'])['routes']))
|
||||
|
||||
# Now we should be able to pay it.
|
||||
l1.dev_pay(inv['bolt11'], use_shadow=False)
|
||||
l1.dev_pay(inv['bolt11'], dev_use_shadow=False)
|
||||
|
||||
# Status should show all the gory details.
|
||||
status = l1.rpc.call('paystatus', [inv['bolt11']])
|
||||
|
@ -1896,7 +1896,7 @@ def test_pay_routeboost(node_factory, bitcoind):
|
|||
label='test_pay_routeboost2',
|
||||
description='test_pay_routeboost2',
|
||||
dev_routes=[routel3l4l5])
|
||||
l1.dev_pay(inv['bolt11'], use_shadow=False)
|
||||
l1.dev_pay(inv['bolt11'], dev_use_shadow=False)
|
||||
status = l1.rpc.call('paystatus', [inv['bolt11']])
|
||||
pay = only_one(status['pay'])
|
||||
attempts = pay['attempts']
|
||||
|
@ -1919,7 +1919,7 @@ def test_pay_routeboost(node_factory, bitcoind):
|
|||
description='test_pay_routeboost5',
|
||||
dev_routes=[routel3l4l5, routel3l5])
|
||||
l1.dev_pay(inv['bolt11'], label="paying test_pay_routeboost5",
|
||||
use_shadow=False)
|
||||
dev_use_shadow=False)
|
||||
|
||||
status = l1.rpc.call('paystatus', [inv['bolt11']])
|
||||
assert only_one(status['pay'])['bolt11'] == inv['bolt11']
|
||||
|
@ -2159,7 +2159,7 @@ def test_setchannel_state(node_factory, bitcoind):
|
|||
|
||||
l0.wait_for_route(l2)
|
||||
inv = l2.rpc.invoice(100000, 'test_setchannel_state', 'desc')['bolt11']
|
||||
result = l0.dev_pay(inv, use_shadow=False)
|
||||
result = l0.dev_pay(inv, dev_use_shadow=False)
|
||||
assert result['status'] == 'complete'
|
||||
assert result['amount_sent_msat'] == 100042
|
||||
|
||||
|
@ -2235,7 +2235,7 @@ def test_setchannel_routing(node_factory, bitcoind):
|
|||
description='desc',
|
||||
dev_routes=[])
|
||||
with pytest.raises(RpcError) as routefail:
|
||||
l1.dev_pay(inv['bolt11'], use_shadow=False)
|
||||
l1.dev_pay(inv['bolt11'], dev_use_shadow=False)
|
||||
assert routefail.value.error['attempts'][0]['failreason'] == 'No path found'
|
||||
|
||||
# 1337 + 4000000 * 137 / 1000000 = 1885
|
||||
|
@ -2335,7 +2335,7 @@ def test_setchannel_zero(node_factory, bitcoind):
|
|||
|
||||
# do and check actual payment
|
||||
inv = l3.rpc.invoice(4999999, 'test_setchannel_3', 'desc')['bolt11']
|
||||
result = l1.dev_pay(inv, use_shadow=False)
|
||||
result = l1.dev_pay(inv, dev_use_shadow=False)
|
||||
assert result['status'] == 'complete'
|
||||
assert result['amount_sent_msat'] == 4999999
|
||||
|
||||
|
@ -2391,7 +2391,7 @@ def test_setchannel_restart(node_factory, bitcoind):
|
|||
# l1 can make payment to l3 with custom fees being applied
|
||||
# Note: BOLT #7 math works out to 1405 msat fees
|
||||
inv = l3.rpc.invoice(499999, 'test_setchannel_1', 'desc')['bolt11']
|
||||
result = l1.dev_pay(inv, use_shadow=False)
|
||||
result = l1.dev_pay(inv, dev_use_shadow=False)
|
||||
assert result['status'] == 'complete'
|
||||
assert result['amount_sent_msat'] == 501404
|
||||
|
||||
|
@ -3404,7 +3404,7 @@ def test_blockheight_disagreement(node_factory, bitcoind, executor):
|
|||
|
||||
# Have l1 pay l2
|
||||
def pay(l1, inv):
|
||||
l1.dev_pay(inv, use_shadow=False)
|
||||
l1.dev_pay(inv, dev_use_shadow=False)
|
||||
fut = executor.submit(pay, l1, inv)
|
||||
|
||||
# Make sure l1 sends out the HTLC.
|
||||
|
@ -3709,10 +3709,10 @@ def test_pay_exemptfee(node_factory):
|
|||
err = r'Ran out of routes to try'
|
||||
|
||||
with pytest.raises(RpcError, match=err):
|
||||
l1.dev_pay(l3.rpc.invoice(1, "lbl1", "desc")['bolt11'], use_shadow=False)
|
||||
l1.dev_pay(l3.rpc.invoice(1, "lbl1", "desc")['bolt11'], dev_use_shadow=False)
|
||||
|
||||
# If we tell our node that 5001msat is ok this should work
|
||||
l1.dev_pay(l3.rpc.invoice(1, "lbl2", "desc")['bolt11'], use_shadow=False, exemptfee=5001)
|
||||
l1.dev_pay(l3.rpc.invoice(1, "lbl2", "desc")['bolt11'], dev_use_shadow=False, exemptfee=5001)
|
||||
|
||||
# Given the above network this is the smallest amount that passes without
|
||||
# the fee-exemption (notice that we let it through on equality).
|
||||
|
@ -3720,10 +3720,10 @@ def test_pay_exemptfee(node_factory):
|
|||
|
||||
# This should be just below the fee-exemption and is the first value that is allowed through
|
||||
with pytest.raises(RpcError, match=err):
|
||||
l1.dev_pay(l3.rpc.invoice(threshold - 1, "lbl3", "desc")['bolt11'], use_shadow=False)
|
||||
l1.dev_pay(l3.rpc.invoice(threshold - 1, "lbl3", "desc")['bolt11'], dev_use_shadow=False)
|
||||
|
||||
# While this'll work just fine
|
||||
l1.dev_pay(l3.rpc.invoice(int(5001 * 200), "lbl4", "desc")['bolt11'], use_shadow=False)
|
||||
l1.dev_pay(l3.rpc.invoice(int(5001 * 200), "lbl4", "desc")['bolt11'], dev_use_shadow=False)
|
||||
|
||||
|
||||
@pytest.mark.developer("Requires use_shadow flag")
|
||||
|
@ -3762,7 +3762,7 @@ def test_pay_peer(node_factory, bitcoind):
|
|||
for i in range(0, direct):
|
||||
inv = l2.rpc.invoice(amt.millisatoshis, "lbl{}".format(i),
|
||||
"desc{}".format(i))['bolt11']
|
||||
l1.dev_pay(inv, use_shadow=False)
|
||||
l1.dev_pay(inv, dev_use_shadow=False)
|
||||
|
||||
# We should not have more than amt in the direct channel anymore
|
||||
assert(spendable(l1, l2) < amt)
|
||||
|
@ -3770,7 +3770,7 @@ def test_pay_peer(node_factory, bitcoind):
|
|||
|
||||
# Next one should take the alternative, but it should still work
|
||||
inv = l2.rpc.invoice(amt.millisatoshis, "final", "final")['bolt11']
|
||||
l1.dev_pay(inv, use_shadow=False)
|
||||
l1.dev_pay(inv, dev_use_shadow=False)
|
||||
|
||||
|
||||
def test_mpp_adaptive(node_factory, bitcoind):
|
||||
|
@ -4068,7 +4068,7 @@ def test_mpp_waitblockheight_routehint_conflict(node_factory, bitcoind, executor
|
|||
|
||||
# Have l1 pay l3
|
||||
def pay(l1, inv):
|
||||
l1.dev_pay(inv, use_shadow=False)
|
||||
l1.dev_pay(inv, dev_use_shadow=False)
|
||||
fut = executor.submit(pay, l1, inv)
|
||||
|
||||
# Make sure l1 sends out the HTLC.
|
||||
|
|
|
@ -430,7 +430,7 @@ def test_pay_plugin(node_factory):
|
|||
'[retry_for] [maxdelay] [exemptfee] [localinvreqid] [exclude] '\
|
||||
'[maxfee] [description]'
|
||||
if DEVELOPER:
|
||||
msg += ' [use_shadow]'
|
||||
msg += ' [dev_use_shadow]'
|
||||
assert only_one(l1.rpc.help('pay')['help'])['command'] == msg
|
||||
|
||||
|
||||
|
@ -1169,7 +1169,7 @@ def test_htlc_accepted_hook_forward_restart(node_factory, executor):
|
|||
], wait_for_announce=True)
|
||||
|
||||
i1 = l3.rpc.invoice(amount_msat=1000, label="direct", description="desc")['bolt11']
|
||||
f1 = executor.submit(l1.dev_pay, i1, use_shadow=False)
|
||||
f1 = executor.submit(l1.dev_pay, i1, dev_use_shadow=False)
|
||||
|
||||
l2.daemon.wait_for_log(r'Holding onto an incoming htlc for 10 seconds')
|
||||
|
||||
|
@ -1239,7 +1239,7 @@ def test_invoice_payment_notification(node_factory):
|
|||
preimage = '1' * 64
|
||||
label = "a_descriptive_label"
|
||||
inv1 = l2.rpc.invoice(msats, label, 'description', preimage=preimage)
|
||||
l1.dev_pay(inv1['bolt11'], use_shadow=False)
|
||||
l1.dev_pay(inv1['bolt11'], dev_use_shadow=False)
|
||||
|
||||
l2.daemon.wait_for_log(r"Received invoice_payment event for label {},"
|
||||
" preimage {}, and amount of {}msat"
|
||||
|
|
Loading…
Add table
Reference in a new issue