nip46: cache the received pubkey.

This commit is contained in:
fiatjaf 2024-10-23 17:09:00 -03:00
parent 4c2d2b5ce6
commit 75660e7ff1
1 changed files with 6 additions and 1 deletions

View File

@ -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<string> {
return await this.sendRequest('get_public_key', [])
if (!this.cachedPubKey) {
this.cachedPubKey = await this.sendRequest('get_public_key', [])
}
return this.cachedPubKey
}
/**