Giter Club home page Giter Club logo

Comments (4)

niftynei avatar niftynei commented on May 29, 2024 1

One way to do this would be to:

  • add new states: "underpaid" and "overpaid" (and "unconfirmed")
  • update the amount_received and increment the updated_index for the event; any amount paid should mark the invoice as paid
  • if an invoice is marked as paid but the amount_received is less than amount, a lightning payment should be accepted (and the amount_received added to)

Any client watching for payment attempts etc will be able to inspect the "amount" vs the "amount_received" fields and will be notified of updates to the event due to the updated_index changing.

If an invoice gets paid twice: same logic. Update the amount_received and increment the updated_index.

The bookkeeper can keep a log of all the independent onchain/in-channel events that contributed to the payment of that invoice, which can be inspected later (or programatically by an app/client).

The app that's operating on top can take action to notify a client/user/administrator of payments that need attention (refunds, etc).

States an invoice can be in:

unpaid
unconfirmed (TODO)
underpaid, amount_received < amount
paid, amount_received == amount
overpaid, amount_received > amount
expired

Payments can move from

unpaid -> underpaid -> paid -> overpaid
unpaid -> expired
unpaid -> expired -> (onchain only!) underpaid -> paid -> overpaid (rcv > amt)

if underpaid && !expired -> LN payment allowed
if underpaid && expired -> LN payment not allowed (requires second invoice)

Alternately: we could not include overpaid as a state, and just use the amount_received field to figure out if a refund is owed? This would happen in a client/calling app, not CLN.

from lightning.

chrisguida avatar chrisguida commented on May 29, 2024

For item 1:

2023-10-31T20:38:48.105Z UNUSUAL lightningd: On-chain payment received for expired invoice with label label3. Outpoint for received payment: dcc98acced809a4c59a30faa1f0e869271de2f096e6b0e010008ad512950386b:1

Look good? ^

As for item 2, how would i determine if an invoice has been paid expired? Should I store something in the db, either in the invoice_fallbacks table (new column) or the invoices table (new status / column)? Or I could also generate this field dynamically by joining the wallet txs with the invoices table?

from lightning.

chrisguida avatar chrisguida commented on May 29, 2024

We can also address the scenario of underpayments here

from lightning.

chrisguida avatar chrisguida commented on May 29, 2024

Both issues could be addressed by adding new statuses to the status enum on the invoices table, eg: PAID_EXPIRED and UNDERPAID

from lightning.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.