From 275a61166795005c9b01b4b4c949a1db4dc3a4ce Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Fri, 16 Aug 2024 11:53:09 +0200 Subject: [PATCH 1/5] p2pk in receive --- src/components/P2PKDialog.vue | 39 +++++++++--------- src/components/ReceiveTokenDialog.vue | 58 ++++++++++++++++++++++----- src/stores/wallet.ts | 9 ++++- 3 files changed, 76 insertions(+), 30 deletions(-) diff --git a/src/components/P2PKDialog.vue b/src/components/P2PKDialog.vue index 297dc098..94574427 100644 --- a/src/components/P2PKDialog.vue +++ b/src/components/P2PKDialog.vue @@ -18,31 +18,15 @@
- P2PK Lock
-
- - - - -
Warning: You have already used this lock before.Warning: You have already used this lock before
@@ -50,11 +34,23 @@ caption class="text-weight-light text-white" style="font-size: 14px" - >You can receive ecash locked to this key.Receive ecash locked to this key
+ + + Generate new key
diff --git a/src/components/ReceiveTokenDialog.vue b/src/components/ReceiveTokenDialog.vue index 305278d4..58ac3ec6 100644 --- a/src/components/ReceiveTokenDialog.vue +++ b/src/components/ReceiveTokenDialog.vue @@ -11,6 +11,18 @@
Receive Ecash
+ + + +
+
+ +
+ > + +
Paste + + > + + Scan + Close @@ -97,6 +122,7 @@ import { useTokensStore } from "src/stores/tokens"; import { useCameraStore } from "src/stores/camera"; import { useP2PKStore } from "src/stores/p2pk"; import token from "src/js/token"; +import P2PKDialog from "./P2PKDialog.vue"; import { mapActions, mapState, mapWritableState } from "pinia"; // import ChooseMint from "components/ChooseMint.vue"; @@ -107,10 +133,13 @@ export default defineComponent({ mixins: [windowMixin], components: { TokenInformation, + P2PKDialog, }, props: {}, data: function () { - return {}; + return { + showP2PKDialog: false, + }; }, computed: { ...mapWritableState(useReceiveTokensStore, [ @@ -125,6 +154,7 @@ export default defineComponent({ ]), ...mapWritableState(useMintsStore, ["addMintData", "showAddMintDialog"]), ...mapState(useCameraStore, ["hasCamera"]), + ...mapState(useP2PKStore, ["p2pkKeys"]), canPasteFromClipboard: function () { return ( window.isSecureContext && @@ -144,7 +174,10 @@ export default defineComponent({ ...mapActions(useWalletStore, ["redeem"]), ...mapActions(useCameraStore, ["closeCamera", "showCamera"]), ...mapActions(useTokensStore, ["addPendingToken"]), - ...mapActions(useP2PKStore, ["getPrivateKeyForP2PKEncodedToken"]), + ...mapActions(useP2PKStore, [ + "getPrivateKeyForP2PKEncodedToken", + "showKeyDetails", + ]), knowThisMintOfTokenJson: function (tokenJson) { const mintStore = useMintsStore(); // check if we have all mints @@ -212,6 +245,13 @@ export default defineComponent({ getMint: function (decoded_token) { return token.getMint(decoded_token); }, + handleLockBtn: function () { + this.showP2PKDialog = !this.showP2PKDialog; + if (!this.p2pkKeys.length || !this.showP2PKDialog) { + return; + } + this.showKeyDetails(this.p2pkKeys[0].publicKey); + }, receveIfDecodes: function () { try { const decodedToken = this.decodeToken(this.receiveData.tokensBase64); diff --git a/src/stores/wallet.ts b/src/stores/wallet.ts index 649d6b9d..bc9f6404 100644 --- a/src/stores/wallet.ts +++ b/src/stores/wallet.ts @@ -989,6 +989,12 @@ export const useWalletStore = defineStore("wallet", { this.payInvoiceData.show = false; receiveStore.showReceiveTokens = true; }, + handleP2PK: function (req: string) { + const sendTokenStore = useSendTokensStore() + sendTokenStore.sendData.p2pkPubkey = req + sendTokenStore.showSendTokens = true + sendTokenStore.showLockInput = true + }, decodeRequest: async function (req: string) { const p2pkStore = useP2PKStore() this.payInvoiceData.input.request = req @@ -1017,8 +1023,7 @@ export const useWalletStore = defineStore("wallet", { receiveStore.receiveData.tokensBase64 = req.slice(req.indexOf("cashuA")); this.handleCashuToken() } else if (p2pkStore.isValidPubkey(req)) { - const sendTokenStore = useSendTokensStore() - sendTokenStore.sendData.p2pkPubkey = req + this.handleP2PK(req) } else if ( req.startsWith("http") ) { From 455b4858f385e4e97ff15fff52f3d2f99183cc50 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Fri, 16 Aug 2024 12:45:14 +0200 Subject: [PATCH 2/5] fix units --- src/components/BalanceView.vue | 6 ++++-- src/components/P2PKDialog.vue | 1 + src/components/ToggleUnit.vue | 18 ++++++++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/components/BalanceView.vue b/src/components/BalanceView.vue index e325bf02..68230c60 100644 --- a/src/components/BalanceView.vue +++ b/src/components/BalanceView.vue @@ -3,7 +3,7 @@ -->
- +
- + {{ formatCurrency( (getTotalBalance / 100 / bitcoinPrice) * 100000000, diff --git a/src/components/P2PKDialog.vue b/src/components/P2PKDialog.vue index 94574427..a9b568d1 100644 --- a/src/components/P2PKDialog.vue +++ b/src/components/P2PKDialog.vue @@ -40,6 +40,7 @@