feat: generic public and private transfers

This commit is contained in:
Pravdyvy 2026-06-05 19:08:50 +03:00
parent 4f6b9e8838
commit 65afa0de6a
3 changed files with 12748 additions and 4172 deletions

16863
flake.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
inputs = {
logos-module-builder.url = "github:logos-co/logos-module-builder";
nix-bundle-lgx.url = "github:logos-co/nix-bundle-lgx";
logos_execution_zone.url = "github:logos-blockchain/logos-execution-zone-module";
logos_execution_zone.url = "github:logos-blockchain/logos-execution-zone-module?rev=9ad5e83615cabf5f88efa9cde3f94185498e9b5a";
};
outputs = inputs@{ logos-module-builder, ... }:

View File

@ -9,6 +9,8 @@
#include <QSettings>
#include <QTimer>
#include <QUrl>
#include <QList>
#include <QString>
#include "logos_api.h"
#include "logos_sdk.h"
@ -42,6 +44,14 @@ namespace {
}
}
static bool hexToU128(const QString& hex, uint8_t (*output)[16]) {
QByteArray buffer;
if (!hexToBytes(hex, buffer, 16))
return false;
memcpy(output, buffer.constData(), 16);
return true;
}
LEZWalletBackend::LEZWalletBackend(LogosAPI* logosAPI, QObject* parent)
: LEZWalletBackendSimpleSource(parent),
m_accountModel(new LEZWalletAccountModel(this)),
@ -205,9 +215,30 @@ bool LEZWalletBackend::syncToBlock(quint64 blockId)
QString LEZWalletBackend::transferPublic(QString fromHex, QString toHex, QString amountStr)
{
QList<QString> account_ids = { fromHex, toHex };
QList<bool> signing_requirements = { true, false };
const QString amountHex = amountToLe16Hex(amountStr);
if (amountHex.isEmpty()) return QStringLiteral("Error: Invalid amount.");
return m_logos->logos_execution_zone.transfer_public(fromHex, toHex, amountHex);
uint8_t amount[16];
if (!hexToU128(amount_le16_hex, &amount)) {
return QStringLiteral("Error: Invalid amount.");
}
QList<uint8_t> input_data_raw;
input_data_raw.reserve(17);
input_data_raw.append(0);
for (int i = 0; i < 16; i++) {
input_data_raw.append(amount[i]);
}
QList<uint32_t> input_data = m_logos->logos_execution_zone.serialization_helper(&input_data_raw);
QList<uint8_t> elf = m_logos->logos_execution_zone.authenticated_transfer_elf();
QList<QList<uint8_t>> program_dependencies;
return m_logos->logos_execution_zone.send_generic_public_transaction(&account_ids, &signing_requirements, &input_data, &elf, &program_dependencies);
}
QString LEZWalletBackend::transferPrivate(QString fromHex, QString toHex, QString amountStr)
@ -229,9 +260,29 @@ QString LEZWalletBackend::transferPrivate(QString fromHex, QString toHex, QStrin
QString LEZWalletBackend::transferPrivateOwned(QString fromHex, QString toHex, QString amountStr)
{
QList<QString> account_ids = { fromHex, toHex };
const QString amountHex = amountToLe16Hex(amountStr);
if (amountHex.isEmpty()) return QStringLiteral("Error: Invalid amount.");
return m_logos->logos_execution_zone.transfer_private_owned(fromHex, toHex.trimmed(), amountHex);
uint8_t amount[16];
if (!hexToU128(amount_le16_hex, &amount)) {
return QStringLiteral("Error: Invalid amount.");
}
QList<uint8_t> input_data_raw;
input_data_raw.reserve(17);
input_data_raw.append(0);
for (int i = 0; i < 16; i++) {
input_data_raw.append(amount[i]);
}
QList<uint32_t> input_data = m_logos->logos_execution_zone.serialization_helper(&input_data_raw);
QList<uint8_t> elf = m_logos->logos_execution_zone.authenticated_transfer_elf();
QList<QList<uint8_t>> program_dependencies;
return m_logos->logos_execution_zone.send_generic_private_transaction(&account_ids, &input_data, &elf, &program_dependencies);
}
bool LEZWalletBackend::createNew(QString configPath, QString storagePath, QString password)