fix: lazy init nip46, no pubkey
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
9e896c5c27
commit
6cbc3aeb7f
@ -76,6 +76,10 @@ export class Nip46Signer extends EventEmitter<Nip46Events> implements EventSigne
|
|||||||
|
|
||||||
this.#relay = unwrap(u.searchParams.get("relay"));
|
this.#relay = unwrap(u.searchParams.get("relay"));
|
||||||
this.#insideSigner = insideSigner ?? new PrivateKeySigner(secp256k1.utils.randomPrivateKey());
|
this.#insideSigner = insideSigner ?? new PrivateKeySigner(secp256k1.utils.randomPrivateKey());
|
||||||
|
|
||||||
|
if (this.isBunker) {
|
||||||
|
this.#remotePubkey = this.#localPubkey;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get supports(): string[] {
|
get supports(): string[] {
|
||||||
@ -92,17 +96,17 @@ export class Nip46Signer extends EventEmitter<Nip46Events> implements EventSigne
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isBunker() {
|
||||||
|
return this.#proto === "bunker:";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect to the bunker relay
|
* Connect to the bunker relay
|
||||||
* @param autoConnect Start connect flow for pubkey
|
* @param autoConnect Start connect flow for pubkey
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async init(autoConnect = true) {
|
async init(autoConnect = true) {
|
||||||
const isBunker = this.#proto === "bunker:";
|
this.#localPubkey = await this.#insideSigner.getPubKey();
|
||||||
if (isBunker) {
|
|
||||||
this.#remotePubkey = this.#localPubkey;
|
|
||||||
this.#localPubkey = await this.#insideSigner.getPubKey();
|
|
||||||
}
|
|
||||||
return await new Promise<void>((resolve, reject) => {
|
return await new Promise<void>((resolve, reject) => {
|
||||||
this.#conn = new Connection(this.#relay, { read: true, write: true });
|
this.#conn = new Connection(this.#relay, { read: true, write: true });
|
||||||
this.#conn.on("event", async (sub, e) => {
|
this.#conn.on("event", async (sub, e) => {
|
||||||
@ -121,7 +125,7 @@ export class Nip46Signer extends EventEmitter<Nip46Events> implements EventSigne
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if (autoConnect) {
|
if (autoConnect) {
|
||||||
if (isBunker) {
|
if (this.isBunker) {
|
||||||
const rsp = await this.#connect(unwrap(this.#remotePubkey));
|
const rsp = await this.#connect(unwrap(this.#remotePubkey));
|
||||||
if (rsp.result === "ack") {
|
if (rsp.result === "ack") {
|
||||||
resolve();
|
resolve();
|
||||||
|
Loading…
Reference in New Issue
Block a user