35 lines
1.3 KiB
C++
35 lines
1.3 KiB
C++
#pragma once
|
|
#include <QtCore>
|
|
#include <array>
|
|
|
|
inline const QString NrbGenesis = QStringLiteral("0177ee4010f9617feb8e2956aa4dfb7a8df18b6e4f6cc3359bdb8cfef9d10bfd");
|
|
void wipe(QByteArray &bytes);
|
|
[[noreturn]] void walletError(const QString &message);
|
|
QJsonObject offlineCore(QJsonObject request);
|
|
|
|
class WalletStore {
|
|
QString filename;
|
|
unsigned char *key = nullptr;
|
|
bool plainOpen = false;
|
|
QByteArray salt;
|
|
QByteArray plaintext;
|
|
QJsonObject decrypt(const QByteArray &file, QByteArray &password, unsigned char *outKey, QByteArray &outSalt);
|
|
void save(const QJsonObject &data);
|
|
public:
|
|
explicit WalletStore(QString path);
|
|
~WalletStore();
|
|
bool exists() const;
|
|
bool unlocked() const { return key != nullptr || plainOpen; }
|
|
bool passwordProtected() const { return key != nullptr; }
|
|
static bool fileRequiresPassword(const QString &path);
|
|
QString path() const { return filename; }
|
|
void create(QByteArray password);
|
|
void unlock(QByteArray password);
|
|
void changePassword(QByteArray password);
|
|
void lock();
|
|
QJsonArray entries() const;
|
|
QString addKey(const QJsonObject &pair, const QString &label);
|
|
void backup(const QString &destination) const;
|
|
void restore(const QString &source, QByteArray password);
|
|
};
|