Builder's Guide
  • Welcome to the Builder's Guide to the LND Galaxy!
  • The Lightning Network
    • Overview
    • Payment Channels
      • Lifecycle of a Payment Channel
      • Watchtowers
      • Understanding Sweeping
      • Etymology
    • The Gossip Network
      • Identifying Good Peers on the Lightning Network
    • Pathfinding
      • Finding routes in the Lightning Network
      • Channel Fees
      • Multipath Payments (MPP)
    • Lightning Network Invoices
      • Understanding Lightning Invoices
    • Making Payments
      • The Payment Cycle
      • Timelocks
      • ⭐Hashed Timelock Contract (HTLC)
      • Payment Etymology
      • ⭐What Makes a Good Routing Node
      • Understanding Submarine Swaps
      • Instant Submarine Swaps
    • Liquidity
      • ⭐Understanding Liquidity
      • Managing Liquidity on the Lightning Network
      • Liquidity Management for Lightning Merchants
      • How to Get Inbound Capacity on the Lightning Network
      • Lightning Service Provider
    • L402: Lightning HTTP 402 Protocol
      • Macaroons
      • L402
      • 📋Protocol Specification
      • Implementations and Links
    • Taproot Assets
      • Taproot Assets Protocol
      • Taproot Assets on Lightning
      • Edge Nodes
      • Taproot Assets Trustless Swap
      • FAQ
      • Glossary
  • Lightning Network Tools
    • LND
      • 🛠️Get Started
      • lnd.conf
      • First Steps With LND
      • Wallet Management
      • Sending Payments
      • Atomic Multi-path Payments (AMP)
      • Receiving Payments
      • Unconfirmed Bitcoin Transactions
      • Channel Fees
      • Inbound Channel Fees
      • Macaroons
      • Configuring Watchtowers
      • Pathfinding
      • Blinded Paths
      • Key Import
      • Secure Your Lightning Network Node
      • Configuration of a Routing Node
      • Quick Tor Setup
      • Configuring Tor
      • Enable ‘Neutrino mode’ in Bitcoin Core
      • Send Messages With Keysend
      • Partially Signed Bitcoin Transactions
      • Bulk onchain actions with PSBTs
      • Sweeper
      • Debugging LND
      • Fuzzing LND
      • LND API documentation
      • Channel Acceptor
      • RPC Middleware Interceptor
      • HTLC Interceptor
      • NAT Traversal
      • Recovery: Planning for Failure
      • Migrating LND
      • Disaster recovery
      • Contribute to LND
    • Lightning Terminal
      • What is Lightning Terminal?
      • 🛠️Get litd
      • Run litd
      • Integrating litd
      • Demo: Litd Speed Run
      • Connect to Terminal
      • Recommended Channels
      • Rankings
      • Health Checks
      • Liquidity Report
      • Opening Lightning Network Channels
      • Managing Channel Liquidity
      • Autofees
      • AutoOpen
      • LND Accounts
      • Loop and Lightning Terminal
      • Loop Fees
      • Pool and Lightning Terminal
      • Command Line Interface
      • Troubleshooting
      • Lightning Node Connect: Under the hood
      • LNC Node Package
      • LITD API Documentation
      • Privacy and Security
      • Privacy Policy
      • Terms of Use
    • Loop
      • 🛠️Get Started
      • The Loop CLI
      • Autoloop
      • Static Loop In Addresses
      • Instant Loop Outs
      • Peer with Loop
      • Loop API Documentation
    • Pool
      • Overview
      • Quickstart
      • 🛠️Installation
      • First Steps
      • Accounts
      • Orders and Asks
      • Sidecar Channels
      • Zero-confirmation Channels
      • Channel Leases
      • Batch Execution
      • Account Recovery
      • Pool API Documentation
      • FAQs
    • Taproot Assets
      • Get Started
      • First Steps
      • Taproot Assets Channels
      • Asset Decimal Display
      • Become an Edge Node
      • RFQ
      • Collectibles
      • Universes
      • Asset Loop
      • Debugging Tapd
      • Multisignature
      • Minting Assets With an External Signer
      • Lightning Polar
      • Operational Safety Guidelines
      • Taproot Assets API Documentation
    • Aperture
      • ⚒️Get Aperture
      • LNC Backend
      • LNC Mailbox
      • Pricing
    • Faraday
      • 🛠️Get Started
      • The Faraday CLI
      • Faraday API Documentation
  • LAPPs
    • Guides
      • Use Polar to Build Your First LAPP
        • Setup: Local Cluster with Polar
        • Setup: Run the Completed App
        • Setup: Run the App Without LND
      • Add Features
        • Feature 1: Connect to LND
        • Feature 2: Display Node Alias and Balance
        • Feature 3: Sign and Verify Posts
        • Feature 4: Modify Upvote Action
      • Make Your own LNC-powered Application
    • Next Steps
  • Community Resources
    • Resource List
    • Lightning Bulb 💡
    • Glossary
    • FAQ
