Overview
Muun Wallet provides native Lightning Network support without requiring users to run a Lightning node, manage channels, or understand Lightning’s technical complexity. Users can send and receive Lightning payments as easily as on-chain transactions.Muun doesn’t use traditional Lightning channels. Instead, it uses submarine swaps to convert between on-chain Bitcoin and Lightning payments in real-time.
How It Works
No Lightning Node Required
Unlike traditional Lightning wallets, Muun:- No channels to manage: No need to open, close, or balance channels
- No inbound liquidity issues: Can receive any amount at any time
- No force closures: No risk of losing funds due to channel disputes
- No watchtowers: No need for online monitoring
Architecture
Muun’s Lightning implementation uses:- On-chain multisig wallet as the base layer
- Submarine swaps to convert to/from Lightning
- Swap server operated by Muun for Lightning routing
- HTLC contracts for trustless atomic swaps
Receiving Lightning Payments
Invoice Generation
When you create a Lightning invoice in Muun:- Generate invoice: App creates standard BOLT-11 Lightning invoice
- Store secrets: Payment hash and preimage stored locally
- Wait for HTLC: Muun’s swap server watches for incoming Lightning payment
- Submarine swap: Lightning payment converted to on-chain UTXO
- Collect funds: User signs to collect funds to their wallet
HTLC Verification
Before collecting funds, the wallet verifies the incoming swap:- Payment hash matches the invoice
- Amount is correct (allows overpayment)
- Sphinx packet is valid (proves it came through Lightning network)
- HTLC script is correctly constructed
HTLC Script Structure
Incoming swaps use a specialized HTLC script:- User must sign: Maintains 2-of-2 multisig security
- Preimage required: Proves Lightning payment was received
- Timeout protection: Swap server can refund if user doesn’t collect
Sending Lightning Payments
Submarine Swap Flow
When sending to a Lightning invoice:- Parse invoice: Extract destination, amount, payment hash
- Create swap: Lock on-chain funds in an HTLC
- Lightning payment: Muun’s swap server pays the Lightning invoice
- Reveal preimage: Recipient reveals the preimage
- Collect funds: Swap server collects the locked on-chain funds using preimage
- Funds are locked in an HTLC script, not sent directly to Muun
- Preimage is required to claim funds
- If Lightning payment fails, user can reclaim funds after timeout
Submarine Swap V1
- Non-native SegWit (P2WSH wrapped in P2SH)
- User-specified refund address
- Time-based refund after expiry
Submarine Swap V2
- Native SegWit (P2WSH) for lower fees
- Integrates with 2-of-2 multisig
- Block-based expiration
- Server must provide signature upfront
libwallet/submarineSwapV2.go:13-24
Payment Validation
Before creating a swap, Muun validates:- Invoice is valid BOLT-11 format
- Amount matches user’s intention
- Expiration is reasonable
- Keys are correctly derived
- Server signature is valid (v2)
libwallet/submarineSwap.go:41
User Experience
Seamless Integration
From the user’s perspective:- Unified balance: No distinction between on-chain and Lightning funds
- No liquidity management: Can receive any amount instantly
- Automatic routing: App automatically chooses best payment method
- Standard invoices: Compatible with any Lightning wallet
When to Use Lightning
Muun recommends Lightning for: On-chain is better for:- Large payments: Lower percentage fees
- Maximum security: Direct blockchain settlement
- Cold storage: Long-term savings
Technical Trade-offs
Advantages
- Zero channel management: No technical complexity
- Always online: No need to keep app running
- No stuck funds: No liquidity locked in channels
- Universal compatibility: Works with all Lightning wallets
Considerations
- Swap fees: Each Lightning payment includes a swap fee
- On-chain footprint: Every Lightning payment creates on-chain transaction
- Server dependency: Requires Muun’s swap server to be operational
- Not true Lightning: Uses submarine swaps rather than native channels
During high on-chain fee periods, Muun subsidizes swap costs to keep Lightning payments affordable. However, users should be aware of the on-chain component.
Privacy Considerations
What’s Private
- Payment hash is unique and not linkable to your identity
- Sphinx routing hides payment path
- On-chain swap UTXO doesn’t reveal Lightning invoice details
What’s Not Private
- Muun’s swap server knows:
- You’re sending/receiving a Lightning payment
- The amount and timing
- Your on-chain addresses (already known due to multisig)
Best Practices
- Use separate wallets for privacy-sensitive payments
- Be aware submarine swaps create on-chain transaction history
- Consider the trust model: Muun can see your Lightning payment patterns
Implementation Details
Sphinx Packet Validation
Muun validates the Sphinx onion routing packet to ensure payments came through the Lightning network:Fulfillment Transaction
When collecting an incoming Lightning payment:- Spends the HTLC output
- Provides the preimage in the witness
- Includes both user and Muun signatures
- Sends funds to user’s multisig address
libwallet/incoming_swap.go:177-180
Related Features
Submarine Swaps
Deep dive into the submarine swap protocol
Multisig
How Lightning integrates with 2-of-2 multisig
Recovery
Recovering Lightning funds in emergency scenarios