PRCYCoin  2.0.0.7rc1
P2P Digital Currency
walletmodel.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2014 The Bitcoin developers
2 // Copyright (c) 2015-2018 The PIVX developers
3 // Copyright (c) 2014-2015 The Dash developers
4 // Copyright (c) 2018-2020 The DAPS Project developers
5 // Distributed under the MIT/X11 software license, see the accompanying
6 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
7 
8 #include "walletmodel.h"
9 
10 #include "addresstablemodel.h"
11 #include "bitcoinunits.h"
12 #include "guiconstants.h"
13 #include "guiutil.h"
14 #include "transactionrecord.h"
15 #include "transactiontablemodel.h"
16 #include "init.h" // for ShutdownRequested(). Future: move to an interface wrapper
17 
18 #include "base58.h"
19 #include "wallet/db.h"
20 #include "keystore.h"
21 #include "main.h"
22 #include "miner.h"
23 #include "sync.h"
24 #include "guiinterface.h"
25 #include "wallet/wallet.h"
26 #include "wallet/walletdb.h" // for BackupWallet
27 #include <stdint.h>
28 #include <regex>
29 #include <QDebug>
30 #include <QLocale>
31 #include <QSet>
32 #include <QTimer>
33 #include <QtCore>
34 #include <QtMath>
35 #include <stdint.h>
36 #include <QTextStream>
37 
38 
39 WalletModel::WalletModel(CWallet* wallet, OptionsModel* optionsModel, QObject* parent) : QObject(parent), wallet(wallet), optionsModel(optionsModel), addressTableModel(0),
40  transactionTableModel(0),
41  cachedBalance(0), cachedUnconfirmedBalance(0), spendableBalance(0), cachedImmatureBalance(0), cachedWatchOnlyBalance(0),
42  cachedWatchUnconfBalance(0), cachedWatchImmatureBalance(0),
43  cachedEncryptionStatus(Unencrypted),
44  cachedNumBlocks(0), cachedTxLocks(0),
45  txTableModel(0)
46 
47 {
50 
53 
54  // This timer will be fired repeatedly to update the balance
55  pollTimer = new QTimer(this);
56  connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollBalanceChanged()));
57  pollTimer->start(MODEL_UPDATE_DELAY);
58 
60 }
61 
63 {
64  return ShutdownRequested();
65 }
66 
68 {
70 }
71 
73 {
74  return Params().MinimumStakeAmount();
75 }
76 
77 CAmount WalletModel::getBalance(const CCoinControl* coinControl) const
78 {
79  if (coinControl) {
80 
81  {
82  return wallet->GetBalance();
83  }
84  }
85 
86  return wallet->GetBalance();
87 }
88 
90 {
91  return wallet->GetUnconfirmedBalance();
92 }
93 
95 {
96  return wallet->GetSpendableBalance();
97 }
98 
100 {
101  return wallet->GetImmatureBalance();
102 }
103 
105 {
106  return wallet->GetLockedCoins();
107 }
108 
110 {
111  return fHaveWatchOnly;
112 }
113 
115 {
116  return wallet->GetWatchOnlyBalance();
117 }
118 
120 {
122 }
123 
125 {
127 }
128 
130 {
131  EncryptionStatus newEncryptionStatus = getEncryptionStatus();
132 
133  if (cachedEncryptionStatus != newEncryptionStatus)
134  Q_EMIT encryptionStatusChanged(newEncryptionStatus);
135 }
136 
138  return fImporting || fReindex;
139 }
140 
142 {
143  if (wallet->walletUnlockCountStatus == 1) {
144  Q_EMIT WalletUnlocked();
146  }
147 
148  // Wait a little bit more when the wallet is reindexing and/or importing, no need to lock cs_main so often.
149  if (IsImportingOrReindexing()) {
150  static uint8_t waitLonger = 0;
151  waitLonger++;
152  if (waitLonger < 10) // 10 seconds
153  return;
154  waitLonger = 0;
155  }
156 
157  // Get required locks upfront. This avoids the GUI from getting stuck on
158  // periodical polls if the core is holding the locks for a longer time -
159  // for example, during a wallet rescan.
160  TRY_LOCK(cs_main, lockMain);
161  if (!lockMain)
162  return;
163  TRY_LOCK(wallet->cs_wallet, lockWallet);
164  if (!lockWallet)
165  return;
166 
167  int chainHeight = chainActive.Height();
168  if (fForceCheckBalanceChanged || chainHeight != cachedNumBlocks) {
170 
171  // Balance and number of transactions might have changed
172  cachedNumBlocks = chainHeight;
173 
175  if (transactionTableModel) {
177  }
178  } else {
180  }
181 }
182 
184 {
185  // Force update of UI elements even when no values have changed
186  if (cachedBalance == 0 && !checkBalanceChanged())
187  return;
188 
191 }
192 
194 {
195  CAmount newBalance = getBalance();
196  CAmount newUnconfirmedBalance = getUnconfirmedBalance();
197  CAmount newImmatureBalance = getImmatureBalance();
198  CAmount newSpendableBalance = newBalance - newImmatureBalance;
199  static bool stkEnabled = false;
200  static bool walletLocked = wallet->IsLocked();
201  CAmount newWatchOnlyBalance = 0;
202  CAmount newWatchUnconfBalance = 0;
203  CAmount newWatchImmatureBalance = 0;
204  if (haveWatchOnly()) {
205  newWatchOnlyBalance = getWatchBalance();
206  newWatchUnconfBalance = getWatchUnconfirmedBalance();
207  newWatchImmatureBalance = getWatchImmatureBalance();
208  }
209 
210  if (walletLocked != wallet->IsLocked() ||
211  (stkEnabled != (nLastCoinStakeSearchInterval > 0)) ||
212  newSpendableBalance != spendableBalance ||
213  cachedBalance != newBalance ||
214  cachedUnconfirmedBalance != newUnconfirmedBalance ||
215  cachedImmatureBalance != newImmatureBalance ||
216  cachedWatchOnlyBalance != newWatchOnlyBalance ||
217  cachedWatchUnconfBalance != newWatchUnconfBalance ||
218  cachedWatchImmatureBalance != newWatchImmatureBalance ||
220  cachedBalance = newBalance;
221  cachedUnconfirmedBalance = newUnconfirmedBalance;
222  cachedImmatureBalance = newImmatureBalance;
223  spendableBalance = newSpendableBalance;
225  cachedWatchOnlyBalance = newWatchOnlyBalance;
226  cachedWatchUnconfBalance = newWatchUnconfBalance;
227  cachedWatchImmatureBalance = newWatchImmatureBalance;
228  stkEnabled = (nLastCoinStakeSearchInterval > 0);
229  walletLocked = wallet->IsLocked();
230  Q_EMIT balanceChanged(newBalance, newUnconfirmedBalance, newImmatureBalance,
231  newWatchOnlyBalance, newWatchUnconfBalance, newWatchImmatureBalance);
232  return true;
233  }
234 
235  return false;
236 }
237 
239 {
240  // Balance and number of transactions might have changed
242 }
243 
244 void WalletModel::updateAddressBook(const QString& address, const QString& label, bool isMine, const QString& purpose, int status)
245 {
246  if (addressTableModel)
247  addressTableModel->updateEntry(address, label, isMine, purpose, status);
248 }
249 void WalletModel::updateAddressBook(const QString& pubCoin, const QString& isUsed, int status)
250 {
251  if (addressTableModel)
252  addressTableModel->updateEntry(pubCoin, isUsed, status);
253 }
254 
255 
256 void WalletModel::updateWatchOnlyFlag(bool fHaveWatchonly)
257 {
258  fHaveWatchOnly = fHaveWatchonly;
259  Q_EMIT notifyWatchonlyChanged(fHaveWatchonly);
260 }
261 
262 bool WalletModel::validateAddress(const QString& address)
263 {
264  CBitcoinAddress addressParsed(address.toStdString());
265  bool valid = (regex_match(address.toStdString(), std::regex("[a-zA-z0-9]+")))&&(address.length()==99||address.length()==110);
266  return valid||addressParsed.IsValid();
267 }
268 
270 {
271  CAmount total = 0;
272  QList<SendCoinsRecipient> recipients = transaction.getRecipients();
273  std::vector<std::pair<CScript, CAmount> > vecSend;
274 
275  if (recipients.empty()) {
276  return OK;
277  }
278 
279  if (isStakingOnlyUnlocked()) {
280  return StakingOnlyUnlocked;
281  }
282 
283  QSet<QString> setAddress; // Used to detect duplicates
284  int nAddresses = 0;
285 
286  // Pre-check input data for validity
287  Q_FOREACH (const SendCoinsRecipient& rcp, recipients) {
288  { // User-entered prcycoin address / amount:
289  if (!validateAddress(rcp.address)) {
290  return InvalidAddress;
291  }
292  if (rcp.amount <= 0) {
293  return InvalidAmount;
294  }
295  setAddress.insert(rcp.address);
296  ++nAddresses;
297 
298  CScript scriptPubKey = GetScriptForDestination(CBitcoinAddress(rcp.address.toStdString()).Get());
299  vecSend.push_back(std::pair<CScript, CAmount>(scriptPubKey, rcp.amount));
300 
301  total += rcp.amount;
302  }
303  }
304  if (setAddress.size() != nAddresses) {
305  return DuplicateAddress;
306  }
307 
308  CAmount nBalance = getBalance(coinControl);
309 
310  if (total > nBalance) {
311  return AmountExceedsBalance;
312  }
313 
314  {
316 
317  transaction.newPossibleKeyChange(wallet);
318  CAmount nFeeRequired = 0;
319  std::string strFailReason;
320 
321  CWalletTx* newTx = transaction.getTransaction();
322  CReserveKey* keyChange = transaction.getPossibleKeyChange();
323 
324  bool fCreated = wallet->CreateTransaction(vecSend, *newTx, *keyChange, nFeeRequired, strFailReason, coinControl, recipients[0].inputType, recipients[0].useSwiftTX);
325  transaction.setTransactionFee(nFeeRequired);
326 
327  if (!fCreated) {
328  if ((total + nFeeRequired) > nBalance) {
330  }
331  Q_EMIT message(tr("Send Coins"), QString::fromStdString(strFailReason),
334  }
335 
336  // reject insane fee
337  if (nFeeRequired > ::minRelayTxFee.GetFee(transaction.getTransactionSize()) * 10000)
338  return InsaneFee;
339  }
340 
341  return SendCoinsReturn(OK);
342 }
343 
345 {
346  QByteArray transaction_array; /* store serialized transaction */
347 
348  std::string stealthAddr = transaction.getRecipients()[0].address.toStdString();
349  CAmount nValue = transaction.getRecipients()[0].amount;
350  CWalletTx wtxNew;
351 
352  if (wallet->SendToStealthAddress(stealthAddr, nValue, wtxNew,false))
353  return SendCoinsReturn(OK);
354 
356 }
357 
359 {
360  return optionsModel;
361 }
362 
364 {
365  return addressTableModel;
366 }
367 
369 {
370  return transactionTableModel;
371 }
372 
374 {
375  if (!wallet->IsLocked()) {
376  return Unencrypted;
377  } else if (wallet->fWalletUnlockStakingOnly) {
378  return UnlockedForStakingOnly;
379  } else if (wallet->IsLocked()) {
380  return Locked;
381  } else {
382  return Unlocked;
383  }
384 }
385 
386 bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString& passphrase)
387 {
388  if (encrypted) {
389  // Encrypt
390  return wallet->EncryptWallet(passphrase);
391  } else {
392  // Decrypt -- TODO; not supported yet
393  return false;
394  }
395 }
396 
397 bool WalletModel::setWalletLocked(bool locked, const SecureString& passPhrase, bool stakingOnly)
398 {
399  if (locked) {
400  // Lock
402  return wallet->Lock();
403  } else {
404  // Unlock
405  return wallet->Unlock(passPhrase, stakingOnly);
406  }
407 }
408 
410 {
411  if (!wallet->IsLocked()) {
413  return true;
414  } else {
415  setWalletLocked(false, passPhrase, true);
416  }
417  return false;
418 }
419 
421 {
423 }
424 
425 bool WalletModel::changePassphrase(const SecureString& oldPass, const SecureString& newPass)
426 {
427  bool retval;
428  {
430  wallet->Lock(); // Make sure wallet is locked before attempting pass change
431  retval = wallet->ChangeWalletPassphrase(oldPass, newPass);
432  }
433  return retval;
434 }
435 
436 bool WalletModel::backupWallet(const QString& filename)
437 {
438  //attempt regular backup
439  if(!BackupWallet(*wallet, filename.toLocal8Bit().data())) {
440  return error("ERROR: Failed to backup wallet!");
441  }
442 
443  return true;
444 }
445 
446 // Handlers for core signals
447 static void NotifyKeyStoreStatusChanged(WalletModel* walletmodel, CCryptoKeyStore* wallet)
448 {
449  qDebug() << "NotifyKeyStoreStatusChanged";
450  QMetaObject::invokeMethod(walletmodel, "updateStatus", Qt::QueuedConnection);
451 }
452 
453 static void NotifyAddressBookChanged(WalletModel* walletmodel, CWallet* wallet, const CTxDestination& address, const std::string& label, bool isMine, const std::string& purpose, ChangeType status)
454 {
455  QString strAddress = QString::fromStdString(CBitcoinAddress(address).ToString());
456  QString strLabel = QString::fromStdString(label);
457  QString strPurpose = QString::fromStdString(purpose);
458 
459  qDebug() << "NotifyAddressBookChanged : " + strAddress + " " + strLabel + " isMine=" + QString::number(isMine) + " purpose=" + strPurpose + " status=" + QString::number(status);
460  QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection,
461  Q_ARG(QString, strAddress),
462  Q_ARG(QString, strLabel),
463  Q_ARG(bool, isMine),
464  Q_ARG(QString, strPurpose),
465  Q_ARG(int, status));
466 }
467 
468 // queue notifications to show a non freezing progress dialog e.g. for rescan
469 static bool fQueueNotifications = false;
470 static std::vector<std::pair<uint256, ChangeType> > vQueueNotifications;
471 static void NotifyTransactionChanged(WalletModel* walletmodel, CWallet* wallet, const uint256& hash, ChangeType status)
472 {
473  if (fQueueNotifications) {
474  vQueueNotifications.push_back(std::make_pair(hash, status));
475  return;
476  }
477 
478  QString strHash = QString::fromStdString(hash.GetHex());
479 
480  qDebug() << "NotifyTransactionChanged : " + strHash + " status= " + QString::number(status);
481  QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection
482  );
483 }
484 
485 static void ShowProgress(WalletModel* walletmodel, const std::string& title, int nProgress)
486 {
487  // emits signal "showProgress"
488  QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection,
489  Q_ARG(QString, QString::fromStdString(title)),
490  Q_ARG(int, nProgress));
491 }
492 
493 static void NotifyWatchonlyChanged(WalletModel* walletmodel, bool fHaveWatchonly)
494 {
495  QMetaObject::invokeMethod(walletmodel, "updateWatchOnlyFlag", Qt::QueuedConnection,
496  Q_ARG(bool, fHaveWatchonly));
497 }
498 
499 static void NotifyWalletBacked(WalletModel* model, const bool& fSuccess, const std::string& filename)
500 {
501  std::string message;
502  std::string title = "Backup ";
504 
505  if (fSuccess) {
506  title += "Successful: ";
507  method = CClientUIInterface::MessageBoxFlags::MSG_INFORMATION;
508  } else {
509  message = "There was an error trying to save the wallet data to ";
510  title += "Failed: ";
511  method = CClientUIInterface::MessageBoxFlags::MSG_ERROR;
512  }
513 
514  message += _(filename.data());
515 
516 
517  QMetaObject::invokeMethod(model, "message", Qt::QueuedConnection,
518  Q_ARG(QString, QString::fromStdString(title)),
519  Q_ARG(QString, QString::fromStdString(message)),
520  Q_ARG(unsigned int, (unsigned int)method));
521 }
522 
524 {
525  // Connect signals to wallet
526  wallet->NotifyStatusChanged.connect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1));
527  wallet->NotifyAddressBookChanged.connect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5, _6));
528  wallet->NotifyTransactionChanged.connect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3));
529  wallet->ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2));
530  wallet->NotifyWatchonlyChanged.connect(boost::bind(NotifyWatchonlyChanged, this, _1));
531  wallet->NotifyWalletBacked.connect(boost::bind(NotifyWalletBacked, this, _1, _2));
532 }
533 
535 {
536  // Disconnect signals from wallet
537  wallet->NotifyStatusChanged.disconnect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1));
538  wallet->NotifyAddressBookChanged.disconnect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5, _6));
539  wallet->NotifyTransactionChanged.disconnect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3));
540  wallet->ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
541  wallet->NotifyWatchonlyChanged.disconnect(boost::bind(NotifyWatchonlyChanged, this, _1));
542  wallet->NotifyWalletBacked.disconnect(boost::bind(NotifyWalletBacked, this, _1, _2));
543 }
544 
545 // WalletModel::UnlockContext implementation
547 {
548  bool was_locked = getEncryptionStatus() == Locked;
549 
550  if (!was_locked && isStakingOnlyUnlocked()) {
551  setWalletLocked(true);
553  was_locked = getEncryptionStatus() == Locked;
554  }
555 
556  if (was_locked) {
557  // Request UI to unlock wallet
558  Q_EMIT requireUnlock(context);
559  }
560  // If wallet is still locked, unlock was failed or cancelled, mark context as invalid
561  bool valid = getEncryptionStatus() != Locked;
562 
563  return UnlockContext(valid, relock);
564 }
565 
566 WalletModel::UnlockContext::UnlockContext(bool valid, bool relock) : valid(valid), relock(relock)
567 {
568 }
569 
571 {
572 }
573 
575 {
576  return this->wallet;
577 }
578 
580 {
581  // Transfer context; old object no longer relocks wallet
582  *this = rhs;
583  rhs.relock = false;
584 }
585 
586 bool WalletModel::getPubKey(const CKeyID& address, CPubKey& vchPubKeyOut) const
587 {
588  return wallet->GetPubKey(address, vchPubKeyOut);
589 }
590 
591 bool WalletModel::getSeedPhrase(std::string &phrase) const
592 {
593  return wallet->GetSeedPhrase(phrase);
594 }
595 
596 // returns a list of COutputs from COutPoints
597 void WalletModel::getOutputs(const std::vector<COutPoint>& vOutpoints, std::vector<COutput>& vOutputs)
598 {
600  for (const COutPoint& outpoint : vOutpoints) {
601  if (!wallet->mapWallet.count(outpoint.hash)) continue;
602  int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain();
603  if (nDepth < 0) continue;
604  COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, true);
605  vOutputs.push_back(out);
606  }
607 }
608 
609 bool WalletModel::isSpent(const COutPoint& outpoint) const
610 {
612  return wallet->IsSpent(outpoint.hash, outpoint.n);
613 }
614 
615 // AvailableCoins + LockedCoins grouped by wallet address (put change in one group with wallet address)
616 void WalletModel::listCoins(std::map<QString, std::vector<COutput> >& mapCoins) const
617 {
618  std::vector<COutput> vCoins;
619  wallet->AvailableCoins(vCoins);
620 
621  LOCK2(cs_main, wallet->cs_wallet); // ListLockedCoins, mapWallet
622  std::vector<COutPoint> vLockedCoins;
623  wallet->ListLockedCoins(vLockedCoins);
624 
625  // add locked coins
626  for (const COutPoint& outpoint : vLockedCoins) {
627  if (!wallet->mapWallet.count(outpoint.hash)) continue;
628  int nDepth = wallet->mapWallet[outpoint.hash].GetDepthInMainChain();
629  if (nDepth < 0) continue;
630  COutput out(&wallet->mapWallet[outpoint.hash], outpoint.n, nDepth, true);
631  if (outpoint.n < out.tx->vout.size() && wallet->IsMine(out.tx->vout[outpoint.n]) == ISMINE_SPENDABLE)
632  vCoins.push_back(out);
633  }
634 
635  for (const COutput& out : vCoins) {
636  COutput cout = out;
637 
638  while (wallet->IsChange(cout.tx->vout[cout.i]) && cout.tx->vin.size() > 0 && wallet->IsMine(cout.tx->vin[0])) {
639  if (!wallet->mapWallet.count(wallet->findMyOutPoint(cout.tx->vin[0]).hash)) break;
640  cout = COutput(&wallet->mapWallet[wallet->findMyOutPoint(cout.tx->vin[0]).hash], wallet->findMyOutPoint(cout.tx->vin[0]).n, 0, true);
641  }
642 
643  CTxDestination address;
644  if (!out.fSpendable || !ExtractDestination(cout.tx->vout[cout.i].scriptPubKey, address))
645  continue;
646  mapCoins[QString::fromStdString(CBitcoinAddress(address).ToString())].push_back(out);
647  }
648 }
649 
650 bool WalletModel::isLockedCoin(uint256 hash, unsigned int n) const
651 {
653  return wallet->IsLockedCoin(hash, n);
654 }
655 
657 {
659  wallet->LockCoin(output);
660 }
661 
663 {
665  wallet->UnlockCoin(output);
666 }
667 
668 void WalletModel::listLockedCoins(std::vector<COutPoint>& vOutpts)
669 {
671  wallet->ListLockedCoins(vOutpts);
672 }
673 
674 void WalletModel::loadReceiveRequests(std::vector<std::string>& vReceiveRequests)
675 {
678  for (const PAIRTYPE(std::string, std::string) & item2 : item.second.destdata)
679  if (item2.first.size() > 2 && item2.first.substr(0, 2) == "rr") // receive request
680  vReceiveRequests.push_back(item2.second);
681 }
682 
683 bool WalletModel::saveReceiveRequest(const std::string& sAddress, const int64_t nId, const std::string& sRequest)
684 {
685  CTxDestination dest = CBitcoinAddress(sAddress).Get();
686 
687  std::stringstream ss;
688  ss << nId;
689  std::string key = "rr" + ss.str(); // "rr" prefix = "receive request" in destdata
690 
692  if (sRequest.empty())
693  return wallet->EraseDestData(dest, key);
694  else
695  return wallet->AddDestData(dest, key, sRequest);
696 }
697 
699 {
700  return IsMine(*wallet, address.Get());
701 }
702 
704 {
705  /* {
706  bool fMintable = wallet->MintableCoins();
707  CAmount balance = wallet->GetSpendableBalance();
708  const CAmount minStakingAmount = Params().MinimumStakeAmount();
709  if (!fMintable || nReserveBalance > balance) {
710  if (balance < minStakingAmount) {
711  error = "\nBalance is under the minimum 2,5000 staking threshold.\nPlease send more PRCY to this wallet.\n";
712  return StakingStatusError::STAKING_OK;
713  }
714  if (nReserveBalance > balance || (balance > nReserveBalance && balance - nReserveBalance < minStakingAmount)) {
715  error = "Reserve balance is too high.\nPlease lower it in order to turn staking on.";
716  return StakingStatusError::RESERVE_TOO_HIGH;
717  }
718  if (!fMintable) {
719  if (balance > minStakingAmount) {
720  //1 is to cover transaction fees
721  if (balance >= minStakingAmount + 1*COIN) {
722  error = "Not enough mintable coins.\nDo you want to merge & make a sent-to-yourself transaction to make the wallet stakable?";
723  return StakingStatusError::UTXO_UNDER_THRESHOLD;
724  }
725  }
726  }
727  }
728  }*/
730 }
731 
732 void WalletModel::generateCoins(bool fGenerate, int nGenProcLimit)
733 {
734  GeneratePrcycoins(fGenerate, wallet, nGenProcLimit);
735  if (false /*if regtest*/ && fGenerate) {
736  //regtest generate
737  } else {
738  GeneratePrcycoins(fGenerate, wallet, nGenProcLimit);
739  }
740 }
741 
742 QAbstractTableModel* WalletModel::getTxTableModel()
743 {
744  if (!txTableModel) {
745  return NULL;
746  } else
747  return txTableModel;
748 }
749 
750 namespace WalletUtil
751 {
752 std::map<QString, QString> getTx(CWallet* wallet, uint256 hash)
753 {
754  return getTx(wallet, *wallet->GetWalletTx(hash));
755 }
756 
757 std::vector<std::map<QString, QString> > getTXs(CWallet* wallet)
758 {
759  std::vector<std::map<QString, QString> > txs;
760  if (!wallet || wallet->IsLocked()) return txs;
761  std::map<uint256, CWalletTx> txMap = wallet->mapWallet;
762  {
764  for (std::map<uint256, CWalletTx>::iterator tx = txMap.begin(); tx != txMap.end(); ++tx) {
765  if (tx->second.GetDepthInMainChain() > 0) {
766  txs.push_back(getTx(wallet, tx->second));
767  }
768  }
769  }
770 
771  return txs;
772 }
773 
774 std::map<QString, QString> getTx(CWallet* wallet, CWalletTx tx)
775 {
776 
777  // get stx amount
778  CAmount totalamount = CAmount(0);
779  CAmount totalIn = 0;
780  if (wallet && !wallet->IsLocked()) {
781  for (CTxIn in: tx.vin) {
782  COutPoint prevout = wallet->findMyOutPoint(in);
783  std::map<uint256, CWalletTx>::const_iterator mi = wallet->mapWallet.find(prevout.hash);
784  if (mi != wallet->mapWallet.end()) {
785  const CWalletTx& prev = (*mi).second;
786  if (prevout.n < prev.vout.size()) {
787  if (wallet->IsMine(prev.vout[prevout.n])) {
788  CAmount decodedAmount = 0;
789  CKey blind;
790  wallet->RevealTxOutAmount(prev, prev.vout[prevout.n], decodedAmount, blind);
791  totalIn += decodedAmount;
792  }
793  }
794  }
795  }
796  }
797  CAmount firstOut = 0;
798  if (wallet && !wallet->IsLocked()) {
799  for (CTxOut out: tx.vout){
800  CAmount vamount;
801  CKey blind;
802  if (wallet->IsMine(out) && wallet->RevealTxOutAmount(tx,out,vamount, blind)) {
803  if (vamount != 0 && firstOut == 0) {
804  firstOut = vamount;
805  }
806  totalamount+=vamount; //this is the total output
807  }
808  }
809  }
810  QList<TransactionRecord> decomposedTx = TransactionRecord::decomposeTransaction(wallet, tx);
811  std::string txHash = tx.GetHash().GetHex();
812  QList<QString> addressBook = getAddressBookData(wallet);
813  std::map<QString, QString> txData;
814 
815  if (tx.hashBlock != 0) {
816  BlockMap::iterator mi = mapBlockIndex.find(tx.hashBlock);
817  if (mi != mapBlockIndex.end() && (*mi).second) {
818  CBlockIndex* pindex = (*mi).second;
819  if (chainActive.Contains(pindex))
820  txData["confirmations"] = QString::number(1 + chainActive.Height() - pindex->nHeight);
821  else
822  txData["confirmations"] = QString::number(0);
823  }
824  }
825 
826  for (TransactionRecord TxRecord : decomposedTx) {
827  txData["date"] = QString(GUIUtil::dateTimeStr(TxRecord.time));
828  // if address is in book, use data from book, else use data from transaction
829  txData["address"]="";
830 // for (QString addressBookEntry : addressBook)
831 // if (addressBookEntry.contains(TxRecord.address.c_str())) {
832 // txData["address"] = addressBookEntry;
833 // wallet->addrToTxHashMap[addressBookEntry.toStdString()] = txHash;
834 // }
835  if (!txData["address"].length()) {
836  txData["address"] = QString(TxRecord.address.c_str());
837  wallet->addrToTxHashMap[TxRecord.address] = txHash;
838  }
839 
840  txData["amount"] = BitcoinUnits::format(0, totalamount); //absolute value of total amount
841  txData["id"] = QString(TxRecord.hash.GetHex().c_str());
842  // parse transaction type
843  switch (TxRecord.type) {
844  case 1:
845  txData["type"] = QString("Mined");
846  txData["amount"] = BitcoinUnits::format(0, totalamount - totalIn); //absolute value of total amount
847  return txData;
848  break;
850  txData["type"] = QString("Payment to yourself");
851  txData["amount"] = BitcoinUnits::format(0, TxRecord.debit); //absolute value of total amount
852  return txData;
853  break;
856  txData["type"] = QString("Sent");
857  txData["amount"] = BitcoinUnits::format(0, totalIn - totalamount - tx.nTxFee); //absolute value of total amount
858  return txData;
859  break;
860  case 0:
863  txData["type"] = QString("Received");
864  break;
865  case 2:
866  txData["type"] = QString("Minted");
867  txData["amount"] = BitcoinUnits::format(0, totalamount - totalIn); //absolute value of total amount
868  break;
870  txData["type"] = QString("Masternode");
871  txData["amount"] = BitcoinUnits::format(0, TxRecord.credit); //absolute value of total amount
872  break;
873  default:
874  txData["type"] = QString("Payment");
875  //txData["type"] = QString("Unknown");
876  }
877  }
878  return txData;
879 }
880 
882 {
883  std::map<CTxDestination, CAddressBookData> mapAddressBook = wallet->mapAddressBook;
884  QList<QString> AddressBookData;
885  for (std::map<CTxDestination, CAddressBookData>::iterator address = mapAddressBook.begin(); address != mapAddressBook.end(); ++address) {
886  QString desc = address->second.name.c_str();
887  QString addressHash = CBitcoinAddress(address->first).ToString().c_str();
888  if (desc.length())
889  AddressBookData.push_front(desc + " | " + addressHash);
890  else
891  AddressBookData.push_front(addressHash);
892 
893  }
894  return AddressBookData;
895 }
896 
897 } // namespace WalletUtil
WalletModel::changePassphrase
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass)
Definition: walletmodel.cpp:425
SendCoinsRecipient::amount
CAmount amount
Definition: walletmodel.h:61
CWallet::LockCoin
void LockCoin(COutPoint &output)
Definition: wallet.cpp:5057
CTxIn
An input of a transaction.
Definition: transaction.h:83
WalletModel::updateStatus
void updateStatus()
Definition: walletmodel.cpp:129
LOCK2
#define LOCK2(cs1, cs2)
Definition: sync.h:183
fImporting
std::atomic< bool > fImporting
Definition: main.cpp:80
WalletModelTransaction::newPossibleKeyChange
void newPossibleKeyChange(CWallet *wallet)
Definition: walletmodeltransaction.cpp:57
WalletModel::getOptionsModel
OptionsModel * getOptionsModel()
Definition: walletmodel.cpp:358
WalletModel::isMine
bool isMine(CBitcoinAddress address)
Definition: walletmodel.cpp:698
WalletUtil::getTXs
std::vector< std::map< QString, QString > > getTXs(CWallet *wallet)
Definition: walletmodel.cpp:757
IsMine
isminetype IsMine(const CKeyStore &keystore, const CTxDestination &dest)
Definition: wallet_ismine.cpp:30
transactiontablemodel.h
CWallet::NotifyAddressBookChanged
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:601
WalletModel::cachedWatchOnlyBalance
CAmount cachedWatchOnlyBalance
Definition: walletmodel.h:250
WalletModel::listLockedCoins
void listLockedCoins(std::vector< COutPoint > &vOutpts)
Definition: walletmodel.cpp:668
TransactionTableModel::updateConfirmations
void updateConfirmations()
Definition: transactiontablemodel.cpp:320
minRelayTxFee
CFeeRate minRelayTxFee
Fees smaller than this (in duffs) are considered zero fee (for relaying and mining) We are ~100 times...
Definition: main.cpp:100
CWallet::fWalletUnlockStakingOnly
bool fWalletUnlockStakingOnly
Definition: wallet.h:304
ShutdownRequested
bool ShutdownRequested()
Definition: init.cpp:135
CWallet::mapWallet
std::map< uint256, CWalletTx > mapWallet
Definition: wallet.h:344
WalletModel::TransactionCommitFailed
@ TransactionCommitFailed
Definition: walletmodel.h:119
WalletModel::EncryptionStatus
EncryptionStatus
Definition: walletmodel.h:124
CWallet::addrToTxHashMap
std::map< std::string, std::string > addrToTxHashMap
Definition: wallet.h:355
WalletModel::transactionTableModel
TransactionTableModel * transactionTableModel
Definition: walletmodel.h:242
WalletModel
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:102
CWallet::GetImmatureBalance
CAmount GetImmatureBalance() const
Definition: wallet.cpp:2333
CWallet::RevealTxOutAmount
bool RevealTxOutAmount(const CTransaction &tx, const CTxOut &out, CAmount &amount, CKey &) const
Definition: wallet.cpp:7047
zxcvbn::regex_match
std::vector< Match > regex_match(const std::string &password, const std::vector< std::pair< RegexTag, std::regex >> &regexen)
Definition: matching.cpp:603
CWallet::IsMine
isminetype IsMine(const CTxIn &txin) const
Definition: wallet.cpp:1333
CCryptoKeyStore
Keystore which keeps the private keys encrypted.
Definition: crypter.h:127
base_uint::GetHex
std::string GetHex() const
Definition: arith_uint256.cpp:155
WalletModel::InsaneFee
@ InsaneFee
Definition: walletmodel.h:121
WalletModel::TransactionCreationFailed
@ TransactionCreationFailed
Definition: walletmodel.h:118
WalletModel::StakingOnlyUnlocked
@ StakingOnlyUnlocked
Definition: walletmodel.h:120
AskPassphraseDialog::Context
Context
Definition: askpassphrasedialog.h:34
sync.h
chainActive
CChain chainActive
The currently-connected chain of blocks.
Definition: main.cpp:70
TransactionRecord::RecvWithAddress
@ RecvWithAddress
Definition: transactionrecord.h:81
walletmodel.h
COutPoint::hash
uint256 hash
Definition: transaction.h:39
GetScriptForDestination
CScript GetScriptForDestination(const CTxDestination &dest)
Definition: standard.cpp:285
WalletModel::getStakingStatusError
StakingStatusError getStakingStatusError(QString &)
Definition: walletmodel.cpp:703
CBitcoinAddress
base58-encoded PRCY addresses.
Definition: base58.h:109
AddressTableModel
Qt model of the address book in the core.
Definition: addresstablemodel.h:19
WalletModel::backupWallet
bool backupWallet(const QString &filename)
Definition: walletmodel.cpp:436
WalletModel::getAddressTableModel
AddressTableModel * getAddressTableModel()
Definition: walletmodel.cpp:363
WalletModel::DuplicateAddress
@ DuplicateAddress
Definition: walletmodel.h:117
CCoinControl
Coin Control Features.
Definition: coincontrol.h:15
CWallet::Unlock
bool Unlock(const SecureString &strWalletPassphrase, bool anonimizeOnly=false)
Definition: wallet.cpp:552
CBlockIndex::nHeight
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:181
WalletModel::sendCoins
SendCoinsReturn sendCoins(WalletModelTransaction &transaction)
Definition: walletmodel.cpp:344
CReserveKey
A key allocated from the key pool.
Definition: wallet.h:679
WalletModel::AmountWithFeeExceedsBalance
@ AmountWithFeeExceedsBalance
Definition: walletmodel.h:116
WalletModel::Unlocked
@ Unlocked
Definition: walletmodel.h:127
wallet.h
CWallet::GetSpendableBalance
CAmount GetSpendableBalance()
Definition: wallet.cpp:2260
WalletModel::cachedWatchUnconfBalance
CAmount cachedWatchUnconfBalance
Definition: walletmodel.h:251
WalletModel::spendableBalance
CAmount spendableBalance
Definition: walletmodel.h:248
WalletModel::isShutdownRequested
bool isShutdownRequested()
Definition: walletmodel.cpp:62
IsImportingOrReindexing
bool IsImportingOrReindexing()
Definition: walletmodel.cpp:137
WalletModel::requireUnlock
void requireUnlock(AskPassphraseDialog::Context context)
CWallet::NotifyWatchonlyChanged
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
Definition: wallet.h:613
WalletModel::checkBalanceChanged
bool checkBalanceChanged()
Definition: walletmodel.cpp:193
WalletModel::cachedBalance
CAmount cachedBalance
Definition: walletmodel.h:246
CWallet::IsSpent
bool IsSpent(const uint256 &hash, unsigned int n)
Outpoint is spent if any non-conflicted transaction spends it:
Definition: wallet.cpp:860
CWallet::CreateTransaction
bool CreateTransaction(CScript scriptPubKey, int64_t nValue, CWalletTx &wtxNew, CReserveKey &reservekey, int64_t &nFeeRet, std::string &strFailReason, const CCoinControl *coinControl)
WalletModel::getTransactionTableModel
TransactionTableModel * getTransactionTableModel()
Definition: walletmodel.cpp:368
WalletModel::~WalletModel
~WalletModel()
Definition: walletmodel.cpp:67
TRY_LOCK
#define TRY_LOCK(cs, name)
Definition: sync.h:186
CKeyID
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:29
WalletModelTransaction::getTransactionSize
unsigned int getTransactionSize()
Definition: walletmodeltransaction.cpp:33
TransactionRecord::MNReward
@ MNReward
Definition: transactionrecord.h:82
WalletModel::getPubKey
bool getPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const
Definition: walletmodel.cpp:586
guiinterface.h
CBase58Data::ToString
std::string ToString() const
Definition: base58.cpp:200
WalletModel::cachedUnconfirmedBalance
CAmount cachedUnconfirmedBalance
Definition: walletmodel.h:247
nCompleteTXLocks
int nCompleteTXLocks
Definition: swifttx.cpp:30
db.h
WalletModel::cachedImmatureBalance
CAmount cachedImmatureBalance
Definition: walletmodel.h:249
CWallet::UnlockCoin
void UnlockCoin(COutPoint &output)
Definition: wallet.cpp:5063
TransactionRecord::RecvFromOther
@ RecvFromOther
Definition: transactionrecord.h:83
WalletModel::txTableModel
QAbstractTableModel * txTableModel
Definition: walletmodel.h:243
TransactionRecord
UI model for a transaction.
Definition: transactionrecord.h:72
CWallet::AddDestData
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:5226
WalletUtil::getTx
std::map< QString, QString > getTx(CWallet *wallet, CWalletTx tx)
Definition: walletmodel.cpp:774
CWallet::NotifyWalletBacked
boost::signals2::signal< void(const bool &fSuccess, const std::string &filename)> NotifyWalletBacked
notify wallet file backed up
Definition: wallet.h:616
WalletModel::cachedNumBlocks
int cachedNumBlocks
Definition: walletmodel.h:254
WalletModel::addressTableModel
AddressTableModel * addressTableModel
Definition: walletmodel.h:241
CCryptoKeyStore::NotifyStatusChanged
boost::signals2::signal< void(CCryptoKeyStore *wallet)> NotifyStatusChanged
Wallet status (encrypted, locked) changed.
Definition: crypter.h:203
cs_main
RecursiveMutex cs_main
Global state.
Definition: main.cpp:65
WalletModel::cachedWatchImmatureBalance
CAmount cachedWatchImmatureBalance
Definition: walletmodel.h:252
SendCoinsRecipient
Definition: walletmodel.h:46
OptionsModel
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:18
CWallet::GetUnconfirmedWatchOnlyBalance
CAmount GetUnconfirmedWatchOnlyBalance() const
Definition: wallet.cpp:2361
StakingStatusError
StakingStatusError
Definition: wallet.h:223
WalletModel::emitBalanceChanged
void emitBalanceChanged()
Definition: walletmodel.cpp:183
WalletModel::getLockedBalance
CAmount getLockedBalance() const
Definition: walletmodel.cpp:104
WalletModel::AmountExceedsBalance
@ AmountExceedsBalance
Definition: walletmodel.h:115
WalletModel::lockCoin
void lockCoin(COutPoint &output)
Definition: walletmodel.cpp:656
WalletModel::unsubscribeFromCoreSignals
void unsubscribeFromCoreSignals()
Definition: walletmodel.cpp:534
WalletModel::validateAddress
bool validateAddress(const QString &address)
Definition: walletmodel.cpp:262
WalletModel::updateWatchOnlyFlag
void updateWatchOnlyFlag(bool fHaveWatchonly)
Definition: walletmodel.cpp:256
CTxOut
An output of a transaction.
Definition: transaction.h:164
_
std::string _(const char *psz)
Translation function: Call Translate signal on UI interface, which returns a boost::optional result.
Definition: guiinterface.h:119
WalletModel::saveReceiveRequest
bool saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest)
Definition: walletmodel.cpp:683
TransactionRecord::SendToOther
@ SendToOther
Definition: transactionrecord.h:80
init.h
CTransaction::vout
std::vector< CTxOut > vout
Definition: transaction.h:286
WalletModel::message
void message(const QString &title, const QString &message, unsigned int style)
WalletModelTransaction::setTransactionFee
void setTransactionFee(const CAmount &newFee)
Definition: walletmodeltransaction.cpp:43
CWallet::IsLockedCoin
bool IsLockedCoin(uint256 hash, unsigned int n) const
Definition: wallet.cpp:5075
WalletModel::lockForStakingOnly
bool lockForStakingOnly(const SecureString &passPhrase=SecureString())
Definition: walletmodel.cpp:409
WalletModel::getCWallet
CWallet * getCWallet()
Definition: walletmodel.cpp:574
CChainParams::MinimumStakeAmount
CAmount MinimumStakeAmount() const
Definition: chainparams.h:87
WalletUtil::getAddressBookData
QList< QString > getAddressBookData(CWallet *wallet)
Definition: walletmodel.cpp:881
CAddressBookData
Address book data.
Definition: wallet.h:148
STAKING_OK
@ STAKING_OK
Definition: wallet.h:225
CWallet::IsChange
bool IsChange(const CTxOut &txout) const
Definition: wallet.cpp:1419
miner.h
CWallet::GetLockedCoins
CAmount GetLockedCoins() const
Definition: wallet.cpp:2300
SecureString
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: allocators.h:262
CWallet::GetWalletTx
const CWalletTx * GetWalletTx(const uint256 &hash) const
Definition: wallet.cpp:167
WalletModel::isLockedCoin
bool isLockedCoin(uint256 hash, unsigned int n) const
Definition: walletmodel.cpp:650
WalletModel::generateCoins
void generateCoins(bool fGenerate, int nGenProcLimit)
Definition: walletmodel.cpp:732
WalletModel::getEncryptionStatus
EncryptionStatus getEncryptionStatus() const
Definition: walletmodel.cpp:373
PAIRTYPE
#define PAIRTYPE(t1, t2)
This is needed because the foreach macro can't get over the comma in pair<t1, t2>
Definition: utilstrencodings.h:24
CWallet::ShowProgress
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
Definition: wallet.h:610
WalletModel::getWatchImmatureBalance
CAmount getWatchImmatureBalance() const
Definition: walletmodel.cpp:124
WalletModel::Unencrypted
@ Unencrypted
Definition: walletmodel.h:125
CAmount
int64_t CAmount
Amount in PRCY (Can be negative)
Definition: amount.h:17
CTransaction::nTxFee
CAmount nTxFee
Definition: transaction.h:298
WalletModel::loadReceiveRequests
void loadReceiveRequests(std::vector< std::string > &vReceiveRequests)
Definition: walletmodel.cpp:674
guiutil.h
ISMINE_SPENDABLE
@ ISMINE_SPENDABLE
Definition: wallet_ismine.h:20
keystore.h
WalletModel::cachedTxLocks
int cachedTxLocks
Definition: walletmodel.h:255
CWallet::GetBalance
CAmount GetBalance()
Definition: wallet.cpp:2243
WalletModel::getSpendableBalance
CAmount getSpendableBalance() const
Definition: walletmodel.cpp:94
uint256
256-bit unsigned big integer.
Definition: uint256.h:38
CWallet::GetUnconfirmedBalance
CAmount GetUnconfirmedBalance() const
Definition: wallet.cpp:2319
WalletModel::getSeedPhrase
bool getSeedPhrase(std::string &phrase) const
Definition: walletmodel.cpp:591
WalletModel::Locked
@ Locked
Definition: walletmodel.h:126
WalletUtil
Definition: walletmodel.cpp:750
TransactionRecord::SendToSelf
@ SendToSelf
Definition: transactionrecord.h:84
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:363
ExtractDestination
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Definition: standard.cpp:199
CWallet::SendToStealthAddress
bool SendToStealthAddress(const std::string &stealthAddr, CAmount nValue, CWalletTx &wtxNew, bool fUseIX=false, int ringSize=5)
Definition: wallet.cpp:6640
CWallet::GetWatchOnlyBalance
CAmount GetWatchOnlyBalance() const
Definition: wallet.cpp:2346
CWallet::GetImmatureWatchOnlyBalance
CAmount GetImmatureWatchOnlyBalance() const
Definition: wallet.cpp:2375
WalletModel::isSpent
bool isSpent(const COutPoint &outpoint) const
Definition: walletmodel.cpp:609
WalletModelTransaction::getTransaction
CWalletTx * getTransaction()
Definition: walletmodeltransaction.cpp:28
CTxDestination
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:81
CChain::Height
int Height() const
Return the maximal height in the chain.
Definition: chain.h:641
BitcoinUnits::format
static QString format(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string.
Definition: bitcoinunits.cpp:140
CWallet::Lock
bool Lock()
Lock Wallet.
Definition: wallet.cpp:582
CWallet::EncryptWallet
bool EncryptWallet(const SecureString &strWalletPassphrase)
Definition: wallet.cpp:1049
ChangeType
ChangeType
General change type (added, updated, removed).
Definition: guiinterface.h:21
nLastCoinStakeSearchInterval
int64_t nLastCoinStakeSearchInterval
Definition: miner.cpp:67
transactionrecord.h
COutput::tx
const CWalletTx * tx
Definition: wallet.h:925
CClientUIInterface::MSG_ERROR
@ MSG_ERROR
Definition: guiinterface.h:76
TransactionTableModel
UI model for the transaction table of a wallet.
Definition: transactiontablemodel.h:21
CPubKey
An encapsulated public key.
Definition: pubkey.h:37
WalletModel::OK
@ OK
Definition: walletmodel.h:112
CWallet::AvailableCoins
bool AvailableCoins(std::vector< COutput > &vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl=NULL, bool fIncludeZeroValue=false, AvailableCoinsType nCoinType=ALL_COINS, bool fUseIX=false)
populate vCoins with vector of available COutputs.
Definition: wallet.cpp:2490
WalletModel::listCoins
void listCoins(std::map< QString, std::vector< COutput > > &mapCoins) const
Definition: walletmodel.cpp:616
WalletModel::setWalletEncrypted
bool setWalletEncrypted(bool encrypted, const SecureString &passphrase)
Definition: walletmodel.cpp:386
guiconstants.h
WalletModel::unlockCoin
void unlockCoin(COutPoint &output)
Definition: walletmodel.cpp:662
WalletModel::optionsModel
OptionsModel * optionsModel
Definition: walletmodel.h:239
WalletModel::updateTransaction
void updateTransaction()
Definition: walletmodel.cpp:238
WalletModel::getOutputs
void getOutputs(const std::vector< COutPoint > &vOutpoints, std::vector< COutput > &vOutputs)
Definition: walletmodel.cpp:597
TransactionRecord::decomposeTransaction
static QList< TransactionRecord > decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx)
Decompose CWallet transaction to model transaction records.
Definition: transactionrecord.cpp:20
CKey
An encapsulated private key.
Definition: key.h:39
WalletModel::UnlockContext
Definition: walletmodel.h:189
WalletModel::getMinStakingAmount
CAmount getMinStakingAmount() const
Definition: walletmodel.cpp:72
WalletModel::InvalidAmount
@ InvalidAmount
Definition: walletmodel.h:113
CAddressBookData::destdata
StringMap destdata
Definition: wallet.h:160
fReindex
std::atomic< bool > fReindex
Definition: main.cpp:81
main.h
COutPoint::n
uint32_t n
Definition: transaction.h:40
CTransaction::vin
std::vector< CTxIn > vin
Definition: transaction.h:285
LOCK
#define LOCK(cs)
Definition: sync.h:182
SendCoinsRecipient::address
QString address
Definition: walletmodel.h:57
key
CKey key
Definition: bip38tooldialog.cpp:173
CWallet
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
Definition: wallet.h:243
WalletModel::InvalidAddress
@ InvalidAddress
Definition: walletmodel.h:114
WalletModel::fForceCheckBalanceChanged
bool fForceCheckBalanceChanged
Definition: walletmodel.h:235
WalletModel::fHaveWatchOnly
bool fHaveWatchOnly
Definition: walletmodel.h:234
CWalletTx
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:792
CWallet::NotifyTransactionChanged
boost::signals2::signal< void(CWallet *wallet, const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
Definition: wallet.h:607
WalletModel::prepareTransaction
SendCoinsReturn prepareTransaction(WalletModelTransaction &transaction, const CCoinControl *coinControl=NULL)
Definition: walletmodel.cpp:269
CWallet::GetPubKey
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const
GetPubKey implementation that also checks the mapHdPubKeys.
Definition: wallet.cpp:6894
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:463
WalletModel::SendCoinsReturn
Definition: walletmodel.h:162
TransactionRecord::SendToAddress
@ SendToAddress
Definition: transactionrecord.h:79
CChain::Contains
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
Definition: chain.h:626
CWallet::GetSeedPhrase
bool GetSeedPhrase(std::string &phrase)
Definition: wallet.cpp:351
WalletModel::updateAddressBook
void updateAddressBook(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
Definition: walletmodel.cpp:244
bitcoinunits.h
WalletModel::setWalletLocked
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString(), bool stakingOnly=false)
Definition: walletmodel.cpp:397
CWallet::cs_wallet
RecursiveMutex cs_wallet
Definition: wallet.h:301
WalletModel::getWatchBalance
CAmount getWatchBalance() const
Definition: walletmodel.cpp:114
CWallet::findMyOutPoint
COutPoint findMyOutPoint(const CTxIn &txin) const
Definition: wallet.cpp:1348
base58.h
GUIUtil::dateTimeStr
QString dateTimeStr(const QDateTime &date)
Definition: guiutil.cpp:70
WalletModel::subscribeToCoreSignals
void subscribeToCoreSignals()
Definition: walletmodel.cpp:523
CTransaction::GetHash
const uint256 & GetHash() const
Definition: transaction.h:342
BackupWallet
bool BackupWallet(const CWallet &wallet, const fs::path &strDest, bool fEnableCustom)
Definition: walletdb.cpp:1045
CMerkleTx::hashBlock
uint256 hashBlock
Definition: wallet.h:737
COutput::i
int i
Definition: wallet.h:926
WalletModel::UnlockedForStakingOnly
@ UnlockedForStakingOnly
Definition: walletmodel.h:128
walletdb.h
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:36
WalletModel::getWatchUnconfirmedBalance
CAmount getWatchUnconfirmedBalance() const
Definition: walletmodel.cpp:119
WalletModel::haveWatchOnly
bool haveWatchOnly() const
Definition: walletmodel.cpp:109
WalletModel::WalletUnlocked
void WalletUnlocked()
CWallet::EraseDestData
bool EraseDestData(const CTxDestination &dest, const std::string &key)
Erases a destination data tuple in the store and on disk.
Definition: wallet.cpp:5237
WalletModel::isStakingOnlyUnlocked
bool isStakingOnlyUnlocked()
Definition: walletmodel.cpp:420
WalletModel::UnlockContext::UnlockContext
UnlockContext(bool valid, bool relock)
Definition: walletmodel.cpp:566
AddressTableModel::updateEntry
void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
Definition: addresstablemodel.cpp:314
CWallet::ChangeWalletPassphrase
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
Definition: wallet.cpp:656
CFeeRate::GetFee
CAmount GetFee(size_t size) const
Definition: amount.cpp:20
WalletModel::balanceChanged
void balanceChanged(const CAmount &balance, const CAmount &unconfirmedBalance, const CAmount &immatureBalance, const CAmount &watchOnlyBalance, const CAmount &watchUnconfBalance, const CAmount &watchImmatureBalance)
CBitcoinAddress::IsValid
bool IsValid() const
Definition: base58.cpp:254
WalletModelTransaction::getRecipients
QList< SendCoinsRecipient > getRecipients()
Definition: walletmodeltransaction.cpp:23
WalletModel::pollTimer
QTimer * pollTimer
Definition: walletmodel.h:256
WalletModel::UnlockContext::CopyFrom
void CopyFrom(const UnlockContext &rhs)
Definition: walletmodel.cpp:579
WalletModel::getTxTableModel
QAbstractTableModel * getTxTableModel()
Definition: walletmodel.cpp:742
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:162
CBasicKeyStore::HaveWatchOnly
virtual bool HaveWatchOnly(const CScript &dest) const
Definition: keystore.cpp:75
WalletModel::getUnconfirmedBalance
CAmount getUnconfirmedBalance() const
Definition: walletmodel.cpp:89
CBitcoinAddress::Get
CTxDestination Get() const
Definition: base58.cpp:267
CWallet::ListLockedCoins
void ListLockedCoins(std::vector< COutPoint > &vOutpts)
Definition: wallet.cpp:5083
WalletModel::pollBalanceChanged
void pollBalanceChanged()
Definition: walletmodel.cpp:141
COutput
Definition: wallet.h:922
WalletModel::getImmatureBalance
CAmount getImmatureBalance() const
Definition: walletmodel.cpp:99
CClientUIInterface::MessageBoxFlags
MessageBoxFlags
Flags for CClientUIInterface::ThreadSafeMessageBox.
Definition: guiinterface.h:32
WalletModel::requestUnlock
UnlockContext requestUnlock(AskPassphraseDialog::Context context, bool relock=false)
Definition: walletmodel.cpp:546
WalletModel::WalletModel
WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent=0)
Definition: walletmodel.cpp:39
addresstablemodel.h
WalletModelTransaction
Data model for a walletmodel transaction.
Definition: walletmodeltransaction.h:22
WalletModel::notifyWatchonlyChanged
void notifyWatchonlyChanged(bool fHaveWatchonly)
WalletModel::cachedEncryptionStatus
EncryptionStatus cachedEncryptionStatus
Definition: walletmodel.h:253
WalletModel::wallet
CWallet * wallet
Definition: walletmodel.h:233
CWallet::mapAddressBook
std::map< CTxDestination, CAddressBookData > mapAddressBook
Definition: wallet.h:354
WalletModel::getBalance
CAmount getBalance(const CCoinControl *coinControl=NULL) const
Definition: walletmodel.cpp:77
CCryptoKeyStore::IsLocked
bool IsLocked() const
Definition: crypter.h:159
error
bool error(const char *fmt, const Args &... args)
Definition: util.h:61
mapBlockIndex
BlockMap mapBlockIndex
Definition: main.cpp:67
WalletModelTransaction::getPossibleKeyChange
CReserveKey * getPossibleKeyChange()
Definition: walletmodeltransaction.cpp:62
WalletModel::UnlockContext::~UnlockContext
~UnlockContext()
Definition: walletmodel.cpp:570
CWallet::walletUnlockCountStatus
int walletUnlockCountStatus
Definition: wallet.h:319
WalletModel::encryptionStatusChanged
void encryptionStatusChanged(int status)
WalletModel::UnlockContext::relock
bool relock
Definition: walletmodel.h:207