common/amount: make fmt_amount_sat / fmt_amount_msat etc take copy.

We pass by copy everywhere else, let's do it here too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2021-01-09 14:55:17 +10:30
committed by Christian Decker
parent 23af9d4972
commit 2de467274e
8 changed files with 43 additions and 31 deletions

View File

@@ -295,7 +295,7 @@ static struct command_result *listoffers_done(struct command *cmd,
/* We could allow invoices for less, I suppose. */
if (!amount_msat_eq(expected, amt))
return fail_inv(cmd, inv, "Expected invoice for %s",
fmt_amount_msat(tmpctx, &expected));
fmt_amount_msat(tmpctx, expected));
}
plugin_log(cmd->plugin, LOG_INFORM,

View File

@@ -1767,10 +1767,10 @@ static void add_new_entry(struct json_stream *ret,
* failures. */
if (pm->amount != NULL && pm->num_nonfailed_parts > 0)
json_add_string(ret, "amount_msat",
fmt_amount_msat(tmpctx, pm->amount));
fmt_amount_msat(tmpctx, *pm->amount));
json_add_string(ret, "amount_sent_msat",
fmt_amount_msat(tmpctx, &pm->amount_sent));
fmt_amount_msat(tmpctx, pm->amount_sent));
if (pm->num_nonfailed_parts > 1)
json_add_u64(ret, "number_of_parts",

View File

@@ -1050,7 +1050,7 @@ fundchannel_start_dest(struct multifundchannel_destination *dest)
json_add_node_id(req->js, "id", &dest->id);
assert(!dest->all);
json_add_string(req->js, "amount",
fmt_amount_sat(tmpctx, &dest->amount));
fmt_amount_sat(tmpctx, dest->amount));
if (mfc->cmtmt_feerate_str)
json_add_string(req->js, "feerate", mfc->cmtmt_feerate_str);
@@ -1058,7 +1058,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_string(req->js, "push_msat",
fmt_amount_msat(tmpctx, &dest->push_msat));
fmt_amount_msat(tmpctx, dest->push_msat));
if (dest->close_to_str)
json_add_string(req->js, "close_to", dest->close_to_str);

View File

@@ -1014,7 +1014,7 @@ openchannel_init_dest(struct multifundchannel_destination *dest)
json_add_node_id(req->js, "id", &dest->id);
assert(!dest->all);
json_add_string(req->js, "amount",
fmt_amount_sat(tmpctx, &dest->amount));
fmt_amount_sat(tmpctx, dest->amount));
/* Copy the original parent down */
tal_wally_start();