Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
lncli+invoices: experimental key send mode #3795
This PR implements the key send functionality that is described in #2455 in
Throughout the year 2019, many PRs have been merged that together created a solid foundation to implement key send on. This is reflected in the size of this PR. The core changes to the invoice registry are relatively small and non-intrusive.
Key send isn't part of the Lightning spec yet. Therefore the preimage is sent as a custom record (in the type range >= 65536):
It is likely that this custom record will be deprecated eventually and replaced by either spontaneous sending as an AMP payment or a an official key send payload record.
What this means is that applications using the functionality as it is introduced in this PR may break when either the sender or receiver upgrades to a newer version of
As before, intermediate hops will support key send with any version of the software.
To enable receiving key send spontaneous payments, start
Sending a spontaneous payment can be done via
This PR is also the final step in enabling mainline
Main open question is at what level(s) we want to support key send. My philosophy for this pr was to keep it as non-intrusive as possible. Postpone adding any new rpc fields until we reconcile with amp. What is in now, is enough for people to start building off of it without requiring a fork of
Previously 5 seconds was used, which made the otherwise fast registry tests relatively slow.
This field isn't optional. It was introduced in 5ed31b1 which was part of release 0.4.0. This release contained breaking database changes, so it is safe to assume that from there on the field is always populated. If there would still be empty payment request fields in the wild, users would also experience issues with ListInvoices. ListInvoices decodes the payment request.
This commit adds handling code for the key send custom record. If this record is present and its hash matches the payment hash, invoice registry will insert a new invoice into the database "just in time". The subsequent settle flow is unchanged. The newly inserted invoice is picked up and settled. Notifications will be broadcast as usual.
Extend lncli with a flag that indicates the intention to send a spontaneous payment. lncli will generate a preimage/hash combination and send the preimage as a custom record to the recipient.
Roasbeef left a comment
Works as advertised on the tin:
One follow up that I think we should consider is exposing setting custom records on the command line as well, while merging that with the keysend feature if the flag is set. This makes the entire suite a bit more useful, as users can then specify other custom information along with the core