Skip to content

Commit 6387604

Browse files
feat(abstract-lightning): make valueMsat optional add valueSat support
The CreateInvoiceBody type is updated to: 1. Make valueMsat field optional instead of required 2. Add new optional valueSat field (numeric representation) 3. Simplify the type definition structure Also adds valueSat field to the Invoice type as a backward compatibility measure with older API versions. BTC-2775 TICKET: BTC-2775
1 parent 30f26d9 commit 6387604

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

  • modules/abstract-lightning/src/codecs/api

modules/abstract-lightning/src/codecs/api/invoice.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,12 @@ export const InvoiceStatus = t.union(
1818
);
1919
export type InvoiceStatus = t.TypeOf<typeof InvoiceStatus>;
2020

21-
export const CreateInvoiceBody = t.intersection(
22-
[
23-
t.type({
24-
valueMsat: BigIntFromString,
25-
}),
26-
t.partial({
27-
memo: t.string,
28-
expiry: t.number,
29-
}),
30-
],
31-
'CreateInvoiceBody'
32-
);
21+
export const CreateInvoiceBody = t.partial({
22+
valueMsat: BigIntFromString,
23+
valueSat: t.number,
24+
memo: t.string,
25+
expiry: t.number,
26+
});
3327
export type CreateInvoiceBody = t.TypeOf<typeof CreateInvoiceBody>;
3428

3529
/**
@@ -52,6 +46,9 @@ export const Invoice = t.intersection(
5246
updatedAt: DateFromISOString,
5347
}),
5448
t.partial({
49+
// Keep valueSat for backward compatibility with older versions of the API
50+
// Will be moved up to required fields in the future
51+
valueSat: t.number,
5552
memo: t.string,
5653
amtPaidMsat: BigIntFromString,
5754
}),

0 commit comments

Comments
 (0)