Skip to content

Commit

Permalink
set p2pk keys as used
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Aug 16, 2024
1 parent 518600b commit 722f9bd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/components/P2PKDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
<div v-if="showP2PKData.used" class="row justify-center q-pt-sm">
<q-item-label
caption
class="text-weight-light text-white"
class="text-weight-bold text-warning"
style="font-size: 14px"
>Warning: You have already used this lock before</q-item-label
>Warning: This key was used before. Use a new key for better
privacy.</q-item-label
>
</div>
<div v-else class="row justify-center q-pt-sm">
Expand Down
12 changes: 9 additions & 3 deletions src/components/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
<q-icon
name="content_copy"
@click="copyText(key.publicKey)"
size="1em"
size="1.2em"
color="grey"
class="q-mr-xs cursor-pointer"
/>
Expand All @@ -107,13 +107,19 @@
<q-item-label
caption
clickable
style="word-break: break-word"
style="word-break: break-word; font-size: 0.65rem"
class="q-mx-sm"
@click="showP2PKKeyEntry(key.publicKey)"
>{{ key.publicKey }}</q-item-label
>
</q-item-section>
<q-item-section side>
<q-badge v-if="key.used" label="used" color="primary" />
<q-badge
v-if="key.used"
label="used"
color="primary"
class="q-mr-sm"
/>
</q-item-section>
<q-item-section class="q-mx-none q-pl-none" style="max-width: 1.05em">
<q-icon
Expand Down
7 changes: 7 additions & 0 deletions src/stores/p2pk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ export const useP2PKStore = defineStore("p2pk", {
isValidPubkey: function (key: string) {
return key && key.length == 66;
},
setPrivateKeyUsed: function (key: string) {
const thisKeys = this.p2pkKeys.filter((k) => k.privateKey == key)
if (thisKeys.length) {
thisKeys[0].used = true;
thisKeys[0].usedCount += 1;
}
},
showKeyDetails: function (key: string) {
const thisKeys = this.p2pkKeys.filter((k) => k.publicKey == key)
if (thisKeys.length) {
Expand Down
3 changes: 3 additions & 0 deletions src/stores/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ export const useWalletStore = defineStore("wallet", {
*/
const uIStore = useUiStore();
const mintStore = useMintsStore();
const p2pkStore = useP2PKStore();

receiveStore.showReceiveTokens = false;
console.log("### receive tokens", receiveStore.receiveData.tokensBase64);

Expand All @@ -393,6 +395,7 @@ export const useWalletStore = defineStore("wallet", {
if (tokensWithErrors?.token || tokenReceived.token.length == 0) {
throw new Error("Error receiving tokens");
}
p2pkStore.setPrivateKeyUsed(privkey);

// this.increaseKeysetCounter(keysetId, tokenReceived.token[0].proofs.length);
this.increaseKeysetCounter(keysetId, tokenReceived.token.map(t => t.proofs.length).reduce((a, b) => a + b, 0));
Expand Down

0 comments on commit 722f9bd

Please sign in to comment.