diff --git a/packages/lnbits/src/client.ts b/packages/lnbits/src/client.ts index cb3645d..ad212a8 100644 --- a/packages/lnbits/src/client.ts +++ b/packages/lnbits/src/client.ts @@ -37,6 +37,7 @@ import type { CreateInvoiceBody, PayInvoiceBody, WalletInfo, + CreatedWallet, MachineConfigResponse, SubscribePaymentsBody, SubscribeAck, @@ -211,6 +212,17 @@ export class LnbitsClient { return data ?? [] } + /** + * Create an additional wallet on the calling account (`create_wallet`). + * + * Account-scoped (AUTH_ACCOUNT): the envelope carries no `wallet_id`, which + * is what makes the server resolve auth to the Account rather than a Wallet. + * NOT wrapped in `idempotent()` — a retry would mint a duplicate wallet. + */ + async createWallet(name: string): Promise { + return this.sendRpc('create_wallet', { body: { name } }) + } + /** Pull server-delivered machine config (operator pubkey + fee config) over * the authenticated transport — spirekeeper's `get_machine_config` RPC * (bitspire#70 P1). Lets a seed-only ATM configure itself with no per-machine diff --git a/packages/lnbits/src/index.ts b/packages/lnbits/src/index.ts index 9618a2f..e1e87c1 100644 --- a/packages/lnbits/src/index.ts +++ b/packages/lnbits/src/index.ts @@ -66,6 +66,7 @@ export type { CreateInvoiceBody, PayInvoiceBody, WalletInfo, + CreatedWallet, SubscribePaymentsBody, SubscribeAck, SubscribePush, diff --git a/packages/lnbits/src/types.ts b/packages/lnbits/src/types.ts index dd5e7a9..fdebb95 100644 --- a/packages/lnbits/src/types.ts +++ b/packages/lnbits/src/types.ts @@ -112,6 +112,15 @@ export interface WalletInfo { balance: number } +/** Reply shape of the `create_wallet` RPC — unlike WalletInfo it carries the + * fresh wallet's keys, so never log it verbatim. */ +export interface CreatedWallet { + id: string + name: string + adminkey: string + inkey: string +} + // ============================================================================ // Subscriptions // ============================================================================