blink icon indicating copy to clipboard operation
blink copied to clipboard

add payment metadata to medici_transactions

Open nicolasburtey opened this issue 4 years ago • 5 comments

lnd 0.14 will have the capability to delete individual payments.

in the interest of making our node database smaller, we should take advance of this features and delete payment after they complete.

that said, we will loose some data that we need to store beforehands.

Currently, for data analysis (ie: to know where payment are most frequently sent to), we are getting the individual payment using trackpayment (using listpayments would get better but our node is currently failing with that)

now if we want to delete succesful payments, we need to store this metadata somewhere. I'm suggesting to store it alongside the medici transactions. we could store the json as a blob, and will extract/handle the data manually at a later stage in a data pipeline/data exploration environment.

I think both postgres and mongodb accept having a field as a json (mongodb even more so than postgres. the point is we don't need a structured schema for it)

nicolasburtey avatar Sep 29 '21 12:09 nicolasburtey

maybe also @vindard or @dolcalmi can look over this

nicolasburtey avatar Sep 29 '21 12:09 nicolasburtey

Adding implementation notes here, I believe we'd be persisting values from the returns of these two functions:

  • https://github.com/alexbosworth/ln-service#payViaRoutes
  • https://github.com/alexbosworth/ln-service#payviapaymentdetails

vindard avatar Oct 04 '21 13:10 vindard

Adding implementation notes here, I believe we'd be persisting values from the returns of these two functions:

  • https://github.com/alexbosworth/ln-service#payViaRoutes
  • https://github.com/alexbosworth/ln-service#payviapaymentdetails

these methods not always return a final state so we need to use getPayment (for ex in trigger), the only concern about this is that lightning library not always return all attributes from lnd node

dolcalmi avatar Oct 05 '21 03:10 dolcalmi

Adding some other things we'd like to persist as well:

  • Add preimage to PayInvoiceResult type and persist in medici (see comment)

vindard avatar Oct 05 '21 12:10 vindard

Draft of this being built on persist-ln-payment-in-medici branch

I'm using our LnLookupPayment type to persist data to mongoDB, the new "payment" property object in the transactions collection looks like this (@nicolasburtey):

image

vindard avatar Oct 13 '21 13:10 vindard

this is done

nicolasburtey avatar Sep 15 '23 10:09 nicolasburtey

@vindard : "I'll double-check that cron deletes these from lnd"

nicolasburtey avatar Sep 15 '23 10:09 nicolasburtey

@vindard : "I'll double-check that cron deletes these from lnd"

It does, all good

vindard avatar Sep 15 '23 11:09 vindard