cleanup: rename json_add_amount_msat_only to json_add_amount_msat

Now there's no compat variant, we can rename this function.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-03-14 15:51:50 +10:30
parent 983542f2a7
commit 9366e6b39f
29 changed files with 129 additions and 145 deletions

View File

@@ -589,7 +589,7 @@ void json_add_psbt(struct json_stream *stream,
tal_free(psbt); tal_free(psbt);
} }
void json_add_amount_msat_only(struct json_stream *result, void json_add_amount_msat(struct json_stream *result,
const char *msatfieldname, const char *msatfieldname,
struct amount_msat msat) struct amount_msat msat)
{ {
@@ -604,7 +604,7 @@ void json_add_amount_sat_msat(struct json_stream *result,
struct amount_msat msat; struct amount_msat msat;
assert(strends(msatfieldname, "_msat")); assert(strends(msatfieldname, "_msat"));
if (amount_sat_to_msat(&msat, sat)) if (amount_sat_to_msat(&msat, sat))
json_add_amount_msat_only(result, msatfieldname, msat); json_add_amount_msat(result, msatfieldname, msat);
} }
void json_add_sats(struct json_stream *result, void json_add_sats(struct json_stream *result,
@@ -639,9 +639,9 @@ void json_add_lease_rates(struct json_stream *result,
amount_sat(rates->lease_fee_base_sat)); amount_sat(rates->lease_fee_base_sat));
json_add_num(result, "lease_fee_basis", rates->lease_fee_basis); json_add_num(result, "lease_fee_basis", rates->lease_fee_basis);
json_add_num(result, "funding_weight", rates->funding_weight); json_add_num(result, "funding_weight", rates->funding_weight);
json_add_amount_msat_only(result, json_add_amount_msat(result,
"channel_fee_max_base_msat", "channel_fee_max_base_msat",
amount_msat(rates->channel_fee_max_base_msat)); amount_msat(rates->channel_fee_max_base_msat));
json_add_num(result, "channel_fee_max_proportional_thousandths", json_add_num(result, "channel_fee_max_proportional_thousandths",
rates->channel_fee_max_proportional_thousandths); rates->channel_fee_max_proportional_thousandths);
} }

View File

