![]() |
Master Core
v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
|
Interface to Bitcoin wallet from Qt view code. More...
#include <walletmodel.h>
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 () | |
OptionsModel * | getOptionsModel () |
AddressTableModel * | getAddressTableModel () |
TransactionTableModel * | getTransactionTableModel () |
RecentRequestsTableModel * | getRecentRequestsTableModel () |
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 | |
CWallet * | wallet |
OptionsModel * | optionsModel |
AddressTableModel * | addressTableModel |
TransactionTableModel * | transactionTableModel |
RecentRequestsTableModel * | recentRequestsTableModel |
qint64 | cachedBalance |
qint64 | cachedUnconfirmedBalance |
qint64 | cachedImmatureBalance |
qint64 | cachedNumTransactions |
EncryptionStatus | cachedEncryptionStatus |
int | cachedNumBlocks |
QTimer * | pollTimer |
Interface to Bitcoin wallet from Qt view code.
Definition at line 96 of file walletmodel.h.
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.
|
explicit |
Definition at line 27 of file walletmodel.cpp.
References addressTableModel, MODEL_UPDATE_DELAY, pollBalanceChanged(), pollTimer, recentRequestsTableModel, subscribeToCoreSignals(), and transactionTableModel.
WalletModel::~WalletModel | ( | ) |
Definition at line 48 of file walletmodel.cpp.
References unsubscribeFromCoreSignals().
bool WalletModel::backupWallet | ( | const QString & | filename | ) |
Definition at line 406 of file walletmodel.cpp.
References BackupWallet(), and wallet.
Referenced by WalletView::backupWallet().
|
signal |
Definition at line 128 of file moc_walletmodel.cpp.
Referenced by checkBalanceChanged().
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().
|
private |
Definition at line 122 of file walletmodel.cpp.
References balanceChanged(), cachedBalance, cachedImmatureBalance, cachedUnconfirmedBalance, getBalance(), getImmatureBalance(), and getUnconfirmedBalance().
Referenced by pollBalanceChanged(), and updateTransaction().
|
signal |
Definition at line 162 of file moc_walletmodel.cpp.
Referenced by sendCoins().
|
signal |
Definition at line 142 of file moc_walletmodel.cpp.
Referenced by updateStatus().
AddressTableModel * WalletModel::getAddressTableModel | ( | ) |
Definition at line 336 of file walletmodel.cpp.
References addressTableModel.
Referenced by TransactionTableModel::addressColor(), SendCoinsDialog::coinControlChangeEdited(), TransactionTableModel::data(), TransactionView::editLabel(), TransactionTableModel::lookupAddress(), SendCoinsEntry::on_addressBookButton_clicked(), SignVerifyMessageDialog::on_addressBookButton_SM_clicked(), SignVerifyMessageDialog::on_addressBookButton_VM_clicked(), ReceiveCoinsDialog::on_receiveButton_clicked(), CoinControlDialog::setModel(), SendCoinsEntry::updateLabel(), CoinControlDialog::updateView(), WalletView::usedReceivingAddresses(), and WalletView::usedSendingAddresses().
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().
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().
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().
int WalletModel::getNumTransactions | ( | ) | const |
Definition at line 79 of file walletmodel.cpp.
References CWallet::cs_wallet, LOCK, CWallet::mapWallet, and wallet.
Referenced by updateTransaction().
OptionsModel * WalletModel::getOptionsModel | ( | ) |
Definition at line 331 of file walletmodel.cpp.
References optionsModel.
Referenced by TransactionView::changedAmount(), SendCoinsDialog::coinControlUpdateLabels(), TransactionTableModel::data(), RecentRequestsTableModel::data(), TransactionTableModel::formatTxAmount(), TransactionTableModel::lookupAddress(), ReceiveCoinsDialog::on_receiveButton_clicked(), ReceiveCoinsDialog::on_recentRequestsView_doubleClicked(), SendCoinsDialog::on_sendButton_clicked(), WalletView::processNewTransaction(), OverviewPage::setBalance(), SendCoinsDialog::setBalance(), SendCoinsEntry::setModel(), CoinControlDialog::setModel(), SendCoinsDialog::setModel(), TransactionView::setModel(), ReceiveCoinsDialog::setModel(), OverviewPage::setWalletModel(), TransactionTableModel::TransactionTableModel(), OverviewPage::updateDisplayUnit(), SendCoinsEntry::updateDisplayUnit(), ReceiveCoinsDialog::updateDisplayUnit(), CoinControlDialog::updateLabels(), and CoinControlDialog::updateView().
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().
Definition at line 528 of file walletmodel.cpp.
References CCryptoKeyStore::GetPubKey(), and wallet.
Referenced by SendCoinsDialog::coinControlChangeEdited(), CoinControlDialog::updateLabels(), and CoinControlDialog::updateView().
RecentRequestsTableModel * WalletModel::getRecentRequestsTableModel | ( | ) |
Definition at line 346 of file walletmodel.cpp.
References recentRequestsTableModel.
Referenced by ReceiveCoinsDialog::copyColumnToClipboard(), ReceiveCoinsDialog::on_receiveButton_clicked(), ReceiveCoinsDialog::on_recentRequestsView_doubleClicked(), ReceiveCoinsDialog::on_removeRequestButton_clicked(), ReceiveCoinsDialog::on_showRequestButton_clicked(), ReceiveCoinsDialog::setModel(), and ReceiveCoinsDialog::showMenu().
TransactionTableModel * WalletModel::getTransactionTableModel | ( | ) |
Definition at line 341 of file walletmodel.cpp.
References transactionTableModel.
Referenced by WalletView::processNewTransaction(), TransactionView::setModel(), OverviewPage::setWalletModel(), and WalletView::setWalletModel().
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().
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().
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().
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().
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().
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().
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().
|
signal |
Definition at line 155 of file moc_walletmodel.cpp.
Referenced by prepareTransaction().
|
signal |
Definition at line 135 of file moc_walletmodel.cpp.
Referenced by updateTransaction().
|
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().
WalletModel::SendCoinsReturn WalletModel::prepareTransaction | ( | WalletModelTransaction & | transaction, |
const CCoinControl * | coinControl = NULL |
||
) |
Definition at line 166 of file walletmodel.cpp.
References SendCoinsRecipient::address, SendCoinsRecipient::amount, payments::Output::amount(), AmountExceedsBalance, AmountWithFeeExceedsBalance, CWallet::CreateTransaction(), cs_main, CWallet::cs_wallet, DuplicateAddress, getBalance(), PaymentRequestPlus::getDetails(), WalletModelTransaction::getPossibleKeyChange(), WalletModelTransaction::getRecipients(), WalletModelTransaction::getTransaction(), InvalidAddress, InvalidAmount, PaymentRequestPlus::IsInitialized(), LOCK2, message(), CClientUIInterface::MSG_ERROR, WalletModelTransaction::newPossibleKeyChange(), nTransactionFee, OK, payments::PaymentDetails::outputs(), payments::PaymentDetails::outputs_size(), SendCoinsRecipient::paymentRequest, payments::Output::script(), CScript::SetDestination(), WalletModelTransaction::setTransactionFee(), TransactionCreationFailed, validateAddress(), and wallet.
Referenced by SendCoinsDialog::on_sendButton_clicked().
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().
|
signal |
Definition at line 149 of file moc_walletmodel.cpp.
Referenced by requestUnlock().
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().
WalletModel::SendCoinsReturn WalletModel::sendCoins | ( | WalletModelTransaction & | transaction | ) |
Definition at line 267 of file walletmodel.cpp.
References SendCoinsRecipient::address, coinsSent(), CWallet::CommitTransaction(), cs_main, CWallet::cs_wallet, CBitcoinAddress::Get(), WalletModelTransaction::getPossibleKeyChange(), WalletModelTransaction::getRecipients(), WalletModelTransaction::getTransaction(), PaymentRequestPlus::IsInitialized(), SendCoinsRecipient::label, LOCK, LOCK2, CWallet::mapAddressBook, SendCoinsRecipient::message, OK, SendCoinsRecipient::paymentRequest, PROTOCOL_VERSION, SER_NETWORK, PaymentRequestPlus::SerializeToString(), CWallet::SetAddressBook(), CDataStream::size(), TransactionCommitFailed, CWalletTx::vOrderForm, and wallet.
Referenced by SendCoinsDialog::on_sendButton_clicked().
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().
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().
|
signal |
Definition at line 169 of file moc_walletmodel.cpp.
|
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().
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().
|
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().
|
slot |
Definition at line 153 of file walletmodel.cpp.
References addressTableModel, and AddressTableModel::updateEntry().
|
slot |
Definition at line 91 of file walletmodel.cpp.
References cachedEncryptionStatus, encryptionStatusChanged(), and getEncryptionStatus().
|
slot |
Definition at line 137 of file walletmodel.cpp.
References cachedNumTransactions, checkBalanceChanged(), getNumTransactions(), numTransactionsChanged(), transactionTableModel, and TransactionTableModel::updateTransaction().
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().
|
private |
Definition at line 201 of file walletmodel.h.
Referenced by getAddressTableModel(), updateAddressBook(), and WalletModel().
|
private |
Definition at line 206 of file walletmodel.h.
Referenced by checkBalanceChanged().
|
private |
Definition at line 210 of file walletmodel.h.
Referenced by updateStatus().
|
private |
Definition at line 208 of file walletmodel.h.
Referenced by checkBalanceChanged().
|
private |
Definition at line 211 of file walletmodel.h.
Referenced by pollBalanceChanged().
|
private |
Definition at line 209 of file walletmodel.h.
Referenced by updateTransaction().
|
private |
Definition at line 207 of file walletmodel.h.
Referenced by checkBalanceChanged().
|
private |
Definition at line 199 of file walletmodel.h.
Referenced by getOptionsModel().
|
private |
Definition at line 213 of file walletmodel.h.
Referenced by WalletModel().
|
private |
Definition at line 203 of file walletmodel.h.
Referenced by getRecentRequestsTableModel(), and WalletModel().
|
private |
Definition at line 202 of file walletmodel.h.
Referenced by getTransactionTableModel(), pollBalanceChanged(), updateTransaction(), and WalletModel().
|
private |
Definition at line 195 of file walletmodel.h.
Referenced by backupWallet(), changePassphrase(), getBalance(), getEncryptionStatus(), getImmatureBalance(), getNumTransactions(), getOutputs(), getPubKey(), getUnconfirmedBalance(), isLockedCoin(), isSpent(), listCoins(), listLockedCoins(), loadReceiveRequests(), lockCoin(), pollBalanceChanged(), prepareTransaction(), saveReceiveRequest(), sendCoins(), setWalletEncrypted(), setWalletLocked(), subscribeToCoreSignals(), unlockCoin(), unsubscribeFromCoreSignals(), and WalletModel::UnlockContext::~UnlockContext().