Changeset View
Changeset View
Standalone View
Standalone View
src/qt/walletmodel.cpp
Show First 20 Lines • Show All 406 Lines • ▼ Show 20 Lines | |||||
static void NotifyWatchonlyChanged(WalletModel *walletmodel, | static void NotifyWatchonlyChanged(WalletModel *walletmodel, | ||||
bool fHaveWatchonly) { | bool fHaveWatchonly) { | ||||
QMetaObject::invokeMethod(walletmodel, "updateWatchOnlyFlag", | QMetaObject::invokeMethod(walletmodel, "updateWatchOnlyFlag", | ||||
Qt::QueuedConnection, | Qt::QueuedConnection, | ||||
Q_ARG(bool, fHaveWatchonly)); | Q_ARG(bool, fHaveWatchonly)); | ||||
} | } | ||||
static void NotifyCanGetAddressesChanged(WalletModel *walletmodel) { | |||||
QMetaObject::invokeMethod(walletmodel, "canGetAddressesChanged"); | |||||
} | |||||
void WalletModel::subscribeToCoreSignals() { | void WalletModel::subscribeToCoreSignals() { | ||||
// Connect signals to wallet | // Connect signals to wallet | ||||
m_handler_unload = m_wallet->handleUnload(std::bind(&NotifyUnload, this)); | m_handler_unload = m_wallet->handleUnload(std::bind(&NotifyUnload, this)); | ||||
m_handler_status_changed = m_wallet->handleStatusChanged( | m_handler_status_changed = m_wallet->handleStatusChanged( | ||||
std::bind(&NotifyKeyStoreStatusChanged, this)); | std::bind(&NotifyKeyStoreStatusChanged, this)); | ||||
m_handler_address_book_changed = m_wallet->handleAddressBookChanged( | m_handler_address_book_changed = m_wallet->handleAddressBookChanged( | ||||
std::bind(NotifyAddressBookChanged, this, std::placeholders::_1, | std::bind(NotifyAddressBookChanged, this, std::placeholders::_1, | ||||
std::placeholders::_2, std::placeholders::_3, | std::placeholders::_2, std::placeholders::_3, | ||||
std::placeholders::_4, std::placeholders::_5)); | std::placeholders::_4, std::placeholders::_5)); | ||||
m_handler_transaction_changed = m_wallet->handleTransactionChanged( | m_handler_transaction_changed = m_wallet->handleTransactionChanged( | ||||
std::bind(NotifyTransactionChanged, this, std::placeholders::_1, | std::bind(NotifyTransactionChanged, this, std::placeholders::_1, | ||||
std::placeholders::_2)); | std::placeholders::_2)); | ||||
m_handler_show_progress = m_wallet->handleShowProgress(std::bind( | m_handler_show_progress = m_wallet->handleShowProgress(std::bind( | ||||
ShowProgress, this, std::placeholders::_1, std::placeholders::_2)); | ShowProgress, this, std::placeholders::_1, std::placeholders::_2)); | ||||
m_handler_watch_only_changed = m_wallet->handleWatchOnlyChanged( | m_handler_watch_only_changed = m_wallet->handleWatchOnlyChanged( | ||||
std::bind(NotifyWatchonlyChanged, this, std::placeholders::_1)); | std::bind(NotifyWatchonlyChanged, this, std::placeholders::_1)); | ||||
m_handler_can_get_addrs_changed = m_wallet->handleCanGetAddressesChanged( | |||||
std::bind(NotifyCanGetAddressesChanged, this)); | |||||
} | } | ||||
void WalletModel::unsubscribeFromCoreSignals() { | void WalletModel::unsubscribeFromCoreSignals() { | ||||
// Disconnect signals from wallet | // Disconnect signals from wallet | ||||
m_handler_unload->disconnect(); | m_handler_unload->disconnect(); | ||||
m_handler_status_changed->disconnect(); | m_handler_status_changed->disconnect(); | ||||
m_handler_address_book_changed->disconnect(); | m_handler_address_book_changed->disconnect(); | ||||
m_handler_transaction_changed->disconnect(); | m_handler_transaction_changed->disconnect(); | ||||
m_handler_show_progress->disconnect(); | m_handler_show_progress->disconnect(); | ||||
m_handler_watch_only_changed->disconnect(); | m_handler_watch_only_changed->disconnect(); | ||||
m_handler_can_get_addrs_changed->disconnect(); | |||||
} | } | ||||
// WalletModel::UnlockContext implementation | // WalletModel::UnlockContext implementation | ||||
WalletModel::UnlockContext WalletModel::requestUnlock() { | WalletModel::UnlockContext WalletModel::requestUnlock() { | ||||
bool was_locked = getEncryptionStatus() == Locked; | bool was_locked = getEncryptionStatus() == Locked; | ||||
if (was_locked) { | if (was_locked) { | ||||
// Request UI to unlock wallet | // Request UI to unlock wallet | ||||
Q_EMIT requireUnlock(); | Q_EMIT requireUnlock(); | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
bool WalletModel::isWalletEnabled() { | bool WalletModel::isWalletEnabled() { | ||||
return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET); | return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET); | ||||
} | } | ||||
bool WalletModel::privateKeysDisabled() const { | bool WalletModel::privateKeysDisabled() const { | ||||
return m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS); | return m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS); | ||||
} | } | ||||
bool WalletModel::canGetAddresses() const { | |||||
// The wallet can provide a fresh address if: | |||||
// * hdEnabled(): an HD seed is present; or | |||||
// * it is a legacy wallet, because: | |||||
// * !hdEnabled(): an HD seed is not present; and | |||||
// * !IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS): private keys | |||||
// have not been disabled (which results in hdEnabled() == true) | |||||
return m_wallet->hdEnabled() || | |||||
(!m_wallet->hdEnabled() && | |||||
!m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)); | |||||
} | |||||
QString WalletModel::getWalletName() const { | QString WalletModel::getWalletName() const { | ||||
return QString::fromStdString(m_wallet->getWalletName()); | return QString::fromStdString(m_wallet->getWalletName()); | ||||
} | } | ||||
QString WalletModel::getDisplayName() const { | QString WalletModel::getDisplayName() const { | ||||
const QString name = getWalletName(); | const QString name = getWalletName(); | ||||
return name.isEmpty() ? "[" + tr("default wallet") + "]" : name; | return name.isEmpty() ? "[" + tr("default wallet") + "]" : name; | ||||
} | } | ||||
bool WalletModel::isMultiwallet() { | bool WalletModel::isMultiwallet() { | ||||
return m_node.getWallets().size() > 1; | return m_node.getWallets().size() > 1; | ||||
} | } | ||||
const CChainParams &WalletModel::getChainParams() const { | const CChainParams &WalletModel::getChainParams() const { | ||||
return Params(); | return Params(); | ||||
} | } |