import {
SwapError,
SchemaError,
NetworkError,
SwapExpiredError,
InvoiceExpiredError,
InvoiceFailedToPayError,
InsufficientFundsError,
TransactionFailedError,
} from '@arkade-os/boltz-swap';
try {
await arkadeLightning.sendLightningPayment({
invoice: 'lnbc500u1pj...',
});
} catch (error) {
if (error instanceof InvoiceExpiredError) {
console.error('The invoice has expired. Please request a new one.');
} else if (error instanceof InvoiceFailedToPayError) {
console.error('The provider failed to pay the invoice. Please request a new one.');
} else if (error instanceof InsufficientFundsError) {
console.error('Not enough funds available:', error.message);
} else if (error instanceof NetworkError) {
console.error('Network issue. Please try again later:', error.message);
} else if (error instanceof SchemaError) {
console.error('Invalid response from API. Please try again later.');
} else if (error instanceof SwapExpiredError) {
console.error('The swap has expired. Please request a new invoice.');
} else if (error instanceof SwapError) {
console.error('Swap failed:', error.message);
} else if (error instanceof TransactionFailedError) {
console.error('Transaction failed. Please try again later');
} else {
console.error('Unknown error:', error);
}
// You might be able to claim a refund
if (error.isRefundable && error.pendingSwap) {
const refundResult = await arkadeLightning.refundVHTLC(error.pendingSwap);
console.log('Refund claimed:', refundResult.txid);
}
}