Skip to content

Commit

Permalink
json-rpc: Only show the amount_msat field if we know it in payments
Browse files Browse the repository at this point in the history
If we initiated the payment using an externally generated onion we don't know
what the final hop gets, or even who it is, so we don't display the amount in
these cases. I chose to show `null` instead in order not to break dependees
that rely on the value being there.
  • Loading branch information
cdecker committed Nov 28, 2019
1 parent 65342b1 commit f256bd8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lightningd/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,15 @@ void json_add_payment_fields(struct json_stream *response,
if (t->destination != NULL)
json_add_node_id(response, "destination", t->destination);

json_add_amount_msat_compat(response, t->msatoshi,
"msatoshi", "amount_msat");
/* If we have a 0 amount delivered at the remote end we simply don't
* know since the onion was generated externally. */
if (amount_msat_greater(t->msatoshi, AMOUNT_MSAT(0)))
json_add_amount_msat_compat(response, t->msatoshi, "msatoshi",
"amount_msat");
else
json_add_null(response, "amount_msat");


json_add_amount_msat_compat(response, t->msatoshi_sent,
"msatoshi_sent", "amount_sent_msat");
json_add_u64(response, "created_at", t->timestamp);
Expand Down

0 comments on commit f256bd8

Please sign in to comment.