ElementsProject / lightning

Core Lightning — Lightning Network implementation focusing on spec compliance and performance
Other
2.81k stars 892 forks source link

need extra hop/route information on "listinvoices" command #2349

Open bidelakbari opened 5 years ago

bidelakbari commented 5 years ago

I searched the issues before creating one, but didn't find anything related.

Here is the situation: suppose my hub has about 10 inbound channels with other hubs, when I receive an invoice I want to know which one passed/routed the payment to me. currently I am tracking my inbound channels via in_payments_fulfilled but it is a tedious job to do. My question/suggestion: is there any way to have the hop/route information on listinvoices command?

"version": "v0.6.3"

m-schmoock commented 5 years ago

This would be possible by modifying lightningd/peer_htlcs.c +246

static void handle_localpay(struct htlc_in *hin, ...)

Currently this function calls the method that will mark the payment as PAID in line +333

wallet_invoice_resolve(ld->wallet, invoice, hin->msatoshi);

It seems straight forward to add the peer id of the incoming htlc_in towards the database and output the new value in in lightningd/invoice.c +41. For example we could name the new attributes in_scid and in_peer.

static void json_add_invoice(struct json_stream *response, const struct invoice_details *inv);

I think I can do this if @cdecker or @rustyrussell think this is a good idea.

ZmnSCPxj commented 5 years ago

A better solution might be a plugin hook on invoice payment, then a separate plugin which tracks this statistic.

We would not want to have the overhead of keeping this information around in our databases if most users do not need it.

cdecker commented 3 years ago

A better solution might be a plugin hook on invoice payment, then a separate plugin which tracks this statistic.

We would not want to have the overhead of keeping this information around in our databases if most users do not need it.

Note that this is already possible with the htlc_accepted hook. You'd have to match them manually to invoices, but nothing prevents you from doing that.