Skip to content

Commit 3a2b703

Browse files
vincenzopalazzoShahanaFarooqui
authored andcommitted
jsonrpc: Remove the old "_msat" prefix in the listpeerchannels command
This is a regression that we introduced in this release due to some dirty parts of our codebase. For historical reasons (I think), we were using a `json_add_sat_only` procedure defined in `peer_control.c`. So when @rustyrussell removed the _msat, we thought that all the fields were reflecting the new behavior, but we were wrong. This PR fixes this bug and also removes the additional function from `peer_control.c`. This way, we can be sure that there is no other part of our codebase that uses this method (except for other `json_add` methods). Link: #6244 Reported-by: @hMsats Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent fe5f3ce commit 3a2b703

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

lightningd/peer_control.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -486,18 +486,6 @@ static void json_add_htlcs(struct lightningd *ld,
486486
json_array_end(response);
487487
}
488488

489-
/* We do this replication manually because it's an array. */
490-
static void json_add_sat_only(struct json_stream *result,
491-
const char *fieldname,
492-
struct amount_sat sat)
493-
{
494-
struct amount_msat msat;
495-
496-
if (amount_sat_to_msat(&msat, sat))
497-
json_add_string(result, fieldname,
498-
type_to_string(tmpctx, struct amount_msat, &msat));
499-
}
500-
501489
/* Fee a commitment transaction would currently cost */
502490
static struct amount_sat commit_txfee(const struct channel *channel,
503491
struct amount_msat amount,
@@ -900,15 +888,15 @@ static void json_add_channel(struct lightningd *ld,
900888
"Overflow adding our_funds to push");
901889
total = channel->our_funds;
902890
}
903-
json_add_sat_only(response, "local_funds_msat", total);
891+
json_add_amount_sat_msat(response, "local_funds_msat", total);
904892

905893
if (!amount_sat_sub(&total, peer_funded_sats, funds)) {
906894
log_broken(channel->log,
907895
"Underflow sub'ing push from"
908896
" peer's funds");
909897
total = peer_funded_sats;
910898
}
911-
json_add_sat_only(response, "remote_funds_msat", total);
899+
json_add_amount_sat_msat(response, "remote_funds_msat", total);
912900

913901
json_add_amount_msat(response, "fee_paid_msat",
914902
channel->push);
@@ -918,23 +906,23 @@ static void json_add_channel(struct lightningd *ld,
918906
"Overflow adding peer funds to push");
919907
total = peer_funded_sats;
920908
}
921-
json_add_sat_only(response, "remote_funds_msat", total);
909+
json_add_amount_sat_msat(response, "remote_funds_msat", total);
922910

923911
if (!amount_sat_sub(&total, channel->our_funds, funds)) {
924912
log_broken(channel->log,
925913
"Underflow sub'ing push from"
926914
" our_funds");
927915
total = channel->our_funds;
928916
}
929-
json_add_sat_only(response, "local_funds_msat", total);
917+
json_add_amount_sat_msat(response, "local_funds_msat", total);
930918
json_add_amount_msat(response, "fee_rcvd_msat",
931919
channel->push);
932920
}
933921

934922
} else {
935-
json_add_sat_only(response, "local_funds_msat",
923+
json_add_amount_sat_msat(response, "local_funds_msat",
936924
channel->our_funds);
937-
json_add_sat_only(response, "remote_funds_msat",
925+
json_add_amount_sat_msat(response, "remote_funds_msat",
938926
peer_funded_sats);
939927
json_add_amount_msat(response, "pushed_msat",
940928
channel->push);

0 commit comments

Comments
 (0)