add shielded tab

This commit is contained in:
Sergio Chouhy 2026-06-04 23:34:11 -03:00
parent b8ce93b180
commit 48fab40a3c
6 changed files with 77 additions and 12 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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))

View File

@ -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()

View File

@ -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)
}
}

View File

@ -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)
}
}
}
}