-
Notifications
You must be signed in to change notification settings - Fork 912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hold-Invoices over grpc #6358
Hold-Invoices over grpc #6358
Conversation
Would this plugin stay in a separate repository and use tools like coffee to manage it in the system that it is planning to use this plugin? I see some pattern in cln, and it is the correct thing to do imho, to implement this to the core level (also with a rust plugin) and expose low-level RPC call. Then use the GRPC/Rest/Command to expose these commands through another protocol. So maybe it something missing in this PR to be included at the core level? |
Imo it shouldn't be a separate plugin at all, but i'm following you guys lead on how hold-invoices are made available in cln. If it has to be a separate plugin i'd like to see it installed automatically with cln and only if these options are out make it available in a separate repo.
What do you mean by this? To make hold-invoice methods available like regular invoice is, directly from cln? I wouldn't know how to do this.
Do you mean i should put this code into cln-rpc and others use those methods? |
If I understand correctly, your plugin currently works only with gRPC, but theoretically, it could also function as a regular plugin without gRPC. So, why not develop the plugin in Rust and then expose the API via gRPC? |
It can definitely work as a regular plugin.
Can you clarify this a bit more? Do you want me to edit cln-rpc and cln-grpc for this or make a "cln-rpc-hold" and a "cln-grpc-hold" that exposes the API from "cln-rpc-hold". Currently this pr has just a "cln-grpc-hold" and instead of exposing something else it is all self-contained. |
…ys save earliest expiry
b115112
to
5b4ea0f
Compare
cleaned up some clippy complains + rebase |
Wow this is great and really needed. Thanks for getting this started. In terms of fitting into existing infrastructure, I think we can cut down on what this PR is doing by a lot. Ideally this PR would just:
Once this plugin is tested + added to CLN, we can then work with @cdecker on how to expose these methods via the existing grpc transport code. (There's another todo currently for other built-in plugins) In summary, the biggest TODO here is to remove all the independent grpc server code and trim this down significantly to just add a single plugin that runs on startup and offers all the new RPC methods you need to make this work. That'll make this PR much easier to review + test; and allows us to re-use existing grpc code to expose it in a follow on PR. |
i'll close this in favor of #6611 |
Hi,
Motivation
Hold-Invoices are used today on different projects for different purposes like return-payments for merchants or security bonds for exchanges.
This PR
This pr adds a stripped-down copy of cln-grpc that enables cln to have Hold-Invoices like lnd.
For this i tried to mimic lnds grpc methods by introducing these new methods:
The most notable difference for users of Hold-Invoices between lnd and cln is that if an invoice is close (60s) to expiry, this plugin will reject all related htlcs and mark it as CANCELED since cln can't accept htlcs for expired invoices.
Some technical stuff:
the plugin saves the payment hashes of Hold-Invoices in the cln database and is hooked into htlc_accepted. If the payment_hash of the htlc is found by the plugin the htlc is held in a loop. This makes the Hold-Invoices restart-persistent but requires the plugin to be loaded as important (can i enforce this?)!
the plugin also rejects htlcs if they get close to expiry to prevent force closes, but looking at the values i get from the hook and looking at this i got a little confused and chose 6 blocks before
"htlc_hook_payload".htlc.cltv_expiry
see hereWhat this pr is missing:
Performance:
I tested this plugin on regtest and an i7-6700k and held ~500 htlcs on 80 invoices with
top
showing 3-7% cpu for the plugin and a little less ram than lightningdFinally:
This plugin is running (in a slightly older version) on testnet in combination with Robosats.
Thank you @cdecker for helping me make this plugin possible. He told me to make it a separate plugin but ideally i would like to see it merged into cln-grpc.
If you have any questions/feedback/improvement proposals please feel free to answer here :)