From 75660e7ff1c6b9dde438026bb46619f83bd64c03 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Wed, 23 Oct 2024 17:09:00 -0300 Subject: [PATCH] nip46: cache the received pubkey. --- nip46.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nip46.ts b/nip46.ts index e758d2f..d29c985 100644 --- a/nip46.ts +++ b/nip46.ts @@ -89,6 +89,8 @@ export class BunkerSigner { private secretKey: Uint8Array public bp: BunkerPointer + private cachedPubKey: string | undefined + /** * Creates a new instance of the Nip46 class. * @param relays - An array of relay addresses. @@ -213,7 +215,10 @@ export class BunkerSigner { * pubkey may be different.) */ async getPublicKey(): Promise { - return await this.sendRequest('get_public_key', []) + if (!this.cachedPubKey) { + this.cachedPubKey = await this.sendRequest('get_public_key', []) + } + return this.cachedPubKey } /**