Skip to content

Commit

Permalink
compute nsec dynamically (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc authored Sep 3, 2024
1 parent cbe579c commit fb12e10
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/stores/nostr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ export const useNostrStore = defineStore("nostr", {
nip46signer: {} as NDKNip46Signer,
privateKeySignerPrivateKey: useLocalStorage<string>("cashu.ndk.privateKeySignerPrivateKey", ""),
seedSignerPrivateKey: useLocalStorage<string>("cashu.ndk.seedSignerPrivateKey", ""),
seedSignerPrivateKeyNsec: useLocalStorage<string>("cashu.ndk.seedSignerPrivateKeyNsec", ""),
seedSignerPrivateKeyNsec: "",
privateKeySigner: {} as NDKPrivateKeySigner,
signer: {} as NDKSigner,
mintRecommendations: useLocalStorage<MintRecommendation[]>("cashu.ndk.mintRecommendations", []),
initialized: false,
}),
getters: {

seedSignerPrivateKeyNsec: (state) => {
const sk = hexToBytes(state.seedSignerPrivateKey);
return nip19.nsecEncode(sk);
}
},
actions: {
initNdkReadOnly: function () {
Expand Down Expand Up @@ -166,7 +169,6 @@ export const useNostrStore = defineStore("nostr", {
const walletPublicKeyHex = getPublicKey(sk) // `pk` is a hex string
const walletPrivateKeyHex = bytesToHex(sk)
this.seedSignerPrivateKey = walletPrivateKeyHex;
this.seedSignerPrivateKeyNsec = nip19.nsecEncode(sk);
this.privateKeySigner = new NDKPrivateKeySigner(walletPrivateKeyHex)
this.signerType = SignerType.SEED;
this.setSigner(this.privateKeySigner);
Expand Down

0 comments on commit fb12e10

Please sign in to comment.