Master Core  v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
walletmodel.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2014 The Bitcoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include "walletmodel.h"
6 
7 #include "addresstablemodel.h"
8 #include "guiconstants.h"
10 #include "transactiontablemodel.h"
11 
12 #include "base58.h"
13 #include "db.h"
14 #include "keystore.h"
15 #include "main.h"
16 #include "sync.h"
17 #include "ui_interface.h"
18 #include "wallet.h"
19 #include "walletdb.h" // for BackupWallet
20 
21 #include <stdint.h>
22 
23 #include <QDebug>
24 #include <QSet>
25 #include <QTimer>
26 
27 WalletModel::WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent) :
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),
34  cachedNumBlocks(0)
35 {
36  addressTableModel = new AddressTableModel(wallet, this);
37  transactionTableModel = new TransactionTableModel(wallet, this);
39 
40  // This timer will be fired repeatedly to update the balance
41  pollTimer = new QTimer(this);
42  connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollBalanceChanged()));
44 
46 }
47 
49 {
51 }
52 
53 qint64 WalletModel::getBalance(const CCoinControl *coinControl) const
54 {
55  if (coinControl)
56  {
57  qint64 nBalance = 0;
58  std::vector<COutput> vCoins;
59  wallet->AvailableCoins(vCoins, true, coinControl);
60  BOOST_FOREACH(const COutput& out, vCoins)
61  nBalance += out.tx->vout[out.i].nValue;
62 
63  return nBalance;
64  }
65 
66  return wallet->GetBalance();
67 }
68 
70 {
71  return wallet->GetUnconfirmedBalance();
72 }
73 
75 {
76  return wallet->GetImmatureBalance();
77 }
78 
80 {
81  int numTransactions = 0;
82  {
84  // the size of mapWallet contains the number of unique transaction IDs
85  // (e.g. payments to yourself generate 2 transactions, but both share the same transaction ID)
86  numTransactions = wallet->mapWallet.size();
87  }
88  return numTransactions;
89 }
90 
92 {
93  EncryptionStatus newEncryptionStatus = getEncryptionStatus();
94 
95  if(cachedEncryptionStatus != newEncryptionStatus)
96  emit encryptionStatusChanged(newEncryptionStatus);
97 }
98 
100 {
101  // Get required locks upfront. This avoids the GUI from getting stuck on
102  // periodical polls if the core is holding the locks for a longer time -
103  // for example, during a wallet rescan.
104  TRY_LOCK(cs_main, lockMain);
105  if(!lockMain)
106  return;
107  TRY_LOCK(wallet->cs_wallet, lockWallet);
108  if(!lockWallet)
109  return;
110 
112  {
113  // Balance and number of transactions might have changed
115 
119  }
120 }
121 
123 {
124  qint64 newBalance = getBalance();
125  qint64 newUnconfirmedBalance = getUnconfirmedBalance();
126  qint64 newImmatureBalance = getImmatureBalance();
127 
128  if(cachedBalance != newBalance || cachedUnconfirmedBalance != newUnconfirmedBalance || cachedImmatureBalance != newImmatureBalance)
129  {
130  cachedBalance = newBalance;
131  cachedUnconfirmedBalance = newUnconfirmedBalance;
132  cachedImmatureBalance = newImmatureBalance;
133  emit balanceChanged(newBalance, newUnconfirmedBalance, newImmatureBalance);
134  }
135 }
136 
137 void WalletModel::updateTransaction(const QString &hash, int status)
138 {
141 
142  // Balance and number of transactions might have changed
144 
145  int newNumTransactions = getNumTransactions();
146  if(cachedNumTransactions != newNumTransactions)
147  {
148  cachedNumTransactions = newNumTransactions;
149  emit numTransactionsChanged(newNumTransactions);
150  }
151 }
152 
153 void WalletModel::updateAddressBook(const QString &address, const QString &label,
154  bool isMine, const QString &purpose, int status)
155 {
157  addressTableModel->updateEntry(address, label, isMine, purpose, status);
158 }
159 
160 bool WalletModel::validateAddress(const QString &address)
161 {
162  CBitcoinAddress addressParsed(address.toStdString());
163  return addressParsed.IsValid();
164 }
165 
167 {
168  qint64 total = 0;
169  QList<SendCoinsRecipient> recipients = transaction.getRecipients();
170  std::vector<std::pair<CScript, int64_t> > vecSend;
171 
172  if(recipients.empty())
173  {
174  return OK;
175  }
176 
177  QSet<QString> setAddress; // Used to detect duplicates
178  int nAddresses = 0;
179 
180  // Pre-check input data for validity
181  foreach(const SendCoinsRecipient &rcp, recipients)
182  {
183  if (rcp.paymentRequest.IsInitialized())
184  { // PaymentRequest...
185  int64_t subtotal = 0;
186  const payments::PaymentDetails& details = rcp.paymentRequest.getDetails();
187  for (int i = 0; i < details.outputs_size(); i++)
188  {
189  const payments::Output& out = details.outputs(i);
190  if (out.amount() <= 0) continue;
191  subtotal += out.amount();
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()));
195  }
196  if (subtotal <= 0)
197  {
198  return InvalidAmount;
199  }
200  total += subtotal;
201  }
202  else
203  { // User-entered bitcoin address / amount:
204  if(!validateAddress(rcp.address))
205  {
206  return InvalidAddress;
207  }
208  if(rcp.amount <= 0)
209  {
210  return InvalidAmount;
211  }
212  setAddress.insert(rcp.address);
213  ++nAddresses;
214 
215  CScript scriptPubKey;
216  scriptPubKey.SetDestination(CBitcoinAddress(rcp.address.toStdString()).Get());
217  vecSend.push_back(std::pair<CScript, int64_t>(scriptPubKey, rcp.amount));
218 
219  total += rcp.amount;
220  }
221  }
222  if(setAddress.size() != nAddresses)
223  {
224  return DuplicateAddress;
225  }
226 
227  qint64 nBalance = getBalance(coinControl);
228 
229  if(total > nBalance)
230  {
231  return AmountExceedsBalance;
232  }
233 
234  if((total + nTransactionFee) > nBalance)
235  {
236  transaction.setTransactionFee(nTransactionFee);
238  }
239 
240  {
242 
243  transaction.newPossibleKeyChange(wallet);
244  int64_t nFeeRequired = 0;
245  std::string strFailReason;
246 
247  CWalletTx *newTx = transaction.getTransaction();
248  CReserveKey *keyChange = transaction.getPossibleKeyChange();
249  bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, strFailReason, coinControl);
250  transaction.setTransactionFee(nFeeRequired);
251 
252  if(!fCreated)
253  {
254  if((total + nFeeRequired) > nBalance)
255  {
257  }
258  emit message(tr("Send Coins"), QString::fromStdString(strFailReason),
261  }
262  }
263 
264  return SendCoinsReturn(OK);
265 }
266 
268 {
269  QByteArray transaction_array; /* store serialized transaction */
270 
271  {
273  CWalletTx *newTx = transaction.getTransaction();
274 
275  // Store PaymentRequests in wtx.vOrderForm in wallet.
276  foreach(const SendCoinsRecipient &rcp, transaction.getRecipients())
277  {
278  if (rcp.paymentRequest.IsInitialized())
279  {
280  std::string key("PaymentRequest");
281  std::string value;
282  rcp.paymentRequest.SerializeToString(&value);
283  newTx->vOrderForm.push_back(make_pair(key, value));
284  }
285  else if (!rcp.message.isEmpty()) // Message from normal bitcoin:URI (bitcoin:123...?message=example)
286  newTx->vOrderForm.push_back(make_pair("Message", rcp.message.toStdString()));
287  }
288 
289  CReserveKey *keyChange = transaction.getPossibleKeyChange();
290  if(!wallet->CommitTransaction(*newTx, *keyChange))
292 
293  CTransaction* t = (CTransaction*)newTx;
295  ssTx << *t;
296  transaction_array.append(&(ssTx[0]), ssTx.size());
297  }
298 
299  // Add addresses / update labels that we've sent to to the address book,
300  // and emit coinsSent signal for each recipient
301  foreach(const SendCoinsRecipient &rcp, transaction.getRecipients())
302  {
303  // Don't touch the address book when we have a payment request
304  if (!rcp.paymentRequest.IsInitialized())
305  {
306  std::string strAddress = rcp.address.toStdString();
307  CTxDestination dest = CBitcoinAddress(strAddress).Get();
308  std::string strLabel = rcp.label.toStdString();
309  {
311 
312  std::map<CTxDestination, CAddressBookData>::iterator mi = wallet->mapAddressBook.find(dest);
313 
314  // Check if we have a new address or an updated label
315  if (mi == wallet->mapAddressBook.end())
316  {
317  wallet->SetAddressBook(dest, strLabel, "send");
318  }
319  else if (mi->second.name != strLabel)
320  {
321  wallet->SetAddressBook(dest, strLabel, ""); // "" means don't change purpose
322  }
323  }
324  }
325  emit coinsSent(wallet, rcp, transaction_array);
326  }
327 
328  return SendCoinsReturn(OK);
329 }
330 
332 {
333  return optionsModel;
334 }
335 
337 {
338  return addressTableModel;
339 }
340 
342 {
343  return transactionTableModel;
344 }
345 
347 {
349 }
350 
352 {
353  if(!wallet->IsCrypted())
354  {
355  return Unencrypted;
356  }
357  else if(wallet->IsLocked())
358  {
359  return Locked;
360  }
361  else
362  {
363  return Unlocked;
364  }
365 }
366 
367 bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphrase)
368 {
369  if(encrypted)
370  {
371  // Encrypt
372  return wallet->EncryptWallet(passphrase);
373  }
374  else
375  {
376  // Decrypt -- TODO; not supported yet
377  return false;
378  }
379 }
380 
381 bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase)
382 {
383  if(locked)
384  {
385  // Lock
386  return wallet->Lock();
387  }
388  else
389  {
390  // Unlock
391  return wallet->Unlock(passPhrase);
392  }
393 }
394 
395 bool WalletModel::changePassphrase(const SecureString &oldPass, const SecureString &newPass)
396 {
397  bool retval;
398  {
400  wallet->Lock(); // Make sure wallet is locked before attempting pass change
401  retval = wallet->ChangeWalletPassphrase(oldPass, newPass);
402  }
403  return retval;
404 }
405 
406 bool WalletModel::backupWallet(const QString &filename)
407 {
408  return BackupWallet(*wallet, filename.toLocal8Bit().data());
409 }
410 
411 // Handlers for core signals
412 static void NotifyKeyStoreStatusChanged(WalletModel *walletmodel, CCryptoKeyStore *wallet)
413 {
414  qDebug() << "NotifyKeyStoreStatusChanged";
415  QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection);
416 }
417 
418 static void NotifyAddressBookChanged(WalletModel *walletmodel, CWallet *wallet,
419  const CTxDestination &address, const std::string &label, bool isMine,
420  const std::string &purpose, ChangeType status)
421 {
422  QString strAddress = QString::fromStdString(CBitcoinAddress(address).ToString());
423  QString strLabel = QString::fromStdString(label);
424  QString strPurpose = QString::fromStdString(purpose);
425 
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),
430  Q_ARG(bool, isMine),
431  Q_ARG(QString, strPurpose),
432  Q_ARG(int, status));
433 }
434 
435 // queue notifications to show a non freezing progress dialog e.g. for rescan
436 static bool fQueueNotifications = false;
437 static std::vector<std::pair<uint256, ChangeType> > vQueueNotifications;
438 static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, const uint256 &hash, ChangeType status)
439 {
441  {
442  vQueueNotifications.push_back(make_pair(hash, status));
443  return;
444  }
445 
446  QString strHash = QString::fromStdString(hash.GetHex());
447 
448  qDebug() << "NotifyTransactionChanged : " + strHash + " status= " + QString::number(status);
449  QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection,
450  Q_ARG(QString, strHash),
451  Q_ARG(int, status));
452 }
453 
454 static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
455 {
456  // emits signal "showProgress"
457  QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection,
458  Q_ARG(QString, QString::fromStdString(title)),
459  Q_ARG(int, nProgress));
460 
461  if (nProgress == 0)
462  fQueueNotifications = true;
463 
464  if (nProgress == 100)
465  {
466  fQueueNotifications = false;
467  BOOST_FOREACH(const PAIRTYPE(uint256, ChangeType)& notification, vQueueNotifications)
468  NotifyTransactionChanged(walletmodel, NULL, notification.first, notification.second);
469  std::vector<std::pair<uint256, ChangeType> >().swap(vQueueNotifications); // clear
470  }
471 }
472 
474 {
475  // Connect signals to wallet
476  wallet->NotifyStatusChanged.connect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1));
477  wallet->NotifyAddressBookChanged.connect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5, _6));
478  wallet->NotifyTransactionChanged.connect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3));
479  wallet->ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2));
480 }
481 
483 {
484  // Disconnect signals from wallet
485  wallet->NotifyStatusChanged.disconnect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1));
486  wallet->NotifyAddressBookChanged.disconnect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5, _6));
487  wallet->NotifyTransactionChanged.disconnect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3));
488  wallet->ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
489 }
490 
491 // WalletModel::UnlockContext implementation
493 {
494  bool was_locked = getEncryptionStatus() == Locked;
495  if(was_locked)
496  {
497  // Request UI to unlock wallet
498  emit requireUnlock();
499  }
500  // If wallet is still locked, unlock was failed or cancelled, mark context as invalid
501  bool valid = getEncryptionStatus() != Locked;
502 
503  return UnlockContext(this, valid, was_locked);
504 }
505 
506 WalletModel::UnlockContext::UnlockContext(WalletModel *wallet, bool valid, bool relock):
507  wallet(wallet),
508  valid(valid),
509  relock(relock)
510 {
511 }
512 
514 {
515  if(valid && relock)
516  {
517  wallet->setWalletLocked(true);
518  }
519 }
520 
522 {
523  // Transfer context; old object no longer relocks wallet
524  *this = rhs;
525  rhs.relock = false;
526 }
527 
528 bool WalletModel::getPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) const
529 {
530  return wallet->GetPubKey(address, vchPubKeyOut);
531 }
532 
533 // returns a list of COutputs from COutPoints
534 void WalletModel::getOutputs(const std::vector<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs)
535 {
537  BOOST_FOREACH(const COutPoint& outpoint, vOutpoints)
538  {
539  if (!wallet->mapWallet.count(outpoint.hash)) continue;
540  int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain();
541  if (nDepth < 0) continue;
542  COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth);
543  vOutputs.push_back(out);
544  }
545 }
546 
547 bool WalletModel::isSpent(const COutPoint& outpoint) const
548 {
550  return wallet->IsSpent(outpoint.hash, outpoint.n);
551 }
552 
553 // AvailableCoins + LockedCoins grouped by wallet address (put change in one group with wallet address)
554 void WalletModel::listCoins(std::map<QString, std::vector<COutput> >& mapCoins) const
555 {
556  std::vector<COutput> vCoins;
557  wallet->AvailableCoins(vCoins);
558 
559  LOCK2(cs_main, wallet->cs_wallet); // ListLockedCoins, mapWallet
560  std::vector<COutPoint> vLockedCoins;
561  wallet->ListLockedCoins(vLockedCoins);
562 
563  // add locked coins
564  BOOST_FOREACH(const COutPoint& outpoint, vLockedCoins)
565  {
566  if (!wallet->mapWallet.count(outpoint.hash)) continue;
567  int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain();
568  if (nDepth < 0) continue;
569  COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth);
570  vCoins.push_back(out);
571  }
572 
573  BOOST_FOREACH(const COutput& out, vCoins)
574  {
575  COutput cout = out;
576 
577  while (wallet->IsChange(cout.tx->vout[cout.i]) && cout.tx->vin.size() > 0 && wallet->IsMine(cout.tx->vin[0]))
578  {
579  if (!wallet->mapWallet.count(cout.tx->vin[0].prevout.hash)) break;
580  cout = COutput(&wallet->mapWallet[cout.tx->vin[0].prevout.hash], cout.tx->vin[0].prevout.n, 0);
581  }
582 
583  CTxDestination address;
584  if(!ExtractDestination(cout.tx->vout[cout.i].scriptPubKey, address)) continue;
585  mapCoins[CBitcoinAddress(address).ToString().c_str()].push_back(out);
586  }
587 }
588 
589 bool WalletModel::isLockedCoin(uint256 hash, unsigned int n) const
590 {
592  return wallet->IsLockedCoin(hash, n);
593 }
594 
596 {
598  wallet->LockCoin(output);
599 }
600 
602 {
604  wallet->UnlockCoin(output);
605 }
606 
607 void WalletModel::listLockedCoins(std::vector<COutPoint>& vOutpts)
608 {
610  wallet->ListLockedCoins(vOutpts);
611 }
612 
613 void WalletModel::loadReceiveRequests(std::vector<std::string>& vReceiveRequests)
614 {
616  BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, wallet->mapAddressBook)
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") // receive request
619  vReceiveRequests.push_back(item2.second);
620 }
621 
622 bool WalletModel::saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest)
623 {
624  CTxDestination dest = CBitcoinAddress(sAddress).Get();
625 
626  std::stringstream ss;
627  ss << nId;
628  std::string key = "rr" + ss.str(); // "rr" prefix = "receive request" in destdata
629 
631  if (sRequest.empty())
632  return wallet->EraseDestData(dest, key);
633  else
634  return wallet->AddDestData(dest, key, sRequest);
635 }
void loadReceiveRequests(std::vector< std::string > &vReceiveRequests)
bool IsValid() const
Definition: base58.cpp:215
Model for list of recently generated payment requests / bitcoin: URIs.
TransactionTableModel * transactionTableModel
Definition: walletmodel.h:202
bool IsCrypted() const
Definition: crypter.h:137
void getOutputs(const std::vector< COutPoint > &vOutpoints, std::vector< COutput > &vOutputs)
int i
Definition: wallet.h:713
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
Definition: wallet.cpp:1548
RecentRequestsTableModel * recentRequestsTableModel
Definition: walletmodel.h:203
PaymentRequestPlus paymentRequest
Definition: walletmodel.h:55
bool IsInitialized() const
int64_t GetImmatureBalance() const
Definition: wallet.cpp:1011
void lockCoin(COutPoint &output)
bool IsMine(const CTxIn &txin) const
Definition: wallet.cpp:653
qint64 getImmatureBalance() const
Definition: walletmodel.cpp:74
#define TRY_LOCK(cs, name)
Definition: sync.h:158
qint64 cachedImmatureBalance
Definition: walletmodel.h:208
void ListLockedCoins(std::vector< COutPoint > &vOutpts)
Definition: wallet.cpp:1997
std::map< CTxDestination, CAddressBookData > mapAddressBook
Definition: wallet.h:173
#define PAIRTYPE(t1, t2)
Definition: util.h:48
CCriticalSection cs_wallet
Main wallet lock.
Definition: wallet.h:132
qint64 cachedNumTransactions
Definition: walletmodel.h:209
qint64 cachedUnconfirmedBalance
Definition: walletmodel.h:207
UnlockContext requestUnlock()
void unsubscribeFromCoreSignals()
bool isLockedCoin(uint256 hash, unsigned int n) const
bool SerializeToString(string *output) const
CCriticalSection cs_main
Definition: main.cpp:43
bool backupWallet(const QString &filename)
SendCoinsReturn sendCoins(WalletModelTransaction &transaction)
bool IsLocked() const
Definition: crypter.h:142
Double ended buffer combining vector and stream-like interfaces.
Definition: serialize.h:839
void updateTransaction(const QString &hash, int status)
base58-encoded Bitcoin addresses.
Definition: base58.h:101
unsigned int n
Definition: core.h:26
bool BackupWallet(const CWallet &wallet, const string &strDest)
Definition: walletdb.cpp:825
AddressTableModel * getAddressTableModel()
Keystore which keeps the private keys encrypted.
Definition: crypter.h:113
CTxDestination Get() const
Definition: base58.cpp:222
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const
Definition: crypter.cpp:235
CChain chainActive
The currently-connected chain of blocks.
Definition: main.cpp:48
Coin Control Features.
Definition: coincontrol.h:11
const ::std::string & script() const
void updateStatus()
Definition: walletmodel.cpp:91
void newPossibleKeyChange(CWallet *wallet)
void setTransactionFee(qint64 newFee)
UnlockContext(WalletModel *wallet, bool valid, bool relock)
void SetDestination(const CTxDestination &address)
Definition: script.cpp:1925
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.
Definition: wallet.h:395
int64_t GetBalance() const
Definition: wallet.cpp:980
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)
Definition: walletmodel.cpp:27
boost::signals2::signal< void(CCryptoKeyStore *wallet)> NotifyStatusChanged
Definition: crypter.h:189
void checkBalanceChanged()
#define LOCK2(cs1, cs2)
Definition: sync.h:157
int Height() const
Return the maximal height in the chain.
Definition: main.h:1043
bool IsSpent(const uint256 &hash, unsigned int n) const
Definition: wallet.cpp:319
CWallet * wallet
Definition: walletmodel.h:195
void numTransactionsChanged(int count)
void LockCoin(COutPoint &output)
Definition: wallet.cpp:1971
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
Definition: wallet.cpp:167
int64_t nTransactionFee
Definition: wallet.cpp:19
ChangeType
General change type (added, updated, removed).
Definition: ui_interface.h:20
bool isSpent(const COutPoint &outpoint) const
#define LOCK(cs)
Definition: sync.h:156
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass)
std::vector< CTxOut > vout
Definition: core.h:191
size_type size() const
Definition: serialize.h:928
void UnlockCoin(COutPoint &output)
Definition: wallet.cpp:1977
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: allocators.h:253
qint64 getUnconfirmedBalance() const
Definition: walletmodel.cpp:69
const ::payments::Output & outputs(int index) const
An encapsulated public key.
Definition: key.h:42
std::vector< CTxIn > vin
Definition: core.h:190
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.
Definition: wallet.cpp:2070
bool CommitTransaction(CWalletTx &wtxNew, CReserveKey &reservekey)
Definition: wallet.cpp:1401
std::string ToString() const
Definition: base58.cpp:174
OptionsModel * optionsModel
Definition: walletmodel.h:199
const payments::PaymentDetails & getDetails() const
TransactionTableModel * getTransactionTableModel()
void AvailableCoins(std::vector< COutput > &vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl=NULL) const
Definition: wallet.cpp:1026
EncryptionStatus cachedEncryptionStatus
Definition: walletmodel.h:210
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: core.h:22
void CopyFrom(const UnlockContext &rhs)
std::string GetHex() const
Definition: uint256.h:297
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
Definition: guiconstants.h:9
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString())
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:451
void encryptionStatusChanged(int status)
QTimer * pollTimer
Definition: walletmodel.h:213
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)
256-bit unsigned integer
Definition: uint256.h:531
int cachedNumBlocks
Definition: walletmodel.h:211
static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, const uint256 &hash, ChangeType status)
int64_t GetUnconfirmedBalance() const
Definition: wallet.cpp:996
RecentRequestsTableModel * getRecentRequestsTableModel()
bool EncryptWallet(const SecureString &strWalletPassphrase)
Definition: wallet.cpp:356
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.
Definition: wallet.h:389
void listLockedCoins(std::vector< COutPoint > &vOutpts)
A key allocated from the key pool.
Definition: wallet.h:402
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:20
Address book data.
Definition: wallet.h:82
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:401
StringMap destdata
Definition: wallet.h:94
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:96
static const int PROTOCOL_VERSION
Definition: version.h:29
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.
Definition: key.h:26
qint64 getBalance(const CCoinControl *coinControl=NULL) const
Definition: walletmodel.cpp:53
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Definition: script.cpp:1493
const CWalletTx * tx
Definition: wallet.h:712
bool Unlock(const SecureString &strWalletPassphrase)
Definition: wallet.cpp:147
void updateTransaction(const QString &hash, int status)
bool IsChange(const CTxOut &txout) const
Definition: wallet.cpp:685
int getNumTransactions() const
Definition: walletmodel.cpp:79
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:100
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
Definition: wallet.h:168
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
Definition: wallet.h:398
AddressTableModel * addressTableModel
Definition: walletmodel.h:201
qint64 cachedBalance
Definition: walletmodel.h:206
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
Definition: script.h:218
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: core.h:183
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.
Definition: wallet.cpp:2059
void listCoins(std::map< QString, std::vector< COutput > > &mapCoins) const
static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
bool saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest)
bool IsLockedCoin(uint256 hash, unsigned int n) const
Definition: wallet.cpp:1989
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()
Definition: walletmodel.cpp:99
OptionsModel * getOptionsModel()
void subscribeToCoreSignals()
std::vector< std::pair< std::string, std::string > > vOrderForm
Definition: wallet.h:458
uint256 hash
Definition: core.h:25