fedimint-web-sdk icon indicating copy to clipboard operation
fedimint-web-sdk copied to clipboard

Invoice Generates in millisats instead of sats

Open MrImmortal09 opened this issue 7 months ago • 3 comments

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.

MrImmortal09 avatar Apr 07 '25 19:04 MrImmortal09


  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?

MrImmortal09 avatar Apr 07 '25 19:04 MrImmortal09

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

alexlwn123 avatar Jul 01 '25 17:07 alexlwn123

and what about the parseBolt11Invoice? should I keep it as sats or convert the value to msats on the ts side?

MrImmortal09 avatar Nov 12 '25 22:11 MrImmortal09