mirror of
https://github.com/logos-blockchain/logos-execution-zone-module.git
synced 2026-07-08 11:40:18 +00:00
faet: mnemonic functionality
This commit is contained in:
parent
5d42559db8
commit
ce0209f2f8
8676
flake.lock
generated
8676
flake.lock
generated
File diff suppressed because it is too large
Load Diff
@ -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/lssa?rev=cf3639d8252040d13b3d4e933feb19b42c76e14a"; # v0.1.2
|
||||
logos-execution-zone.url = "github:logos-blockchain/lssa?rev=a3ed22288759961a2cabd74cbf1bd5f9319ec6af"; # latest functionality
|
||||
};
|
||||
|
||||
outputs = inputs@{ logos-module-builder, ... }:
|
||||
|
||||
@ -89,11 +89,12 @@ public:
|
||||
virtual QString register_private_account(const QString& account_id_hex) = 0;
|
||||
|
||||
// Wallet Lifecycle
|
||||
virtual int create_new(
|
||||
virtual QString create_new(
|
||||
const QString& config_path,
|
||||
const QString& storage_path,
|
||||
const QString& password
|
||||
) = 0;
|
||||
virtual int restore_storage(const QString& mnemonic, const QString password) = 0;
|
||||
virtual int open(const QString& config_path, const QString& storage_path) = 0;
|
||||
virtual int save() = 0;
|
||||
|
||||
|
||||
@ -728,24 +728,39 @@ QString LogosExecutionZoneWalletModule::register_private_account(const QString&
|
||||
|
||||
// === Wallet Lifecycle ===
|
||||
|
||||
int LogosExecutionZoneWalletModule::create_new(
|
||||
QString LogosExecutionZoneWalletModule::create_new(
|
||||
const QString& config_path,
|
||||
const QString& storage_path,
|
||||
const QString& password
|
||||
) {
|
||||
if (walletHandle) {
|
||||
qWarning() << "create_new: wallet is already open";
|
||||
return INTERNAL_ERROR;
|
||||
return transferResultToJson(nullptr, QStringLiteral("create_new: wallet is already open"));
|
||||
}
|
||||
|
||||
const QByteArray config_utf8 = config_path.toUtf8();
|
||||
const QByteArray storage_utf8 = storage_path.toUtf8();
|
||||
const QByteArray password_utf8 = password.toUtf8();
|
||||
|
||||
walletHandle = wallet_ffi_create_new(config_utf8.constData(), storage_utf8.constData(), password_utf8.constData());
|
||||
if (!walletHandle) {
|
||||
FfiCreateWalletResult create_result = wallet_ffi_create_new(config_utf8.constData(), storage_utf8.constData(), password_utf8.constData());
|
||||
if (!create_result.wallet) {
|
||||
qWarning() << "create_new: wallet_ffi_create_new returned null";
|
||||
return INTERNAL_ERROR;
|
||||
return transferResultToJson(nullptr, QStringLiteral("create_new: wallet_ffi_create_new returned null"));
|
||||
}
|
||||
|
||||
walletHandle = create_result.wallet;
|
||||
|
||||
return QString::fromUtf8(*(create_result.mnemonic));
|
||||
}
|
||||
|
||||
int LogosExecutionZoneWalletModule::restore_storage(const QString& mnemonic, const QString password) {
|
||||
const QByteArray mnemonic_utf8 = mnemonic.toUtf8();
|
||||
const QByteArray password_utf8 = password.toUtf8();
|
||||
|
||||
const WalletFfiError error = wallet_ffi_restore_data(walletHandle, mnemonic_utf8.constData(), password_utf8.constData());
|
||||
if (error != SUCCESS) {
|
||||
qWarning() << "restore_storage: wallet FFI error" << error;
|
||||
return error;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
|
||||
@ -116,7 +116,8 @@ public:
|
||||
Q_INVOKABLE QString register_private_account(const QString& account_id_hex) override;
|
||||
|
||||
// Wallet Lifecycle
|
||||
Q_INVOKABLE int create_new(const QString& config_path, const QString& storage_path, const QString& password) override;
|
||||
Q_INVOKABLE QString create_new(const QString& config_path, const QString& storage_path, const QString& password) override;
|
||||
Q_INVOKABLE int restore_storage(const QString& mnemonic, const QString password) override;
|
||||
Q_INVOKABLE int open(const QString& config_path, const QString& storage_path) override;
|
||||
Q_INVOKABLE int save() override;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user