PIVX Core  5.6.99
P2P Digital Currency
walletmodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2014 The Bitcoin developers
2 // Copyright (c) 2014-2016 The Dash developers
3 // Copyright (c) 2017-2021 The PIVX Core developers
4 // Distributed under the MIT/X11 software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #ifndef PIVX_QT_WALLETMODEL_H
8 #define PIVX_QT_WALLETMODEL_H
9 
10 #if defined(HAVE_CONFIG_H)
11 #include "config/pivx-config.h"
12 #endif
13 
14 #include "interfaces/wallet.h"
15 
16 #include "key.h"
17 #include "operationresult.h"
19 
20 #include <map>
21 #include <vector>
22 
23 #include <QObject>
24 #include <QFuture>
25 #include <QSettings>
26 
27 class AddressTableModel;
28 class CBudgetProposal;
29 class ClientModel;
30 class OptionsModel;
33 
34 class CCoinControl;
35 class CKeyID;
36 class COutPoint;
37 class OutPointWrapper;
38 class COutput;
39 class CPubKey;
40 class CWallet;
41 class uint256;
42 
43 namespace interfaces {
44  class Handler;
45 };
46 
47 QT_BEGIN_NAMESPACE
48 class QTimer;
49 QT_END_NAMESPACE
50 
52 {
53 public:
55  explicit SendCoinsRecipient(const QString& addr, const QString& label, const CAmount& amount, const QString& message) : address(addr), label(label), amount(amount), message(message), nVersion(SendCoinsRecipient::CURRENT_VERSION) {}
56 
57  // If from an insecure payment request, this is used for storing
58  // the addresses, e.g. address-A<br />address-B<br />address-C.
59  // Info: As we don't need to process addresses in here when using
60  // payment requests, we can abuse it for displaying an address list.
61  // Todo: This is a hack, should be replaced with a cleaner solution!
62  QString address{};
63  QString label{};
64 
65  // Cold staking.
66  bool isP2CS{false};
67  QString ownerAddress{};
68 
69  // Quick flag to not have to check the address type more than once.
70  bool isShieldedAddr{false};
71 
72  // Whether to subtract the tx fee from this recipient
73  bool fSubtractFee{false};
74 
75  // Amount
77  // If from a payment request, this is used for storing the memo
78  QString message{};
79 
80  // serialized string to ensure load/store is lossless
81  std::string sPaymentRequest{};
82 
83  // Empty if no authentication or invalid signature/cert/etc.
85 
86  static const int CURRENT_VERSION = 1;
87  int nVersion;
88 
90  {
91  std::string address_str, label_str, message_str, auth_merchant_str;
92 
93  SER_WRITE(obj, address_str = obj.address.toStdString());
94  SER_WRITE(obj, label_str = obj.label.toStdString());
95  SER_WRITE(obj, message_str = obj.message.toStdString());
96  SER_WRITE(obj, auth_merchant_str = obj.authenticatedMerchant.toStdString());
97 
98  READWRITE(obj.nVersion, address_str, label_str, obj.amount, message_str, obj.sPaymentRequest, auth_merchant_str);
99 
100  SER_READ(obj, obj.address = QString::fromStdString(address_str));
101  SER_READ(obj, obj.label = QString::fromStdString(label_str));
102  SER_READ(obj, obj.message = QString::fromStdString(message_str));
103  SER_READ(obj, obj.authenticatedMerchant = QString::fromStdString(auth_merchant_str));
104  }
105 };
106 
108 class WalletModel : public QObject
109 {
110  Q_OBJECT
111 
112 public:
113  explicit WalletModel(CWallet* wallet, OptionsModel* optionsModel, QObject* parent = 0);
114  ~WalletModel();
115  void init();
116 
117  enum StatusCode // Returned by sendCoins
118  {
119  OK,
131  };
132 
134  Unencrypted, // !wallet->IsCrypted()
135  Locked, // wallet->IsCrypted() && wallet->IsLocked()
136  Unlocked, // wallet->IsCrypted() && !wallet->IsLocked()
137  UnlockedForStaking // wallet->IsCrypted() && !wallet->IsLocked() && wallet->fWalletUnlockStaking
138  };
139 
143 
144  void resetWalletOptions(QSettings& settings);
145  bool isTestNetwork() const;
146  bool isRegTestNetwork() const;
147  bool isShutdownRequested();
149  bool isColdStakingNetworkelyEnabled() const;
150  bool isSaplingInMaintenance() const;
151  bool isV6Enforced() const;
153  /* current staking status from the miner thread **/
154  bool isStakingStatusActive() const;
155 
156  bool hasWallet() { return wallet; };
157 
158  bool isHDEnabled() const;
159  bool isSaplingWalletEnabled() const;
160  bool upgradeWallet(std::string& upgradeError);
161 
162  // Returns the path to the first wallet db (future: add multi-wallet support)
163  QString getWalletPath();
164 
166 
167  CAmount getBalance(const CCoinControl* coinControl = nullptr, bool fIncludeDelegated = true, bool fUnlockedOnly = false, bool fIncludeShielded = true) const;
168  CAmount getUnlockedBalance(const CCoinControl* coinControl = nullptr, bool fIncludeDelegated = true, bool fIncludeShielded = true) const;
169  CAmount getLockedBalance(bool isTransparent) const;
170  bool haveWatchOnly() const;
172 
173  bool isColdStaking() const;
174  void getAvailableP2CSCoins(std::vector<COutput>& vCoins) const;
175 
177  bool isWalletUnlocked() const;
178  bool isWalletLocked(bool fFullUnlocked = true) const;
179  void emitBalanceChanged(); // Force update of UI-elements even when no values have changed
180 
181  // Check address for validity
182  bool validateAddress(const QString& address);
183  // Check address for validity and type (whether cold staking address or not)
184  bool validateAddress(const QString& address, bool fStaking);
185  // Check address for validity and type (whether cold staking address or not),
186  // plus return isShielded = true if the parsed address is a valid shielded address.
187  bool validateAddress(const QString& address, bool fStaking, bool& isShielded);
188 
189  // Return the address from where the shielded spend is taking the funds from (if possible)
191 
192  // Return status record for SendCoins, contains error id + information
195  explicit SendCoinsReturn(CWallet::CommitResult _commitRes) : commitRes(_commitRes)
196  {
198  }
201  };
202 
203  void setWalletDefaultFee(CAmount fee = DEFAULT_TRANSACTION_FEE);
204  bool hasWalletCustomFee();
205  bool getWalletCustomFee(CAmount& nFeeRet);
206  void setWalletCustomFee(bool fUseCustomFee, const CAmount nFee = DEFAULT_TRANSACTION_FEE);
208 
209  void setWalletStakeSplitThreshold(const CAmount nStakeSplitThreshold);
211  /* Minimum stake split threshold*/
212  double getSSTMinimum() const;
213 
214  const CWalletTx* getTx(uint256 id);
215 
216  // prepare transaction for getting txfee before sending coins
217  SendCoinsReturn prepareTransaction(WalletModelTransaction* transaction, const CCoinControl* coinControl = nullptr, bool fIncludeDelegations = true);
218 
219  // Send coins to a list of recipients
221 
222  // Prepare shielded transaction.
224  bool fromTransparent,
225  const CCoinControl* coinControl = nullptr);
226 
228 
229  // Wallet encryption
230  bool setWalletEncrypted(bool encrypted, const SecureString& passphrase);
231  // Passphrase only needed when unlocking
232  bool setWalletLocked(bool locked, const SecureString& passPhrase = SecureString(), bool stakingOnly = false);
233 
234  // Method used to "lock" the wallet only for staking purposes. Just a flag that should prevent possible movements in the wallet.
235  // Passphrase only needed when unlocking.
236  bool lockForStakingOnly(const SecureString& passPhrase = SecureString());
237 
238  bool changePassphrase(const SecureString& oldPass, const SecureString& newPass);
239  // Is wallet unlocked for staking only?
240  bool isStakingOnlyUnlocked();
241  // Wallet backup
242  bool backupWallet(const QString& filename);
243 
244  // RAI object for unlocking wallet, returned by requestUnlock()
246  {
247  public:
249  ~UnlockContext();
250 
251  bool isValid() const { return valid; }
252 
253  // Copy constructor is disabled
254  UnlockContext(const UnlockContext&) = delete;
255  // Copy operator and constructor transfer the context
256  UnlockContext(UnlockContext&& obj) { CopyFrom(std::move(obj)); }
257  UnlockContext& operator=(UnlockContext&& rhs) { CopyFrom(std::move(rhs)); return *this; }
258 
259  private:
261  bool valid;
263  mutable bool relock; // mutable, as it can be set to false by copying
264 
266  void CopyFrom(UnlockContext&& rhs);
267  };
268 
270 
271  bool getPubKey(const CKeyID& address, CPubKey& vchPubKeyOut) const;
272  int64_t getCreationTime() const;
273  int64_t getKeyCreationTime(const CPubKey& key);
274  int64_t getKeyCreationTime(const CTxDestination& address);
275  int64_t getKeyCreationTime(const std::string& address);
276  int64_t getKeyCreationTime(const libzcash::SaplingPaymentAddress& address);
277  CallResult<Destination> getNewAddress(const std::string& label = "") const;
281  CallResult<Destination> getNewStakingAddress(const std::string& label = "") const;
282 
284  CallResult<Destination> getNewShieldedAddress(std::string strLabel = "");
285 
288 
289  bool whitelistAddressFromColdStaking(const QString &addressStr);
290  bool blacklistAddressFromColdStaking(const QString &address);
291  bool updateAddressBookPurpose(const QString &addressStr, const std::string& purpose);
292  std::string getLabelForAddress(const CTxDestination& address);
293  QString getSaplingAddressString(const CWalletTx* wtx, const SaplingOutPoint& op) const;
294  bool getKeyId(const CTxDestination& address, CKeyID& keyID);
295  bool getKey(const CKeyID& keyID, CKey& key) const { return wallet->GetKey(keyID, key); }
296  bool haveKey(const CKeyID& keyID) const { return wallet->HaveKey(keyID); }
297  bool addKeys(const CKey& key, const CPubKey& pubkey, WalletRescanReserver& reserver);
298 
299  bool isMine(const CWDestination& address);
300  bool isMine(const QString& addressStr);
301  bool IsShieldedDestination(const CWDestination& address);
302  bool isUsed(CTxDestination address);
303  bool getMNCollateralCandidate(COutPoint& outPoint);
304  // Depth of a wallet transaction or -1 if not found
305  int getWalletTxDepth(const uint256& txHash) const;
306  bool isSpent(const COutPoint& outpoint) const;
307 
308  class ListCoinsKey {
309  public:
310  QString address;
311  bool isChange;
312  Optional<QString> stakerAddress; // used only for P2CS utxo
313 
314  bool operator==(const ListCoinsKey& key2) const {
315  return address == key2.address && stakerAddress == key2.stakerAddress;
316  }
317 
318  bool operator<(const ListCoinsKey& key2) const {
319  return this->address < key2.address ||
320  (this->address == key2.address && this->stakerAddress < key2.stakerAddress);
321  }
322  };
323 
325  public:
326  ListCoinsValue() = delete;
327  ListCoinsValue(const uint256& _txhash, int _outIndex, CAmount _nValue, int64_t _nTime, int _nDepth) :
328  txhash(_txhash), outIndex(_outIndex), nValue(_nValue), nTime(_nTime), nDepth(_nDepth)
329  {}
330 
332  int outIndex;
334  int64_t nTime;
335  int nDepth;
336  };
337 
338  void listCoins(std::map<ListCoinsKey, std::vector<ListCoinsValue>>& mapCoins, bool fSelectTransparent) const;
339  void listCoins(std::map<ListCoinsKey, std::vector<ListCoinsValue>>& mapCoins) const;
340  void listAvailableNotes(std::map<ListCoinsKey, std::vector<ListCoinsValue>>& mapCoins) const;
341 
342  bool isLockedCoin(uint256 hash, unsigned int n, bool isTransparent = true) const;
343  void lockCoin(uint256 hash, unsigned int n, bool isTransparent = true);
344  void unlockCoin(uint256 hash, unsigned int n, bool isTransparent = true);
345 
346  std::set<COutPoint> listLockedCoins();
347  std::set<SaplingOutPoint> listLockedNotes();
348 
349  void loadReceiveRequests(std::vector<std::string>& vReceiveRequests);
350  bool saveReceiveRequest(const std::string& sAddress, const int64_t nId, const std::string& sRequest);
351 
352  ClientModel& clientModel() const { return *m_client_model; }
353  void setClientModel(ClientModel* client_model);
354 
356  int getLastBlockProcessedNum() const;
357 
359  void setCacheNumBlocks(int _cachedNumBlocks) { cachedNumBlocks = _cachedNumBlocks; }
361  void setCacheBlockHash(const uint256& _blockHash) { m_cached_best_block_hash = _blockHash; }
362  void setfForceCheckBalanceChanged(bool _fForceCheckBalanceChanged) { fForceCheckBalanceChanged = _fForceCheckBalanceChanged; }
363  Q_INVOKABLE void checkBalanceChanged(const interfaces::WalletBalances& new_balances);
365 
366  void stop();
367 
368 private:
369  CWallet* wallet{nullptr};
370  // Simple Wallet interface.
371  // todo: Goal would be to move every CWallet* call to the wallet wrapper and
372  // in the model only perform the data organization (and QT wrappers) to be presented on the UI.
374 
375  // Listeners
376  std::unique_ptr<interfaces::Handler> m_handler_notify_status_changed;
377  std::unique_ptr<interfaces::Handler> m_handler_notify_addressbook_changed;
378  std::unique_ptr<interfaces::Handler> m_handler_notify_sst_changed;
379  std::unique_ptr<interfaces::Handler> m_handler_notify_transaction_changed;
380  std::unique_ptr<interfaces::Handler> m_handler_show_progress;
381  std::unique_ptr<interfaces::Handler> m_handler_notify_watch_only_changed;
382  std::unique_ptr<interfaces::Handler> m_handler_notify_walletbacked;
384 
387 
388  // Wallet has an options model for wallet-specific options
389  // (transaction fee, for example)
391 
394 
395  // Cache balance to be able to detect changes
397 
401 
402  QTimer* pollTimer;
403  QFuture<void> pollFuture;
404 
406 
407  void subscribeToCoreSignals();
409 
410 Q_SIGNALS:
411  // Signal that balance in wallet changed
412  void balanceChanged(const interfaces::WalletBalances& walletBalances);
413 
414  // Encryption status of wallet changed
415  void encryptionStatusChanged(int status);
416 
417  // Signal emitted when wallet needs to be unlocked
418  // It is valid behaviour for listeners to keep the wallet locked after this signal;
419  // this means that the unlocking failed or was cancelled.
421 
422  // Fired when a message should be reported to the user
423  void message(const QString& title, const QString& body, unsigned int style, bool* ret = nullptr);
424 
425  // Coins sent: from wallet, to recipient, in (serialized) transaction:
426  void coinsSent(CWallet* wallet, const SendCoinsRecipient& recipient, const QByteArray& transaction);
427 
428  // Show progress dialog e.g. for rescan
429  void showProgress(const QString& title, int nProgress);
430 
431  // Watch-only address added
432  void notifyWatchonlyChanged(bool fHaveWatchonly);
433 
434  // Receive tab address may have changed
436 
438  void notifySSTChanged(const double sstVal);
439 
440 public Q_SLOTS:
441  /* Wallet balances changes */
442  void balanceNotify();
443  /* Update transaction model after wallet changes */
444  void updateTxModelData();
445  /* Balance polling process finished */
446  void pollFinished();
447  /* Wallet status might have changed */
448  void updateStatus();
449  /* New transaction, or transaction changed status */
450  void updateTransaction();
451  /* New, updated or removed address book entry */
452  void updateAddressBook(const QString& address, const QString& label, bool isMine, const QString& purpose, int status);
453  /* Watch-only added */
454  void updateWatchOnlyFlag(bool fHaveWatchonly);
455  /* Current, immature or unconfirmed balance might have changed - emit 'balanceChanged' if so */
456  void pollBalanceChanged();
457  /* Update address book labels in the database */
458  bool updateAddressBookLabels(const CWDestination& address, const std::string& strName, const std::string& strPurpose);
459 };
460 
461 #endif // PIVX_QT_WALLETMODEL_H
int64_t CAmount
Amount in PIV (Can be negative)
Definition: amount.h:13
Qt model of the address book in the core.
Coin Control Features.
Definition: coincontrol.h:34
bool GetKey(const CKeyID &address, CKey &keyOut) const override
Definition: crypter.cpp:199
bool HaveKey(const CKeyID &address) const override
Check whether a key corresponding to a given address is present in the store.
Definition: crypter.cpp:179
An encapsulated private key.
Definition: key.h:30
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:21
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:72
An encapsulated public key.
Definition: pubkey.h:44
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
Definition: wallet.h:577
A transaction with a bunch of additional info that only the owner cares about.
Definition: wallet.h:325
Model for PIVX network client.
Definition: clientmodel.h:50
Interface from Qt to configuration data structure for PIVX client.
Definition: optionsmodel.h:22
An outpoint - a combination of a transaction hash and an index n into its sapling output description ...
Definition: transaction.h:82
QString ownerAddress
Definition: walletmodel.h:67
static const int CURRENT_VERSION
Definition: walletmodel.h:86
SendCoinsRecipient(const QString &addr, const QString &label, const CAmount &amount, const QString &message)
Definition: walletmodel.h:55
SERIALIZE_METHODS(SendCoinsRecipient, obj)
Definition: walletmodel.h:89
std::string sPaymentRequest
Definition: walletmodel.h:81
QString authenticatedMerchant
Definition: walletmodel.h:84
UI model for the transaction table of a wallet.
Optional< QString > stakerAddress
Definition: walletmodel.h:312
bool operator<(const ListCoinsKey &key2) const
Definition: walletmodel.h:318
bool operator==(const ListCoinsKey &key2) const
Definition: walletmodel.h:314
ListCoinsValue(const uint256 &_txhash, int _outIndex, CAmount _nValue, int64_t _nTime, int _nDepth)
Definition: walletmodel.h:327
UnlockContext & operator=(UnlockContext &&rhs)
Definition: walletmodel.h:257
UnlockContext & operator=(const UnlockContext &)=default
UnlockContext(WalletModel *wallet, bool valid, const WalletModel::EncryptionStatus &status_before)
UnlockContext(const UnlockContext &)=delete
WalletModel::EncryptionStatus was_status
Definition: walletmodel.h:262
UnlockContext(UnlockContext &&obj)
Definition: walletmodel.h:256
void CopyFrom(UnlockContext &&rhs)
Interface to PIVX wallet from Qt view code.
Definition: walletmodel.h:109
OptionsModel * optionsModel
Definition: walletmodel.h:390
int getLastBlockProcessedNum() const
bool validateAddress(const QString &address)
bool hasWallet()
Definition: walletmodel.h:156
AddressTableModel * addressTableModel
Definition: walletmodel.h:392
void getAvailableP2CSCoins(std::vector< COutput > &vCoins) const
bool isStakingStatusActive() const
void balanceChanged(const interfaces::WalletBalances &walletBalances)
void loadReceiveRequests(std::vector< std::string > &vReceiveRequests)
std::unique_ptr< interfaces::Handler > m_handler_notify_watch_only_changed
Definition: walletmodel.h:381
void lockCoin(uint256 hash, unsigned int n, bool isTransparent=true)
EncryptionStatus cachedEncryptionStatus
Definition: walletmodel.h:398
QString getSaplingAddressString(const CWalletTx *wtx, const SaplingOutPoint &op) const
CAmount getNetMinFee()
void coinsSent(CWallet *wallet, const SendCoinsRecipient &recipient, const QByteArray &transaction)
void message(const QString &title, const QString &body, unsigned int style, bool *ret=nullptr)
CallResult< Destination > getNewAddress(const std::string &label="") const
ClientModel * m_client_model
Definition: walletmodel.h:383
bool isWalletLocked(bool fFullUnlocked=true) const
bool isMine(const CWDestination &address)
bool isTestNetwork() const
Definition: walletmodel.cpp:76
std::string getLabelForAddress(const CTxDestination &address)
bool updateAddressBookLabels(const CWDestination &address, const std::string &strName, const std::string &strPurpose)
bool isSaplingInMaintenance() const
Definition: walletmodel.cpp:96
void resetWalletOptions(QSettings &settings)
Definition: walletmodel.cpp:69
CAmount getLockedBalance(bool isTransparent) const
bool isShutdownRequested()
Definition: walletmodel.cpp:86
void unlockCoin(uint256 hash, unsigned int n, bool isTransparent=true)
bool setWalletEncrypted(bool encrypted, const SecureString &passphrase)
CAmount getUnlockedBalance(const CCoinControl *coinControl=nullptr, bool fIncludeDelegated=true, bool fIncludeShielded=true) const
bool haveKey(const CKeyID &keyID) const
Definition: walletmodel.h:296
WalletRescanReserver getRescanReserver() const
Return new wallet rescan reserver.
Definition: walletmodel.h:287
void listCoins(std::map< ListCoinsKey, std::vector< ListCoinsValue >> &mapCoins, bool fSelectTransparent) const
void listAvailableNotes(std::map< ListCoinsKey, std::vector< ListCoinsValue >> &mapCoins) const
void setWalletCustomFee(bool fUseCustomFee, const CAmount nFee=DEFAULT_TRANSACTION_FEE)
void encryptionStatusChanged(int status)
void pollBalanceChanged()
SendCoinsReturn sendCoins(WalletModelTransaction &transaction)
bool isHDEnabled() const
bool isV6Enforced() const
CallResult< Destination > getNewShieldedAddress(std::string strLabel="")
Return a new shielded address.
bool getWalletCustomFee(CAmount &nFeeRet)
bool addKeys(const CKey &key, const CPubKey &pubkey, WalletRescanReserver &reserver)
@ UnlockedForStaking
Definition: walletmodel.h:137
bool upgradeWallet(std::string &upgradeError)
TransactionTableModel * transactionTableModel
Definition: walletmodel.h:393
std::unique_ptr< interfaces::Handler > m_handler_notify_transaction_changed
Definition: walletmodel.h:379
ClientModel & clientModel() const
Definition: walletmodel.h:352
void notifyWatchonlyChanged(bool fHaveWatchonly)
bool updateAddressBookPurpose(const QString &addressStr, const std::string &purpose)
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass)
void showProgress(const QString &title, int nProgress)
interfaces::Wallet walletWrapper
Definition: walletmodel.h:373
void notifyReceiveAddressChanged()
bool isStakingOnlyUnlocked()
bool getKeyId(const CTxDestination &address, CKeyID &keyID)
void emitBalanceChanged()
void setCacheNumBlocks(int _cachedNumBlocks)
Definition: walletmodel.h:359
CAmount getMinColdStakingAmount() const
bool isWalletUnlocked() const
void setClientModel(ClientModel *client_model)
void pollFinished()
OperationResult PrepareShieldedTransaction(WalletModelTransaction *modelTransaction, bool fromTransparent, const CCoinControl *coinControl=nullptr)
bool saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest)
void updateStatus()
AddressTableModel * getAddressTableModel()
bool blacklistAddressFromColdStaking(const QString &address)
CAmount getWalletStakeSplitThreshold() const
OptionsModel * getOptionsModel()
int getWalletTxDepth(const uint256 &txHash) const
SendCoinsReturn prepareTransaction(WalletModelTransaction *transaction, const CCoinControl *coinControl=nullptr, bool fIncludeDelegations=true)
std::set< COutPoint > listLockedCoins()
bool whitelistAddressFromColdStaking(const QString &addressStr)
bool getMNCollateralCandidate(COutPoint &outPoint)
bool processBalanceChangeInternal()
bool isColdStaking() const
bool backupWallet(const QString &filename)
std::unique_ptr< interfaces::Handler > m_handler_notify_status_changed
Definition: walletmodel.h:376
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString(), bool stakingOnly=false)
std::unique_ptr< interfaces::Handler > m_handler_notify_sst_changed
Definition: walletmodel.h:378
double getSSTMinimum() const
EncryptionStatus getEncryptionStatus() const
CAmount getDelegatedBalance() const
bool isColdStakingNetworkelyEnabled() const
Whether cold staking is enabled or disabled in the network.
Definition: walletmodel.cpp:91
void balanceNotify()
uint256 m_cached_best_block_hash
Definition: walletmodel.h:400
interfaces::WalletBalances m_cached_balances
Definition: walletmodel.h:396
int64_t getKeyCreationTime(const CPubKey &key)
bool fForceCheckBalanceChanged
Definition: walletmodel.h:386
bool haveWatchOnly() const
interfaces::WalletBalances getBalances()
Definition: walletmodel.h:405
CWallet * wallet
Definition: walletmodel.h:369
void notifySSTChanged(const double sstVal)
notify stake-split threshold changed
bool getPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const
int getCacheNumBLocks()
Definition: walletmodel.h:360
Q_INVOKABLE void checkBalanceChanged(const interfaces::WalletBalances &new_balances)
OperationResult createAndSendProposalFeeTx(CBudgetProposal &prop)
bool getKey(const CKeyID &keyID, CKey &key) const
Definition: walletmodel.h:295
QTimer * pollTimer
Definition: walletmodel.h:402
void unsubscribeFromCoreSignals()
bool isSpent(const COutPoint &outpoint) const
bool IsShieldedDestination(const CWDestination &address)
void requireUnlock()
bool isLockedCoin(uint256 hash, unsigned int n, bool isTransparent=true) const
void updateTransaction()
Optional< QString > getShieldedAddressFromSpendDesc(const uint256 &txHash, int index)
std::unique_ptr< interfaces::Handler > m_handler_notify_walletbacked
Definition: walletmodel.h:382
int64_t getCreationTime() const
QString getWalletPath()
void updateTxModelData()
void updateAddressBook(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
uint256 getLastBlockProcessed() const
bool fHaveWatchOnly
Definition: walletmodel.h:385
void updateWatchOnlyFlag(bool fHaveWatchonly)
CallResult< Destination > getNewStakingAddress(const std::string &label="") const
Return a new address used to receive for delegated cold stake purpose.
void setCacheBlockHash(const uint256 &_blockHash)
Definition: walletmodel.h:361
interfaces::WalletBalances GetWalletBalances()
Definition: walletmodel.h:165
void setWalletDefaultFee(CAmount fee=DEFAULT_TRANSACTION_FEE)
CAmount getBalance(const CCoinControl *coinControl=nullptr, bool fIncludeDelegated=true, bool fUnlockedOnly=false, bool fIncludeShielded=true) const
std::set< SaplingOutPoint > listLockedNotes()
UnlockContext requestUnlock()
int cachedNumBlocks
Definition: walletmodel.h:399
QFuture< void > pollFuture
Definition: walletmodel.h:403
void setWalletStakeSplitThreshold(const CAmount nStakeSplitThreshold)
std::unique_ptr< interfaces::Handler > m_handler_notify_addressbook_changed
Definition: walletmodel.h:377
WalletModel(CWallet *wallet, OptionsModel *optionsModel, QObject *parent=0)
Definition: walletmodel.cpp:42
bool isRegTestNetwork() const
Definition: walletmodel.cpp:81
const CWalletTx * getTx(uint256 id)
bool hasForceCheckBalance()
Definition: walletmodel.h:358
void setfForceCheckBalanceChanged(bool _fForceCheckBalanceChanged)
Definition: walletmodel.h:362
std::unique_ptr< interfaces::Handler > m_handler_show_progress
Definition: walletmodel.h:380
bool lockForStakingOnly(const SecureString &passPhrase=SecureString())
bool isUsed(CTxDestination address)
bool isSaplingWalletEnabled() const
@ StakingOnlyUnlocked
Definition: walletmodel.h:128
@ AmountWithFeeExceedsBalance
Definition: walletmodel.h:123
@ TransactionCheckFailed
Definition: walletmodel.h:126
@ TransactionCreationFailed
Definition: walletmodel.h:125
@ CannotCreateInternalAddress
Definition: walletmodel.h:130
@ AmountExceedsBalance
Definition: walletmodel.h:122
@ TransactionCommitFailed
Definition: walletmodel.h:127
void subscribeToCoreSignals()
bool hasWalletCustomFee()
TransactionTableModel * getTransactionTableModel()
Data model for a walletmodel transaction.
RAII object to check and reserve a wallet rescan.
Definition: wallet.h:1324
WalletBalances getBalances()
Definition: wallet.cpp:11
Sapling functions.
Definition: address.h:30
256-bit opaque blob.
Definition: uint256.h:138
boost::variant< CTxDestination, libzcash::SaplingPaymentAddress > CWDestination
boost::optional< T > Optional
Substitute for C++17 std::optional.
Definition: optional.h:12
QSettings * settings
Definition: qtutils.cpp:197
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:61
#define SER_WRITE(obj, code)
Definition: serialize.h:186
#define SER_READ(obj, code)
Definition: serialize.h:185
#define READWRITE(...)
Definition: serialize.h:183
boost::variant< CNoDestination, CKeyID, CScriptID, CExchangeKeyID > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:72
CWallet::CommitStatus status
Definition: wallet.h:1106
SendCoinsReturn(CWallet::CommitResult _commitRes)
Definition: walletmodel.h:195
SendCoinsReturn(StatusCode status=OK)
Definition: walletmodel.h:194
CWallet::CommitResult commitRes
Definition: walletmodel.h:200
Collection of wallet balances.
Definition: wallet.h:16