Lightning Send Fee Estimates

To estimate fees for sending Lightning payments, use getLightningSendFeeEstimate. This is useful before making a Lightning payment to understand the potential routing costs. PLease note: the actual fee asessed may be different the the fee estimate as it will be determined by the actual Lightning node routing.

// Get fee estimate for a Lightning payment
const feeEstimate = await wallet.getLightningSendFeeEstimate({
  encodedInvoice: "lnbc...", // Your BOLT11 invoice string
});

console.log("Lightning send fee estimate:", feeEstimate);

Example feeEstimate response:

{
  feeEstimate: {
    originalValue: 100,
    originalUnit: 'SATOSHI',
    preferredCurrencyUnit: 'USD',
    preferredCurrencyValueRounded: 0.05,
    preferredCurrencyValueApprox: 0.048
  }
}

Cooperative Exit Fee Estimates

When withdrawing funds back to the Bitcoin network (cooperative exit), you can estimate the associated fees using getCoopExitFeeEstimate:

// Get fee estimate for withdrawing to Bitcoin
const exitFeeEstimate = await wallet.getCoopExitFeeEstimate({
  amountSats: 10000n,
  withdrawalAddress: "bc1...", // Bitcoin address for withdrawal
});

Example exitFeeEstimate response:

{
  feeEstimate: {
    originalValue: 1000,
    originalUnit: 'SATOSHI',
    preferredCurrencyUnit: 'USD',
    preferredCurrencyValueRounded: 0.50,
    preferredCurrencyValueApprox: 0.483
  }
}

Understanding Fee Components

Fee Estimate Fields

  • originalValue: The fee amount in the original unit (SATOSHI)
  • originalUnit: The unit of the original value (always ‘SATOSHI’)
  • preferredCurrencyUnit: The converted currency unit (e.g., ‘USD’)
  • preferredCurrencyValueRounded: The rounded value in preferred currency
  • preferredCurrencyValueApprox: The approximate value in preferred currency

Best Practices

  • Monitor fee variations during different network conditions
  • Include fee estimates in your transaction planning

Next Steps

After understanding fee estimates, you can:

Need Help?