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
  • Bulk channel opens
  • Bulk onchain transactions

Was this helpful?

  1. Lightning Network Tools
  2. LND

Bulk onchain actions with PSBTs

PSBTs can be used to batch custom onchain transactions for maximum cost efficiency, for example to open multiple channels or send to multiple destinations in one transaction.

PreviousPartially Signed Bitcoin TransactionsNextSweeper

Last updated 1 year ago

Was this helpful?

Partially Signed Bitcoin Transactions (PSBTs) are a standardized format to create, edit, amend, and sign Bitcoin transactions. This is useful when creating custom transactions, for example by specifying which inputs to consume, or including non-standard outputs.

An introductory guide to PSBTs and LND .

Bulk channel opens

PSBTs can be used to open multiple channels in a single onchain transaction, similar to lncli batchopenchannel.

To begin, a channel open is initiated using the , specifically the lnrpc.OpenChannelRequest. We specify all the parameters we need for the channel open, such as the channel size (local_funding_amount), the peer pubkey (node_pubkey) and whether the channel shall be announced (private).

For funding_shim we use lnrpc.PsbtShim and an empty base_pbst. We must not forget to set no_publish to true as well.

This will return a PSBT (psbt_fund.psbt). We repeat the above for the channel parameters of the second channel. This round, we pass the returned PSBT as the base_psbt, instead of an empty value.

We can repeat this as often as we need. For the final round, we will set no_publish to false.

To finalize the PSBT, we can use the call. If you want to use funds held in another application or device, remember to make sure that the wallet’s xpubs have been .

To sign the transaction, we will have to pass the PSBT either to LND using the RPC call. Alternatively, the PSBT will have to be signed by the external application or wallet.

Now we need the API to verify the PSBT using the psbt_verify call with skip_finalize set to true for all channels except the last one (1 to n-1). The correct pending_chan_id has to be specified each time. This verifies that the transaction contains the correct outputs to fund the channel. These outputs have to be used to create the correct commitment transactions.

Only for the last channel do we repeat the above step with the latest pending_chan_id with skip_finalize set to false.

Finally, we repeat the above step one last time for the first channel, using the latest PSBT, the latest pending_chan_id and psbt_finalize set to true.

Bulk onchain transactions

The API lets you send an onchain transaction with multiple outputs, but it does not let you select specific inputs, and cannot be combined with a channel open.

We begin by calling the API. We can specify our raw inputs and outputs as part of the raw field. If we want to send this transaction from an external wallet, or have multiple onchain accounts imported to LND, we will also need to specify the account.

Using the PSBT returned in the above step, we call the API.

The resulting PSBT only needs to be signed. This is done with the RPC call.

Finally, the PSBT needs to be published, which is done with the raw transaction and .

can be found here
OpenChan API
FundPsbt
imported to LND
signPsbt
fundingStateStep
SendMany
FundPsbt
FinalizePsbt
signPsbt
PublishTransaction