Master Core  v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Public Types | Public Slots | Signals | Public Member Functions | Private Member Functions | Private Attributes | List of all members
WalletModel Class Reference

Interface to Bitcoin wallet from Qt view code. More...

#include <walletmodel.h>

+ Inheritance diagram for WalletModel:
+ Collaboration diagram for WalletModel:

Classes

struct  SendCoinsReturn
 
class  UnlockContext
 

Public Types

enum  StatusCode {
  OK,
  InvalidAmount,
  InvalidAddress,
  AmountExceedsBalance,
  AmountWithFeeExceedsBalance,
  DuplicateAddress,
  TransactionCreationFailed,
  TransactionCommitFailed
}
 
enum  EncryptionStatus {
  Unencrypted,
  Locked,
  Unlocked
}
 

Public Slots

void updateStatus ()
 
void updateTransaction (const QString &hash, int status)
 
void updateAddressBook (const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
 
void pollBalanceChanged ()
 

Signals

void balanceChanged (qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance)
 
void numTransactionsChanged (int count)
 
void encryptionStatusChanged (int status)
 
void requireUnlock ()
 
void message (const QString &title, const QString &message, unsigned int style)
 
void coinsSent (CWallet *wallet, SendCoinsRecipient recipient, QByteArray transaction)
 
void showProgress (const QString &title, int nProgress)
 

Public Member Functions

 WalletModel (CWallet *wallet, OptionsModel *optionsModel, QObject *parent=0)
 
 ~WalletModel ()
 
OptionsModelgetOptionsModel ()
 
AddressTableModelgetAddressTableModel ()
 
TransactionTableModelgetTransactionTableModel ()
 
RecentRequestsTableModelgetRecentRequestsTableModel ()
 
qint64 getBalance (const CCoinControl *coinControl=NULL) const
 
qint64 getUnconfirmedBalance () const
 
qint64 getImmatureBalance () const
 
int getNumTransactions () const
 
EncryptionStatus getEncryptionStatus () const
 
bool validateAddress (const QString &address)
 
SendCoinsReturn prepareTransaction (WalletModelTransaction &transaction, const CCoinControl *coinControl=NULL)
 
SendCoinsReturn sendCoins (WalletModelTransaction &transaction)
 
bool setWalletEncrypted (bool encrypted, const SecureString &passphrase)
 
bool setWalletLocked (bool locked, const SecureString &passPhrase=SecureString())
 
bool changePassphrase (const SecureString &oldPass, const SecureString &newPass)
 
bool backupWallet (const QString &filename)
 
UnlockContext requestUnlock ()
 
bool getPubKey (const CKeyID &address, CPubKey &vchPubKeyOut) const
 
void getOutputs (const std::vector< COutPoint > &vOutpoints, std::vector< COutput > &vOutputs)
 
bool isSpent (const COutPoint &outpoint) const
 
void listCoins (std::map< QString, std::vector< COutput > > &mapCoins) const
 
bool isLockedCoin (uint256 hash, unsigned int n) const
 
void lockCoin (COutPoint &output)
 
void unlockCoin (COutPoint &output)
 
void listLockedCoins (std::vector< COutPoint > &vOutpts)
 
void loadReceiveRequests (std::vector< std::string > &vReceiveRequests)
 
bool saveReceiveRequest (const std::string &sAddress, const int64_t nId, const std::string &sRequest)
 

Private Member Functions

void subscribeToCoreSignals ()
 
void unsubscribeFromCoreSignals ()
 
void checkBalanceChanged ()
 

Private Attributes

CWalletwallet
 
OptionsModeloptionsModel
 
AddressTableModeladdressTableModel
 
TransactionTableModeltransactionTableModel
 
RecentRequestsTableModelrecentRequestsTableModel
 
qint64 cachedBalance
 
qint64 cachedUnconfirmedBalance
 
qint64 cachedImmatureBalance
 
qint64 cachedNumTransactions
 
EncryptionStatus cachedEncryptionStatus
 
int cachedNumBlocks
 
QTimer * pollTimer
 

Detailed Description

Interface to Bitcoin wallet from Qt view code.

Definition at line 96 of file walletmodel.h.

Member Enumeration Documentation

Enumerator
Unencrypted 
Locked 
Unlocked 

Definition at line 116 of file walletmodel.h.

Enumerator
OK 
InvalidAmount 
InvalidAddress 
AmountExceedsBalance 
AmountWithFeeExceedsBalance 
DuplicateAddress 
TransactionCreationFailed 
TransactionCommitFailed 

Definition at line 104 of file walletmodel.h.

Constructor & Destructor Documentation

WalletModel::WalletModel ( CWallet wallet,
OptionsModel optionsModel,
QObject parent = 0 
)
explicit

Definition at line 27 of file walletmodel.cpp.

References addressTableModel, MODEL_UPDATE_DELAY, pollBalanceChanged(), pollTimer, recentRequestsTableModel, subscribeToCoreSignals(), and transactionTableModel.

+ Here is the call graph for this function:

WalletModel::~WalletModel ( )

Definition at line 48 of file walletmodel.cpp.

References unsubscribeFromCoreSignals().

+ Here is the call graph for this function:

Member Function Documentation

bool WalletModel::backupWallet ( const QString &  filename)

Definition at line 406 of file walletmodel.cpp.

References BackupWallet(), and wallet.

Referenced by WalletView::backupWallet().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WalletModel::balanceChanged ( qint64  balance,
qint64  unconfirmedBalance,
qint64  immatureBalance 
)
signal

Definition at line 128 of file moc_walletmodel.cpp.

Referenced by checkBalanceChanged().

+ Here is the caller graph for this function:

bool WalletModel::changePassphrase ( const SecureString oldPass,
const SecureString newPass 
)

Definition at line 395 of file walletmodel.cpp.

References CWallet::ChangeWalletPassphrase(), CWallet::cs_wallet, CCryptoKeyStore::Lock(), LOCK, and wallet.

Referenced by AskPassphraseDialog::accept().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WalletModel::checkBalanceChanged ( )
private

Definition at line 122 of file walletmodel.cpp.

References balanceChanged(), cachedBalance, cachedImmatureBalance, cachedUnconfirmedBalance, getBalance(), getImmatureBalance(), and getUnconfirmedBalance().

Referenced by pollBalanceChanged(), and updateTransaction().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WalletModel::coinsSent ( CWallet wallet,
SendCoinsRecipient  recipient,
QByteArray  transaction 
)
signal

Definition at line 162 of file moc_walletmodel.cpp.

Referenced by sendCoins().

+ Here is the caller graph for this function:

void WalletModel::encryptionStatusChanged ( int  status)
signal

Definition at line 142 of file moc_walletmodel.cpp.

Referenced by updateStatus().

+ Here is the caller graph for this function:

AddressTableModel * WalletModel::getAddressTableModel ( )
qint64 WalletModel::getBalance ( const CCoinControl coinControl = NULL) const

Definition at line 53 of file walletmodel.cpp.

References CWallet::AvailableCoins(), CWallet::GetBalance(), COutput::i, COutput::tx, CTransaction::vout, and wallet.

Referenced by checkBalanceChanged(), prepareTransaction(), SendCoinsDialog::setModel(), OverviewPage::setWalletModel(), and SendCoinsDialog::updateDisplayUnit().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

WalletModel::EncryptionStatus WalletModel::getEncryptionStatus ( ) const

Definition at line 351 of file walletmodel.cpp.

References CCryptoKeyStore::IsCrypted(), CCryptoKeyStore::IsLocked(), Locked, Unencrypted, Unlocked, and wallet.

Referenced by requestUnlock(), WalletView::unlockWallet(), WalletView::updateEncryptionStatus(), and updateStatus().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

qint64 WalletModel::getImmatureBalance ( ) const

Definition at line 74 of file walletmodel.cpp.

References CWallet::GetImmatureBalance(), and wallet.

Referenced by checkBalanceChanged(), SendCoinsDialog::setModel(), and OverviewPage::setWalletModel().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int WalletModel::getNumTransactions ( ) const

Definition at line 79 of file walletmodel.cpp.

References CWallet::cs_wallet, LOCK, CWallet::mapWallet, and wallet.

Referenced by updateTransaction().

+ Here is the caller graph for this function:

OptionsModel * WalletModel::getOptionsModel ( )
void WalletModel::getOutputs ( const std::vector< COutPoint > &  vOutpoints,
std::vector< COutput > &  vOutputs 
)

Definition at line 534 of file walletmodel.cpp.

References cs_main, CWallet::cs_wallet, COutPoint::hash, LOCK2, CWallet::mapWallet, COutPoint::n, and wallet.

Referenced by CoinControlDialog::updateLabels().

+ Here is the caller graph for this function:

bool WalletModel::getPubKey ( const CKeyID address,
CPubKey vchPubKeyOut 
) const

Definition at line 528 of file walletmodel.cpp.

References CCryptoKeyStore::GetPubKey(), and wallet.

Referenced by SendCoinsDialog::coinControlChangeEdited(), CoinControlDialog::updateLabels(), and CoinControlDialog::updateView().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RecentRequestsTableModel * WalletModel::getRecentRequestsTableModel ( )
TransactionTableModel * WalletModel::getTransactionTableModel ( )

Definition at line 341 of file walletmodel.cpp.

References transactionTableModel.

Referenced by WalletView::processNewTransaction(), TransactionView::setModel(), OverviewPage::setWalletModel(), and WalletView::setWalletModel().

+ Here is the caller graph for this function:

qint64 WalletModel::getUnconfirmedBalance ( ) const

Definition at line 69 of file walletmodel.cpp.

References CWallet::GetUnconfirmedBalance(), and wallet.

Referenced by checkBalanceChanged(), SendCoinsDialog::setModel(), and OverviewPage::setWalletModel().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool WalletModel::isLockedCoin ( uint256  hash,
unsigned int  n 
) const

Definition at line 589 of file walletmodel.cpp.

References cs_main, CWallet::cs_wallet, CWallet::IsLockedCoin(), LOCK2, and wallet.

Referenced by CoinControlDialog::showMenu(), and CoinControlDialog::updateView().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool WalletModel::isSpent ( const COutPoint outpoint) const

Definition at line 547 of file walletmodel.cpp.

References cs_main, CWallet::cs_wallet, COutPoint::hash, CWallet::IsSpent(), LOCK2, COutPoint::n, and wallet.

Referenced by CoinControlDialog::updateLabels().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WalletModel::listCoins ( std::map< QString, std::vector< COutput > > &  mapCoins) const

Definition at line 554 of file walletmodel.cpp.

References CWallet::AvailableCoins(), cs_main, CWallet::cs_wallet, ExtractDestination(), COutPoint::hash, COutput::i, CWallet::IsChange(), CWallet::IsMine(), CWallet::ListLockedCoins(), LOCK2, CWallet::mapWallet, COutPoint::n, CBase58Data::ToString(), COutput::tx, CTransaction::vin, CTransaction::vout, and wallet.

Referenced by CoinControlDialog::updateView().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WalletModel::listLockedCoins ( std::vector< COutPoint > &  vOutpts)

Definition at line 607 of file walletmodel.cpp.

References cs_main, CWallet::cs_wallet, CWallet::ListLockedCoins(), LOCK2, and wallet.

Referenced by CoinControlDialog::updateLabelLocked().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WalletModel::loadReceiveRequests ( std::vector< std::string > &  vReceiveRequests)

Definition at line 613 of file walletmodel.cpp.

References CWallet::cs_wallet, CAddressBookData::destdata, LOCK, CWallet::mapAddressBook, PAIRTYPE, and wallet.

Referenced by RecentRequestsTableModel::RecentRequestsTableModel().

+ Here is the caller graph for this function:

void WalletModel::lockCoin ( COutPoint output)

Definition at line 595 of file walletmodel.cpp.

References cs_main, CWallet::cs_wallet, LOCK2, CWallet::LockCoin(), and wallet.

Referenced by CoinControlDialog::lockCoin().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WalletModel::message ( const QString &  title,
const QString &  message,
unsigned int  style 
)
signal

Definition at line 155 of file moc_walletmodel.cpp.

Referenced by prepareTransaction().

+ Here is the caller graph for this function:

void WalletModel::numTransactionsChanged ( int  count)
signal

Definition at line 135 of file moc_walletmodel.cpp.

Referenced by updateTransaction().

+ Here is the caller graph for this function:

void WalletModel::pollBalanceChanged ( )
slot

Definition at line 99 of file walletmodel.cpp.

References cachedNumBlocks, chainActive, checkBalanceChanged(), cs_main, CWallet::cs_wallet, CChain::Height(), transactionTableModel, TRY_LOCK, TransactionTableModel::updateConfirmations(), and wallet.

Referenced by WalletModel().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

WalletModel::SendCoinsReturn WalletModel::prepareTransaction ( WalletModelTransaction transaction,
const CCoinControl coinControl = NULL 
)
WalletModel::UnlockContext WalletModel::requestUnlock ( )

Definition at line 492 of file walletmodel.cpp.

References getEncryptionStatus(), Locked, and requireUnlock().

Referenced by AddressTableModel::addRow(), SendCoinsDialog::on_sendButton_clicked(), SignVerifyMessageDialog::on_signMessageButton_SM_clicked(), and SendMPDialog::sendMPTransaction().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WalletModel::requireUnlock ( )
signal

Definition at line 149 of file moc_walletmodel.cpp.

Referenced by requestUnlock().

+ Here is the caller graph for this function:

bool WalletModel::saveReceiveRequest ( const std::string &  sAddress,
const int64_t  nId,
const std::string &  sRequest 
)

Definition at line 622 of file walletmodel.cpp.

References CWallet::AddDestData(), CWallet::cs_wallet, CWallet::EraseDestData(), CBitcoinAddress::Get(), LOCK, and wallet.

Referenced by RecentRequestsTableModel::addNewRequest(), and RecentRequestsTableModel::removeRows().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

WalletModel::SendCoinsReturn WalletModel::sendCoins ( WalletModelTransaction transaction)
bool WalletModel::setWalletEncrypted ( bool  encrypted,
const SecureString passphrase 
)

Definition at line 367 of file walletmodel.cpp.

References CWallet::EncryptWallet(), and wallet.

Referenced by AskPassphraseDialog::accept().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool WalletModel::setWalletLocked ( bool  locked,
const SecureString passPhrase = SecureString() 
)

Definition at line 381 of file walletmodel.cpp.

References CCryptoKeyStore::Lock(), CWallet::Unlock(), and wallet.

Referenced by AskPassphraseDialog::accept().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WalletModel::showProgress ( const QString &  title,
int  nProgress 
)
signal

Definition at line 169 of file moc_walletmodel.cpp.

void WalletModel::subscribeToCoreSignals ( )
private

Definition at line 473 of file walletmodel.cpp.

References CWallet::NotifyAddressBookChanged, NotifyAddressBookChanged(), NotifyKeyStoreStatusChanged(), CCryptoKeyStore::NotifyStatusChanged, CWallet::NotifyTransactionChanged, NotifyTransactionChanged(), CWallet::ShowProgress, ShowProgress(), and wallet.

Referenced by WalletModel().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WalletModel::unlockCoin ( COutPoint output)

Definition at line 601 of file walletmodel.cpp.

References cs_main, CWallet::cs_wallet, LOCK2, CWallet::UnlockCoin(), and wallet.

Referenced by CoinControlDialog::unlockCoin().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WalletModel::unsubscribeFromCoreSignals ( )
private

Definition at line 482 of file walletmodel.cpp.

References CWallet::NotifyAddressBookChanged, NotifyAddressBookChanged(), NotifyKeyStoreStatusChanged(), CCryptoKeyStore::NotifyStatusChanged, CWallet::NotifyTransactionChanged, NotifyTransactionChanged(), CWallet::ShowProgress, ShowProgress(), and wallet.

Referenced by ~WalletModel().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WalletModel::updateAddressBook ( const QString &  address,
const QString &  label,
bool  isMine,
const QString &  purpose,
int  status 
)
slot

Definition at line 153 of file walletmodel.cpp.

References addressTableModel, and AddressTableModel::updateEntry().

+ Here is the call graph for this function:

void WalletModel::updateStatus ( )
slot

Definition at line 91 of file walletmodel.cpp.

References cachedEncryptionStatus, encryptionStatusChanged(), and getEncryptionStatus().

+ Here is the call graph for this function:

void WalletModel::updateTransaction ( const QString &  hash,
int  status 
)
slot

Definition at line 137 of file walletmodel.cpp.

References cachedNumTransactions, checkBalanceChanged(), getNumTransactions(), numTransactionsChanged(), transactionTableModel, and TransactionTableModel::updateTransaction().

+ Here is the call graph for this function:

bool WalletModel::validateAddress ( const QString &  address)

Definition at line 160 of file walletmodel.cpp.

References CBitcoinAddress::IsValid().

Referenced by AddressTableModel::addRow(), prepareTransaction(), and SendCoinsEntry::validate().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

AddressTableModel* WalletModel::addressTableModel
private

Definition at line 201 of file walletmodel.h.

Referenced by getAddressTableModel(), updateAddressBook(), and WalletModel().

qint64 WalletModel::cachedBalance
private

Definition at line 206 of file walletmodel.h.

Referenced by checkBalanceChanged().

EncryptionStatus WalletModel::cachedEncryptionStatus
private

Definition at line 210 of file walletmodel.h.

Referenced by updateStatus().

qint64 WalletModel::cachedImmatureBalance
private

Definition at line 208 of file walletmodel.h.

Referenced by checkBalanceChanged().

int WalletModel::cachedNumBlocks
private

Definition at line 211 of file walletmodel.h.

Referenced by pollBalanceChanged().

qint64 WalletModel::cachedNumTransactions
private

Definition at line 209 of file walletmodel.h.

Referenced by updateTransaction().

qint64 WalletModel::cachedUnconfirmedBalance
private

Definition at line 207 of file walletmodel.h.

Referenced by checkBalanceChanged().

OptionsModel* WalletModel::optionsModel
private

Definition at line 199 of file walletmodel.h.

Referenced by getOptionsModel().

QTimer* WalletModel::pollTimer
private

Definition at line 213 of file walletmodel.h.

Referenced by WalletModel().

RecentRequestsTableModel* WalletModel::recentRequestsTableModel
private

Definition at line 203 of file walletmodel.h.

Referenced by getRecentRequestsTableModel(), and WalletModel().

TransactionTableModel* WalletModel::transactionTableModel
private
CWallet* WalletModel::wallet
private

The documentation for this class was generated from the following files: