cryptosharks131 / lndg

Lite GUI web interface to analyze lnd data and leverage the backend database for automation tools around rebalancing and other basic maintenance tasks.
MIT License
219 stars 41 forks source link

[bug]: Incorrectly shown forwarded payments amount #374

Open mabeebam opened 8 months ago

mabeebam commented 8 months ago

Background

Occationally, forwarded payments are shown with incorrect amount. Unclear when it exactly happens. Observed with different peers, but not consistenly. For some forwards wrong, for others right. It seems to be forward specific.

I guess it is related to formatting of amounts.

Example forward for a channel with zero base fee and 400 ppm : lncli fwdinghistory:

...
        {
            "timestamp":  "<timestamp>",
            "chan_id_in":  "<in-channel-id>",
            "chan_id_out":  "<out-channel-id>",
            "amt_in":  "937",
            "amt_out":  "937",
            "fee":  "0",
            "fee_msat":  "374",
            "amt_in_msat":  "937467",
            "amt_out_msat":  "937093",
            "timestamp_ns":  "<timestamp>",
            "peer_alias_in":  "<in-peer>",
            "peer_alias_out":  "<out-peer>"
        },
...

In Thunderhub and Raspiblitz the forward is correctly shown with amount 937 sats and fee 374 msats.

The same forward is shown incorrectly in lndg (see last row of screenshot, other rows are forwards of the same in/out-peers with unchanged same PPM): bug

Environment

Steps to reproduce

Unclear.

Expected behaviour

Amounts shown as within lncli.

Actual behaviour

Amounts sometimes shown wrong.

cryptosharks131 commented 7 months ago

The last row here appears to match what you have shown from lncli, the ones above seem odd to me, what do these other records look like from lncli?

mabeebam commented 7 months ago

Hi @cryptosharks131,

Thank you for checking the issue. Have a closer look, the five "Payments Routed" shown in the screenshot have all the same in-peer and out-peer with unchanged=same fee 400ppm.

  1. 1.209 for fee earned 0,483 sats
  2. 1.254 for fee earned 0,501 sats
  3. 1.370 for fee earned 0,548 sats
  4. 1.133 for fee earned 0,453 sats
  5. 937.467 for fee earned 0,374 sats

The last row as shown by lncli output is a payment with 937,467 sats but is shown as 937.467 sats.

BR

cryptosharks131 commented 7 months ago

I do see that, it is odd. I was hoping to get an example of both a record that looked okay and one that was wrong.

Another good comparison would be seeing what is in the LNDg api data that is feeding the page, you can browse the api data from this url: /api/forwards/

I have not been able to replicate this but I suspect this is some sort of browser language issue when the page is rendering.

mabeebam commented 7 months ago

Hi @cryptosharks131,

Here a lncli fwdinghistory output for a couple of forwarding records, some of them ok, some of them shown wrong:

{
    "forwarding_events":  [
        {
            "timestamp":  "<timestamp>",
            "chan_id_in":  "<in-channel-id>",
            "chan_id_out":  "<out-channel-id>",
            "amt_in":  "1063",
            "amt_out":  "1063",
            "fee":  "0",
            "fee_msat":  "425",
            "amt_in_msat":  "1063531",
            "amt_out_msat":  "1063106",
            "timestamp_ns":  "<timestamp>",
            "peer_alias_in":  "<in-peer>",
            "peer_alias_out":  "<out-peer>"
        },
        {
            "timestamp":  "<timestamp>",
            "chan_id_in":  "<in-channel-id>",
            "chan_id_out":  "<out-channel-id>",
            "amt_in":  "996",
            "amt_out":  "996",
            "fee":  "0",
            "fee_msat":  "398",
            "amt_in_msat":  "996506",
            "amt_out_msat":  "996108",
            "timestamp_ns":  "<timestamp>",
            "peer_alias_in":  "<in-peer>",
            "peer_alias_out":  "<out-peer>"
        },
        {
            "timestamp":  "<timestamp>",
            "chan_id_in":  "<in-channel-id>",
            "chan_id_out":  "<out-channel-id>",
            "amt_in":  "1205",
            "amt_out":  "1205",
            "fee":  "0",
            "fee_msat":  "482",
            "amt_in_msat":  "1205614",
            "amt_out_msat":  "1205132",
            "timestamp_ns":  "<timestamp>",
            "peer_alias_in":  "<in-peer>",
            "peer_alias_out":  "<out-peer>"
        },
        {
            "timestamp":  "<timestamp>",
            "chan_id_in":  "<in-channel-id>",
            "chan_id_out":  "<out-channel-id>",
            "amt_in":  "1458",
            "amt_out":  "1458",
            "fee":  "0",
            "fee_msat":  "583",
            "amt_in_msat":  "1458742",
            "amt_out_msat":  "1458159",
            "timestamp_ns":  "<timestamp>",
            "peer_alias_in":  "<in-peer>",
            "peer_alias_out":  "<out-peer>"
        },
        {
            "timestamp":  "<timestamp>",
            "chan_id_in":  "<in-channel-id>",
            "chan_id_out":  "<out-channel-id>",
            "amt_in":  "1171",
            "amt_out":  "1171",
            "fee":  "0",
            "fee_msat":  "468",
            "amt_in_msat":  "1171585",
            "amt_out_msat":  "1171117",
            "timestamp_ns":  "<timestamp>",
            "peer_alias_in":  "<in-peer>",
            "peer_alias_out":  "<out-peer>"
        },
        {
            "timestamp":  "<timestamp>",
            "chan_id_in":  "<in-channel-id>",
            "chan_id_out":  "<out-channel-id>",
            "amt_in":  "874",
            "amt_out":  "874",
            "fee":  "0",
            "fee_msat":  "349",
            "amt_in_msat":  "874436",
            "amt_out_msat":  "874087",
            "timestamp_ns":  "<timestamp>",
            "peer_alias_in":  "<in-peer>",
            "peer_alias_out":  "<out-peer>"
        },
        {
            "timestamp":  "<timestamp>",
            "chan_id_in":  "<in-channel-id>",
            "chan_id_out":  "<out-channel-id>",
            "amt_in":  "880",
            "amt_out":  "880",
            "fee":  "0",
            "fee_msat":  "352",
            "amt_in_msat":  "880440",
            "amt_out_msat":  "880088",
            "timestamp_ns":  "<timestamp>",
            "peer_alias_in":  "<in-peer>",
            "peer_alias_out":  "<out-peer>"
        }
    ],
    "last_offset_index":  7
}

Here the corresponding UI-appearance (within Firefox, default language German) bug

BR

cryptosharks131 commented 7 months ago

Thanks for the details! Could you also confirm what these records look like from your LNDg api data? This will help rule out any issue from the backend loading the data and it should match what you see in the lncli responses.

You can filter the LNDg api data from /api/forwards/ or open browser dev tools (F12) on the lndg page you took a screenshot, refresh the page, open the network tab and look for the forwards api call that was made. This will have the records that got loaded onto this page in the response data.

These are the calculation done on the front-end, I don't see anything in particular that might cause the issue https://github.com/cryptosharks131/lndg/blob/master/gui/templates/channel.html#L523-L525 https://github.com/cryptosharks131/lndg/blob/master/gui/templates/base.html#L20-L32

Does changing your browser language to English give accurate results (although they may not be in the preferred language format)?

mabeebam commented 7 months ago

Hi @cryptosharks131,

I can confirm that LNDg api data from /api/forwards match those from lncli fwdinghistory. Changing the browser language to English does not give accurate results. Tried it with Chrome/English. Also no accurate result.

BR