@@ -325,14 +325,11 @@ void json_add_address_internal(struct json_stream *response,
const struct wireaddr_internal *addr); const struct wireaddr_internal *addr);
/* Adds an 'msat' field */ /* Adds an 'msat' field */
void json_add_amount_msat_only(struct json_stream *result, void json_add_amount_msat(struct json_stream *result,
const char *msatfieldname, const char *msatfieldname,
struct amount_msat msat) struct amount_msat msat)
NO_NULL_ARGS; NO_NULL_ARGS;
/* Compat shim */
#define json_add_amount_msat json_add_amount_msat_only
/* Adds an 'msat' field */ /* Adds an 'msat' field */
void json_add_amount_sat_msat(struct json_stream *result, void json_add_amount_sat_msat(struct json_stream *result,
const char *msatfieldname, const char *msatfieldname,

View File

@@ -10,8 +10,6 @@
#include <stdio.h> #include <stdio.h>
/* AUTOGENERATED MOCKS START */ /* AUTOGENERATED MOCKS START */
/* Generated stub for deprecated_apis */
bool deprecated_apis;
/* Generated stub for fromwire_tlv */ /* Generated stub for fromwire_tlv */
bool fromwire_tlv(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, bool fromwire_tlv(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
const struct tlv_record_type *types UNNEEDED, size_t num_types UNNEEDED, const struct tlv_record_type *types UNNEEDED, size_t num_types UNNEEDED,

View File

@@ -230,7 +230,7 @@ int main(int argc, char *argv[])
json_object_start(js, NULL); json_object_start(js, NULL);
json_add_u32(js, "index", i+j); json_add_u32(js, "index", i+j);
json_add_amount_msat_only(js, "amount_msat", amount_msat(12)); json_add_amount_msat(js, "amount_msat", amount_msat(12));
if (j == 0) if (j == 0)
json_add_string(js, "type", "sometype"); json_add_string(js, "type", "sometype");
json_add_string(js, "scriptPubKey", "00000000"); json_add_string(js, "scriptPubKey", "00000000");

View File

@@ -55,8 +55,6 @@ struct command_result *command_fail(struct command *cmd UNNEEDED, enum jsonrpc_e
/* Generated stub for command_filter_ptr */ /* Generated stub for command_filter_ptr */
struct json_filter **command_filter_ptr(struct command *cmd UNNEEDED) struct json_filter **command_filter_ptr(struct command *cmd UNNEEDED)
{ fprintf(stderr, "command_filter_ptr called!\n"); abort(); } { fprintf(stderr, "command_filter_ptr called!\n"); abort(); }
/* Generated stub for deprecated_apis */
bool deprecated_apis;
/* Generated stub for fmt_amount_sat */ /* Generated stub for fmt_amount_sat */
const char *fmt_amount_sat(const tal_t *ctx UNNEEDED, struct amount_sat sat UNNEEDED) const char *fmt_amount_sat(const tal_t *ctx UNNEEDED, struct amount_sat sat UNNEEDED)
{ fprintf(stderr, "fmt_amount_sat called!\n"); abort(); } { fprintf(stderr, "fmt_amount_sat called!\n"); abort(); }
@@ -132,10 +130,6 @@ void towire_u8(u8 **pptr UNNEEDED, u8 v UNNEEDED)
/* Generated stub for towire_u8_array */ /* Generated stub for towire_u8_array */
void towire_u8_array(u8 **pptr UNNEEDED, const u8 *arr UNNEEDED, size_t num UNNEEDED) void towire_u8_array(u8 **pptr UNNEEDED, const u8 *arr UNNEEDED, size_t num UNNEEDED)
{ fprintf(stderr, "towire_u8_array called!\n"); abort(); } { fprintf(stderr, "towire_u8_array called!\n"); abort(); }
/* Generated stub for type_to_string_ */
const char *type_to_string_(const tal_t *ctx UNNEEDED, const char *typename UNNEEDED,
union printable_types u UNNEEDED)
{ fprintf(stderr, "type_to_string_ called!\n"); abort(); }
/* AUTOGENERATED MOCKS END */ /* AUTOGENERATED MOCKS END */
int main(int argc, char *argv[]) int main(int argc, char *argv[])

View File

@@ -290,10 +290,10 @@ static void openchannel2_hook_serialize(struct openchannel2_payload *payload,
json_add_amount_sat_msat(stream, json_add_amount_sat_msat(stream,
"dust_limit_msat", payload->dust_limit_satoshis); "dust_limit_msat", payload->dust_limit_satoshis);
json_add_amount_msat_only(stream, "max_htlc_value_in_flight_msat", json_add_amount_msat(stream, "max_htlc_value_in_flight_msat",
payload->max_htlc_value_in_flight_msat); payload->max_htlc_value_in_flight_msat);
json_add_amount_msat_only(stream, "htlc_minimum_msat", json_add_amount_msat(stream, "htlc_minimum_msat",
payload->htlc_minimum_msat); payload->htlc_minimum_msat);
json_add_num(stream, "funding_feerate_per_kw", json_add_num(stream, "funding_feerate_per_kw",
payload->funding_feerate_per_kw); payload->funding_feerate_per_kw);
json_add_num(stream, "commitment_feerate_per_kw", json_add_num(stream, "commitment_feerate_per_kw",

View File

@@ -437,8 +437,8 @@ static struct command_result *json_setleaserates(struct command *cmd,
amount_sat(rates->lease_fee_base_sat)); amount_sat(rates->lease_fee_base_sat));
json_add_num(res, "lease_fee_basis", rates->lease_fee_basis); json_add_num(res, "lease_fee_basis", rates->lease_fee_basis);
json_add_num(res, "funding_weight", rates->funding_weight); json_add_num(res, "funding_weight", rates->funding_weight);
json_add_amount_msat_only(res, "channel_fee_max_base_msat", json_add_amount_msat(res, "channel_fee_max_base_msat",
amount_msat(rates->channel_fee_max_base_msat)); amount_msat(rates->channel_fee_max_base_msat));
json_add_num(res, "channel_fee_max_proportional_thousandths", json_add_num(res, "channel_fee_max_proportional_thousandths",
rates->channel_fee_max_proportional_thousandths); rates->channel_fee_max_proportional_thousandths);

View File

@@ -490,8 +490,8 @@ static void coin_movement_notification_serialize(struct json_stream *stream,
json_add_string(stream, "originating_account", json_add_string(stream, "originating_account",
mvt->originating_acct); mvt->originating_acct);
json_mvt_id(stream, mvt->type, &mvt->id); json_mvt_id(stream, mvt->type, &mvt->id);
json_add_amount_msat_only(stream, "credit_msat", mvt->credit); json_add_amount_msat(stream, "credit_msat", mvt->credit);
json_add_amount_msat_only(stream, "debit_msat", mvt->debit); json_add_amount_msat(stream, "debit_msat", mvt->debit);
/* Only chain movements */ /* Only chain movements */
if (mvt->output_val) if (mvt->output_val)
@@ -502,8 +502,7 @@ static void coin_movement_notification_serialize(struct json_stream *stream,
mvt->output_count); mvt->output_count);
if (mvt->fees) { if (mvt->fees) {
json_add_amount_msat_only(stream, "fees_msat", json_add_amount_msat(stream, "fees_msat", *mvt->fees);
*mvt->fees);
} }
json_array_start(stream, "tags"); json_array_start(stream, "tags");
@@ -548,8 +547,8 @@ static void balance_snapshot_notification_serialize(struct json_stream *stream,
json_object_start(stream, NULL); json_object_start(stream, NULL);
json_add_string(stream, "account_id", json_add_string(stream, "account_id",
snap->accts[i]->acct_id); snap->accts[i]->acct_id);
json_add_amount_msat_only(stream, "balance_msat", json_add_amount_msat(stream, "balance_msat",
snap->accts[i]->balance); snap->accts[i]->balance);
json_add_string(stream, "coin_type", snap->accts[i]->bip173_name); json_add_string(stream, "coin_type", snap->accts[i]->bip173_name);
json_object_end(stream); json_object_end(stream);
} }

View File

@@ -646,15 +646,15 @@ static void openchannel_hook_serialize(struct openchannel_hook_payload *payload,
json_add_node_id(stream, "id", &uc->peer->id); json_add_node_id(stream, "id", &uc->peer->id);
json_add_amount_sat_msat(stream, "funding_msat", json_add_amount_sat_msat(stream, "funding_msat",
payload->funding_satoshis); payload->funding_satoshis);
json_add_amount_msat_only(stream, "push_msat", payload->push_msat); json_add_amount_msat(stream, "push_msat", payload->push_msat);
json_add_amount_sat_msat(stream, "dust_limit_msat", json_add_amount_sat_msat(stream, "dust_limit_msat",
payload->dust_limit_satoshis); payload->dust_limit_satoshis);
json_add_amount_msat_only(stream, "max_htlc_value_in_flight_msat", json_add_amount_msat(stream, "max_htlc_value_in_flight_msat",
payload->max_htlc_value_in_flight_msat); payload->max_htlc_value_in_flight_msat);
json_add_amount_sat_msat(stream, "channel_reserve_msat", json_add_amount_sat_msat(stream, "channel_reserve_msat",
payload->channel_reserve_satoshis); payload->channel_reserve_satoshis);
json_add_amount_msat_only(stream, "htlc_minimum_msat", json_add_amount_msat(stream, "htlc_minimum_msat",
payload->htlc_minimum_msat); payload->htlc_minimum_msat);
json_add_num(stream, "feerate_per_kw", payload->feerate_per_kw); json_add_num(stream, "feerate_per_kw", payload->feerate_per_kw);
json_add_num(stream, "to_self_delay", payload->to_self_delay); json_add_num(stream, "to_self_delay", payload->to_self_delay);
json_add_num(stream, "max_accepted_htlcs", payload->max_accepted_htlcs); json_add_num(stream, "max_accepted_htlcs", payload->max_accepted_htlcs);

View File

@@ -1752,7 +1752,7 @@ static void add_config(struct lightningd *ld,
* --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) {
/* We allow -msat not _msat here, unlike /* We allow -msat not _msat here, unlike
* json_add_amount_msat_only */ * json_add_amount_msat */
assert(strends(name0, "-msat")); assert(strends(name0, "-msat"));
json_add_string(response, name0, json_add_string(response, name0,
fmt_amount_msat(tmpctx, fmt_amount_msat(tmpctx,

View File

@@ -887,8 +887,8 @@ static void json_add_channel(struct lightningd *ld,
} }
json_add_sat_only(response, "remote_funds_msat", total); json_add_sat_only(response, "remote_funds_msat", total);
json_add_amount_msat_only(response, "fee_paid_msat", json_add_amount_msat(response, "fee_paid_msat",
channel->push); channel->push);
} else { } else {
if (!amount_sat_add(&total, peer_funded_sats, funds)) { if (!amount_sat_add(&total, peer_funded_sats, funds)) {
log_broken(channel->log, log_broken(channel->log,
@@ -904,8 +904,8 @@ static void json_add_channel(struct lightningd *ld,
total = channel->our_funds; total = channel->our_funds;
} }
json_add_sat_only(response, "local_funds_msat", total); json_add_sat_only(response, "local_funds_msat", total);
json_add_amount_msat_only(response, "fee_rcvd_msat", json_add_amount_msat(response, "fee_rcvd_msat",
channel->push); channel->push);
} }
} else { } else {
@@ -913,8 +913,8 @@ static void json_add_channel(struct lightningd *ld,
channel->our_funds); channel->our_funds);
json_add_sat_only(response, "remote_funds_msat", json_add_sat_only(response, "remote_funds_msat",
peer_funded_sats); peer_funded_sats);
json_add_amount_msat_only(response, "pushed_msat", json_add_amount_msat(response, "pushed_msat",
channel->push); channel->push);
} }
json_object_end(response); json_object_end(response);
@@ -934,8 +934,8 @@ static void json_add_channel(struct lightningd *ld,
json_add_amount_msat(response, "total_msat", funding_msat); json_add_amount_msat(response, "total_msat", funding_msat);
/* routing fees */ /* routing fees */
json_add_amount_msat_only(response, "fee_base_msat", json_add_amount_msat(response, "fee_base_msat",
amount_msat(channel->feerate_base)); amount_msat(channel->feerate_base));
json_add_u32(response, "fee_proportional_millionths", json_add_u32(response, "fee_proportional_millionths",
channel->feerate_ppm); channel->feerate_ppm);
@@ -972,12 +972,12 @@ static void json_add_channel(struct lightningd *ld,
json_add_amount_msat(response, json_add_amount_msat(response,
"minimum_htlc_in_msat", "minimum_htlc_in_msat",
channel->our_config.htlc_minimum); channel->our_config.htlc_minimum);
json_add_amount_msat_only(response, json_add_amount_msat(response,
"minimum_htlc_out_msat", "minimum_htlc_out_msat",
channel->htlc_minimum_msat); channel->htlc_minimum_msat);
json_add_amount_msat_only(response, json_add_amount_msat(response,
"maximum_htlc_out_msat", "maximum_htlc_out_msat",
channel->htlc_maximum_msat); channel->htlc_maximum_msat);
/* The `to_self_delay` is imposed on the *other* /* The `to_self_delay` is imposed on the *other*
* side, so our configuration `to_self_delay` is * side, so our configuration `to_self_delay` is
@@ -2707,19 +2707,19 @@ static void set_channel_config(struct command *cmd, struct channel *channel,
/* setchannel lists these explicitly */ /* setchannel lists these explicitly */
if (add_details) { if (add_details) {
json_add_amount_msat_only(response, "fee_base_msat", json_add_amount_msat(response, "fee_base_msat",
amount_msat(channel->feerate_base)); amount_msat(channel->feerate_base));
json_add_u32(response, "fee_proportional_millionths", json_add_u32(response, "fee_proportional_millionths",
channel->feerate_ppm); channel->feerate_ppm);
json_add_amount_msat_only(response, json_add_amount_msat(response,
"minimum_htlc_out_msat", "minimum_htlc_out_msat",
channel->htlc_minimum_msat); channel->htlc_minimum_msat);
if (warn_cannot_set_min) if (warn_cannot_set_min)
json_add_string(response, "warning_htlcmin_too_low", json_add_string(response, "warning_htlcmin_too_low",
"Set minimum_htlc_out_msat to minimum allowed by peer"); "Set minimum_htlc_out_msat to minimum allowed by peer");
json_add_amount_msat_only(response, json_add_amount_msat(response,
"maximum_htlc_out_msat", "maximum_htlc_out_msat",
channel->htlc_maximum_msat); channel->htlc_maximum_msat);
if (warn_cannot_set_max) if (warn_cannot_set_max)
json_add_string(response, "warning_htlcmax_too_high", json_add_string(response, "warning_htlcmax_too_high",
"Set maximum_htlc_out_msat to maximum possible in channel"); "Set maximum_htlc_out_msat to maximum possible in channel");

View File

@@ -1088,14 +1088,14 @@ static void htlc_accepted_hook_serialize(struct htlc_accepted_hook_payload *p,
if (p->payload->forward_node_id) if (p->payload->forward_node_id)
json_add_pubkey(s, "next_node_id", json_add_pubkey(s, "next_node_id",
p->payload->forward_node_id); p->payload->forward_node_id);
json_add_amount_msat_only(s, "forward_msat", json_add_amount_msat(s, "forward_msat",
p->payload->amt_to_forward); p->payload->amt_to_forward);
json_add_u32(s, "outgoing_cltv_value", p->payload->outgoing_cltv); json_add_u32(s, "outgoing_cltv_value", p->payload->outgoing_cltv);
/* These are specified together in TLV, so only print total_msat /* These are specified together in TLV, so only print total_msat
* if payment_secret set (ie. modern, and final hop) */ * if payment_secret set (ie. modern, and final hop) */
if (p->payload->payment_secret) { if (p->payload->payment_secret) {
json_add_amount_msat_only(s, "total_msat", json_add_amount_msat(s, "total_msat",
*p->payload->total_msat); *p->payload->total_msat);
json_add_secret(s, "payment_secret", json_add_secret(s, "payment_secret",
p->payload->payment_secret); p->payload->payment_secret);
} }
@@ -1116,7 +1116,7 @@ static void htlc_accepted_hook_serialize(struct htlc_accepted_hook_payload *p,
s, "short_channel_id", s, "short_channel_id",
channel_scid_or_local_alias(hin->key.channel)); channel_scid_or_local_alias(hin->key.channel));
json_add_u64(s, "id", hin->key.id); json_add_u64(s, "id", hin->key.id);
json_add_amount_msat_only(s, "amount_msat", hin->msat); json_add_amount_msat(s, "amount_msat", hin->msat);
json_add_u32(s, "cltv_expiry", expiry); json_add_u32(s, "cltv_expiry", expiry);
json_add_s32(s, "cltv_expiry_relative", expiry - blockheight); json_add_s32(s, "cltv_expiry_relative", expiry - blockheight);
json_add_sha256(s, "payment_hash", &hin->payment_hash); json_add_sha256(s, "payment_hash", &hin->payment_hash);
@@ -3122,7 +3122,7 @@ static struct command_result *json_listhtlcs(struct command *cmd,
json_add_u32(response, "expiry", cltv_expiry); json_add_u32(response, "expiry", cltv_expiry);
json_add_string(response, "direction", json_add_string(response, "direction",
owner == LOCAL ? "out": "in"); owner == LOCAL ? "out": "in");
json_add_amount_msat_only(response, "amount_msat", msat); json_add_amount_msat(response, "amount_msat", msat);
json_add_sha256(response, "payment_hash", &payment_hash); json_add_sha256(response, "payment_hash", &payment_hash);
json_add_string(response, "state", htlc_state_name(hstate)); json_add_string(response, "state", htlc_state_name(hstate));
json_object_end(response); json_object_end(response);

View File

@@ -333,12 +333,12 @@ void json_add_address_internal(struct json_stream *response UNNEEDED,
const char *fieldname UNNEEDED, const char *fieldname UNNEEDED,
const struct wireaddr_internal *addr UNNEEDED) const struct wireaddr_internal *addr UNNEEDED)
{ fprintf(stderr, "json_add_address_internal called!\n"); abort(); } { fprintf(stderr, "json_add_address_internal called!\n"); abort(); }
/* Generated stub for json_add_amount_msat_only */ /* Generated stub for json_add_amount_msat */
void json_add_amount_msat_only(struct json_stream *result UNNEEDED, void json_add_amount_msat(struct json_stream *result UNNEEDED,
const char *msatfieldname UNNEEDED, const char *msatfieldname UNNEEDED,
struct amount_msat msat) struct amount_msat msat)
{ fprintf(stderr, "json_add_amount_msat_only called!\n"); abort(); } { fprintf(stderr, "json_add_amount_msat called!\n"); abort(); }
/* Generated stub for json_add_amount_sat_msat */ /* Generated stub for json_add_amount_sat_msat */
void json_add_amount_sat_msat(struct json_stream *result UNNEEDED, void json_add_amount_sat_msat(struct json_stream *result UNNEEDED,
const char *msatfieldname UNNEEDED, const char *msatfieldname UNNEEDED,

View File

@@ -281,11 +281,11 @@ static struct command_result *json_inspect(struct command *cmd,
fee_sum = find_sum_for_txid(fee_sums, set->txid); fee_sum = find_sum_for_txid(fee_sums, set->txid);
if (fee_sum) if (fee_sum)
json_add_amount_msat_only(res, "fees_paid_msat", json_add_amount_msat(res, "fees_paid_msat",
fee_sum->fees_paid); fee_sum->fees_paid);
else else
json_add_amount_msat_only(res, "fees_paid_msat", json_add_amount_msat(res, "fees_paid_msat",
AMOUNT_MSAT(0)); AMOUNT_MSAT(0));
json_array_start(res, "outputs"); json_array_start(res, "outputs");
for (size_t j = 0; j < tal_count(set->pairs); j++) { for (size_t j = 0; j < tal_count(set->pairs); j++) {
@@ -312,10 +312,10 @@ static struct command_result *json_inspect(struct command *cmd,
json_add_num(res, "outnum", json_add_num(res, "outnum",
ev->outpoint.n); ev->outpoint.n);
json_add_string(res, "output_tag", ev->tag); json_add_string(res, "output_tag", ev->tag);
json_add_amount_msat_only(res, "output_value_msat", json_add_amount_msat(res, "output_value_msat",
ev->output_value); ev->output_value);
json_add_amount_msat_only(res, "credit_msat", json_add_amount_msat(res, "credit_msat",
ev->credit); ev->credit);
json_add_string(res, "currency", ev->currency); json_add_string(res, "currency", ev->currency);
if (ev->origin_acct) if (ev->origin_acct)
json_add_string(res, "originating_account", json_add_string(res, "originating_account",
@@ -329,15 +329,17 @@ static struct command_result *json_inspect(struct command *cmd,
ev->acct_name); ev->acct_name);
json_add_num(res, "outnum", json_add_num(res, "outnum",
ev->outpoint.n); ev->outpoint.n);
json_add_amount_msat_only(res, "output_value_msat", json_add_amount_msat(res,
ev->output_value); "output_value_msat",
ev->output_value);
json_add_string(res, "currency", json_add_string(res, "currency",
ev->currency); ev->currency);
} }
json_add_string(res, "spend_tag", ev->tag); json_add_string(res, "spend_tag", ev->tag);
json_add_txid(res, "spending_txid", json_add_txid(res, "spending_txid",
ev->spending_txid); ev->spending_txid);
json_add_amount_msat_only(res, "debit_msat", ev->debit); json_add_amount_msat(res,
"debit_msat", ev->debit);
if (ev->payment_id) if (ev->payment_id)
json_add_sha256(res, "payment_id", json_add_sha256(res, "payment_id",
ev->payment_id); ev->payment_id);
@@ -507,8 +509,8 @@ static struct command_result *json_list_balances(struct command *cmd,
json_array_start(res, "balances"); json_array_start(res, "balances");
for (size_t j = 0; j < tal_count(balances); j++) { for (size_t j = 0; j < tal_count(balances); j++) {
json_object_start(res, NULL); json_object_start(res, NULL);
json_add_amount_msat_only(res, "balance_msat", json_add_amount_msat(res, "balance_msat",
balances[j]->balance); balances[j]->balance);
json_add_string(res, "coin_type", json_add_string(res, "coin_type",
balances[j]->currency); balances[j]->currency);
json_object_end(res); json_object_end(res);

View File

@@ -11,8 +11,8 @@ void json_add_chain_event(struct json_stream *out, struct chain_event *ev)
json_add_string(out, "origin", ev->origin_acct); json_add_string(out, "origin", ev->origin_acct);
json_add_string(out, "type", "chain"); json_add_string(out, "type", "chain");
json_add_string(out, "tag", ev->tag); json_add_string(out, "tag", ev->tag);
json_add_amount_msat_only(out, "credit_msat", ev->credit); json_add_amount_msat(out, "credit_msat", ev->credit);
json_add_amount_msat_only(out, "debit_msat", ev->debit); json_add_amount_msat(out, "debit_msat", ev->debit);
json_add_string(out, "currency", ev->currency); json_add_string(out, "currency", ev->currency);
json_add_outpoint(out, "outpoint", &ev->outpoint); json_add_outpoint(out, "outpoint", &ev->outpoint);

View File

@@ -39,10 +39,10 @@ void json_add_channel_event(struct json_stream *out,
json_add_string(out, "account", ev->acct_name); json_add_string(out, "account", ev->acct_name);
json_add_string(out, "type", "channel"); json_add_string(out, "type", "channel");
json_add_string(out, "tag", ev->tag); json_add_string(out, "tag", ev->tag);
json_add_amount_msat_only(out, "credit_msat", ev->credit); json_add_amount_msat(out, "credit_msat", ev->credit);
json_add_amount_msat_only(out, "debit_msat", ev->debit); json_add_amount_msat(out, "debit_msat", ev->debit);
if (!amount_msat_zero(ev->fees)) if (!amount_msat_zero(ev->fees))
json_add_amount_msat_only(out, "fees_msat", ev->fees); json_add_amount_msat(out, "fees_msat", ev->fees);
json_add_string(out, "currency", ev->currency); json_add_string(out, "currency", ev->currency);
if (ev->payment_id) { if (ev->payment_id) {
json_add_sha256(out, "payment_id", ev->payment_id); json_add_sha256(out, "payment_id", ev->payment_id);

View File

@@ -301,21 +301,21 @@ void json_add_channel_apy(struct json_stream *res,
json_add_string(res, "account", apy->acct_name); json_add_string(res, "account", apy->acct_name);
json_add_amount_msat_only(res, "routed_out_msat", apy->routed_out); json_add_amount_msat(res, "routed_out_msat", apy->routed_out);
json_add_amount_msat_only(res, "routed_in_msat", apy->routed_in); json_add_amount_msat(res, "routed_in_msat", apy->routed_in);
json_add_amount_msat_only(res, "lease_fee_paid_msat", apy->lease_out); json_add_amount_msat(res, "lease_fee_paid_msat", apy->lease_out);
json_add_amount_msat_only(res, "lease_fee_earned_msat", apy->lease_in); json_add_amount_msat(res, "lease_fee_earned_msat", apy->lease_in);
json_add_amount_msat_only(res, "pushed_out_msat", apy->push_out); json_add_amount_msat(res, "pushed_out_msat", apy->push_out);
json_add_amount_msat_only(res, "pushed_in_msat", apy->push_in); json_add_amount_msat(res, "pushed_in_msat", apy->push_in);
json_add_amount_msat_only(res, "our_start_balance_msat", apy->our_start_bal); json_add_amount_msat(res, "our_start_balance_msat", apy->our_start_bal);
json_add_amount_msat_only(res, "channel_start_balance_msat", json_add_amount_msat(res, "channel_start_balance_msat",
apy->total_start_bal); apy->total_start_bal);
ok = amount_msat_add(&total_fees, apy->fees_in, apy->fees_out); ok = amount_msat_add(&total_fees, apy->fees_in, apy->fees_out);
assert(ok); assert(ok);
json_add_amount_msat_only(res, "fees_out_msat", apy->fees_out); json_add_amount_msat(res, "fees_out_msat", apy->fees_out);
json_add_amount_msat_only(res, "fees_in_msat", apy->fees_in); json_add_amount_msat(res, "fees_in_msat", apy->fees_in);
/* utilization (out): routed_out/total_balance */ /* utilization (out): routed_out/total_balance */
assert(!amount_msat_zero(apy->total_start_bal)); assert(!amount_msat_zero(apy->total_start_bal));

View File

@@ -436,8 +436,8 @@ void json_add_income_event(struct json_stream *out, struct income_event *ev)
json_object_start(out, NULL); json_object_start(out, NULL);
json_add_string(out, "account", ev->acct_name); json_add_string(out, "account", ev->acct_name);
json_add_string(out, "tag", ev->tag); json_add_string(out, "tag", ev->tag);
json_add_amount_msat_only(out, "credit_msat", ev->credit); json_add_amount_msat(out, "credit_msat", ev->credit);
json_add_amount_msat_only(out, "debit_msat", ev->debit); json_add_amount_msat(out, "debit_msat", ev->debit);
json_add_string(out, "currency", ev->currency); json_add_string(out, "currency", ev->currency);
json_add_u64(out, "timestamp", ev->timestamp); json_add_u64(out, "timestamp", ev->timestamp);

View File

@@ -10,8 +10,8 @@ void json_add_onchain_fee(struct json_stream *out,
json_add_string(out, "account", fee->acct_name); json_add_string(out, "account", fee->acct_name);
json_add_string(out, "type", "onchain_fee"); json_add_string(out, "type", "onchain_fee");
json_add_string(out, "tag", "onchain_fee"); json_add_string(out, "tag", "onchain_fee");
json_add_amount_msat_only(out, "credit_msat", fee->credit); json_add_amount_msat(out, "credit_msat", fee->credit);
json_add_amount_msat_only(out, "debit_msat", fee->debit); json_add_amount_msat(out, "debit_msat", fee->debit);
json_add_string(out, "currency", fee->currency); json_add_string(out, "currency", fee->currency);
json_add_u64(out, "timestamp", fee->timestamp); json_add_u64(out, "timestamp", fee->timestamp);
json_add_txid(out, "txid", &fee->txid); json_add_txid(out, "txid", &fee->txid);

View File

@@ -272,8 +272,8 @@ static struct command_result *handle_invreq_response(struct command *cmd,
/* We always tell them this unless it's trivial to calc and /* We always tell them this unless it's trivial to calc and
* exactly as expected. */ * exactly as expected. */
if (!expected_amount || *inv->invoice_amount != *expected_amount) { if (!expected_amount || *inv->invoice_amount != *expected_amount) {
json_add_amount_msat_only(out, "amount_msat", json_add_amount_msat(out, "amount_msat",
amount_msat(*inv->invoice_amount)); amount_msat(*inv->invoice_amount));
} }
json_object_end(out); json_object_end(out);

View File

@@ -440,8 +440,7 @@ psbt_funded(struct command *cmd,
response = jsonrpc_stream_success(cmd); response = jsonrpc_stream_success(cmd);
json_add_string(response, "result", "continue"); json_add_string(response, "result", "continue");
json_add_psbt(response, "psbt", psbt); json_add_psbt(response, "psbt", psbt);
json_add_amount_msat_only(response, "our_funding_msat", json_add_amount_msat(response, "our_funding_msat", our_funding_msat);
our_funding_msat);
/* If we're accepting an lease request, *and* they've /* If we're accepting an lease request, *and* they've
* requested one, fill in our most recent infos */ * requested one, fill in our most recent infos */

View File

@@ -150,7 +150,7 @@ static void check_preapprovekeysend_start(void *d UNUSED, struct payment *p)
&preapprovekeysend_rpc_failure, p); &preapprovekeysend_rpc_failure, p);
json_add_node_id(req->js, "destination", p->destination); json_add_node_id(req->js, "destination", p->destination);
json_add_sha256(req->js, "payment_hash", p->payment_hash); json_add_sha256(req->js, "payment_hash", p->payment_hash);
json_add_amount_msat_only(req->js, "amount_msat", p->amount); json_add_amount_msat(req->js, "amount_msat", p->amount);
(void) send_outreq(p->plugin, req); (void) send_outreq(p->plugin, req);
} }

View File

@@ -1575,14 +1575,14 @@ static struct command_result *payment_createonion_success(struct command *cmd,
json_add_hex_talarr(req->js, "onion", p->createonion_response->onion); json_add_hex_talarr(req->js, "onion", p->createonion_response->onion);
json_object_start(req->js, "first_hop"); json_object_start(req->js, "first_hop");
json_add_amount_msat_only(req->js, "amount_msat", first->amount); json_add_amount_msat(req->js, "amount_msat", first->amount);
json_add_num(req->js, "delay", first->delay); json_add_num(req->js, "delay", first->delay);
json_add_node_id(req->js, "id", &first->node_id); json_add_node_id(req->js, "id", &first->node_id);
json_add_short_channel_id(req->js, "channel", &first->scid); json_add_short_channel_id(req->js, "channel", &first->scid);
json_object_end(req->js); json_object_end(req->js);
json_add_sha256(req->js, "payment_hash", p->payment_hash); json_add_sha256(req->js, "payment_hash", p->payment_hash);
json_add_amount_msat_only(req->js, "amount_msat", p->amount); json_add_amount_msat(req->js, "amount_msat", p->amount);
json_array_start(req->js, "shared_secrets"); json_array_start(req->js, "shared_secrets");
secrets = p->createonion_response->shared_secrets; secrets = p->createonion_response->shared_secrets;
@@ -1896,7 +1896,7 @@ 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_msat", p->amount); json_add_amount_msat(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);

View File

@@ -272,7 +272,7 @@ static bool json_add_blinded_paths(struct json_stream *js,
/* Don't crash if we're short a payinfo! */ /* Don't crash if we're short a payinfo! */
if (i < tal_count(blindedpay)) { if (i < tal_count(blindedpay)) {
json_object_start(js, "payinfo"); json_object_start(js, "payinfo");
json_add_amount_msat_only(js, "fee_base_msat", json_add_amount_msat(js, "fee_base_msat",
amount_msat(blindedpay[i]->fee_base_msat)); amount_msat(blindedpay[i]->fee_base_msat));
json_add_u32(js, "fee_proportional_millionths", json_add_u32(js, "fee_proportional_millionths",
blindedpay[i]->fee_proportional_millionths); blindedpay[i]->fee_proportional_millionths);
@@ -372,8 +372,8 @@ static bool json_add_offer_fields(struct json_stream *js,
json_add_string(js, "warning_unknown_offer_currency", json_add_string(js, "warning_unknown_offer_currency",
"unknown currency code"); "unknown currency code");
} else if (offer_amount) } else if (offer_amount)
json_add_amount_msat_only(js, "offer_amount_msat", json_add_amount_msat(js, "offer_amount_msat",
amount_msat(*offer_amount)); amount_msat(*offer_amount));
/* BOLT-offers #12: /* BOLT-offers #12:
* A reader of an offer: * A reader of an offer:
@@ -533,8 +533,8 @@ static bool json_add_invreq_fields(struct json_stream *js,
json_add_sha256(js, "invreq_chain", &invreq_chain->shad.sha); json_add_sha256(js, "invreq_chain", &invreq_chain->shad.sha);
if (invreq_amount) if (invreq_amount)
json_add_amount_msat_only(js, "invreq_amount_msat", json_add_amount_msat(js, "invreq_amount_msat",
amount_msat(*invreq_amount)); amount_msat(*invreq_amount));
if (invreq_features) if (invreq_features)
json_add_hex_talarr(js, "invreq_features", invreq_features); json_add_hex_talarr(js, "invreq_features", invreq_features);
if (invreq_quantity) if (invreq_quantity)
@@ -797,8 +797,8 @@ static void json_add_b12_invoice(struct json_stream *js,
* - MUST reject the invoice if `invoice_amount` is not present. * - MUST reject the invoice if `invoice_amount` is not present.
*/ */
if (invoice->invoice_amount) if (invoice->invoice_amount)
json_add_amount_msat_only(js, "invoice_amount_msat", json_add_amount_msat(js, "invoice_amount_msat",
amount_msat(*invoice->invoice_amount)); amount_msat(*invoice->invoice_amount));
else { else {
json_add_string(js, "warning_missing_invoice_amount", json_add_string(js, "warning_missing_invoice_amount",
"invoices without an amount are invalid"); "invoices without an amount are invalid");

View File

@@ -216,7 +216,7 @@ static struct command_result *json_paystatus(struct command *cmd,
if (p->invstring) if (p->invstring)
json_add_invstring(ret, p->invstring); json_add_invstring(ret, p->invstring);
json_add_amount_msat_only(ret, "amount_msat", p->amount); json_add_amount_msat(ret, "amount_msat", p->amount);
json_add_node_id(ret, "destination", p->destination); json_add_node_id(ret, "destination", p->destination);
@@ -406,10 +406,9 @@ static void add_new_entry(struct json_stream *ret,
/* This is only tallied for pending and successful payments, not /* This is only tallied for pending and successful payments, not
* failures. */ * failures. */
if (pm->amount != NULL && pm->num_nonfailed_parts > 0) if (pm->amount != NULL && pm->num_nonfailed_parts > 0)
json_add_amount_msat_only(ret, "amount_msat", *pm->amount); json_add_amount_msat(ret, "amount_msat", *pm->amount);
json_add_amount_msat_only(ret, "amount_sent_msat", json_add_amount_msat(ret, "amount_sent_msat", pm->amount_sent);
pm->amount_sent);
if (pm->num_nonfailed_parts > 1) if (pm->num_nonfailed_parts > 1)
json_add_u64(ret, "number_of_parts", json_add_u64(ret, "number_of_parts",
@@ -668,7 +667,7 @@ 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_msat", p->amount); json_add_amount_msat(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);

View File

@@ -1117,7 +1117,7 @@ fundchannel_start_dest(struct multifundchannel_destination *dest)
json_add_string(req->js, "feerate", mfc->feerate_str); json_add_string(req->js, "feerate", mfc->feerate_str);
json_add_bool(req->js, "announce", dest->announce); json_add_bool(req->js, "announce", dest->announce);
json_add_amount_msat_only(req->js, "push_msat", dest->push_msat); json_add_amount_msat(req->js, "push_msat", dest->push_msat);
if (dest->close_to_str) if (dest->close_to_str)
json_add_string(req->js, "close_to", dest->close_to_str); json_add_string(req->js, "close_to", dest->close_to_str);

View File

@@ -21,8 +21,6 @@ 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(); }
@@ -33,12 +31,12 @@ bigsize_t fromwire_bigsize(const u8 **cursor UNNEEDED, size_t *max UNNEEDED)
bool fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, bool fromwire_channel_id(const u8 **cursor UNNEEDED, size_t *max UNNEEDED,
struct channel_id *channel_id UNNEEDED) struct channel_id *channel_id UNNEEDED)
{ fprintf(stderr, "fromwire_channel_id called!\n"); abort(); } { fprintf(stderr, "fromwire_channel_id called!\n"); abort(); }
/* Generated stub for json_add_amount_msat_only */ /* Generated stub for json_add_amount_msat */
void json_add_amount_msat_only(struct json_stream *result UNNEEDED, void json_add_amount_msat(struct json_stream *result UNNEEDED,
const char *msatfieldname UNNEEDED, const char *msatfieldname UNNEEDED,
struct amount_msat msat) struct amount_msat msat)
{ fprintf(stderr, "json_add_amount_msat_only called!\n"); abort(); } { fprintf(stderr, "json_add_amount_msat called!\n"); abort(); }
/* Generated stub for json_add_hex_talarr */ /* Generated stub for json_add_hex_talarr */
void json_add_hex_talarr(struct json_stream *result UNNEEDED, void json_add_hex_talarr(struct json_stream *result UNNEEDED,
const char *fieldname UNNEEDED, const char *fieldname UNNEEDED,

View File

@@ -267,10 +267,10 @@ static void json_add_halfchan(struct json_stream *response,
json_add_num(response, "fee_per_millionth", json_add_num(response, "fee_per_millionth",
fee_proportional_millionths); fee_proportional_millionths);
json_add_num(response, "delay", c->half[dir].delay); json_add_num(response, "delay", c->half[dir].delay);
json_add_amount_msat_only(response, "htlc_minimum_msat", json_add_amount_msat(response, "htlc_minimum_msat",
htlc_minimum_msat); htlc_minimum_msat);
json_add_amount_msat_only(response, "htlc_maximum_msat", json_add_amount_msat(response, "htlc_maximum_msat",
htlc_maximum_msat); htlc_maximum_msat);
json_add_hex_talarr(response, "features", chanfeatures); json_add_hex_talarr(response, "features", chanfeatures);
json_object_end(response); json_object_end(response);
} }
@@ -574,21 +574,19 @@ static struct command_result *json_listincoming(struct command *cmd,
gossmap_node_get_id(gossmap, peer, &peer_id); gossmap_node_get_id(gossmap, peer, &peer_id);
json_add_node_id(js, "id", &peer_id); json_add_node_id(js, "id", &peer_id);
json_add_short_channel_id(js, "short_channel_id", &scid); json_add_short_channel_id(js, "short_channel_id", &scid);
json_add_amount_msat_only(js, "fee_base_msat", json_add_amount_msat(js, "fee_base_msat",
amount_msat(ourchan->half[!dir] amount_msat(ourchan->half[!dir].base_fee));
.base_fee)); json_add_amount_msat(js, "htlc_min_msat",
json_add_amount_msat_only(js, "htlc_min_msat", amount_msat(fp16_to_u64(ourchan->half[!dir]
amount_msat(fp16_to_u64(ourchan->half[!dir] .htlc_min)));
.htlc_min))); json_add_amount_msat(js, "htlc_max_msat",
json_add_amount_msat_only(js, "htlc_max_msat", amount_msat(fp16_to_u64(ourchan->half[!dir]
amount_msat(fp16_to_u64(ourchan->half[!dir] .htlc_max)));
.htlc_max)));
json_add_u32(js, "fee_proportional_millionths", json_add_u32(js, "fee_proportional_millionths",
ourchan->half[!dir].proportional_fee); ourchan->half[!dir].proportional_fee);
json_add_u32(js, "cltv_expiry_delta", ourchan->half[!dir].delay); json_add_u32(js, "cltv_expiry_delta", ourchan->half[!dir].delay);
json_add_amount_msat_only(js, "incoming_capacity_msat", json_add_amount_msat(js, "incoming_capacity_msat",
peer_capacity(gossmap, peer_capacity(gossmap, me, peer, ourchan));
me, peer, ourchan));
json_add_bool(js, "public", !ourchan->private); json_add_bool(js, "public", !ourchan->private);
peer_features = gossmap_node_get_features(tmpctx, gossmap, peer); peer_features = gossmap_node_get_features(tmpctx, gossmap, peer);
if (peer_features) if (peer_features)

View File

@@ -292,12 +292,12 @@ void json_add_address_internal(struct json_stream *response UNNEEDED,
const char *fieldname UNNEEDED, const char *fieldname UNNEEDED,
const struct wireaddr_internal *addr UNNEEDED) const struct wireaddr_internal *addr UNNEEDED)
{ fprintf(stderr, "json_add_address_internal called!\n"); abort(); } { fprintf(stderr, "json_add_address_internal called!\n"); abort(); }
/* Generated stub for json_add_amount_msat_only */ /* Generated stub for json_add_amount_msat */
void json_add_amount_msat_only(struct json_stream *result UNNEEDED, void json_add_amount_msat(struct json_stream *result UNNEEDED,
const char *msatfieldname UNNEEDED, const char *msatfieldname UNNEEDED,
struct amount_msat msat) struct amount_msat msat)
{ fprintf(stderr, "json_add_amount_msat_only called!\n"); abort(); } { fprintf(stderr, "json_add_amount_msat called!\n"); abort(); }
/* Generated stub for json_add_amount_sat_msat */ /* Generated stub for json_add_amount_sat_msat */
void json_add_amount_sat_msat(struct json_stream *result UNNEEDED, void json_add_amount_sat_msat(struct json_stream *result UNNEEDED,
const char *msatfieldname UNNEEDED, const char *msatfieldname UNNEEDED,