28 QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0),
29 transactionTableModel(0),
30 recentRequestsTableModel(0),
31 cachedBalance(0), cachedUnconfirmedBalance(0), cachedImmatureBalance(0),
32 cachedNumTransactions(0),
33 cachedEncryptionStatus(Unencrypted),
58 std::vector<COutput> vCoins;
60 BOOST_FOREACH(
const COutput& out, vCoins)
61 nBalance += out.
tx->
vout[out.
i].nValue;
81 int numTransactions = 0;
88 return numTransactions;
133 emit
balanceChanged(newBalance, newUnconfirmedBalance, newImmatureBalance);
154 bool isMine,
const QString &purpose,
int status)
163 return addressParsed.
IsValid();
169 QList<SendCoinsRecipient> recipients = transaction.
getRecipients();
170 std::vector<std::pair<CScript, int64_t> > vecSend;
172 if(recipients.empty())
177 QSet<QString> setAddress;
185 int64_t subtotal = 0;
190 if (out.
amount() <= 0)
continue;
192 const unsigned char* scriptStr = (
const unsigned char*)out.
script().data();
193 CScript scriptPubKey(scriptStr, scriptStr+out.
script().size());
194 vecSend.push_back(std::pair<CScript, int64_t>(scriptPubKey, out.
amount()));
212 setAddress.insert(rcp.
address);
217 vecSend.push_back(std::pair<CScript, int64_t>(scriptPubKey, rcp.
amount));
222 if(setAddress.size() != nAddresses)
244 int64_t nFeeRequired = 0;
245 std::string strFailReason;
249 bool fCreated =
wallet->
CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, strFailReason, coinControl);
254 if((total + nFeeRequired) > nBalance)
258 emit
message(tr(
"Send Coins"), QString::fromStdString(strFailReason),
269 QByteArray transaction_array;
280 std::string key(
"PaymentRequest");
283 newTx->
vOrderForm.push_back(make_pair(key, value));
285 else if (!rcp.
message.isEmpty())
296 transaction_array.append(&(ssTx[0]), ssTx.
size());
306 std::string strAddress = rcp.
address.toStdString();
308 std::string strLabel = rcp.
label.toStdString();
319 else if (mi->second.name != strLabel)
414 qDebug() <<
"NotifyKeyStoreStatusChanged";
415 QMetaObject::invokeMethod(walletmodel,
"updateStatus", Qt::QueuedConnection);
419 const CTxDestination &address,
const std::string &label,
bool isMine,
420 const std::string &purpose,
ChangeType status)
422 QString strAddress = QString::fromStdString(
CBitcoinAddress(address).ToString());
423 QString strLabel = QString::fromStdString(label);
424 QString strPurpose = QString::fromStdString(purpose);
426 qDebug() <<
"NotifyAddressBookChanged : " + strAddress +
" " + strLabel +
" isMine=" + QString::number(isMine) +
" purpose=" + strPurpose +
" status=" + QString::number(status);
427 QMetaObject::invokeMethod(walletmodel,
"updateAddressBook", Qt::QueuedConnection,
428 Q_ARG(QString, strAddress),
429 Q_ARG(QString, strLabel),
431 Q_ARG(QString, strPurpose),
442 vQueueNotifications.push_back(make_pair(hash, status));
446 QString strHash = QString::fromStdString(hash.
GetHex());
448 qDebug() <<
"NotifyTransactionChanged : " + strHash +
" status= " + QString::number(status);
449 QMetaObject::invokeMethod(walletmodel,
"updateTransaction", Qt::QueuedConnection,
450 Q_ARG(QString, strHash),
457 QMetaObject::invokeMethod(walletmodel,
"showProgress", Qt::QueuedConnection,
458 Q_ARG(QString, QString::fromStdString(title)),
459 Q_ARG(
int, nProgress));
464 if (nProgress == 100)
469 std::vector<std::pair<uint256, ChangeType> >().swap(vQueueNotifications);
517 wallet->setWalletLocked(
true);
537 BOOST_FOREACH(
const COutPoint& outpoint, vOutpoints)
541 if (nDepth < 0)
continue;
543 vOutputs.push_back(out);
556 std::vector<COutput> vCoins;
560 std::vector<COutPoint> vLockedCoins;
564 BOOST_FOREACH(
const COutPoint& outpoint, vLockedCoins)
568 if (nDepth < 0)
continue;
570 vCoins.push_back(out);
573 BOOST_FOREACH(
const COutput& out, vCoins)
617 BOOST_FOREACH(
const PAIRTYPE(std::string, std::string)& item2, item.second.
destdata)
618 if (item2.first.size() > 2 && item2.first.substr(0,2) ==
"rr")
619 vReceiveRequests.push_back(item2.second);
626 std::stringstream ss;
628 std::string key =
"rr" + ss.str();
631 if (sRequest.empty())
void loadReceiveRequests(std::vector< std::string > &vReceiveRequests)
Model for list of recently generated payment requests / bitcoin: URIs.
TransactionTableModel * transactionTableModel
void getOutputs(const std::vector< COutPoint > &vOutpoints, std::vector< COutput > &vOutputs)
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
RecentRequestsTableModel * recentRequestsTableModel
PaymentRequestPlus paymentRequest
bool IsInitialized() const
int64_t GetImmatureBalance() const
void lockCoin(COutPoint &output)
bool IsMine(const CTxIn &txin) const
qint64 getImmatureBalance() const
#define TRY_LOCK(cs, name)
qint64 cachedImmatureBalance
void ListLockedCoins(std::vector< COutPoint > &vOutpts)
std::map< CTxDestination, CAddressBookData > mapAddressBook
CCriticalSection cs_wallet
Main wallet lock.
qint64 cachedNumTransactions
qint64 cachedUnconfirmedBalance
UnlockContext requestUnlock()
void unsubscribeFromCoreSignals()
bool isLockedCoin(uint256 hash, unsigned int n) const
bool SerializeToString(string *output) const
bool backupWallet(const QString &filename)
SendCoinsReturn sendCoins(WalletModelTransaction &transaction)
Double ended buffer combining vector and stream-like interfaces.
void updateTransaction(const QString &hash, int status)
base58-encoded Bitcoin addresses.
bool BackupWallet(const CWallet &wallet, const string &strDest)
AddressTableModel * getAddressTableModel()
Keystore which keeps the private keys encrypted.
CTxDestination Get() const
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const
CChain chainActive
The currently-connected chain of blocks.
const ::std::string & script() const
void newPossibleKeyChange(CWallet *wallet)
void setTransactionFee(qint64 newFee)
UnlockContext(WalletModel *wallet, bool valid, bool relock)
void SetDestination(const CTxDestination &address)
void balanceChanged(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance)
QList< SendCoinsRecipient > getRecipients()
boost::signals2::signal< void(CWallet *wallet, const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
int64_t GetBalance() const
bool CreateTransaction(const std::vector< std::pair< CScript, int64_t > > &vecSend, CWalletTx &wtxNew, CReserveKey &reservekey, int64_t &nFeeRet, std::string &strFailReason, const CCoinControl *coinControl=NULL)
WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent=0)
boost::signals2::signal< void(CCryptoKeyStore *wallet)> NotifyStatusChanged
void checkBalanceChanged()
int Height() const
Return the maximal height in the chain.
bool IsSpent(const uint256 &hash, unsigned int n) const
void numTransactionsChanged(int count)
void LockCoin(COutPoint &output)
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
ChangeType
General change type (added, updated, removed).
bool isSpent(const COutPoint &outpoint) const
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass)
std::vector< CTxOut > vout
void UnlockCoin(COutPoint &output)
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
qint64 getUnconfirmedBalance() const
const ::payments::Output & outputs(int index) const
An encapsulated public key.
bool getPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const
static std::vector< std::pair< uint256, ChangeType > > vQueueNotifications
bool EraseDestData(const CTxDestination &dest, const std::string &key)
Erases a destination data tuple in the store and on disk.
bool CommitTransaction(CWalletTx &wtxNew, CReserveKey &reservekey)
std::string ToString() const
OptionsModel * optionsModel
const payments::PaymentDetails & getDetails() const
TransactionTableModel * getTransactionTableModel()
void AvailableCoins(std::vector< COutput > &vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl=NULL) const
EncryptionStatus cachedEncryptionStatus
An outpoint - a combination of a transaction hash and an index n into its vout.
void CopyFrom(const UnlockContext &rhs)
std::string GetHex() const
UI model for the transaction table of a wallet.
inline::google::protobuf::uint64 amount() const
Qt model of the address book in the core.
static const int MODEL_UPDATE_DELAY
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString())
A transaction with a bunch of additional info that only the owner cares about.
void encryptionStatusChanged(int status)
EncryptionStatus getEncryptionStatus() const
static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet, const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)
bool validateAddress(const QString &address)
CReserveKey * getPossibleKeyChange()
static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, const uint256 &hash, ChangeType status)
int64_t GetUnconfirmedBalance() const
RecentRequestsTableModel * getRecentRequestsTableModel()
bool EncryptWallet(const SecureString &strWalletPassphrase)
boost::signals2::signal< void(CWallet *wallet, const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)> NotifyAddressBookChanged
Address book entry changed.
void listLockedCoins(std::vector< COutPoint > &vOutpts)
A key allocated from the key pool.
Interface from Qt to configuration data structure for Bitcoin client.
Serialized script, used inside transaction inputs and outputs.
Interface to Bitcoin wallet from Qt view code.
static const int PROTOCOL_VERSION
bool setWalletEncrypted(bool encrypted, const SecureString &passphrase)
void unlockCoin(COutPoint &output)
void message(const QString &title, const QString &message, unsigned int style)
A reference to a CKey: the Hash160 of its serialized public key.
qint64 getBalance(const CCoinControl *coinControl=NULL) const
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
bool Unlock(const SecureString &strWalletPassphrase)
void updateTransaction(const QString &hash, int status)
bool IsChange(const CTxOut &txout) const
int getNumTransactions() const
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Data model for a walletmodel transaction.
void coinsSent(CWallet *wallet, SendCoinsRecipient recipient, QByteArray transaction)
static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel, CCryptoKeyStore *wallet)
SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl=NULL)
std::map< uint256, CWalletTx > mapWallet
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
AddressTableModel * addressTableModel
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
The basic transaction that is broadcasted on the network and contained in blocks. ...
bool AddDestData(const CTxDestination &dest, const std::string &key, const std::string &value)
Adds a destination data tuple to the store, and saves it to disk.
void listCoins(std::map< QString, std::vector< COutput > > &mapCoins) const
static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
void updateConfirmations()
bool saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest)
bool IsLockedCoin(uint256 hash, unsigned int n) const
CWalletTx * getTransaction()
void updateAddressBook(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
static bool fQueueNotifications
void pollBalanceChanged()
OptionsModel * getOptionsModel()
void subscribeToCoreSignals()
std::vector< std::pair< std::string, std::string > > vOrderForm