bug: handle nwc reply
This commit is contained in:
parent
9d67da3b6f
commit
1923273f6f
@ -117,9 +117,9 @@ export class NostrConnectWallet implements LNWallet {
|
|||||||
throw new WalletError(WalletErrorCode.GeneralError, "No pending command found");
|
throw new WalletError(WalletErrorCode.GeneralError, "No pending command found");
|
||||||
}
|
}
|
||||||
|
|
||||||
const body = JSON.parse(await EventExt.decryptData(e.content, this.#config.secret, this.#config.walletPubkey));
|
pending.resolve(e.content);
|
||||||
pending.resolve(body);
|
|
||||||
this.#commandQueue.delete(replyTo[1]);
|
this.#commandQueue.delete(replyTo[1]);
|
||||||
|
this.#conn?.CloseReq(sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
async #rpc<T>(method: string, params: Record<string, string>) {
|
async #rpc<T>(method: string, params: Record<string, string>) {
|
||||||
@ -135,12 +135,30 @@ export class NostrConnectWallet implements LNWallet {
|
|||||||
.tag(["p", this.#config.walletPubkey]);
|
.tag(["p", this.#config.walletPubkey]);
|
||||||
|
|
||||||
const evCommand = await eb.buildAndSign(this.#config.secret);
|
const evCommand = await eb.buildAndSign(this.#config.secret);
|
||||||
|
this.#conn.QueueReq(
|
||||||
|
[
|
||||||
|
"REQ",
|
||||||
|
evCommand.id.slice(0, 12),
|
||||||
|
{
|
||||||
|
kinds: [23195],
|
||||||
|
authors: [this.#config.walletPubkey],
|
||||||
|
["#e"]: [evCommand.id],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
() => {
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
);
|
||||||
await this.#conn.SendAsync(evCommand);
|
await this.#conn.SendAsync(evCommand);
|
||||||
/*return await new Promise<T>((resolve, reject) => {
|
return await new Promise<T>((resolve, reject) => {
|
||||||
this.#commandQueue.set(evCommand.id, {
|
this.#commandQueue.set(evCommand.id, {
|
||||||
resolve, reject
|
resolve: async (o: string) => {
|
||||||
})
|
const reply = JSON.parse(await EventExt.decryptData(o, this.#config.secret, this.#config.walletPubkey));
|
||||||
})*/
|
console.debug("NWC", reply);
|
||||||
return {} as T;
|
resolve(reply);
|
||||||
|
},
|
||||||
|
reject,
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user