Skip to content

Commit 7662d30

Browse files
Keysend bLIP
1 parent e169d45 commit 7662d30

File tree

3 files changed

+102
-1
lines changed

3 files changed

+102
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ For more detail on the process, please read [bLIP-0001](./blip-0001.md) and
2121
|--------|---------------------------|-----------------------------|--------|
2222
| [1](./blip-0001.md) | bLIP Process | Ryan Gentry | Active |
2323
| [2](./blip-0002.md) | reserved values | Bastien Teinturier | Active |
24+
| [3](./blip-0003.md) | Keysend | Valentine Wallace | Active |

blip-0002.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ network split.
3333
* [TLV fields in BOLT messages](#tlv-fields-in-bolt-messages)
3434
* [`init`](#init)
3535
* [`ping`](#ping)
36+
* [`update_add_htlc`](#update_add_htlc)
3637

3738
## Feature bits
3839

@@ -44,7 +45,7 @@ bLIPs may reserve feature bits by adding them to the following table:
4445

4546
| Bits | Name | Description | Context | Dependencies | Link |
4647
|---------|----------------------|-------------------------------------------------|----------------|--------------------------------|--------------------------------|
47-
| 256/257 | `feature_name` | Short description | Bolt 9 context | Dependencies on other features | Link to the corresponding bLIP |
48+
| 54/55 | `keysend` | A form of spontaneous payment | N | `var_onion_optin` | [bLIP 3](./blip-0003.md) |
4849

4950
## Messages
5051

@@ -86,6 +87,14 @@ The following table contains extension tlv fields for the `ping` message:
8687
|-------|-----------------------------|--------------------------------|
8788
| 65536 | `tlv_field_name` | Link to the corresponding bLIP |
8889

90+
### `update_add_htlc`
91+
92+
The following table contains extension tlv fields for the `update_add_htlc` message's onion payload:
93+
94+
| Type | Name | Link |
95+
|------------|-----------------------------|--------------------------------|
96+
| 5482373484 | `keysend_preimage` | [bLIP 3](./blip-0003.md) |
97+
8998
# Copyright
9099

91100
This bLIP is licensed under the CC0 license.

blip-0003.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
```
2+
bLIP: 3
3+
Title: Keysend
4+
Status: Active
5+
Author: Valentine Wallace <[email protected]>
6+
Created: 2021-12-08
7+
License: CC0
8+
```
9+
10+
# Abstract
11+
12+
Keysend is a type of lightning payment that does not require the payee to
13+
provide an invoice. Instead, the payer includes their payer-selected payment
14+
preimage in the TLV onion.
15+
16+
This bLIP serves to document what is already well-supported in the wild (see
17+
[Reference Implementations](#reference-implementations)), for posterity and so
18+
that new implementations don't have to reverse-engineer keysend from existing
19+
implementations.
20+
21+
# Copyright
22+
23+
This bLIP is licensed under the CC0 license.
24+
25+
# Specification
26+
27+
Sender:
28+
* MUST include a TLV record keyed by type `5482373484` with a TLV value of a
29+
randomly generated and cryptographically-secure 32-byte value that serves as
30+
the HTLC payment preimage
31+
* MUST NOT reuse a previously used preimage
32+
* MUST NOT reuse a preimage from a previously paid invoice
33+
* MUST set the `payment_hash` field in the `update_add_htlc` message to match
34+
the SHA256 hash of the payment preimage
35+
* SHOULD only send payments to nodes advertising the `keysend` feature bit
36+
37+
Receiver:
38+
* if failing the payment due to not wanting to accept keysend payments or if
39+
the preimage does not match the payment hash, SHOULD error with
40+
`PERM|15 incorrect_or_unknown_payment_details`.
41+
42+
# Motivation
43+
44+
A convenience of layer 1 bitcoin is being able to spontaneously send to a
45+
bitcoin address with no advance work required on the part of the payee. Keysend
46+
brings the convenience of sponaneous payments to layer 2 (with a few caveats,
47+
see the [Drawbacks](#keysend-drawbacks) section).
48+
49+
As previously mentioned, keysend also has the advantage of already being
50+
supported by major implementations. So regardless of whether it is the best
51+
solution to spontaneous payments, it's a good idea to have some form of
52+
official documentation for it.
53+
54+
# Rationale
55+
56+
Design decisions for keysend were largely made by the original lnd keysend
57+
implementation (e.g. the choice of `5482373484` for the TLV type).
58+
59+
* The TLV type `5482373484` was chosen at random
60+
* The rationale behind having a feature bit is that it's nicer to opt-in to
61+
receiving keysend payments: without a feature bit, the only way for senders to
62+
explicitly know that receivers support keysend is by attempting a keysend
63+
payment and seeing whether or not it fails.
64+
65+
# Keysend Drawbacks
66+
67+
* Inability for the payee to specify their preferred `min_final_cltv_expiry`.
68+
This is an issue because payer and payee may have differing security
69+
requirements, which could lead to payment failures if the payee considers the
70+
payer's choice of `min_final_cltv_expiry` too high or too low.
71+
* Loss of being able to use the preimage and invoice signature as
72+
proof-of-payment. With regular lightning payments, payers are able to use (1)
73+
the payment preimage and (2) the invoice signature in a situation where they
74+
need to prove that they made a payment (the invoice signature is necessary to
75+
prove that the payer was not an intermediary hop). This proof cannot be
76+
provided for keysend payments because the preimage is provided by the payer to
77+
begin with and no invoice is being paid.
78+
* Keysend is expected to be deprecated in favor of a more well-developed
79+
spontaneous payment solution like
80+
[Offers](https://github.com/lightningnetwork/lightning-rfc/pull/798) or
81+
[AMP](https://github.com/lightningnetwork/lightning-rfc/pull/658)
82+
83+
# Reference Implementations
84+
85+
LDK: https://github.com/rust-bitcoin/rust-lightning/pull/967
86+
87+
C-Lightning: https://github.com/ElementsProject/lightning/blob/master/plugins/keysend.c
88+
89+
lnd original keysend PR: https://github.com/lightningnetwork/lnd/pull/3795
90+
91+
Eclair: https://github.com/ACINQ/eclair/pull/1485

0 commit comments

Comments
 (0)