Fee breakdown for Lightning payments, cooperative exits, and swaps.
Fee Structure Overview
Below is a breakdown of fees for different transaction types on Spark:
For Bitcoin
Transaction Type Fee structure L1 to Spark On-chain fee paid by the user Spark to Spark Free. Small flat fee coming in 6-12 months Spark to Lightning 0.25% + routing fee Lightning to Spark 0.15% (charged on routing nodes via route hints) Exit to L1 L1 fee + SSP fee (see formula below) Unilateral Exit On-chain fee paid by the user
For BTKN assets
Transaction Type Fee structure L1 to Spark On-chain fee paid by the user Spark to Spark Free. Small flat fee coming in 6-12 months Unilateral Exit On-chain fee + bond locked by user
Some of the fees are sourced directly from the Lightspark SSP, specifically for Spark–Lightning interactions and exits back to L1. Lightspark is the first SSP on Spark, but the system is open. Anyone can run an SSP (SSP specs coming soon). If you’re an SSP, reach out, and we’ll include your fee structure.
Fee Estimation Flow
The complete process for estimating fees before making transactions:
Choose Operation Type
Determine which type of operation you want to estimate fees for. // Lightning payment
const lightningInvoice = "lnbc..." ;
// Cooperative exit (withdrawal to L1)
const withdrawalAmount = 10000 ;
const withdrawalAddress = "bc1p..." ;
// Swap operation
const swapAmount = 5000 ;
Get Fee Estimate
Call the appropriate fee estimation method. // Lightning send fee estimate
const lightningFee = await wallet . getLightningSendFeeEstimate ({
encodedInvoice: lightningInvoice
});
// Cooperative exit fee estimate
const exitFee = await wallet . getWithdrawalFeeQuote ({
amountSats: withdrawalAmount ,
withdrawalAddress: withdrawalAddress
});
// Swap fee estimate
const swapFee = await wallet . getSwapFeeEstimate ( swapAmount );
Review Fee Details
Examine the fee estimate response to understand costs. console . log ( "Lightning fee estimate:" , lightningFee , "sats" );
console . log ( "Exit fee estimate:" , exitFee );
console . log ( "Swap fee estimate:" , swapFee );
Proceed with Transaction
Use the fee estimate to set appropriate limits for your transaction. // Use fee estimate for Lightning payment
const payment = await wallet . payLightningInvoice ({
invoice: lightningInvoice ,
maxFeeSats: lightningFee + 5 // Add buffer to fee estimate
});
Lightning Send Fee Estimates
Estimate fees for sending Lightning payments before making the transaction.
getLightningSendFeeEstimate(params)
Gets an estimated fee for sending a Lightning payment. Note: the actual fee assessed may be different from the fee estimate as it will be determined by the actual Lightning node routing.
const feeEstimateSats = await wallet . getLightningSendFeeEstimate ({
encodedInvoice: "lnbcrt1u1pnm7ammpp4v84f05tl0kzt6g95g056athdpp8f8azvg6d7epz74z562ymer9jqsp5nc50gazvp0e98u42jlu653rw0eutcl067nqq924hf89q4la4kd9sxq9z0rgqnp4qdnmwu8v22cvq9xsv2l05cn9rre7xlcgdtntxawf8m0zxq3qemgzqrzjqtr2vd60g57hu63rdqk87u3clac6jlfhej4kldrrjvfcw3mphcw8sqqqqrj0q7ew45qqqqqqqqqqqqqq9qcqzpgdq5w3jhxapqd9h8vmmfvdjs9qyyssqj7lf2w4m587g04n4t0ferdv0vnwftzca0xuc9yxycng78cnhrvmyw2mzaa8t76jskpypqnwqhp9xh0vnwxz90jytd34vrmhcngsnl8qplz7ylk"
});
console . log ( "Lightning send fee estimate:" , feeEstimateSats , "sats" );
The BOLT11-encoded Lightning invoice
Estimated fee in satoshis
Example Response
100 // fee estimate in satoshis
Cooperative Exit Fee Estimates
Estimate fees for withdrawing funds back to the Bitcoin network (cooperative exit).
getWithdrawalFeeQuote(params)
Gets a fee quote for a cooperative exit (on-chain withdrawal). The quote includes options for different speeds and an expiry time and must be passed to withdraw before it expires.
const exitFeeEstimate = await wallet . getWithdrawalFeeQuote ({
amountSats: 10000 ,
withdrawalAddress: "bc1p5d7rjq7g6rdk2yhzks9smtbqtedr4dekq08ge8ztwac72sfr9rusxg3297"
});
console . log ( "Cooperative exit fee estimate:" , exitFeeEstimate );
The amount in satoshis to withdraw
The Bitcoin address where the funds should be sent
exitFeeEstimate
CoopExitFeeQuote | null
required
A fee quote for the withdrawal, or null if not available
Example Response
{
feeEstimate : {
originalValue : 1000 ,
originalUnit : 'SATOSHI' ,
preferredCurrencyUnit : 'USD' ,
preferredCurrencyValueRounded : 0.50 ,
preferredCurrencyValueApprox : 0.483
}
}
Swap Fee Estimates
Estimate fees for leaves swap operations. Leaves swaps are internal wallet optimization operations that consolidate or split your sats leaves.
getSwapFeeEstimate(amountSats)
Gets the estimated fee for a swap of leaves.
const swapFeeEstimate = await wallet . getSwapFeeEstimate ( 5000 );
console . log ( "Swap fee estimate:" , swapFeeEstimate );
The amount of sats to swap
swapFeeEstimate
LeavesSwapFeeEstimateOutput
required
The estimated fee for the swap operation
When Fees Apply
Understanding when different types of fees are charged:
Lightning Payments:
Routing fees for Lightning Network transactions
Fees vary based on network conditions and routing path
Estimated fees may differ from actual fees charged
Cooperative Exits (L1 Withdrawals):
The fee consists of two components:
L1 broadcast fee : tx_vbytes × sats_per_vbyte
SSP fee : 111 × sats_per_vbyte × 2 (where 111 vbytes is the minimum transaction size)
Total formula: sats_per_vbyte × (111 × 2 + tx_vbytes)
The fee is flat and doesn’t scale with withdrawal amount. For small withdrawals, the fee may represent a higher percentage of the amount.
Different speeds (fast, medium, slow) use different sats_per_vbyte estimates based on mempool conditions.
Leaves Swap Operations:
Fees for consolidating or splitting sats leaves
Swaps are automatic and run as needed by the wallet
Used for internal wallet optimization
Fee Deduction Options
For cooperative exits, you can choose how fees are handled:
Deduct Fee from Withdrawal Amount
When deductFeeFromWithdrawalAmount is set to true:
const withdrawal = await wallet . withdraw ({
onchainAddress: "bc1p..." ,
exitSpeed: "medium" ,
amountSats: 10000 , // This is the net amount you'll receive
feeQuote: feeQuote ,
deductFeeFromWithdrawalAmount: true // Fee deducted from amount
});
// You receive: 10000 sats - fee
Pay Fee Separately
When deductFeeFromWithdrawalAmount is set to false:
const withdrawal = await wallet . withdraw ({
onchainAddress: "bc1p..." ,
exitSpeed: "medium" ,
amountSats: 10000 , // This is the gross amount you'll receive
feeQuote: feeQuote ,
deductFeeFromWithdrawalAmount: false // Fee paid separately
});
// You receive: 10000 sats (fee paid from wallet balance)
Complete Example
import { SparkWallet } from "@buildonspark/spark-sdk" ;
async function estimateAllFees () {
const { wallet } = await SparkWallet . initialize ({
options: { network: "REGTEST" }
});
try {
// 1. Lightning send fee estimate
const lightningInvoice = "lnbcrt1u1pnm7ammpp4v84f05tl0kzt6g95g056athdpp8f8azvg6d7epz74z562ymer9jqsp5nc50gazvp0e98u42jlu653rw0eutcl067nqq924hf89q4la4kd9sxq9z0rgqnp4qdnmwu8v22cvq9xsv2l05cn9rre7xlcgdtntxawf8m0zxq3qemgzqrzjqtr2vd60g57hu63rdqk87u3clac6jlfhej4kldrrjvfcw3mphcw8sqqqqrj0q7ew45qqqqqqqqqqqqqq9qcqzpgdq5w3jhxapqd9h8vmmfvdjs9qyyssqj7lf2w4m587g04n4t0ferdv0vnwftzca0xuc9yxycng78cnhrvmyw2mzaa8t76jskpypqnwqhp9xh0vnwxz90jytd34vrmhcngsnl8qplz7ylk" ;
const lightningFee = await wallet . getLightningSendFeeEstimate ({
encodedInvoice: lightningInvoice
});
console . log ( "Lightning fee estimate:" , lightningFee , "sats" );
// 2. Cooperative exit fee estimate
const exitFee = await wallet . getWithdrawalFeeQuote ({
amountSats: 10000 ,
withdrawalAddress: "bc1p5d7rjq7g6rdk2yhzks9smtbqtedr4dekq08ge8ztwac72sfr9rusxg3297"
});
if ( exitFee ) {
console . log ( "Exit fee estimate:" , exitFee . fast , "sats (fast)" );
console . log ( "Exit fee estimate:" , exitFee . medium , "sats (medium)" );
console . log ( "Exit fee estimate:" , exitFee . slow , "sats (slow)" );
}
// 3. Swap fee estimate
const swapFee = await wallet . getSwapFeeEstimate ( 5000 );
console . log ( "Swap fee estimate:" , swapFee );
// 4. Use estimates for actual transactions
const payment = await wallet . payLightningInvoice ({
invoice: lightningInvoice ,
maxFeeSats: lightningFee + 5 // Add 5 sats buffer
});
console . log ( "Lightning payment initiated with fee buffer" );
} catch ( error ) {
console . error ( "Fee estimation failed:" , error );
}
}