-
Notifications
You must be signed in to change notification settings - Fork 902
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
hsmd: add preapprove invoice and keysend messages #5821
hsmd: add preapprove invoice and keysend messages #5821
Conversation
938acf7
to
72b1383
Compare
ebaee21
to
a72e684
Compare
Thanks @ksedgwic, just a couple of questions for my own understanding:
On a more design-related thing: I'm assuming that I'll review the code as soon as possible, but thought I needed a bit of a wider picture of how things are intended to work on a conceptual level 🙂 |
Right, the other option is to return an error, but that would crash or at least restart the node. There is another reason. Seeing the invoice allows us to bind HTLCs (the payment hash) to payees (the entity who signed the invoice), which in turn allows payee to be allowlisted.
Yes, the signer would start doing the following:
The signer would serialize the preapprovals internally, so the later request for preapproval would fail if the velocity is exceeded. Note that velocity measures amount approved rather than amount actually sent, so that velocity controls can only fail a payment early - in the preapproval stage.
We were currently planning to expire these on invoice expiry, but on second thought it would be useful to be able to withdraw a preapproval for a payment we give up on. I suppose it should only succeed in removal if there are no pending HTLCs involving that payment hash.
I'll defer to @ksedgwic on this question. |
Yes, that's right |
Yes, the approval is remembered and persisted. Subsequent preapproval requests for an approved invoice or keysend are also immediately accepted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor thing about the dangers of sync comms when the outcome itself is not critical itself. It's a relatively new consideration, and therefore not consistently applied to the existing code. I'd be more at ease with async comms :-)
|
||
u8 *msg = towire_hsmd_preapprove_invoice(NULL, invstring); | ||
|
||
if (!wire_sync_write(cmd->ld->hsm_fd, take(msg))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing synchronous comms here may not be what we want. It ends up blocking the entire lightningd
until the signer has responded. This means that if we have a long RTT from lightningd
to hsmd
we are unresponsive for that roundtrip. Worse, if the signer does not respond we are blocked forever and can't react to on-chain events and peer messsages.
We should always prefer async comms in lightningd
.
|
||
u8 *msg = towire_hsmd_preapprove_keysend(NULL, destination, payment_hash, *amount); | ||
|
||
if (!wire_sync_write(cmd->ld->hsm_fd, take(msg))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing about sync comms above.
Async comms are not possible at this point in time.
Hi @ksedgwic, sorry for suggesting this without first checking if we do any async comms with the signer. It turns out we don't, and introducing it in this PR would massively expand the scope of this PR. I therefore retract my previous comments, and think the changes should go in as they are. ACK 31da26c |
@endothermicdev would you like me to rebase this to get rid of the @ksedgwic if CI gets stuck again, ping me, and I can kick it on the console :-) |
@cdecker yes, I would appreciate that. Thanks for the updating your review as well. |
@ksedgwic it seems like the PR disallows maintainers to push to your branch, can you rebase and drop the last commit? Then we'll fold the PR into the release 🎉 |
…ifier Changelog-added: hsmd: A new message `hsmd_preapprove_invoice` is added. Changelog-added: JSON-RPC: A new command `preapproveinvoice` is added.
31da26c
to
3124608
Compare
I can't change that flag from here, but I was able to rebase and drop the extra commit. |
3124608
to
03aae88
Compare
…ifier Changelog-added: hsmd: A new message `hsmd_preapprove_keysend` is added. Changelog-added: JSON-RPC: A new command `preapprovekeysend` is added.
03aae88
to
0fa933e
Compare
CI fail seems unrelated... |
Yes, unrelated but I haven't identified the fix to that one yet. Thanks! ACK 0fa933e |
These messages request payment approval from the hsmd for bolt11 and keysend payments: