diff --git a/modules/sdk-core/src/coins/ofcToken.ts b/modules/sdk-core/src/coins/ofcToken.ts index 8769635f75..44d69377d1 100644 --- a/modules/sdk-core/src/coins/ofcToken.ts +++ b/modules/sdk-core/src/coins/ofcToken.ts @@ -10,7 +10,7 @@ import { SignedTransaction, ITransactionRecipient, } from '../'; -import { isBolt11Invoice, LIGHTNING_INVOICE } from '../lightning'; +import { isBolt11Invoice } from '../lightning'; import { Ofc } from './ofc'; @@ -76,25 +76,19 @@ export class OfcToken extends Ofc { throw new Error(`invalid argument - lightning invoice is only supported for bitcoin`); } - // amount for bolt11 invoices is either 'invoice' or a non-zero bigint - if (recipient.amount === LIGHTNING_INVOICE) { - return; - } - // try to parse the amount as a bigint + // amount for bolt11 invoices must be a non-zero bigint let amount: bigint; try { amount = BigInt(recipient.amount); } catch (e) { throw new Error( - `invalid argument ${recipient.amount} for amount - lightning invoice amount must be >= 0 or ${LIGHTNING_INVOICE}` + `invalid argument ${recipient.amount} for amount - lightning invoice amount must be a non-zero bigint` ); } if (amount > 0n) { return; } - throw new Error( - `invalid argument for amount - lightning invoice amount must be a non-zero bigint or ${LIGHTNING_INVOICE}` - ); + throw new Error(`invalid argument for amount - lightning invoice amount must be a non-zero bigint`); } super.checkRecipient(recipient); diff --git a/modules/sdk-core/src/lightning.ts b/modules/sdk-core/src/lightning.ts index c6543476df..234fe7499e 100644 --- a/modules/sdk-core/src/lightning.ts +++ b/modules/sdk-core/src/lightning.ts @@ -1,5 +1,3 @@ -export const LIGHTNING_INVOICE = 'invoice'; - export function isBolt11Invoice(value: unknown): value is string { if (typeof value !== 'string') { return false;