From 48fab40a3c871e4cd8b3792b35e440c6c655819b Mon Sep 17 00:00:00 2001 From: Sergio Chouhy Date: Thu, 4 Jun 2026 23:34:11 -0300 Subject: [PATCH] add shielded tab --- src/LEZWalletBackend.cpp | 23 +++++++++++++++++ src/LEZWalletBackend.h | 2 ++ src/LEZWalletBackend.rep | 2 ++ src/qml/ExecutionZoneWalletView.qml | 18 +++++++++++++ src/qml/views/DashboardView.qml | 4 +++ src/qml/views/TransferPanel.qml | 40 ++++++++++++++++++++--------- 6 files changed, 77 insertions(+), 12 deletions(-) diff --git a/src/LEZWalletBackend.cpp b/src/LEZWalletBackend.cpp index e8f8f5b..5eda5f3 100644 --- a/src/LEZWalletBackend.cpp +++ b/src/LEZWalletBackend.cpp @@ -234,6 +234,29 @@ QString LEZWalletBackend::transferPrivateOwned(QString fromHex, QString toHex, Q return m_logos->logos_execution_zone.transfer_private_owned(fromHex, toHex.trimmed(), amountHex); } +QString LEZWalletBackend::transferShielded(QString fromHex, QString toKeysJson, QString amountStr) +{ + const QString amountHex = amountToLe16Hex(amountStr); + if (amountHex.isEmpty()) return QStringLiteral("Error: Invalid amount."); + + QString keysPayload = toKeysJson.trimmed(); + if (!keysPayload.startsWith(QLatin1Char('{'))) { + qDebug() << "LEZWalletBackend::transferShielded: resolving keys via get_private_account_keys"; + const QString resolved = getPrivateAccountKeys(keysPayload); + if (!resolved.isEmpty()) + keysPayload = resolved; + } + + return m_logos->logos_execution_zone.transfer_shielded(fromHex, keysPayload, amountHex); +} + +QString LEZWalletBackend::transferShieldedOwned(QString fromHex, QString toHex, QString amountStr) +{ + const QString amountHex = amountToLe16Hex(amountStr); + if (amountHex.isEmpty()) return QStringLiteral("Error: Invalid amount."); + return m_logos->logos_execution_zone.transfer_shielded_owned(fromHex, toHex.trimmed(), amountHex); +} + bool LEZWalletBackend::createNew(QString configPath, QString storagePath, QString password) { const QString localPath = toLocalPath(configPath); diff --git a/src/LEZWalletBackend.h b/src/LEZWalletBackend.h index 0ebcc3e..259b971 100644 --- a/src/LEZWalletBackend.h +++ b/src/LEZWalletBackend.h @@ -40,6 +40,8 @@ public slots: QString transferPublic(QString fromHex, QString toHex, QString amountStr) override; QString transferPrivate(QString fromHex, QString toHex, QString amountStr) override; QString transferPrivateOwned(QString fromHex, QString toHex, QString amountStr) override; + QString transferShielded(QString fromHex, QString toKeysJson, QString amountStr) override; + QString transferShieldedOwned(QString fromHex, QString toHex, QString amountStr) override; bool createNew(QString configPath, QString storagePath, QString password) override; void copyToClipboard(QString text) override; diff --git a/src/LEZWalletBackend.rep b/src/LEZWalletBackend.rep index aec5790..695958f 100644 --- a/src/LEZWalletBackend.rep +++ b/src/LEZWalletBackend.rep @@ -19,6 +19,8 @@ class LEZWalletBackend SLOT(QString transferPublic(QString fromHex, QString toHex, QString amountStr)) SLOT(QString transferPrivate(QString fromHex, QString toHex, QString amountStr)) SLOT(QString transferPrivateOwned(QString fromHex, QString toHex, QString amountStr)) + SLOT(QString transferShielded(QString fromHex, QString toKeysJson, QString amountStr)) + SLOT(QString transferShieldedOwned(QString fromHex, QString toHex, QString amountStr)) SLOT(bool createNew(QString configPath, QString storagePath, QString password)) diff --git a/src/qml/ExecutionZoneWalletView.qml b/src/qml/ExecutionZoneWalletView.qml index 9814e46..5b27095 100644 --- a/src/qml/ExecutionZoneWalletView.qml +++ b/src/qml/ExecutionZoneWalletView.qml @@ -180,6 +180,24 @@ Rectangle { dashboardView.transferResultIsError = true }) } + onTransferShieldedRequested: (fromId, toKeysJsonOrAddress, amount) => { + if (!backend) return + logos.watch(backend.transferShielded(fromId, toKeysJsonOrAddress, amount), + function(raw) { ffiErrors.applyTransferResult(dashboardView, raw) }, + function(error) { + dashboardView.transferResult = qsTr("Error: %1").arg(error) + dashboardView.transferResultIsError = true + }) + } + onTransferShieldedOwnedRequested: (fromId, toAccountId, amount) => { + if (!backend) return + logos.watch(backend.transferShieldedOwned(fromId, toAccountId, amount), + function(raw) { ffiErrors.applyTransferResult(dashboardView, raw) }, + function(error) { + dashboardView.transferResult = qsTr("Error: %1").arg(error) + dashboardView.transferResultIsError = true + }) + } onCopyRequested: (copyText) => { clipHelper.text = copyText clipHelper.selectAll() diff --git a/src/qml/views/DashboardView.qml b/src/qml/views/DashboardView.qml index efd4f3d..49565b6 100644 --- a/src/qml/views/DashboardView.qml +++ b/src/qml/views/DashboardView.qml @@ -20,6 +20,8 @@ Rectangle { signal transferPublicRequested(string fromAccountId, string toAddress, string amount) signal transferPrivateRequested(string fromAccountId, string toKeysJsonOrAddress, string amount) signal transferPrivateOwnedRequested(string fromAccountId, string toAccountId, string amount) + signal transferShieldedRequested(string fromAccountId, string toKeysJsonOrAddress, string amount) + signal transferShieldedOwnedRequested(string fromAccountId, string toAccountId, string amount) signal copyRequested(string copyText) color: Theme.palette.background @@ -53,6 +55,8 @@ Rectangle { onTransferPublicRequested: (fromId, toAddress, amount) => root.transferPublicRequested(fromId, toAddress, amount) onTransferPrivateRequested: (fromId, toKeysJsonOrAddress, amount) => root.transferPrivateRequested(fromId, toKeysJsonOrAddress, amount) onTransferPrivateOwnedRequested: (fromId, toAccountId, amount) => root.transferPrivateOwnedRequested(fromId, toAccountId, amount) + onTransferShieldedRequested: (fromId, toKeysJsonOrAddress, amount) => root.transferShieldedRequested(fromId, toKeysJsonOrAddress, amount) + onTransferShieldedOwnedRequested: (fromId, toAccountId, amount) => root.transferShieldedOwnedRequested(fromId, toAccountId, amount) onCopyRequested: (copyText) => root.copyRequested(copyText) } } diff --git a/src/qml/views/TransferPanel.qml b/src/qml/views/TransferPanel.qml index 9240d3f..adcd2d4 100644 --- a/src/qml/views/TransferPanel.qml +++ b/src/qml/views/TransferPanel.qml @@ -15,10 +15,12 @@ Rectangle { property string transferResult: "" property bool transferResultIsError: false - // --- Public API: signals out (match backend: transfer_public, transfer_private, transfer_private_owned) --- + // --- Public API: signals out (match backend: transfer_public, transfer_private, transfer_private_owned, transfer_shielded, transfer_shielded_owned) --- signal transferPublicRequested(string fromAccountId, string toAddress, string amount) signal transferPrivateRequested(string fromAccountId, string toKeysJsonOrAddress, string amount) signal transferPrivateOwnedRequested(string fromAccountId, string toAccountId, string amount) + signal transferShieldedRequested(string fromAccountId, string toKeysJsonOrAddress, string amount) + signal transferShieldedOwnedRequested(string fromAccountId, string toAccountId, string amount) signal copyRequested(string copyText) readonly property int fromFilterCount: fromCombo.count @@ -26,8 +28,11 @@ Rectangle { QtObject { id: d property bool useOwnedAccountForTo: false + readonly property bool isPublicTab: transferTypeBar.currentIndex === 0 readonly property bool isPrivateTab: transferTypeBar.currentIndex === 1 - readonly property bool toAddressValid: isPrivateTab && useOwnedAccountForTo + readonly property bool isShieldedTab: transferTypeBar.currentIndex === 2 + readonly property bool showOwnedOption: isPrivateTab || isShieldedTab + readonly property bool toAddressValid: showOwnedOption && useOwnedAccountForTo ? (fromFilterCount > 0 && toCombo.currentIndex >= 0) : (toField && toField.text.trim().length > 0) readonly property bool sendEnabled: amountField && manualFromField @@ -54,7 +59,7 @@ Rectangle { // Transfer type toggle TabBar { id: transferTypeBar - Layout.preferredWidth: 200 + Layout.preferredWidth: 300 currentIndex: 0 background: Rectangle { @@ -69,6 +74,10 @@ Rectangle { LogosTabButton { text: qsTr("Private") } + + LogosTabButton { + text: qsTr("Shielded") + } } // From: dropdown when accounts exist, or manual entry when list is empty @@ -111,7 +120,7 @@ Rectangle { CheckBox { id: useOwnedToCheck - visible: d.isPrivateTab + visible: d.showOwnedOption checked: d.useOwnedAccountForTo onCheckedChanged: d.useOwnedAccountForTo = checked text: qsTr("Use owned account") @@ -122,15 +131,15 @@ Rectangle { LogosTextField { id: toField Layout.fillWidth: true - placeholderText: qsTr("Recipient public key") - visible: !d.isPrivateTab || !d.useOwnedAccountForTo + placeholderText: d.isPublicTab ? qsTr("Recipient address") : qsTr("Recipient private keys (JSON)") + visible: !d.showOwnedOption || !d.useOwnedAccountForTo } AccountComboBox { id: toCombo Layout.fillWidth: true model: fromAccountModel - visible: d.isPrivateTab && d.useOwnedAccountForTo && fromFilterCount > 0 + visible: d.showOwnedOption && d.useOwnedAccountForTo && fromFilterCount > 0 onCopyRequested: (text) => root.copyRequested(text) } } @@ -168,12 +177,19 @@ Rectangle { : toField.text.trim() var amount = amountField.text.trim() if (fromId.length > 0 && toAddress.length > 0 && amount.length > 0) { - if (transferTypeBar.currentIndex === 0) + if (d.isPublicTab) root.transferPublicRequested(fromId, toAddress, amount) - else if (d.useOwnedAccountForTo) - root.transferPrivateOwnedRequested(fromId, toAddress, amount) - else - root.transferPrivateRequested(fromId, toAddress, amount) + else if (d.isPrivateTab) { + if (d.useOwnedAccountForTo) + root.transferPrivateOwnedRequested(fromId, toAddress, amount) + else + root.transferPrivateRequested(fromId, toAddress, amount) + } else if (d.isShieldedTab) { + if (d.useOwnedAccountForTo) + root.transferShieldedOwnedRequested(fromId, toAddress, amount) + else + root.transferShieldedRequested(fromId, toAddress, amount) + } } } }