Files
pay/NewWalletConfig.cpp
T
tomFlowee 80d7456898 Make new-wallet pane functional.
This changes the default generated wallet to be a HD wallet.
We also add a helper class to configure newly created wallets from QML.
This finishes up the new wallet panel to have all the visible features
actually do something.
2021-10-27 19:11:00 +02:00

60 lines
1.8 KiB
C++

/*
* This file is part of the Flowee project
* Copyright (C) 2021 Tom Zander <tom@flowee.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "NewWalletConfig.h"
#include "Wallet.h"
NewWalletConfig::NewWalletConfig(Wallet *wallet)
: m_wallet(wallet)
{
// the entire intention is that QML can call some setters, due to its
// declarative nature deleting outselves in the next event loop is quite safe
// unless the QML dev does something really weird or the Qt-implementation
// starts to do magic things
deleteLater();
}
NewWalletConfig::~NewWalletConfig()
{
if (m_wallet)
m_wallet->delayedSave();
m_wallet = nullptr;
}
QString NewWalletConfig::name() const
{
assert(m_wallet);
return m_wallet->name();
}
bool NewWalletConfig::forceSingleAddress() const
{
assert(m_wallet);
return m_wallet->isSingleAddressWallet();
}
void NewWalletConfig::setForceSingleAddress(bool on)
{
assert(m_wallet);
if (m_wallet->isHDWallet()) // a HD wallet with a single address makes no sense.
return;
if (m_wallet->isSingleAddressWallet() != on) {
m_wallet->setSingleAddressWallet(on);
emit SIChanged();
}
}