Comments (4)
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 aspaid
- if an invoice is marked as
paid
but theamount_received
is less thanamount
, 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.
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.
We can also address the scenario of underpayments here
from lightning.
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)
- Crazy logging after this update, losing channels instantly? ! HOT 2
- Error when using `async_method` and `async_hook` in python plugin HOT 1
- Add documentation for all `dev` commands too HOT 4
- Core lightning fails on Umbrel restart if bitcoin is not synced HOT 1
- Funds stuck on channel HOT 1
- document CLN_PLUGIN_LOG behavior
- Funds stuck in channel HOT 11
- CoreLN not properly detecting force close UTXOs HOT 5
- Channel with only one destination HOT 4
- migrating from c-lightning-REST to clnrest.py
- Crash in lightningd HOT 6
- bolt12: adding post-processing hook for onion messages HOT 1
- semver broken between cln-rpc 1.0.2 and 1.0.7 HOT 1
- CLNRest: certificate verify failed: unable to get local issuer certificate (_ssl.c:1007) HOT 3
- cln 23.11: force close tracking is stuck sometimes HOT 6
- fee spike caused channel to get stuck in "update_fee 167962 unaffordable" HOT 4
- crash with --network=liquid HOT 4
- LND nodes unable to pay bolt 11 invoice generated with defaults
- SIGBUS on OpenBSD HOT 3
- *** We need a database, but neither sqlite3 nor postgres found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lightning.