mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
json-rpc: Only show the amount_msat field if we know it in payments
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.
This commit is contained in:
parent
82255e2401
commit
0b61781746
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user