Skip to content

Commit

Permalink
store keys (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc authored Aug 16, 2024
1 parent dc858c8 commit a039e5f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
14 changes: 5 additions & 9 deletions src/components/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@
>
<q-item-label title>Use your nsec</q-item-label>
<q-item-label caption
>Enter your nostr private key
>This method is dangerous and not recommended
</q-item-label>
</q-item-section>
<q-item-section side v-if="signerType === 'PRIVATEKEY'">
Expand Down Expand Up @@ -445,20 +445,16 @@

<q-item>
<q-item-section>
<q-item-label overline>Link wallet</q-item-label>
<q-item-label overline>Nostr Wallet Connect (NWC)</q-item-label>
<q-item-label caption
>Use Nostr Wallet Connect (NWC) to control your wallet from any
other application.</q-item-label
>Use NWC to control your wallet from any other
application.</q-item-label
>
</q-item-section>
</q-item>
<!-- use a q-toggle to turn nwc on and off -->
<q-item>
<q-toggle
v-model="enableNwc"
label="Enable Nostr Wallet Connect"
color="primary"
/>
<q-toggle v-model="enableNwc" label="Enable NWC" color="primary" />
</q-item>
<!-- <q-item>
<q-btn
Expand Down
6 changes: 6 additions & 0 deletions src/stores/nostr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export const useNostrStore = defineStore("nostr", {
this.ndk.connect();
this.connected = true;
},
initSignerIfNotSet: async function () {
if (!this.signer) {
await this.initSigner();
}
},
initSigner: async function () {
if (this.signerType === SignerType.NIP07) {
await this.initNip07Signer();
Expand Down Expand Up @@ -141,6 +146,7 @@ export const useNostrStore = defineStore("nostr", {
}
}
this.privateKeySigner = new NDKPrivateKeySigner(this.privateKeySignerPrivateKey);
this.privateKeySignerPrivateKey = bytesToHex(privateKeyBytes);
this.signerType = SignerType.PRIVATEKEY;
await this.setSigner(this.privateKeySigner);
const publicKeyHex = getPublicKey(privateKeyBytes);
Expand Down
2 changes: 1 addition & 1 deletion src/stores/npubcash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const useNPCStore = defineStore("npc", {
},
generateNip98Event: async function (url: string, method: string, body: string): Promise<string> {
const nostrStore = useNostrStore()
await nostrStore.initSigner()
await nostrStore.initSignerIfNotSet()
const nip98Event = new NDKEvent(new NDK());
nip98Event.kind = NIP98Kind;
nip98Event.content = '';
Expand Down

0 comments on commit a039e5f

Please sign in to comment.