Skip to content

Commit 175bc72

Browse files
authored
Merge pull request #8364 from BitGo/GO-2082
feat: remove usage of 'invoice' in amount field
2 parents 7ac007d + da48dac commit 175bc72

2 files changed

Lines changed: 4 additions & 12 deletions

File tree

modules/sdk-core/src/coins/ofcToken.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
SignedTransaction,
1111
ITransactionRecipient,
1212
} from '../';
13-
import { isBolt11Invoice, LIGHTNING_INVOICE } from '../lightning';
13+
import { isBolt11Invoice } from '../lightning';
1414

1515
import { Ofc } from './ofc';
1616

@@ -76,25 +76,19 @@ export class OfcToken extends Ofc {
7676
throw new Error(`invalid argument - lightning invoice is only supported for bitcoin`);
7777
}
7878

79-
// amount for bolt11 invoices is either 'invoice' or a non-zero bigint
80-
if (recipient.amount === LIGHTNING_INVOICE) {
81-
return;
82-
}
83-
// try to parse the amount as a bigint
79+
// amount for bolt11 invoices must be a non-zero bigint
8480
let amount: bigint;
8581
try {
8682
amount = BigInt(recipient.amount);
8783
} catch (e) {
8884
throw new Error(
89-
`invalid argument ${recipient.amount} for amount - lightning invoice amount must be >= 0 or ${LIGHTNING_INVOICE}`
85+
`invalid argument ${recipient.amount} for amount - lightning invoice amount must be a non-zero bigint`
9086
);
9187
}
9288
if (amount > 0n) {
9389
return;
9490
}
95-
throw new Error(
96-
`invalid argument for amount - lightning invoice amount must be a non-zero bigint or ${LIGHTNING_INVOICE}`
97-
);
91+
throw new Error(`invalid argument for amount - lightning invoice amount must be a non-zero bigint`);
9892
}
9993

10094
super.checkRecipient(recipient);

modules/sdk-core/src/lightning.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
export const LIGHTNING_INVOICE = 'invoice';
2-
31
export function isBolt11Invoice(value: unknown): value is string {
42
if (typeof value !== 'string') {
53
return false;

0 commit comments

Comments
 (0)