2022-02-14 14:38:41 +00:00
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include "controller.h"
|
|
|
|
|
2022-02-21 17:07:16 +00:00
|
|
|
const QString WALLETSERVICE_NULL_ERROR = "wallet service pointer is null";
|
|
|
|
|
2022-02-16 21:51:04 +00:00
|
|
|
namespace Modules::Main::Wallet::Accounts
|
2022-02-14 14:38:41 +00:00
|
|
|
{
|
2022-02-21 17:07:16 +00:00
|
|
|
Controller::Controller(std::shared_ptr<Wallets::ServiceInterface> walletService,
|
|
|
|
QObject* parent)
|
|
|
|
: QObject(parent),
|
|
|
|
m_walletServicePtr(walletService)
|
2022-02-14 14:38:41 +00:00
|
|
|
{ }
|
|
|
|
|
2022-02-21 18:03:38 +00:00
|
|
|
void Controller::init() { }
|
2022-02-14 14:38:41 +00:00
|
|
|
|
|
|
|
QList<Wallets::WalletAccountDto> Controller::getWalletAccounts()
|
|
|
|
{
|
|
|
|
QList<Wallets::WalletAccountDto> wallet_accounts;
|
2022-02-21 17:07:16 +00:00
|
|
|
if(m_walletServicePtr)
|
|
|
|
{
|
|
|
|
wallet_accounts = m_walletServicePtr->getWalletAccounts();
|
|
|
|
}
|
2022-02-14 14:38:41 +00:00
|
|
|
|
|
|
|
return wallet_accounts;
|
|
|
|
}
|
2022-02-21 17:07:16 +00:00
|
|
|
|
|
|
|
QString Controller::generateNewAccount(const QString& password, const QString& accountName, const QString& color)
|
|
|
|
{
|
|
|
|
QString error = WALLETSERVICE_NULL_ERROR;
|
|
|
|
if(m_walletServicePtr)
|
|
|
|
{
|
|
|
|
error = m_walletServicePtr->generateNewAccount(password, accountName, color);
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Controller::addAccountsFromPrivateKey(const QString& privateKey, const QString& password, const QString& accountName, const QString& color)
|
|
|
|
{
|
|
|
|
QString error = WALLETSERVICE_NULL_ERROR;
|
|
|
|
if(m_walletServicePtr)
|
|
|
|
{
|
|
|
|
error = m_walletServicePtr->addAccountsFromPrivateKey(privateKey, password, accountName, color);
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Controller::addAccountsFromSeed(const QString& seedPhrase, const QString& password, const QString& accountName, const QString& color)
|
|
|
|
{
|
|
|
|
QString error = WALLETSERVICE_NULL_ERROR;
|
|
|
|
if(m_walletServicePtr)
|
|
|
|
{
|
|
|
|
error = m_walletServicePtr->addAccountsFromSeed(seedPhrase, password, accountName, color);
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Controller::addWatchOnlyAccount(const QString& address, const QString& accountName, const QString& color)
|
|
|
|
{
|
|
|
|
QString error = WALLETSERVICE_NULL_ERROR;
|
|
|
|
if(m_walletServicePtr)
|
|
|
|
{
|
|
|
|
error = m_walletServicePtr->addWatchOnlyAccount(address, accountName, color);
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Controller::deleteAccount(const QString& address)
|
|
|
|
{
|
|
|
|
if(m_walletServicePtr)
|
|
|
|
{
|
|
|
|
m_walletServicePtr->deleteAccount(address);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-16 21:51:04 +00:00
|
|
|
} // namespace Modules::Main::Wallet::Accounts
|