mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-09 00:28:51 +00:00
nip46: cache the received pubkey.
This commit is contained in:
7
nip46.ts
7
nip46.ts
@@ -89,6 +89,8 @@ export class BunkerSigner {
|
|||||||
private secretKey: Uint8Array
|
private secretKey: Uint8Array
|
||||||
public bp: BunkerPointer
|
public bp: BunkerPointer
|
||||||
|
|
||||||
|
private cachedPubKey: string | undefined
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of the Nip46 class.
|
* Creates a new instance of the Nip46 class.
|
||||||
* @param relays - An array of relay addresses.
|
* @param relays - An array of relay addresses.
|
||||||
@@ -213,7 +215,10 @@ export class BunkerSigner {
|
|||||||
* pubkey may be different.)
|
* pubkey may be different.)
|
||||||
*/
|
*/
|
||||||
async getPublicKey(): Promise<string> {
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user