8 #ifndef PIVX_WALLET_WALLET_H
9 #define PIVX_WALLET_WALLET_H
60 static const CAmount DEFAULT_TRANSACTION_FEE = 0;
62 static const CAmount nHighTransactionFeeWarning = 0.1 * COIN;
64 static const CAmount DEFAULT_TRANSACTION_MINFEE = 10000;
66 static const CAmount DEFAULT_TRANSACTION_MAXFEE = 1 * COIN;
68 static const CAmount MIN_CHANGE = CENT;
70 static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 1;
72 static const CAmount nHighTransactionMaxFeeWarning = 100 * nHighTransactionFeeWarning;
74 static const CAmount DEFAULT_MIN_STAKE_SPLIT_THRESHOLD = 100 * COIN;
76 static const bool DEFAULT_SPEND_ZEROCONF_CHANGE =
true;
78 static const bool DEFAULT_STAKING =
true;
80 static const bool DEFAULT_COLDSTAKING =
true;
82 static const bool DEFAULT_GENERATE =
false;
83 static const unsigned int DEFAULT_GENERATE_PROCLIMIT = 1;
85 static const unsigned int DEFAULT_CREATEWALLETBACKUPS = 10;
87 static const bool DEFAULT_DISABLE_WALLET =
false;
89 static const int64_t TIMESTAMP_MIN = 0;
143 template<
typename Stream>
146 int nVersion = s.GetVersion();
150 s << nTime << vchPubKey << Span<unsigned char>((
unsigned char*)&
type, 1) <<
m_pre_split;
153 template<
typename Stream>
156 int nVersion = s.GetVersion();
163 }
catch (std::ios_base::failure&) {
166 type = HDChain::ChangeType::EXTERNAL;
170 }
catch (std::ios_base::failure&) {
225 virtual std::string
getMemo()
const {
return ""; }
257 it =
map.find(filter);
264 std::map<CWDestination, AddressBook::CAddressBookData>&
map;
265 std::map<CWDestination, AddressBook::CAddressBookData>::iterator
it;
266 std::map<CWDestination, AddressBook::CAddressBookData>::iterator
itEnd;
275 static inline void ReadOrderPos(int64_t& nOrderPos,
mapValue_t& mapValue)
277 if (!mapValue.count(
"n")) {
281 nOrderPos =
atoi64(mapValue[
"n"].c_str());
285 static inline void WriteOrderPos(
const int64_t& nOrderPos,
mapValue_t& mapValue)
289 mapValue[
"n"] =
i64tostr(nOrderPos);
308 template<
typename Stream>
313 std::vector<uint256> vMerkleBranch;
316 s >> tx >> hashBlock >> vMerkleBranch >> nIndex;
337 std::vector<std::pair<std::string, std::string> >
vOrderForm;
396 template<
typename Stream>
401 mapValueCopy[
"fromaccount"] =
"";
407 std::vector<char> dummy_vector1;
408 std::vector<char> dummy_vector2;
409 char dummy_char =
false;
414 if (this->tx->isSaplingVersion()) {
419 template<
typename Stream>
424 std::vector<uint256> dummy_vector1;
425 std::vector<CMerkleTx> dummy_vector2;
430 if (this->tx->isSaplingVersion()) {
443 }
else if (serializedIndex == -1) {
483 const auto& it =
mapValue.find(
"comment");
484 return it !=
mapValue.end() ? it->second :
"";
510 void GetAmounts(std::list<COutputEntry>& listReceived,
511 std::list<COutputEntry>& listSent,
523 bool IsTrusted(
int& nDepth,
bool& fConflicted)
const;
590 std::unique_ptr<ScriptPubKeyMan>
m_spk_man = std::make_unique<ScriptPubKeyMan>(
this);
591 std::unique_ptr<SaplingScriptPubKeyMan>
m_sspk_man = std::make_unique<SaplingScriptPubKeyMan>(
this);
663 const unsigned int outIndex,
666 const bool fCoinsSelected,
667 const bool fIncludeColdStaking,
668 const bool fIncludeDelegated,
669 const bool fIncludeLocked)
const;
682 bool SetupSPKM(
bool newKeypool =
true,
bool memOnly =
false);
692 assert(m_last_block_processed_height >= 0);
693 return m_last_block_processed_height;
701 m_last_block_processed_height = pindex->nHeight;
702 m_last_block_processed = pindex->GetBlockHash();
703 m_last_block_processed_time = pindex->GetBlockTime();
762 CWallet(std::string
name, std::unique_ptr<WalletDatabase> dbw_in);
768 typedef std::multimap<int64_t, CWalletTx*>
TxItems;
793 bool _fIncludeColdStaking,
795 bool _fOnlySpendable,
796 std::set<CTxDestination>* _onlyFilteredDest,
798 bool _fIncludeLocked =
false,
828 AvailableCoinsFilter coinsFilter = AvailableCoinsFilter()
831 bool SelectCoinsToSpend(
const std::vector<COutput>& vAvailableCoins,
const CAmount& nTargetValue, std::set<std::pair<const CWalletTx*, unsigned int> >& setCoinsRet,
CAmount& nValueRet,
const CCoinControl* coinControl =
nullptr)
const;
837 bool SelectCoinsMinConf(
const CAmount& nTargetValue,
int nConfMine,
int nConfTheirs, uint64_t nMaxAncestors, std::vector<COutput> vCoins, std::set<std::pair<const CWalletTx*, unsigned int> >& setCoinsRet,
CAmount& nValueRet)
const;
839 bool StakeableCoins(std::vector<CStakeableOutput>* pCoins =
nullptr);
850 std::map<std::pair<CTxDestination, Optional<CTxDestination>>, std::vector<COutput>>
ListCoins()
const;
854 std::map<libzcash::SaplingPaymentAddress, std::vector<SaplingNoteEntry>>
ListNotes()
const;
860 bool fValidateCollateral,
861 std::string& strError);
955 const std::vector<unsigned char> &vchCryptedSecret);
971 const std::vector<unsigned char> &vchCryptedSecret);
986 bool AddCryptedKey(
const CPubKey& vchPubKey,
const std::vector<unsigned char>& vchCryptedSecret)
override;
1031 void BlockDisconnected(
const std::shared_ptr<const CBlock>& pblock,
const uint256& blockHash,
int nBlockHeight, int64_t blockTime)
override;
1038 bool Upgrade(std::string&
error,
const int prevVersion);
1084 int& nChangePosInOut,
1085 std::string& strFailReason,
1089 bool fIncludeDelegated =
false,
1090 bool* fStakeDelegationVoided =
nullptr,
1094 bool CreateTransaction(
CScript scriptPubKey,
const CAmount& nValue,
CTransactionRef& tx,
CReserveKey& reservekey,
CAmount& nFeeRet, std::string& strFailReason,
const CCoinControl* coinControl =
nullptr,
CAmount nFeePay = 0,
bool fIncludeDelegated =
false,
bool* fStakeDelegationVoided =
nullptr,
int nExtraSize = 0,
int nMinDepth = 0);
1119 int64_t& nTxNewTime,
1120 std::vector<CStakeableOutput>* availableCoins,
1121 bool stopOnNewBlock =
true)
const;
1134 void ReturnKey(int64_t nIndex,
const bool internal =
false,
const bool staking =
false);
1202 void Flush(
bool shutdown=
false);
1242 boost::signals2::signal<void(
const std::string& title,
int nProgress)>
ShowProgress;
1260 bool internal{
false};
1304 COutput(
const CWalletTx *txIn,
int iIn,
int nDepthIn,
bool fSpendableIn,
bool fSolvableIn,
bool fSafeIn) :
int64_t CAmount
Amount in PIV (Can be negative)
An instance of this class represents one database.
AddressBook::CAddressBookData GetValue()
std::map< CWDestination, AddressBook::CAddressBookData >::iterator it
std::map< CWDestination, AddressBook::CAddressBookData > & map
std::map< CWDestination, AddressBook::CAddressBookData >::iterator itEnd
CAddressBookIterator(std::map< CWDestination, AddressBook::CAddressBookData > &_map)
const libzcash::SaplingPaymentAddress * GetShieldedDestKey()
const CWDestination * GetDestKey()
const CTxDestination * GetCTxDestKey()
void SetFilter(CTxDestination &filter)
The block chain is a tree shaped structure starting with the genesis block at the root,...
Keystore which keeps the private keys encrypted.
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override
Add a key to the store.
Fee rate in PIV per kilobyte: CAmount / kB.
An encapsulated private key.
void Unserialize(Stream &s)
uint8_t type
Whether this keypool entry is in the internal, external or staking keypool.
CPubKey vchPubKey
The public key.
int64_t nTime
The time at which the key was generated. Set in AddKeypoolPubKeyWithDB.
bool m_pre_split
Whether this key was generated for a keypool before the wallet was upgraded to HD-split.
void Serialize(Stream &s) const
Legacy class used for deserializing vtxPrev for backwards compatibility.
void Unserialize(Stream &s)
An outpoint - a combination of a transaction hash and an index n into its vout.
bool fSafe
Whether this output is considered safe to spend.
COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn, bool fSolvableIn, bool fSafeIn)
bool fSolvable
Whether we know how to spend this output, ignoring the lack of keys.
bool fSpendable
Whether we have the private keys to spend this output.
An encapsulated public key.
bool fSubtractFeeFromAmount
virtual bool isTransparent() const
virtual std::string getMemo() const
virtual Optional< libzcash::SaplingPaymentAddress > getSapPaymentAddr() const
CRecipientBase(const CAmount &_nAmount, bool _fSubtractFeeFromAmount)
virtual Optional< CScript > getScript() const
Optional< CScript > getScript() const override
bool isTransparent() const override
CRecipient(const CScript &_scriptPubKey, const CAmount &_nAmount, bool _fSubtractFeeFromAmount)
A key allocated from the key pool.
CReserveKey & operator=(const CReserveKey &)=delete
CReserveKey(CWallet *pwalletIn)
CReserveKey(const CReserveKey &)=delete
Serialized script, used inside transaction inputs and outputs.
const CBlockIndex * pindex
CStakeableOutput(const CWalletTx *txIn, int iIn, int nDepthIn, const CBlockIndex *&pindex)
Record info about last stake attempt:
void SetLastTime(const uint64_t lastTime)
int64_t GetLastTime() const
void SetLastTries(const int tries)
const CBlockIndex * GetLastTip() const
uint256 GetLastHash() const
void SetLastCoins(const int coins)
int GetLastHeight() const
void SetLastTip(const CBlockIndex *lastTip)
const CBlockIndex * tipBlock
The basic transaction that is broadcasted on the network and contained in blocks.
An input of a transaction.
An output of a transaction.
Implement this to subscribe to events generated in validation.
Capture information about block/transaction validation.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
WalletBatch * encrypted_batch
std::map< CWDestination, AddressBook::CAddressBookData > mapAddressBook
Destination --> label/purpose mapping.
std::map< uint256, CWalletTx > mapWallet
bool LoadDestData(const CTxDestination &dest, const std::string &key, const std::string &value)
Adds a destination data tuple to the store, without saving it to disk.
int nWalletMaxVersion
the maximum wallet format version: memory-only variable that specifies to what version this wallet ma...
std::map< unsigned int, CMasterKey > MasterKeyMap
uint256 m_last_block_processed GUARDED_BY(cs_wallet)
The following is used to keep track of how far behind the wallet is from the chain sync,...
void GetKeyBirthTimes(std::map< CKeyID, int64_t > &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_main)
TxSpendMap< COutPoint > TxSpends
Used to keep track of spent outpoints, and detect and report conflicts (double-spends or mutated tran...
static CWallet * CreateWalletFromFile(const std::string &name, const fs::path &path)
void IncrementNoteWitnesses(const CBlockIndex *pindex, const CBlock *pblock, SaplingMerkleTree &saplingTree)
pindex is the new tip being connected.
bool LoadCryptedSaplingZKey(const libzcash::SaplingExtendedFullViewingKey &extfvk, const std::vector< unsigned char > &vchCryptedSecret)
Adds an encrypted spending key to the store, without saving it to disk (used by LoadWallet)
MasterKeyMap mapMasterKeys
boost::signals2::signal< void(const CAmount stakeSplitThreshold)> NotifySSTChanged
notify stake-split threshold changed
std::string m_name
Wallet filename from wallet=<path> command line or config option.
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
fs::path GetPathToDBFile()
Get the path to the wallet's db file.
void DecrementNoteWitnesses(const CBlockIndex *pindex)
pindex is the old tip being disconnected.
bool LoadSaplingZKeyMetadata(const libzcash::SaplingIncomingViewingKey &ivk, const CKeyMetadata &meta)
Load spending key metadata (used by LoadWallet)
CStakerStatus * pStakerStatus
void LockOutpointIfMine(const CTransactionRef &ptx, const COutPoint &c)
int64_t m_last_block_processed_time GUARDED_BY(cs_wallet)=0
bool fDecryptionThoroughlyChecked
keeps track of whether Unlock has run a thorough check before
void AutoCombineDust(CConnman *connman)
std::unique_ptr< ScriptPubKeyMan > m_spk_man
Key manager //.
int GetVersion()
get the current wallet format (the oldest client version guaranteed to understand this wallet)
CAddressBookIterator NewAddressBookIterator()
bool AddSaplingZKey(const libzcash::SaplingExtendedSpendingKey &key)
Adds Sapling spending key to the store, and saves it to disk.
bool LoadKey(const CKey &key, const CPubKey &pubkey)
Adds a key to the store, without saving it to disk (used by LoadWallet)
CWallet(std::string name, std::unique_ptr< WalletDatabase > dbw_in)
Construct wallet with specified name and database implementation.
boost::signals2::signal< void(const bool fSuccess, const std::string &filename)> NotifyWalletBacked
notify wallet file backed up
int64_t nRelockTime
Lock Wallet Holds a timestamp at which point the wallet is scheduled (externally) to be relocked.
boost::signals2::signal< void(CWallet *wallet, const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged
Wallet transaction added, removed or updated.
void LockOutpointIfMineWithMutex(const CTransactionRef &ptx, const COutPoint &c)
std::unique_ptr< SaplingScriptPubKeyMan > m_sspk_man
CAmount nStakeSplitThreshold
std::atomic< bool > fAbortRescan
std::set< COutPoint > setLockedCoins
static CAmount minStakeSplitThreshold
minimum accpeted value for stake split threshold
void SetLastBlockProcessed(const CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Set last block processed height, currently only use in unit test.
void postInitProcess(CScheduler &scheduler)
Wallet post-init setup Gives the wallet a chance to register repetitive tasks and complete post-init ...
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
bool BackupWallet(const std::string &strDest)
Creates a wallet backup in strDest path.
bool CanSupportFeature(enum WalletFeature wf)
check whether we are allowed to upgrade (or already support) to the named feature
bool LoadMinVersion(int nVersion)
CAmount nAutoCombineThreshold
bool LoadSaplingZKey(const libzcash::SaplingExtendedSpendingKey &key)
Adds spending key to the store, without saving it to disk (used by LoadWallet)
void LockIfMyCollateral(const CTransactionRef &ptx)
std::vector< std::string > GetDestValues(const std::string &prefix) const
Get all destination values matching a prefix.
bool HaveSpendingKeyForPaymentAddress(const libzcash::SaplingPaymentAddress &zaddr) const
Returns true if the wallet contains the spending key.
bool EraseDestData(const CTxDestination &dest, const std::string &key)
Erases a destination data tuple in the store and on disk.
unsigned int GetKeyPoolSize()
std::set< SaplingOutPoint > setLockedNotes
CAmount GetCredit(const CTxOut &txout, const isminefilter &filter) const
std::unique_ptr< WalletDatabase > database
Internal database handle.
WalletDatabase * GetDBHandlePtr() const
Get database handle used by this wallet.
int m_last_block_processed_height GUARDED_BY(cs_wallet)
static CFeeRate minTxFee
Fees smaller than this (in upiv) are considered zero fee (for transaction creation) We are ~100 times...
std::multimap< int64_t, CWalletTx * > TxItems
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
Watch-only address added.
std::atomic< int64_t > nTimeBestReceived
bool fWalletUnlockStaking
bool IsFromMe(const CTransactionRef &tx) const
should probably be renamed to IsRelevantToMe
CAmount GetChange(const CTxOut &txout) const
SaplingScriptPubKeyMan * GetSaplingScriptPubKeyMan() const
std::string GetUniqueWalletBackupName() const
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.
std::map< CKeyID, CKeyMetadata > mapKeyMetadata
int nWalletVersion
the current wallet version: clients below this version are not able to load the wallet
unsigned int GetStakingKeyPoolSize()
libzcash::SaplingPaymentAddress GenerateNewSaplingZKey(std::string label="")
Generates new Sapling key.
static const CAmount DEFAULT_STAKE_SPLIT_THRESHOLD
bool LoadSaplingPaymentAddress(const libzcash::SaplingPaymentAddress &addr, const libzcash::SaplingIncomingViewingKey &ivk)
Adds a Sapling payment address -> incoming viewing key map entry, without saving it to disk (used by ...
CAmount GetStakeSplitThreshold() const
void ClearNoteWitnessCache()
clear note witness cache
bool AddSaplingIncomingViewingKeyW(const libzcash::SaplingIncomingViewingKey &ivk, const libzcash::SaplingPaymentAddress &addr)
std::atomic< bool > fScanningWallet
int GetAddressBookSize() const
unsigned int nMasterKeyMaxID
boost::signals2::signal< void(CWallet *wallet, const CWDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)> NotifyAddressBookChanged
Address book entry changed.
WalletDatabase & GetDBHandle() const
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
Show progress e.g.
bool AddCryptedSaplingSpendingKeyW(const libzcash::SaplingExtendedFullViewingKey &extfvk, const std::vector< unsigned char > &vchCryptedSecret)
static std::atomic< bool > fFlushScheduled
A transaction with a bunch of additional info that only the owner cares about.
void SetComment(const std::string &comment)
Store a comment.
Optional< std::pair< libzcash::SaplingNotePlaintext, libzcash::SaplingPaymentAddress > > RecoverSaplingNote(const SaplingOutPoint &op, const std::set< uint256 > &ovks) const
int GetDepthInMainChain() const NO_THREAD_SAFETY_ANALYSIS
Return depth of transaction in blockchain: <0 : conflicts with a transaction this deep in the blockch...
bool isUnconfirmed() const
int GetDepthAndMempool(bool &fConflicted) const
bool AcceptToMemoryPool(CValidationState &state) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Pass this transaction to the mempool.
unsigned int nTimeSmart
time received by this node
bool HasP2CSInputs() const
checks whether a tx has P2CS inputs or not
bool IsFromMe(const isminefilter &filter) const
CAmount nShieldedChangeCached
void SetTx(CTransactionRef arg)
void Serialize(Stream &s) const
CAmount GetShieldedChange() const
int GetBlocksToMaturity() const
bool IsEquivalentTo(const CWalletTx &tx) const
void Unserialize(Stream &s)
CAmount GetChange() const
bool isConflicted() const
std::string GetComment() const
AmountType
position in ordered transaction list
@ AMOUNTTYPE_ENUM_ELEMENTS
void SetSaplingNoteData(mapSaplingNoteData_t ¬eData)
static const uint256 ABANDON_HASH
Constant used in hashBlock to indicate tx has been abandoned, only used at serialization/deserializat...
bool fStakeDelegationVoided
Optional< std::pair< libzcash::SaplingNotePlaintext, libzcash::SaplingPaymentAddress > > DecryptSaplingNote(const SaplingOutPoint &op) const
bool fShieldedChangeCached
std::vector< std::pair< std::string, std::string > > vOrderForm
mapSaplingNoteData_t mapSaplingNoteData
bool IsInMainChainImmature() const
CAmount GetShieldedAvailableCredit(bool fUseCache=true) const
void BindWallet(CWallet *pwalletIn)
const uint256 & GetHash() const
unsigned int fTimeReceivedIsTxTime
CachableAmount m_amounts[AMOUNTTYPE_ENUM_ELEMENTS]
void MarkDirty()
make sure balances are recalculated
void Init(const CWallet *pwalletIn)
CWalletTx(const CWallet *pwalletIn, CTransactionRef arg)
unsigned int nTimeReceived
An outpoint - a combination of a transaction hash and an index n into its sapling output description ...
A Span is an object that can refer to a contiguous sequence of objects.
Access to the wallet database.
RAII object to check and reserve a wallet rescan.
WalletRescanReserver(CWalletRef w)
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
boost::variant< CTxDestination, libzcash::SaplingPaymentAddress > CWDestination
void UnlockCoin(const COutPoint &output)
CAmount GetImmatureDelegatedBalance() const
void GetAvailableP2CSCoins(std::vector< COutput > &vCoins) const
Available coins (P2CS)
CAmount GetImmatureWatchOnlyBalance() const
bool SelectCoinsToSpend(const std::vector< COutput > &vAvailableCoins, const CAmount &nTargetValue, std::set< std::pair< const CWalletTx *, unsigned int > > &setCoinsRet, CAmount &nValueRet, const CCoinControl *coinControl=nullptr) const
Available coins (spending)
CAmount loopTxsBalance(const std::function< void(const uint256 &, const CWalletTx &, CAmount &)> &method) const
int64_t GetOldestKeyPoolTime()
CAmount GetUnconfirmedShieldedBalance() const
static std::string ParseIntoAddress(const CWDestination &dest, const std::string &purpose)
bool DelAddressBook(const CWDestination &address, const CChainParams::Base58Type addrType=CChainParams::PUBKEY_ADDRESS)
CAmount GetDelegatedBalance() const
CAmount GetLegacyBalance(const isminefilter &filter, int minDepth) const
std::map< std::pair< CTxDestination, Optional< CTxDestination > >, std::vector< COutput > > ListCoins() const
Return list of available coins and locked coins grouped by non-change output address.
std::string GetPurposeForAddressBookEntry(const CWDestination &address) const
void LockNote(const SaplingOutPoint &op)
CWallet::CommitResult CommitTransaction(CTransactionRef tx, CReserveKey &opReservekey, CConnman *connman)
bool GetKeyFromPool(CPubKey &key, const uint8_t &type=HDChain::ChangeType::EXTERNAL)
void LoadAddressBookPurpose(const CWDestination &dest, const std::string &strPurpose)
size_t KeypoolCountExternalKeys()
CAmount GetImmatureColdStakingBalance() const
CAmount GetColdStakingBalance() const
bool CreateTransaction(const std::vector< CRecipient > &vecSend, CTransactionRef &txRet, CReserveKey &reservekey, CAmount &nFeeRet, int &nChangePosInOut, std::string &strFailReason, const CCoinControl *coinControl=nullptr, bool sign=true, CAmount nFeePay=0, bool fIncludeDelegated=false, bool *fStakeDelegationVoided=nullptr, int nExtraSize=0, int nMinDepth=0)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
DBErrors LoadWallet(bool &fFirstRunRet)
Balance GetBalance(int min_depth=0) const
std::set< std::set< CTxDestination > > GetAddressGroupings()
int GetLastBlockHeightLockWallet() const
Get last block processed height locking the wallet.
bool SelectCoinsMinConf(const CAmount &nTargetValue, int nConfMine, int nConfTheirs, uint64_t nMaxAncestors, std::vector< COutput > vCoins, std::set< std::pair< const CWalletTx *, unsigned int > > &setCoinsRet, CAmount &nValueRet) const
Select coins until nTargetValue is reached.
CAmount GetLockedShieldCoins() const
bool GetMasternodeVinAndKeys(CPubKey &pubKeyRet, CKey &keyRet, const COutPoint &collateralOut, bool fValidateCollateral, std::string &strError)
Get 10000 PIV output and keys which can be used for the Masternode.
CAmount GetImmatureBalance() const
bool IsLockedNote(const SaplingOutPoint &op) const
CAmount GetLockedCoins() const
std::set< SaplingOutPoint > ListLockedNotes()
DBErrors ZapWalletTx(std::vector< CWalletTx > &vWtx)
CAmount GetStakingBalance(const bool fIncludeColdStaking=true) const
bool FundTransaction(CMutableTransaction &tx, CAmount &nFeeRet, bool overrideEstimatedFeeRate, const CFeeRate &specificFeeRate, int &nChangePosInOut, std::string &strFailReason, bool includeWatching, bool lockUnspents, const std::set< int > &setSubtractFeeFromOutputs, const CTxDestination &destChange=CNoDestination())
void LoadAddressBookName(const CWDestination &dest, const std::string &strName)
bool AvailableCoins(std::vector< COutput > *pCoins, const CCoinControl *coinControl=nullptr, AvailableCoinsFilter coinsFilter=AvailableCoinsFilter()) const
populate vCoins with vector of available COutputs.
bool SetStakeSplitThreshold(const CAmount sst)
bool CreateCoinStake(const CBlockIndex *pindexPrev, unsigned int nBits, CMutableTransaction &txNew, int64_t &nTxNewTime, std::vector< CStakeableOutput > *availableCoins, bool stopOnNewBlock=true) const
CAmount GetWatchOnlyBalance() const
bool TopUpKeyPool(unsigned int kpSize=0)
bool CreateBudgetFeeTX(CTransactionRef &tx, const uint256 &hash, CReserveKey &keyChange, CAmount fee)
std::vector< COutput > GetOutputsFromCoinControl(const CCoinControl *coinControl)
Return the selected known outputs.
std::string GetNameForAddressBookEntry(const CWDestination &address) const
CAmount GetUnconfirmedWatchOnlyBalance() const
bool HasDelegator(const CTxOut &out) const
std::map< libzcash::SaplingPaymentAddress, std::vector< SaplingNoteEntry > > ListNotes() const
Return list of available shield notes and locked shield notes grouped by sapling address.
bool HasAddressBook(const CWDestination &address) const
CAmount GetAvailableBalance(bool fIncludeDelegated=true, bool fIncludeShielded=true) const
OutputAvailabilityResult CheckOutputAvailability(const CTxOut &output, const unsigned int outIndex, const uint256 &wtxid, const CCoinControl *coinControl, const bool fCoinsSelected, const bool fIncludeColdStaking, const bool fIncludeDelegated, const bool fIncludeLocked) const
std::set< COutPoint > ListLockedCoins()
bool SetAddressBook(const CWDestination &address, const std::string &strName, const std::string &purpose)
bool IsLockedCoin(const uint256 &hash, unsigned int n) const
bool GetReservedKey(CPubKey &pubkey, bool internal=false)
CAmount GetUnconfirmedBalance(isminetype filter=ISMINE_SPENDABLE_ALL) const
std::string ToString() const
CAmount GetAvailableShieldedBalance(bool fUseCache=true) const
void LockCoin(const COutPoint &output)
std::map< CTxDestination, CAmount > GetAddressBalances()
bool StakeableCoins(std::vector< CStakeableOutput > *pCoins=nullptr)
Available coins (staking)
void KeepKey(int64_t nIndex)
void ReturnKey(int64_t nIndex, const bool internal=false, const bool staking=false)
Optional< AddressBook::CAddressBookData > GetAddressBookEntry(const CWDestination &address) const
std::set< CTxDestination > GetLabelAddresses(const std::string &label) const
bool CreateCoinstakeOuts(const CPivStake &stakeInput, std::vector< CTxOut > &vout, CAmount nTotal) const
bool SignCoinStake(CMutableTransaction &txNew) const
std::map< CTxDestination, std::vector< COutput > > AvailableCoinsByAddress(bool fConfirmed, CAmount maxCoinValue, bool fIncludeColdStaking)
void UnlockNote(const SaplingOutPoint &op)
CAmount GetImmatureCredit(bool fUseCache=true, const isminefilter &filter=ISMINE_SPENDABLE_ALL) const
std::vector< CWalletTx > getWalletTxs()
CAmount GetImmatureWatchOnlyCredit(const bool fUseCache=true) const
bool IsSaplingSpent(const SaplingOutPoint &op) const
bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret)
Adds an encrypted key to the store, without saving it to disk (used by LoadWallet)
CallResult< CTxDestination > getNewAddress(const std::string &addressLabel, const std::string purpose, const CChainParams::Base58Type addrType=CChainParams::PUBKEY_ADDRESS)
void SyncTransaction(const CTransactionRef &tx, const CWalletTx::Confirmation &confirm)
std::vector< CKeyID > GetAffectedKeys(const CScript &spk)
bool AddCScript(const CScript &redeemScript) override
Support for BIP 0013 : see https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki.
void Flush(bool shutdown=false)
Flush wallet (bitdb flush)
CAmount GetAvailableWatchOnlyCredit(const bool fUseCache=true) const
bool SetMaxVersion(int nVersion)
change which version we're allowed to upgrade to (note that this does not immediately imply upgrading...
bool IsAmountCached(AmountType type, const isminefilter &filter) const
bool LoadKeyMetadata(const CPubKey &pubkey, const CKeyMetadata &metadata)
Load metadata (used by LoadWallet)
ScriptPubKeyMan * GetScriptPubKeyMan() const
Get spkm.
bool AddWatchOnly(const CScript &dest) override
Adds a watch-only address to the store, and saves it to disk.
bool RemoveWatchOnly(const CScript &dest) override
bool Upgrade(std::string &error, const int prevVersion)
Upgrade wallet to HD and Sapling if needed.
const CKeyingMaterial & GetEncryptionKey() const
CAmount GetColdStakingCredit(bool fUseCache=true) const
void EraseFromWallet(const uint256 &hash)
std::set< uint256 > GetConflicts(const uint256 &txid) const
Get wallet transactions that conflict with given transaction (spend same outputs)
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
CBlockIndex * ScanForWalletTransactions(CBlockIndex *pindexStart, CBlockIndex *pindexStop, const WalletRescanReserver &reserver, bool fUpdate=false, bool fromStartup=false)
Scan the block chain (starting in pindexStart) for transactions from or to us.
isminetype IsMine(const CTxIn &txin) const
bool SetMinVersion(enum WalletFeature, WalletBatch *batch_in=nullptr, bool fExplicit=false)
signify that a particular wallet feature is now used. this may change nWalletVersion and nWalletMaxVe...
bool LoadToWallet(CWalletTx &wtxIn)
void RelayWalletTransaction(CConnman *connman)
CAmount GetDebit(const CTxIn &txin, const isminefilter &filter) const
bool Unlock(const SecureString &strWalletPassphrase, bool anonimizeOnly=false)
bool AddToWallet(const CWalletTx &wtxIn, bool fFlushOnClose=true)
void AddToSpends(const COutPoint &outpoint, const uint256 &wtxid)
CAmount GetCachableAmount(AmountType type, const isminefilter &filter, bool recalculate=false) const
bool IsKeyUsed(const CPubKey &vchPubKey) const
void UpdateTimeSmart()
Update smart timestamp for a transaction being added to the wallet.
CAmount GetDebit(const isminefilter &filter) const
filter decides which addresses will count towards the debit
void BlockUntilSyncedToCurrentChain()
Blocks until the wallet state is up-to-date to /at least/ the current chain at the time this function...
void SetBestChain(const CBlockLocator &loc) override
Notifies listeners of the new active block chain on-disk.
void UpdateTimeFirstKey(int64_t nCreateTime)
Update wallet first key creation time.
CallResult< CTxDestination > getNewStakingAddress(const std::string &label)
CAmount GetLockedCredit() const
int64_t IncOrderPosNext(WalletBatch *batch=nullptr)
Increment the next transaction order id.
bool AbandonTransaction(const uint256 &hashTx)
bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret) override
Adds an encrypted key to the store, and saves it to disk.
void ReacceptWalletTransactions(bool fFirstLoad=false)
bool FindNotesDataAndAddMissingIVKToKeystore(const CTransaction &tx, Optional< mapSaplingNoteData_t > &saplingNoteData)
bool IsHDEnabled() const
Whether the wallet is hd or not //.
void ResendWalletTransactions(CConnman *connman) override
Tells listeners to broadcast their data.
void GetAmounts(std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, CAmount &nFee, const isminefilter &filter) const
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override
Notifies listeners when the block chain tip advances.
bool EncryptWallet(const SecureString &strWalletPassphrase)
int64_t GetTxTime() const
bool HasSaplingSPKM() const
bool IsChange(const CTxOut &txout) const
int64_t GetKeyCreationTime(const CWDestination &dest)
bool ActivateSaplingWallet(bool memOnly=false)
bool AddToWalletIfInvolvingMe(const CTransactionRef &tx, const CWalletTx::Confirmation &confirm, bool fUpdate)
Add a transaction to the wallet, or update it.
const CWalletTx * GetWalletTx(const uint256 &hash) const
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override
Adds a key to the store, and saves it to disk.
CAmount GetCredit(const isminefilter &filter, bool recalculate=false) const
int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver &reserver, bool update)
Scan active chain for relevant transactions after importing keys.
CAmount GetColdStakingDebit(bool fUseCache=true) const
void SyncMetaData(std::pair< typename TxSpendMap< T >::iterator, typename TxSpendMap< T >::iterator > range)
void SyncMetaDataN(std::pair< TxSpendMap< uint256 >::iterator, TxSpendMap< uint256 >::iterator > range)
bool LoadWatchOnly(const CScript &dest)
Adds a watch-only address to the store, without saving it to disk (used by LoadWallet)
void SetBestChainInternal(WalletBatch &batch, const CBlockLocator &loc)
std::string ToString() const
bool LoadCScript(const CScript &redeemScript)
bool SetupSPKM(bool newKeypool=true, bool memOnly=false)
Generates hd wallet //.
CAmount GetStakeDelegationDebit(bool fUseCache=true) const
std::set< uint256 > GetConflicts() const
bool IsUsed(const CTxDestination address) const
void TransactionAddedToMempool(const CTransactionRef &tx) override
Notifies listeners of a transaction having been added to mempool.
CAmount GetAvailableCredit(bool fUseCache=true, const isminefilter &filter=ISMINE_SPENDABLE) const
bool HasEncryptionKeys() const
void BlockConnected(const std::shared_ptr< const CBlock > &pblock, const CBlockIndex *pindex) override
Notifies listeners of a block being connected.
void MarkAffectedTransactionsDirty(const CTransaction &tx)
void ChainTipAdded(const CBlockIndex *pindex, const CBlock *pblock, SaplingMerkleTree saplingTree)
CAmount GetStakeDelegationCredit(bool fUseCache=true) const
void AddExternalNotesDataToTx(CWalletTx &wtx) const
void MarkConflicted(const uint256 &hashBlock, int conflicting_height, const uint256 &hashTx)
void TransactionRemovedFromMempool(const CTransactionRef &ptx, MemPoolRemovalReason reason) override
Notifies listeners of a transaction leaving mempool.
bool IsSaplingUpgradeEnabled() const
Whether the wallet supports Sapling or not //.
bool IsSpent(const COutPoint &outpoint) const
Outpoint is spent if any non-conflicted transaction spends it:
void BlockDisconnected(const std::shared_ptr< const CBlock > &pblock, const uint256 &blockHash, int nBlockHeight, int64_t blockTime) override
Notifies listeners of a block being disconnected.
ChangeType
General change type (added, updated, removed).
isminetype
IsMine() return codes.
uint8_t isminefilter
used for bitflags of isminetype
RecursiveMutex cs_main
Global state.
boost::optional< T > Optional
Substitute for C++17 std::optional.
std::map< SaplingOutPoint, SaplingNoteData > mapSaplingNoteData_t
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
boost::variant< CNoDestination, CKeyID, CScriptID, CExchangeKeyID > CTxDestination
A txout script template with a specific destination.
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
A mutable version of CTransaction.
CTxDestination destination
AvailableCoinsFilter(bool _fIncludeDelegated, bool _fIncludeColdStaking, bool _fOnlySafe, bool _fOnlySpendable, std::set< CTxDestination > *_onlyFilteredDest, int _minDepth, bool _fIncludeLocked=false, CAmount _nMaxOutValue=0)
std::set< CTxDestination > * onlyFilteredDest
CAmount nMinimumSumAmount
unsigned int nMaximumCount
CAmount m_mine_trusted
Trusted, at depth=GetBalance.min_depth or more.
CAmount m_mine_trusted_shield
Trusted shield, at depth=GetBalance.min_depth or more.
CAmount m_mine_untrusted_pending
Untrusted, but in mempool (pending)
CAmount m_mine_immature
Immature coinbases/coinstakes in the main chain.
CAmount m_mine_untrusted_shielded_balance
Untrusted shield, but in mempool (pending)
CAmount m_mine_cs_delegated_trusted
Trusted, at depth=GetBalance.min_depth or more. Part of m_mine_trusted as well.
CWallet::CommitStatus status
Confirmation(Status s=UNCONFIRMED, int b=0, const uint256 &h=UINT256_ZERO, int i=0)
Cacheable amount subdivided into watchonly and spendable parts.
Sapling note, its location in a transaction, and number of confirmations.
#define AssertLockHeld(cs)
bool error(const char *fmt, const Args &... args)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
#define NO_THREAD_SAFETY_ANALYSIS
std::shared_ptr< const CTransaction > CTransactionRef
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
const uint256 UINT256_ZERO
constant uint256 instances
int64_t atoi64(const char *psz)
std::string i64tostr(int64_t n)
int64_t GetTime()
DEPRECATED Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable)
std::vector< CWalletRef > vpwallets
std::map< SaplingOutPoint, SaplingNoteData > mapSaplingNoteData_t
WalletFeature
(client) version numbers for particular wallet features
@ FEATURE_PRE_SPLIT_KEYPOOL
bool bSpendZeroConfChange
bool fPayAtLeastCustomFee
std::multimap< T, uint256 > TxSpendMap
unsigned int nTxConfirmTarget
std::map< std::string, std::string > mapValue_t
bool bdisableSystemnotifications
CFeeRate payTxFee
Settings.
DBErrors
Error statuses for the wallet database.