29 QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0),
30 transactionTableModel(0),
31 recentRequestsTableModel(0),
32 cachedBalance(0), cachedUnconfirmedBalance(0), cachedImmatureBalance(0),
33 cachedEncryptionStatus(Unencrypted),
62 std::vector<COutput> vCoins;
64 BOOST_FOREACH(
const COutput& out, vCoins)
66 nBalance += out.
tx->
vout[out.
i].nValue;
142 qint64 newWatchOnlyBalance = 0;
143 qint64 newWatchUnconfBalance = 0;
144 qint64 newWatchImmatureBalance = 0;
161 emit
balanceChanged(newBalance, newUnconfirmedBalance, newImmatureBalance,
162 newWatchOnlyBalance, newWatchUnconfBalance, newWatchImmatureBalance);
176 bool isMine,
const QString &purpose,
int status)
191 return addressParsed.
IsValid();
197 QList<SendCoinsRecipient> recipients = transaction.
getRecipients();
198 std::vector<std::pair<CScript, int64_t> > vecSend;
200 if(recipients.empty())
205 QSet<QString> setAddress;
213 int64_t subtotal = 0;
218 if (out.
amount() <= 0)
continue;
220 const unsigned char* scriptStr = (
const unsigned char*)out.
script().data();
221 CScript scriptPubKey(scriptStr, scriptStr+out.
script().size());
222 vecSend.push_back(std::pair<CScript, int64_t>(scriptPubKey, out.
amount()));
240 setAddress.insert(rcp.
address);
245 vecSend.push_back(std::pair<CScript, int64_t>(scriptPubKey, rcp.
amount));
250 if(setAddress.size() != nAddresses)
272 int64_t nFeeRequired = 0;
273 std::string strFailReason;
277 bool fCreated =
wallet->
CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, strFailReason, coinControl);
282 if((total + nFeeRequired) > nBalance)
286 emit
message(tr(
"Send Coins"), QString::fromStdString(strFailReason),
297 QByteArray transaction_array;
308 std::string key(
"PaymentRequest");
311 newTx->
vOrderForm.push_back(make_pair(key, value));
313 else if (!rcp.
message.isEmpty())
324 transaction_array.append(&(ssTx[0]), ssTx.
size());
334 std::string strAddress = rcp.
address.toStdString();
336 std::string strLabel = rcp.
label.toStdString();
347 else if (mi->second.name != strLabel)
443 qDebug() <<
"NotifyKeyStoreStatusChanged";
444 QMetaObject::invokeMethod(walletmodel,
"updateStatus", Qt::QueuedConnection);
448 const CTxDestination &address,
const std::string &label,
bool isMine,
449 const std::string &purpose,
ChangeType status)
451 QString strAddress = QString::fromStdString(
CAnoncoinAddress(address).ToString());
452 QString strLabel = QString::fromStdString(label);
453 QString strPurpose = QString::fromStdString(purpose);
455 qDebug() <<
"NotifyAddressBookChanged : " + strAddress +
" " + strLabel +
" isMine=" + QString::number(isMine) +
" purpose=" + strPurpose +
" status=" + QString::number(status);
456 QMetaObject::invokeMethod(walletmodel,
"updateAddressBook", Qt::QueuedConnection,
457 Q_ARG(QString, strAddress),
458 Q_ARG(QString, strLabel),
460 Q_ARG(QString, strPurpose),
465 static bool fQueueNotifications =
false;
466 static std::vector<std::pair<uint256, ChangeType> > vQueueNotifications;
469 if (fQueueNotifications)
471 vQueueNotifications.push_back(make_pair(hash, status));
475 QString strHash = QString::fromStdString(hash.
GetHex());
477 qDebug() <<
"NotifyTransactionChanged : " + strHash +
" status= " + QString::number(status);
478 QMetaObject::invokeMethod(walletmodel,
"updateTransaction", Qt::QueuedConnection,
479 Q_ARG(QString, strHash),
483 static void ShowProgress(
WalletModel *walletmodel,
const std::string &title,
int nProgress)
486 fQueueNotifications =
true;
488 if (nProgress == 100)
490 fQueueNotifications =
false;
491 if (vQueueNotifications.size() > 10)
492 QMetaObject::invokeMethod(walletmodel,
"setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(
bool,
true));
493 for (
unsigned int i = 0; i < vQueueNotifications.size(); ++i)
495 if (vQueueNotifications.size() - i <= 10)
496 QMetaObject::invokeMethod(walletmodel,
"setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(
bool,
false));
498 NotifyTransactionChanged(walletmodel, NULL, vQueueNotifications[i].first, vQueueNotifications[i].second);
500 std::vector<std::pair<uint256, ChangeType> >().swap(vQueueNotifications);
504 QMetaObject::invokeMethod(walletmodel,
"showProgress", Qt::QueuedConnection,
505 Q_ARG(QString, QString::fromStdString(title)),
506 Q_ARG(
int, nProgress));
509 static void NotifyWatchonlyChanged(
WalletModel *walletmodel,
bool fHaveWatchonly)
511 QMetaObject::invokeMethod(walletmodel,
"updateWatchOnlyFlag", Qt::QueuedConnection,
512 Q_ARG(
bool, fHaveWatchonly));
521 wallet->
ShowProgress.connect(boost::bind(ShowProgress,
this, _1, _2));
528 wallet->
NotifyStatusChanged.disconnect(boost::bind(&NotifyKeyStoreStatusChanged,
this, _1));
531 wallet->
ShowProgress.disconnect(boost::bind(ShowProgress,
this, _1, _2));
561 wallet->setWalletLocked(
true);
574 return wallet->
GetPubKey(address, vchPubKeyOut);
581 BOOST_FOREACH(
const COutPoint& outpoint, vOutpoints)
584 int nDepth = wallet->
mapWallet[outpoint.
hash].GetDepthInMainChain();
585 if (nDepth < 0)
continue;
587 vOutputs.push_back(out);
600 std::vector<COutput> vCoins;
604 std::vector<COutPoint> vLockedCoins;
608 BOOST_FOREACH(
const COutPoint& outpoint, vLockedCoins)
611 int nDepth = wallet->
mapWallet[outpoint.
hash].GetDepthInMainChain();
612 if (nDepth < 0)
continue;
615 vCoins.push_back(out);
618 BOOST_FOREACH(
const COutput& out, vCoins)
624 if (!wallet->
mapWallet.count(cout.
tx->
vin[0].prevout.hash))
break;
663 BOOST_FOREACH(
const PAIRTYPE(std::string, std::string)& item2, item.second.
destdata)
664 if (item2.first.size() > 2 && item2.first.substr(0,2) ==
"rr")
665 vReceiveRequests.push_back(item2.second);
672 std::stringstream ss;
674 std::string key =
"rr" + ss.str();
677 if (sRequest.empty())
void loadReceiveRequests(std::vector< std::string > &vReceiveRequests)
Model for list of recently generated payment requests / anoncoin: 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
isminetype IsMine(const CTxIn &txin) const
bool IsInitialized() const
int64_t GetImmatureBalance() const
void lockCoin(COutPoint &output)
qint64 getImmatureBalance() const
#define TRY_LOCK(cs, name)
qint64 cachedImmatureBalance
int64_t GetUnconfirmedWatchOnlyBalance() const
void ListLockedCoins(std::vector< COutPoint > &vOutpts)
std::map< CTxDestination, CAddressBookData > mapAddressBook
CCriticalSection cs_wallet
Main wallet lock.
qint64 cachedUnconfirmedBalance
UnlockContext requestUnlock()
void unsubscribeFromCoreSignals()
bool isLockedCoin(uint256 hash, unsigned int n) const
CTxDestination Get() const
bool SerializeToString(string *output) const
qint64 getWatchUnconfirmedBalance() const
bool backupWallet(const QString &filename)
SendCoinsReturn sendCoins(WalletModelTransaction &transaction)
Double ended buffer combining vector and stream-like interfaces.
virtual bool HaveWatchOnly(const CScript &dest) const
void updateTransaction(const QString &hash, int status)
bool fProcessingQueuedTransactions
bool BackupWallet(const CWallet &wallet, const string &strDest)
AddressTableModel * getAddressTableModel()
Keystore which keeps the private keys encrypted.
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)
int64_t GetWatchOnlyBalance() const
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()
void balanceChanged(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance, qint64 watchOnlyBalance, qint64 watchUnconfBalance, qint64 watchImmatureBalance)
int Height() const
Return the maximal height in the chain.
bool IsSpent(const uint256 &hash, unsigned int n) const
qint64 getWatchImmatureBalance() const
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
base58-encoded Anoncoin addresses.
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.
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
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
bool validateAddress(const QString &address)
void updateWatchOnlyFlag(bool fHaveWatchonly)
CReserveKey * getPossibleKeyChange()
qint64 cachedWatchOnlyBalance
bool fForceCheckBalanceChanged
int64_t GetImmatureWatchOnlyBalance() const
int64_t GetUnconfirmedBalance() const
qint64 cachedWatchUnconfBalance
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 Anoncoin client.
Serialized script, used inside transaction inputs and outputs.
Interface to Anoncoin wallet from Qt view code.
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
bool haveWatchOnly() const
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
void notifyWatchonlyChanged(bool fHaveWatchonly)
Data model for a walletmodel transaction.
void coinsSent(CWallet *wallet, SendCoinsRecipient recipient, QByteArray transaction)
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.
qint64 cachedWatchImmatureBalance
AddressTableModel * addressTableModel
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
qint64 getWatchBalance() const
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()
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
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)
void pollBalanceChanged()
OptionsModel * getOptionsModel()
void subscribeToCoreSignals()
std::vector< std::pair< std::string, std::string > > vOrderForm