Skip to content

Commit 99dabe0

Browse files
Leo Weesegitbook-bot
authored andcommitted
GitBook: [#175] No subject
1 parent ffeffd5 commit 99dabe0

File tree

3 files changed

+78
-9
lines changed

3 files changed

+78
-9
lines changed

SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
* [Quick Tor Setup](lightning-network-tools/lnd/quick-tor-setup.md)
5252
* [Configuring Tor](lightning-network-tools/lnd/configuring\_tor.md)
5353
* [Enable ‘Neutrino mode’ in Bitcoin Core](lightning-network-tools/lnd/enable-neutrino-mode-in-bitcoin-core.md)
54+
* [Send messages with keysend](lightning-network-tools/lnd/send-messages-with-keysend.md)
5455
* [Debugging LND](lightning-network-tools/lnd/debugging\_lnd.md)
5556
* [Fuzzing LND](lightning-network-tools/lnd/fuzz.md)
5657
* [LND and etcd](lightning-network-tools/lnd/etcd.md)

lightning-network-tools/lnd/amp.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Atomic Multi-path Payments are a new type of Lightning payments implemented by l
1010

1111
Atomic Multi-path payments differ from existing Multi-path Payments (MPP) in that they are atomic, meaning despite being routed through separate paths. In MPPs, all shards use the same payment hash, making the individual routes easily correlatable and prone to only partial settlement. By contrast AMPs are either settled in full or not settled at all. Using AMP, it is possible to make payments safely by only knowing the public key of the recipient. It is also possible to create invoices that can be used repeatedly, which can be used to implement traditional subscriptions. Such invoices can also be published without security implications, allowing for use cases such as static donation invoices.
1212

13-
| | Atomic Multi-path Payments | Keysend |
14-
| --------------------- | ----------------------------------------------- | ------------------------------------ |
15-
| Information necessary | Only node ID | Only node ID |
16-
| Preimage | Generated by sender, but only known by receiver | Generated and known by the sender |
17-
| Multi-path | Each shard carries its own payment hash | All shards use the same payment hash |
18-
| TLV Onion | Required | Required |
19-
| Static invoices | Allows for static invoices | Does not allow for invoices at all |
13+
| | Atomic Multi-path Payments | Keysend |
14+
| --------------------- | ------------------------------------------------------------------------ | ------------------------------------ |
15+
| Information necessary | Only node ID | Only node ID |
16+
| Preimage | Generated by sender, but only known by receiver once all shards are paid | Generated and known by the sender |
17+
| Multi-path | Each shard carries its own payment hash | All shards use the same payment hash |
18+
| TLV Onion | Required | Required |
19+
| Static invoices | Allows for static invoices | Does not allow for invoices at all |
2020

2121
In a regular Lightning payment, the payee generates a preimage and transmits its hash as part of the invoice. The Hash Time-lock Contract (HTLC) pays to this hash, and to claim their payment, the payee reveals the preimage, allowing everyone along the route to finalize the payment.
2222

@@ -67,12 +67,14 @@ Example usage:
6767
Switching from MPP to AMP is easy. You will have to replace the `--key_send` flag with a `--amp` flag. You will no longer have to manually generate a preimage as the sender.
6868

6969
**old:**\
70-
`lncli sendpayment --dest <destination public key> --amt <amount> --key_send`
70+
`lncli sendpayment --dest <destination public key> --amt <amount> --keysend`
7171

7272
**new:**\
7373
`lncli sendpayment --dest <destination public key> --amt <amount> --amp`
7474

75-
If you are currently using keysend over the RPC layer, you will be able to smoothly switch over by simply setting the amp field. It is no longer necessary to manually generate and set a preimage.&#x20;
75+
If you are currently using keysend over the RPC layer, you will be able to smoothly switch over by simply setting the amp field. It is no longer necessary to manually generate and set a preimage.
76+
77+
[Learn: How to send messages with keysend](send-messages-with-keysend.md)
7678

7779
{% content-ref url="amp.md" %}
7880
[amp.md](amp.md)
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
description: >-
3+
Learn how to send messages to anyone in the Lightning Network from the command
4+
line
5+
---
6+
7+
# Send messages with keysend
8+
9+
Keysend allows users in the Lightning network to send payments to others , directly to their public key, as long as their node has public channels and has keysend enabled. Keysend does not require the payee to issue an invoice.
10+
11+
This payment type can also be used to attach messages and other data.
12+
13+
Keysend is currently implemented in LND in two ways, the widely accepted “`--keysend`” and the newer “[`--amp`](amp.md)
14+
15+
## Enable your node to receive keysend
16+
17+
To make sure you are able to receive spontaneous payments, add the following lines to your `lnd.conf` file:
18+
19+
`accept-amp=1`\
20+
`accept-keysend=true`
21+
22+
Then restart your node with `lncli stop` and `lnd`.
23+
24+
If you want to accept spontaneous payments using AMP, you may also create an invoice with routing hints and distribute it to prospective payers. You can use the command:
25+
26+
`lncli addinvoice –amp`
27+
28+
You can optionally also specify an amount (`--amt`), expiry (`--expiry`), a memo (`--memo`) routing hints are needed if your node only has private channels (`--private`).
29+
30+
## Send a spontaneous payment
31+
32+
To send a spontaneous payment, you can craft a command like this:
33+
34+
`lncli sendpayment --dest <destination public key> --amt <amount> --keysend`
35+
36+
or using AMP (recommended):
37+
38+
`lncli sendpayment --dest <destination public key> --amt <amount> --amp`
39+
40+
### Paying AMP invoices
41+
42+
If the payee has a private node without public channels, they can create an AMP invoice and include routing hints as explained above. The payer can then pay this invoice with the command:
43+
44+
`lncli payinvoice <invoice>`
45+
46+
If an amount is not set in the invoice, it can be set by the payer with&#x20;
47+
48+
`lncli payinvoice <invoice> –amt <amount>`
49+
50+
## Send a message to other nodes
51+
52+
You can include messages into your spontaneous payments with the `–data` flag. It must follow the convention `<record_id>=<hex_value>,<record_id>=<hex_value>,..`
53+
54+
Messages are typically sent with the record ID `34349334`. You can find a registry for such records [here](https://github.com/satoshisstream/satoshis.stream/blob/main/TLV\_registry.md). You may also submit your own suggestions.
55+
56+
You can encode any data in hex, either using your favorite command line or web tool.
57+
58+
The phrase “`Happy Genesis Block Day!`” becomes `48617070792047656E6573697320426C6F636B2044617921`
59+
60+
The full command below will send this message together with 10 satoshis to [Amboss.space](https://amboss.space), where it is displayed publicly.
61+
62+
`lncli sendpayment --dest 03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6 --amt 10 --data 34349334=48617070792047656E6573697320426C6F636B2044617921 --keysend`
63+
64+
If the payee has created an AMP invoice, the data can also be appended to the command:
65+
66+
lncli payinvoice \<invoice> --data 34349334=486170707920477265676F7269616E204E6577205965617220746F2065766572796F6E65206174204C696768746E696E67204C61627321

0 commit comments

Comments
 (0)