Powered by GitBook
On this page
  • Get your node ready for AMPs
  • Example: Generate a static donation QR code for your node
  • Switch from Keysend to AMP

Was this helpful?

  1. Lightning Network Tools
  2. LND

Atomic Multi-path Payments (AMP)

Learn how to make use of AMP and send satoshis to a peer without an invoice with keysend.

PreviousSending PaymentsNextReceiving Payments

Last updated 8 days ago

Was this helpful?

Atomic Multi-path Payments are a new type of Lightning payments implemented by lnd in version v0.13.0-beta. As the new payment type is an end-to-end upgrade, it doesn’t require the internal of the network to update before it can be used widely. Instead, only the sender and receiver need to understand the new payment type.

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.

Atomic Multi-path Payments

Keysend

Information necessary

Only node ID

Only node ID

Preimage

Generated by sender, but only known by receiver once all shards are paid

Generated and known by the sender

Multi-path

Each shard carries its own payment hash

All shards use the same payment hash

TLV Onion

Required

Required

Static invoices

Allows for static invoices

Does not allow for invoices at all

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.

In previous keysend payments, the sender generates the preimage and encrypts it in the onion payload of the payment, allowing the recipient to reveal it to claim their payment. Using AMP, the sender creates a single preimage, to which random values are added for each shard. The recipient is able to compute the original preimage using a XOR operation, meaning they are only able to claim the payment once all HTLCs are locked in, requiring them to claim the payment in full.

For a shard of size two this can be simplified as follows, with k being the preimage, and r being a random number:

* shard_1 = k ^ r * shard_2 = r shard_1 xor shard_2 = k ^ r ^ r = k

The information necessary for the recipient node to generate the correct preimages and reveal them to claim their payments is passed on in encrypted form as part of the Onion TLV (Type Length Value). This removes the need for additional interaction between the payer and the payee beyond transmitting a node public key or an invoice.

Get your node ready for AMPs

If you want to be able to receive spontaneous AMPs, you will need to set accept-amp=1 in your lnd.conf file before starting your upgraded node.

You will be able to pay other AMP-enabled nodes with the command

lncli sendpayment --amt <amount> --dest <recipient’s public key> --amp

Alternatively, you will be able to create an AMP invoice by amending --amp to the lncli addinvoice command.

This is especially important for private nodes, as the invoice will include the necessary channel hints that can’t be expressed in the lncli sendpayment command.

AMP invoices can be static and paid multiple times by switching the payment address in the invoice with a newly generated one. This payment address can be specified manually with the --pay_addr flag. From lnd 0.14.0 onwards it is no longer necessary to set the --amp-reuse flag to generate a payment address in LND.

Example usage:

lncli addinvoice --amt <amount in satoshis> --memo=’my first amp’ --amp

lncli payinvoice --pay_req <the amp invoice created by the receiver>

lncli sendpayment --amt <amount in satoshis> --dest <public key of receiver> --amp

lncli payinvoice --pay_req <the amp invoice created by the receiver> --pay_addr <the sha256 hash of a random number>

lncli payinvoice --pay_req <the amp invoice created by the receiver> --amp-reuse

Example: Generate a static donation QR code for your node

Using AMP, we can generate static QR codes that others can pay to, repeatedly.

Prerequisites: You need to run lnd 0.13 or above with accept-amp=1 enabled in your configuration file.

Step 1: Generate an AMP invoice We can create an AMP invoice with the command lncli addinvoice --amp Optionally we can add a (publicly visible) memo or a fixed amount with the --memo="add your memo here" and --amt <amount in satoshis> flags.

Step 2: Turn the invoice into a QR code Your node will return an r_hash, a payment request and a payment address. There are many ways you can use to transform your payment request into a QR code, embed it on your website or add it to your social media. LibreOffice has a built-in functionality, and there are plenty of freely available online tools.

Step 3: Pay a static AMP If your mobile wallet supports payments to AMP invoices, the invoice needs to be scanned and optionally the amount needs to be specified. To pay an AMP invoice from the command line, you only need to execute lncli payinvoice <amp invoice> If the AMP invoice does not contain an amount, you can specify the amount you would like to pay with the --amt flag.

Switch from Keysend to AMP

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.

old: lncli sendpayment --dest <destination public key> --amt <amount> --keysend

new: lncli sendpayment --dest <destination public key> --amt <amount> --amp

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.

To be able to make and send Atomic Multi-path Payments, you will need to upgrade your node to .

Watch:

LND 0.13 or above
Learn: How to send messages with keysend
Atomic Multi-path Payments (AMP)
Get AMPed: Making Atomic Multi-Path Payments
Video: Get AMPed: Making Atomic Multi-Path Payments