diff --git a/common/json_stream.c b/common/json_stream.c index 146af5847..a778d98bd 100644 --- a/common/json_stream.c +++ b/common/json_stream.c @@ -589,7 +589,7 @@ void json_add_psbt(struct json_stream *stream, 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, struct amount_msat msat) { @@ -604,7 +604,7 @@ void json_add_amount_sat_msat(struct json_stream *result, struct amount_msat msat; assert(strends(msatfieldname, "_msat")); 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, @@ -639,9 +639,9 @@ void json_add_lease_rates(struct json_stream *result, amount_sat(rates->lease_fee_base_sat)); json_add_num(result, "lease_fee_basis", rates->lease_fee_basis); json_add_num(result, "funding_weight", rates->funding_weight); - json_add_amount_msat_only(result, - "channel_fee_max_base_msat", - amount_msat(rates->channel_fee_max_base_msat)); + json_add_amount_msat(result, + "channel_fee_max_base_msat", + amount_msat(rates->channel_fee_max_base_msat)); json_add_num(result, "channel_fee_max_proportional_thousandths", rates->channel_fee_max_proportional_thousandths); } diff --git a/common/json_stream.h b/common/json_stream.h index 131589c0d..55a0e16a6 100644 --- a/common/json_stream.h +++ b/common/json_stream.h @@ -325,14 +325,11 @@ void json_add_address_internal(struct json_stream *response, const struct wireaddr_internal *addr); /* 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, struct amount_msat msat) NO_NULL_ARGS; -/* Compat shim */ -#define json_add_amount_msat json_add_amount_msat_only - /* Adds an 'msat' field */ void json_add_amount_sat_msat(struct json_stream *result, const char *msatfieldname, diff --git a/common/test/run-json.c b/common/test/run-json.c index a9dc6daa9..c0c292e93 100644 --- a/common/test/run-json.c +++ b/common/test/run-json.c @@ -10,8 +10,6 @@ #include /* AUTOGENERATED MOCKS START */ -/* Generated stub for deprecated_apis */ -bool deprecated_apis; /* Generated stub for fromwire_tlv */ bool fromwire_tlv(const u8 **cursor UNNEEDED, size_t *max UNNEEDED, const struct tlv_record_type *types UNNEEDED, size_t num_types UNNEEDED, diff --git a/common/test/run-json_filter.c b/common/test/run-json_filter.c index 5ac68b4fb..23704c0ee 100644 --- a/common/test/run-json_filter.c +++ b/common/test/run-json_filter.c @@ -230,7 +230,7 @@ int main(int argc, char *argv[]) json_object_start(js, NULL); 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) json_add_string(js, "type", "sometype"); json_add_string(js, "scriptPubKey", "00000000"); diff --git a/common/test/run-json_stream-filter.c b/common/test/run-json_stream-filter.c index dbd894b68..37729726c 100644 --- a/common/test/run-json_stream-filter.c +++ b/common/test/run-json_stream-filter.c @@ -55,8 +55,6 @@ struct command_result *command_fail(struct command *cmd UNNEEDED, enum jsonrpc_e /* Generated stub for command_filter_ptr */ struct json_filter **command_filter_ptr(struct command *cmd UNNEEDED) { fprintf(stderr, "command_filter_ptr called!\n"); abort(); } -/* Generated stub for deprecated_apis */ -bool deprecated_apis; /* Generated stub for fmt_amount_sat */ const char *fmt_amount_sat(const tal_t *ctx UNNEEDED, struct amount_sat sat UNNEEDED) { 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 */ void towire_u8_array(u8 **pptr UNNEEDED, const u8 *arr UNNEEDED, size_t num UNNEEDED) { 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 */ int main(int argc, char *argv[]) diff --git a/lightningd/dual_open_control.c b/lightningd/dual_open_control.c index 56716212c..d38a3f9c9 100644 --- a/lightningd/dual_open_control.c +++ b/lightningd/dual_open_control.c @@ -290,10 +290,10 @@ static void openchannel2_hook_serialize(struct openchannel2_payload *payload, json_add_amount_sat_msat(stream, "dust_limit_msat", payload->dust_limit_satoshis); - json_add_amount_msat_only(stream, "max_htlc_value_in_flight_msat", - payload->max_htlc_value_in_flight_msat); - json_add_amount_msat_only(stream, "htlc_minimum_msat", - payload->htlc_minimum_msat); + json_add_amount_msat(stream, "max_htlc_value_in_flight_msat", + payload->max_htlc_value_in_flight_msat); + json_add_amount_msat(stream, "htlc_minimum_msat", + payload->htlc_minimum_msat); json_add_num(stream, "funding_feerate_per_kw", payload->funding_feerate_per_kw); json_add_num(stream, "commitment_feerate_per_kw", diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index 6df2751ae..f576f07c6 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -437,8 +437,8 @@ static struct command_result *json_setleaserates(struct command *cmd, amount_sat(rates->lease_fee_base_sat)); json_add_num(res, "lease_fee_basis", rates->lease_fee_basis); json_add_num(res, "funding_weight", rates->funding_weight); - json_add_amount_msat_only(res, "channel_fee_max_base_msat", - amount_msat(rates->channel_fee_max_base_msat)); + json_add_amount_msat(res, "channel_fee_max_base_msat", + amount_msat(rates->channel_fee_max_base_msat)); json_add_num(res, "channel_fee_max_proportional_thousandths", rates->channel_fee_max_proportional_thousandths); diff --git a/lightningd/notification.c b/lightningd/notification.c index 33a05e953..aa1550f87 100644 --- a/lightningd/notification.c +++ b/lightningd/notification.c @@ -490,8 +490,8 @@ static void coin_movement_notification_serialize(struct json_stream *stream, json_add_string(stream, "originating_account", mvt->originating_acct); json_mvt_id(stream, mvt->type, &mvt->id); - json_add_amount_msat_only(stream, "credit_msat", mvt->credit); - json_add_amount_msat_only(stream, "debit_msat", mvt->debit); + json_add_amount_msat(stream, "credit_msat", mvt->credit); + json_add_amount_msat(stream, "debit_msat", mvt->debit); /* Only chain movements */ if (mvt->output_val) @@ -502,8 +502,7 @@ static void coin_movement_notification_serialize(struct json_stream *stream, mvt->output_count); if (mvt->fees) { - json_add_amount_msat_only(stream, "fees_msat", - *mvt->fees); + json_add_amount_msat(stream, "fees_msat", *mvt->fees); } 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_add_string(stream, "account_id", snap->accts[i]->acct_id); - json_add_amount_msat_only(stream, "balance_msat", - snap->accts[i]->balance); + json_add_amount_msat(stream, "balance_msat", + snap->accts[i]->balance); json_add_string(stream, "coin_type", snap->accts[i]->bip173_name); json_object_end(stream); } diff --git a/lightningd/opening_control.c b/lightningd/opening_control.c index 325b714f7..68a3b3037 100644 --- a/lightningd/opening_control.c +++ b/lightningd/opening_control.c @@ -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_amount_sat_msat(stream, "funding_msat", 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", payload->dust_limit_satoshis); - json_add_amount_msat_only(stream, "max_htlc_value_in_flight_msat", - payload->max_htlc_value_in_flight_msat); + json_add_amount_msat(stream, "max_htlc_value_in_flight_msat", + payload->max_htlc_value_in_flight_msat); json_add_amount_sat_msat(stream, "channel_reserve_msat", payload->channel_reserve_satoshis); - json_add_amount_msat_only(stream, "htlc_minimum_msat", - payload->htlc_minimum_msat); + json_add_amount_msat(stream, "htlc_minimum_msat", + payload->htlc_minimum_msat); 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, "max_accepted_htlcs", payload->max_accepted_htlcs); diff --git a/lightningd/options.c b/lightningd/options.c index 2ec7e3ec7..b35b93042 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -1752,7 +1752,7 @@ static void add_config(struct lightningd *ld, * --plugin for each one, so ignore these */ } else if (opt->cb_arg == (void *)opt_set_msat) { /* We allow -msat not _msat here, unlike - * json_add_amount_msat_only */ + * json_add_amount_msat */ assert(strends(name0, "-msat")); json_add_string(response, name0, fmt_amount_msat(tmpctx, diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index a4594c245..b9457e72f 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -887,8 +887,8 @@ static void json_add_channel(struct lightningd *ld, } json_add_sat_only(response, "remote_funds_msat", total); - json_add_amount_msat_only(response, "fee_paid_msat", - channel->push); + json_add_amount_msat(response, "fee_paid_msat", + channel->push); } else { if (!amount_sat_add(&total, peer_funded_sats, funds)) { log_broken(channel->log, @@ -904,8 +904,8 @@ static void json_add_channel(struct lightningd *ld, total = channel->our_funds; } json_add_sat_only(response, "local_funds_msat", total); - json_add_amount_msat_only(response, "fee_rcvd_msat", - channel->push); + json_add_amount_msat(response, "fee_rcvd_msat", + channel->push); } } else { @@ -913,8 +913,8 @@ static void json_add_channel(struct lightningd *ld, channel->our_funds); json_add_sat_only(response, "remote_funds_msat", peer_funded_sats); - json_add_amount_msat_only(response, "pushed_msat", - channel->push); + json_add_amount_msat(response, "pushed_msat", + channel->push); } 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); /* routing fees */ - json_add_amount_msat_only(response, "fee_base_msat", - amount_msat(channel->feerate_base)); + json_add_amount_msat(response, "fee_base_msat", + amount_msat(channel->feerate_base)); json_add_u32(response, "fee_proportional_millionths", channel->feerate_ppm); @@ -972,12 +972,12 @@ static void json_add_channel(struct lightningd *ld, json_add_amount_msat(response, "minimum_htlc_in_msat", channel->our_config.htlc_minimum); - json_add_amount_msat_only(response, - "minimum_htlc_out_msat", - channel->htlc_minimum_msat); - json_add_amount_msat_only(response, - "maximum_htlc_out_msat", - channel->htlc_maximum_msat); + json_add_amount_msat(response, + "minimum_htlc_out_msat", + channel->htlc_minimum_msat); + json_add_amount_msat(response, + "maximum_htlc_out_msat", + channel->htlc_maximum_msat); /* The `to_self_delay` is imposed on the *other* * 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 */ if (add_details) { - json_add_amount_msat_only(response, "fee_base_msat", - amount_msat(channel->feerate_base)); + json_add_amount_msat(response, "fee_base_msat", + amount_msat(channel->feerate_base)); json_add_u32(response, "fee_proportional_millionths", channel->feerate_ppm); - json_add_amount_msat_only(response, - "minimum_htlc_out_msat", - channel->htlc_minimum_msat); + json_add_amount_msat(response, + "minimum_htlc_out_msat", + channel->htlc_minimum_msat); if (warn_cannot_set_min) json_add_string(response, "warning_htlcmin_too_low", "Set minimum_htlc_out_msat to minimum allowed by peer"); - json_add_amount_msat_only(response, - "maximum_htlc_out_msat", - channel->htlc_maximum_msat); + json_add_amount_msat(response, + "maximum_htlc_out_msat", + channel->htlc_maximum_msat); if (warn_cannot_set_max) json_add_string(response, "warning_htlcmax_too_high", "Set maximum_htlc_out_msat to maximum possible in channel"); diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index d1ba1912b..6c4c1c169 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -1088,14 +1088,14 @@ static void htlc_accepted_hook_serialize(struct htlc_accepted_hook_payload *p, if (p->payload->forward_node_id) json_add_pubkey(s, "next_node_id", p->payload->forward_node_id); - json_add_amount_msat_only(s, "forward_msat", - p->payload->amt_to_forward); + json_add_amount_msat(s, "forward_msat", + p->payload->amt_to_forward); json_add_u32(s, "outgoing_cltv_value", p->payload->outgoing_cltv); /* These are specified together in TLV, so only print total_msat * if payment_secret set (ie. modern, and final hop) */ if (p->payload->payment_secret) { - json_add_amount_msat_only(s, "total_msat", - *p->payload->total_msat); + json_add_amount_msat(s, "total_msat", + *p->payload->total_msat); json_add_secret(s, "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", channel_scid_or_local_alias(hin->key.channel)); 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_s32(s, "cltv_expiry_relative", expiry - blockheight); 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_string(response, "direction", 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_string(response, "state", htlc_state_name(hstate)); json_object_end(response); diff --git a/lightningd/test/run-invoice-select-inchan.c b/lightningd/test/run-invoice-select-inchan.c index 47feb56a5..58a8715bb 100644 --- a/lightningd/test/run-invoice-select-inchan.c +++ b/lightningd/test/run-invoice-select-inchan.c @@ -333,12 +333,12 @@ void json_add_address_internal(struct json_stream *response UNNEEDED, const char *fieldname UNNEEDED, const struct wireaddr_internal *addr UNNEEDED) { fprintf(stderr, "json_add_address_internal called!\n"); abort(); } -/* Generated stub for json_add_amount_msat_only */ -void json_add_amount_msat_only(struct json_stream *result UNNEEDED, +/* Generated stub for json_add_amount_msat */ +void json_add_amount_msat(struct json_stream *result UNNEEDED, const char *msatfieldname UNNEEDED, 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 */ void json_add_amount_sat_msat(struct json_stream *result UNNEEDED, const char *msatfieldname UNNEEDED, diff --git a/plugins/bkpr/bookkeeper.c b/plugins/bkpr/bookkeeper.c index 0668895ab..320d230d7 100644 --- a/plugins/bkpr/bookkeeper.c +++ b/plugins/bkpr/bookkeeper.c @@ -281,11 +281,11 @@ static struct command_result *json_inspect(struct command *cmd, fee_sum = find_sum_for_txid(fee_sums, set->txid); if (fee_sum) - json_add_amount_msat_only(res, "fees_paid_msat", - fee_sum->fees_paid); + json_add_amount_msat(res, "fees_paid_msat", + fee_sum->fees_paid); else - json_add_amount_msat_only(res, "fees_paid_msat", - AMOUNT_MSAT(0)); + json_add_amount_msat(res, "fees_paid_msat", + AMOUNT_MSAT(0)); json_array_start(res, "outputs"); 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", ev->outpoint.n); json_add_string(res, "output_tag", ev->tag); - json_add_amount_msat_only(res, "output_value_msat", - ev->output_value); - json_add_amount_msat_only(res, "credit_msat", - ev->credit); + json_add_amount_msat(res, "output_value_msat", + ev->output_value); + json_add_amount_msat(res, "credit_msat", + ev->credit); json_add_string(res, "currency", ev->currency); if (ev->origin_acct) json_add_string(res, "originating_account", @@ -329,15 +329,17 @@ static struct command_result *json_inspect(struct command *cmd, ev->acct_name); json_add_num(res, "outnum", ev->outpoint.n); - json_add_amount_msat_only(res, "output_value_msat", - ev->output_value); + json_add_amount_msat(res, + "output_value_msat", + ev->output_value); json_add_string(res, "currency", ev->currency); } json_add_string(res, "spend_tag", ev->tag); json_add_txid(res, "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) json_add_sha256(res, "payment_id", ev->payment_id); @@ -507,8 +509,8 @@ static struct command_result *json_list_balances(struct command *cmd, json_array_start(res, "balances"); for (size_t j = 0; j < tal_count(balances); j++) { json_object_start(res, NULL); - json_add_amount_msat_only(res, "balance_msat", - balances[j]->balance); + json_add_amount_msat(res, "balance_msat", + balances[j]->balance); json_add_string(res, "coin_type", balances[j]->currency); json_object_end(res); diff --git a/plugins/bkpr/chain_event.c b/plugins/bkpr/chain_event.c index 639930333..a8e75028c 100644 --- a/plugins/bkpr/chain_event.c +++ b/plugins/bkpr/chain_event.c @@ -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, "type", "chain"); json_add_string(out, "tag", ev->tag); - json_add_amount_msat_only(out, "credit_msat", ev->credit); - json_add_amount_msat_only(out, "debit_msat", ev->debit); + json_add_amount_msat(out, "credit_msat", ev->credit); + json_add_amount_msat(out, "debit_msat", ev->debit); json_add_string(out, "currency", ev->currency); json_add_outpoint(out, "outpoint", &ev->outpoint); diff --git a/plugins/bkpr/channel_event.c b/plugins/bkpr/channel_event.c index 89646b964..a050ba490 100644 --- a/plugins/bkpr/channel_event.c +++ b/plugins/bkpr/channel_event.c @@ -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, "type", "channel"); json_add_string(out, "tag", ev->tag); - json_add_amount_msat_only(out, "credit_msat", ev->credit); - json_add_amount_msat_only(out, "debit_msat", ev->debit); + json_add_amount_msat(out, "credit_msat", ev->credit); + json_add_amount_msat(out, "debit_msat", ev->debit); 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); if (ev->payment_id) { json_add_sha256(out, "payment_id", ev->payment_id); diff --git a/plugins/bkpr/channelsapy.c b/plugins/bkpr/channelsapy.c index aba855667..4e81efa6c 100644 --- a/plugins/bkpr/channelsapy.c +++ b/plugins/bkpr/channelsapy.c @@ -301,21 +301,21 @@ void json_add_channel_apy(struct json_stream *res, json_add_string(res, "account", apy->acct_name); - json_add_amount_msat_only(res, "routed_out_msat", apy->routed_out); - json_add_amount_msat_only(res, "routed_in_msat", apy->routed_in); - json_add_amount_msat_only(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_only(res, "pushed_out_msat", apy->push_out); - json_add_amount_msat_only(res, "pushed_in_msat", apy->push_in); + json_add_amount_msat(res, "routed_out_msat", apy->routed_out); + json_add_amount_msat(res, "routed_in_msat", apy->routed_in); + json_add_amount_msat(res, "lease_fee_paid_msat", apy->lease_out); + json_add_amount_msat(res, "lease_fee_earned_msat", apy->lease_in); + json_add_amount_msat(res, "pushed_out_msat", apy->push_out); + 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_only(res, "channel_start_balance_msat", - apy->total_start_bal); + json_add_amount_msat(res, "our_start_balance_msat", apy->our_start_bal); + json_add_amount_msat(res, "channel_start_balance_msat", + apy->total_start_bal); ok = amount_msat_add(&total_fees, apy->fees_in, apy->fees_out); assert(ok); - json_add_amount_msat_only(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_out_msat", apy->fees_out); + json_add_amount_msat(res, "fees_in_msat", apy->fees_in); /* utilization (out): routed_out/total_balance */ assert(!amount_msat_zero(apy->total_start_bal)); diff --git a/plugins/bkpr/incomestmt.c b/plugins/bkpr/incomestmt.c index 1a9502a48..aa600335f 100644 --- a/plugins/bkpr/incomestmt.c +++ b/plugins/bkpr/incomestmt.c @@ -436,8 +436,8 @@ void json_add_income_event(struct json_stream *out, struct income_event *ev) json_object_start(out, NULL); json_add_string(out, "account", ev->acct_name); json_add_string(out, "tag", ev->tag); - json_add_amount_msat_only(out, "credit_msat", ev->credit); - json_add_amount_msat_only(out, "debit_msat", ev->debit); + json_add_amount_msat(out, "credit_msat", ev->credit); + json_add_amount_msat(out, "debit_msat", ev->debit); json_add_string(out, "currency", ev->currency); json_add_u64(out, "timestamp", ev->timestamp); diff --git a/plugins/bkpr/onchain_fee.c b/plugins/bkpr/onchain_fee.c index b4667c14b..de4fea0e6 100644 --- a/plugins/bkpr/onchain_fee.c +++ b/plugins/bkpr/onchain_fee.c @@ -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, "type", "onchain_fee"); json_add_string(out, "tag", "onchain_fee"); - json_add_amount_msat_only(out, "credit_msat", fee->credit); - json_add_amount_msat_only(out, "debit_msat", fee->debit); + json_add_amount_msat(out, "credit_msat", fee->credit); + json_add_amount_msat(out, "debit_msat", fee->debit); json_add_string(out, "currency", fee->currency); json_add_u64(out, "timestamp", fee->timestamp); json_add_txid(out, "txid", &fee->txid); diff --git a/plugins/fetchinvoice.c b/plugins/fetchinvoice.c index 89f7b38d4..98b8e4587 100644 --- a/plugins/fetchinvoice.c +++ b/plugins/fetchinvoice.c @@ -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 * exactly as expected. */ if (!expected_amount || *inv->invoice_amount != *expected_amount) { - json_add_amount_msat_only(out, "amount_msat", - amount_msat(*inv->invoice_amount)); + json_add_amount_msat(out, "amount_msat", + amount_msat(*inv->invoice_amount)); } json_object_end(out); diff --git a/plugins/funder.c b/plugins/funder.c index d147540c1..877c5a08e 100644 --- a/plugins/funder.c +++ b/plugins/funder.c @@ -440,8 +440,7 @@ psbt_funded(struct command *cmd, response = jsonrpc_stream_success(cmd); json_add_string(response, "result", "continue"); json_add_psbt(response, "psbt", psbt); - json_add_amount_msat_only(response, "our_funding_msat", - our_funding_msat); + json_add_amount_msat(response, "our_funding_msat", our_funding_msat); /* If we're accepting an lease request, *and* they've * requested one, fill in our most recent infos */ diff --git a/plugins/keysend.c b/plugins/keysend.c index 359f434bc..807b375bb 100644 --- a/plugins/keysend.c +++ b/plugins/keysend.c @@ -150,7 +150,7 @@ static void check_preapprovekeysend_start(void *d UNUSED, struct payment *p) &preapprovekeysend_rpc_failure, p); json_add_node_id(req->js, "destination", p->destination); 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); } diff --git a/plugins/libplugin-pay.c b/plugins/libplugin-pay.c index 8a7bca987..ce3220c47 100644 --- a/plugins/libplugin-pay.c +++ b/plugins/libplugin-pay.c @@ -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_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_node_id(req->js, "id", &first->node_id); json_add_short_channel_id(req->js, "channel", &first->scid); json_object_end(req->js); 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"); 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_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) json_add_u64(s, "parent_partid", p->parent->partid); diff --git a/plugins/offers.c b/plugins/offers.c index 5dadd97ed..30aa21898 100644 --- a/plugins/offers.c +++ b/plugins/offers.c @@ -272,7 +272,7 @@ static bool json_add_blinded_paths(struct json_stream *js, /* Don't crash if we're short a payinfo! */ if (i < tal_count(blindedpay)) { 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)); json_add_u32(js, "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", "unknown currency code"); } else if (offer_amount) - json_add_amount_msat_only(js, "offer_amount_msat", - amount_msat(*offer_amount)); + json_add_amount_msat(js, "offer_amount_msat", + amount_msat(*offer_amount)); /* BOLT-offers #12: * 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); if (invreq_amount) - json_add_amount_msat_only(js, "invreq_amount_msat", - amount_msat(*invreq_amount)); + json_add_amount_msat(js, "invreq_amount_msat", + amount_msat(*invreq_amount)); if (invreq_features) json_add_hex_talarr(js, "invreq_features", invreq_features); 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. */ if (invoice->invoice_amount) - json_add_amount_msat_only(js, "invoice_amount_msat", - amount_msat(*invoice->invoice_amount)); + json_add_amount_msat(js, "invoice_amount_msat", + amount_msat(*invoice->invoice_amount)); else { json_add_string(js, "warning_missing_invoice_amount", "invoices without an amount are invalid"); diff --git a/plugins/pay.c b/plugins/pay.c index fa1751429..e849b415e 100644 --- a/plugins/pay.c +++ b/plugins/pay.c @@ -216,7 +216,7 @@ static struct command_result *json_paystatus(struct command *cmd, if (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); @@ -406,10 +406,9 @@ static void add_new_entry(struct json_stream *ret, /* This is only tallied for pending and successful payments, not * failures. */ 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", - pm->amount_sent); + json_add_amount_msat(ret, "amount_sent_msat", pm->amount_sent); if (pm->num_nonfailed_parts > 1) 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_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) json_add_u64(s, "parent_partid", p->parent->partid); diff --git a/plugins/spender/multifundchannel.c b/plugins/spender/multifundchannel.c index 9b6c48f73..28a578c07 100644 --- a/plugins/spender/multifundchannel.c +++ b/plugins/spender/multifundchannel.c @@ -1117,7 +1117,7 @@ fundchannel_start_dest(struct multifundchannel_destination *dest) json_add_string(req->js, "feerate", mfc->feerate_str); 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) json_add_string(req->js, "close_to", dest->close_to_str); diff --git a/plugins/test/run-route-overlong.c b/plugins/test/run-route-overlong.c index b4e876e9c..c78350126 100644 --- a/plugins/test/run-route-overlong.c +++ b/plugins/test/run-route-overlong.c @@ -21,8 +21,6 @@ struct command_result *command_finished(struct command *cmd UNNEEDED, struct jso /* Generated stub for command_still_pending */ struct command_result *command_still_pending(struct command *cmd UNNEEDED) { fprintf(stderr, "command_still_pending called!\n"); abort(); } -/* Generated stub for deprecated_apis */ -bool deprecated_apis; /* Generated stub for feature_offered */ bool feature_offered(const u8 *features UNNEEDED, size_t f UNNEEDED) { 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, struct channel_id *channel_id UNNEEDED) { fprintf(stderr, "fromwire_channel_id called!\n"); abort(); } -/* Generated stub for json_add_amount_msat_only */ -void json_add_amount_msat_only(struct json_stream *result UNNEEDED, +/* Generated stub for json_add_amount_msat */ +void json_add_amount_msat(struct json_stream *result UNNEEDED, const char *msatfieldname UNNEEDED, 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 */ void json_add_hex_talarr(struct json_stream *result UNNEEDED, const char *fieldname UNNEEDED, diff --git a/plugins/topology.c b/plugins/topology.c index 570b0682b..c6def06ce 100644 --- a/plugins/topology.c +++ b/plugins/topology.c @@ -267,10 +267,10 @@ static void json_add_halfchan(struct json_stream *response, json_add_num(response, "fee_per_millionth", fee_proportional_millionths); json_add_num(response, "delay", c->half[dir].delay); - json_add_amount_msat_only(response, "htlc_minimum_msat", - htlc_minimum_msat); - json_add_amount_msat_only(response, "htlc_maximum_msat", - htlc_maximum_msat); + json_add_amount_msat(response, "htlc_minimum_msat", + htlc_minimum_msat); + json_add_amount_msat(response, "htlc_maximum_msat", + htlc_maximum_msat); json_add_hex_talarr(response, "features", chanfeatures); 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); json_add_node_id(js, "id", &peer_id); json_add_short_channel_id(js, "short_channel_id", &scid); - json_add_amount_msat_only(js, "fee_base_msat", - amount_msat(ourchan->half[!dir] - .base_fee)); - json_add_amount_msat_only(js, "htlc_min_msat", - amount_msat(fp16_to_u64(ourchan->half[!dir] - .htlc_min))); - json_add_amount_msat_only(js, "htlc_max_msat", - amount_msat(fp16_to_u64(ourchan->half[!dir] - .htlc_max))); + json_add_amount_msat(js, "fee_base_msat", + amount_msat(ourchan->half[!dir].base_fee)); + json_add_amount_msat(js, "htlc_min_msat", + amount_msat(fp16_to_u64(ourchan->half[!dir] + .htlc_min))); + json_add_amount_msat(js, "htlc_max_msat", + amount_msat(fp16_to_u64(ourchan->half[!dir] + .htlc_max))); json_add_u32(js, "fee_proportional_millionths", ourchan->half[!dir].proportional_fee); json_add_u32(js, "cltv_expiry_delta", ourchan->half[!dir].delay); - json_add_amount_msat_only(js, "incoming_capacity_msat", - peer_capacity(gossmap, - me, peer, ourchan)); + json_add_amount_msat(js, "incoming_capacity_msat", + peer_capacity(gossmap, me, peer, ourchan)); json_add_bool(js, "public", !ourchan->private); peer_features = gossmap_node_get_features(tmpctx, gossmap, peer); if (peer_features) diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index 45cbb63e6..4f00783fe 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -292,12 +292,12 @@ void json_add_address_internal(struct json_stream *response UNNEEDED, const char *fieldname UNNEEDED, const struct wireaddr_internal *addr UNNEEDED) { fprintf(stderr, "json_add_address_internal called!\n"); abort(); } -/* Generated stub for json_add_amount_msat_only */ -void json_add_amount_msat_only(struct json_stream *result UNNEEDED, +/* Generated stub for json_add_amount_msat */ +void json_add_amount_msat(struct json_stream *result UNNEEDED, const char *msatfieldname UNNEEDED, 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 */ void json_add_amount_sat_msat(struct json_stream *result UNNEEDED, const char *msatfieldname UNNEEDED,