Browse Source

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.
travis-debug
Christian Decker 5 years ago
parent
commit
0b61781746
  1. 11
      lightningd/pay.c

11
lightningd/pay.c

@ -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…
Cancel
Save