mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
common: enforce that msat fields are called "xxx_msat".
Now we've fixed them all, make sure no new ones slip in! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -402,6 +402,8 @@ void json_add_amount_msat_compat(struct json_stream *result,
|
|||||||
const char *msatfieldname)
|
const char *msatfieldname)
|
||||||
{
|
{
|
||||||
json_add_u64(result, rawfieldname, msat.millisatoshis); /* Raw: low-level helper */
|
json_add_u64(result, rawfieldname, msat.millisatoshis); /* Raw: low-level helper */
|
||||||
|
if (!deprecated_apis)
|
||||||
|
assert(strends(msatfieldname, "_msat"));
|
||||||
json_add_amount_msat_only(result, msatfieldname, msat);
|
json_add_amount_msat_only(result, msatfieldname, msat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,6 +411,8 @@ void json_add_amount_msat_only(struct json_stream *result,
|
|||||||
const char *msatfieldname,
|
const char *msatfieldname,
|
||||||
struct amount_msat msat)
|
struct amount_msat msat)
|
||||||
{
|
{
|
||||||
|
if (!deprecated_apis)
|
||||||
|
assert(strends(msatfieldname, "_msat"));
|
||||||
json_add_string(result, msatfieldname,
|
json_add_string(result, msatfieldname,
|
||||||
type_to_string(tmpctx, struct amount_msat, &msat));
|
type_to_string(tmpctx, struct amount_msat, &msat));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1616,7 +1616,13 @@ static void add_config(struct lightningd *ld,
|
|||||||
/* FIXME: We actually treat it as if they specified
|
/* FIXME: We actually treat it as if they specified
|
||||||
* --plugin for each one, so ignore these */
|
* --plugin for each one, so ignore these */
|
||||||
} else if (opt->cb_arg == (void *)opt_set_msat) {
|
} else if (opt->cb_arg == (void *)opt_set_msat) {
|
||||||
json_add_amount_msat_only(response, name0, ld->config.max_dust_htlc_exposure_msat);
|
/* We allow -msat not _msat here, unlike
|
||||||
|
* json_add_amount_msat_only */
|
||||||
|
assert(strends(name0, "-msat"));
|
||||||
|
json_add_string(response, name0,
|
||||||
|
fmt_amount_msat(tmpctx,
|
||||||
|
*(struct amount_msat *)
|
||||||
|
opt->u.carg));
|
||||||
#if EXPERIMENTAL_FEATURES
|
#if EXPERIMENTAL_FEATURES
|
||||||
} else if (opt->cb_arg == (void *)opt_set_accept_extra_tlv_types) {
|
} else if (opt->cb_arg == (void *)opt_set_accept_extra_tlv_types) {
|
||||||
/* TODO Actually print the option */
|
/* TODO Actually print the option */
|
||||||
|
|||||||
@@ -1825,7 +1825,9 @@ static void payment_add_attempt(struct json_stream *s, const char *fieldname, st
|
|||||||
json_add_string(s, "failreason", p->failreason);
|
json_add_string(s, "failreason", p->failreason);
|
||||||
|
|
||||||
json_add_u64(s, "partid", p->partid);
|
json_add_u64(s, "partid", p->partid);
|
||||||
json_add_amount_msat_only(s, "amount", p->amount);
|
if (deprecated_apis)
|
||||||
|
json_add_amount_msat_only(s, "amount", p->amount);
|
||||||
|
json_add_amount_msat_only(s, "amount_msat", p->amount);
|
||||||
if (p->parent != NULL)
|
if (p->parent != NULL)
|
||||||
json_add_u64(s, "parent_partid", p->parent->partid);
|
json_add_u64(s, "parent_partid", p->parent->partid);
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ struct command_result *command_finished(struct command *cmd UNNEEDED, struct jso
|
|||||||
/* Generated stub for command_still_pending */
|
/* Generated stub for command_still_pending */
|
||||||
struct command_result *command_still_pending(struct command *cmd UNNEEDED)
|
struct command_result *command_still_pending(struct command *cmd UNNEEDED)
|
||||||
{ fprintf(stderr, "command_still_pending called!\n"); abort(); }
|
{ fprintf(stderr, "command_still_pending called!\n"); abort(); }
|
||||||
|
/* Generated stub for deprecated_apis */
|
||||||
|
bool deprecated_apis;
|
||||||
/* Generated stub for feature_offered */
|
/* Generated stub for feature_offered */
|
||||||
bool feature_offered(const u8 *features UNNEEDED, size_t f UNNEEDED)
|
bool feature_offered(const u8 *features UNNEEDED, size_t f UNNEEDED)
|
||||||
{ fprintf(stderr, "feature_offered called!\n"); abort(); }
|
{ fprintf(stderr, "feature_offered called!\n"); abort(); }
|
||||||
|
|||||||
Reference in New Issue
Block a user