1
0
forked from Kieran/snort
This commit is contained in:
vivganes 2023-04-27 19:18:17 +05:30
parent 198b5c3858
commit 8c164c0340

View File

@ -88,7 +88,7 @@ export class MultiAccountStore extends ExternalStore<LoginSession> {
if (this.#accounts.has(key)) { if (this.#accounts.has(key)) {
throw new Error("Already logged in with this pubkey"); throw new Error("Already logged in with this pubkey");
} }
const initRelays = relays ?? Object.fromEntries(DefaultRelays.entries()); const initRelays = this.decideInitRelays(relays);
const newSession = { const newSession = {
...LoggedOut, ...LoggedOut,
publicKey: key, publicKey: key,
@ -105,6 +105,13 @@ export class MultiAccountStore extends ExternalStore<LoginSession> {
return newSession; return newSession;
} }
decideInitRelays(relays: Record<string, RelaySettings> | undefined): Record<string, RelaySettings> {
if (relays && Object.keys(relays).length > 0) {
return relays;
}
return Object.fromEntries(DefaultRelays.entries());
}
loginWithPrivateKey(key: HexKey, entropy?: string, relays?: Record<string, RelaySettings>) { loginWithPrivateKey(key: HexKey, entropy?: string, relays?: Record<string, RelaySettings>) {
const pubKey = secp.utils.bytesToHex(secp.schnorr.getPublicKey(key)); const pubKey = secp.utils.bytesToHex(secp.schnorr.getPublicKey(key));
if (this.#accounts.has(pubKey)) { if (this.#accounts.has(pubKey)) {