fedimint-web-sdk
fedimint-web-sdk copied to clipboard
Invoice Generates in millisats instead of sats
When generating a Lightning invoice using the "Generate Lightning Invoice" form in the Fedimint TypeScript demo, the amount input is in sats (as labeled), but the resulting invoice amount is interpreted as millisats. This leads to a 1000x discrepancy in the invoice value.
async createInvoice(
amountMsats: number,
description: string,
expiryTime?: number, // in seconds
gatewayInfo?: GatewayInfo,
extraMeta?: JSONObject,
): Promise<CreateBolt11Response> {
const gateway = gatewayInfo ?? (await this._getDefaultGatewayInfo())
return await this.client.rpcSingle('ln', 'create_bolt11_invoice', {
amount: amountMsats,
description,
expiry_time: expiryTime ?? null,
extra_meta: extraMeta ?? {},
gateway,
})
}
However, the value entered is passed directly to the createInvoice method without converting it to millisatoshis (msats), which the backend expects.
@alexlwn123, Would you recommend simply multiplying the input by 1000 on the frontend, or would it be better to update the createInvoice function to accept the amount in sats instead?
Sorry for missing this.
Would you recommend simply multiplying the input by 1000 on the frontend, or would it be better to update the createInvoice function to accept the amount in sats instead?
Let's keep the function as MSats to stay aligned with the underlying library. We should correct the example app to say MSats
and what about the parseBolt11Invoice? should I keep it as sats or convert the value to msats on the ts side?