This commit is contained in:
vivganes 2023-04-27 19:18:17 +05:30
parent 198b5c3858
commit 8c164c0340
1 changed files with 8 additions and 1 deletions

View File

@ -88,7 +88,7 @@ export class MultiAccountStore extends ExternalStore<LoginSession> {
if (this.#accounts.has(key)) {
throw new Error("Already logged in with this pubkey");
}
const initRelays = relays ?? Object.fromEntries(DefaultRelays.entries());
const initRelays = this.decideInitRelays(relays);
const newSession = {
...LoggedOut,
publicKey: key,
@ -105,6 +105,13 @@ export class MultiAccountStore extends ExternalStore<LoginSession> {
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>) {
const pubKey = secp.utils.bytesToHex(secp.schnorr.getPublicKey(key));
if (this.#accounts.has(pubKey)) {