7 #ifndef BITCOIN_WALLET_WALLET_H 8 #define BITCOIN_WALLET_WALLET_H 31 #include <boost/shared_ptr.hpp> 135 template <
typename Stream,
typename Operation>
136 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion) {
141 if (ser_action.ForRead()) {
145 catch (std::ios_base::failure&) {
185 if (!mapValue.count(
"n"))
190 nOrderPos =
atoi64(mapValue[
"n"].c_str());
198 mapValue[
"n"] =
i64tostr(nOrderPos);
243 template <
typename Stream,
typename Operation>
245 std::vector<uint256> vMerkleBranch;
282 std::vector<std::pair<std::string, std::string> >
vOrderForm;
375 template <
typename Stream,
typename Operation>
377 if (ser_action.ForRead())
381 if (!ser_action.ForRead())
392 std::vector<CMerkleTx> vUnused;
401 if (ser_action.ForRead())
452 void GetAmounts(std::list<COutputEntry>& listReceived,
453 std::list<COutputEntry>& listSent,
CAmount& nFee, std::string& strSentAccount,
const isminefilter& filter)
const;
520 template <
typename Stream,
typename Operation>
521 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion) {
565 template <
typename Stream,
typename Operation>
566 inline void SerializationOp(Stream& s, Operation ser_action,
int nType,
int nVersion) {
574 if (!ser_action.ForRead())
591 if (ser_action.ForRead())
594 if (std::string::npos != nSepPos)
602 if (std::string::npos != nSepPos)
649 typedef std::multimap<COutPoint, uint256>
TxSpends;
659 void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>);
741 typedef std::pair<CWalletTx*, CAccountingEntry*>
TxPair;
742 typedef std::multimap<int64_t, TxPair >
TxItems;
775 bool SelectCoinsMinConf(
const CAmount& nTargetValue,
int nConfMine,
int nConfTheirs, std::vector<COutput>
vCoins, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet,
CAmount& nValueRet,
bool fUseInstantSend =
false)
const;
780 bool SelectCoinsGrouppedByAddresses(std::vector<CompactTallyItem>& vecTallyRet,
bool fSkipDenominated =
true,
bool fAnonymizable =
true,
bool fSkipUnconfirmed =
true)
const;
832 bool AddCryptedKey(
const CPubKey &vchPubKey,
const std::vector<unsigned char> &vchCryptedSecret);
905 bool ConvertList(std::vector<CTxIn> vecTxIn, std::vector<CAmount>& vecAmounts);
928 void ReturnKey(int64_t nIndex,
bool fInternal);
999 void Flush(
bool shutdown=
false);
1002 static bool Verify(
const std::string& walletFile, std::string& warningString, std::string& errorString);
1009 &address,
const std::string &label,
bool isMine,
1010 const std::string &purpose,
1021 boost::signals2::signal<void (const std::string &title, int nProgress)>
ShowProgress;
1097 template <
typename Stream,
typename Operation>
1105 #endif // BITCOIN_WALLET_WALLET_H CAmount nImmatureCreditCached
CAmount GetCredit(const isminefilter &filter) const
int CountInputsWithAmount(CAmount nInputAmount)
void KeepKey(int64_t nIndex)
boost::signals2::signal< void(bool fHaveWatchOnly)> NotifyWatchonlyChanged
CMerkleTx(const CTransaction &txIn)
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE
Default for -spendzeroconfchange.
unsigned int GetKeyPoolSize()
boost::variant< CNoDestination, CKeyID, CScriptID > CTxDestination
void ReturnKey(int64_t nIndex, bool fInternal)
CAmount GetAnonymizedBalance() const
static const unsigned int DEFAULT_TX_CONFIRM_TARGET
-txconfirmtarget default
bool IsFromMe(const CTransaction &tx) const
void SetBestChain(const CBlockLocator &loc)
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
std::set< CTxDestination > GetAccountAddresses(const std::string &strAccount) const
bool AddAccountingEntry(const CAccountingEntry &, CWalletDB &pwalletdb)
std::string strOtherAccount
CAmount nWatchDebitCached
void SetBroadcastTransactions(bool broadcast)
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
std::set< uint256 > GetConflicts(const uint256 &txid) const
Get wallet transactions that conflict with given transaction (spend same outputs) ...
CAmount nAvailableCreditCached
std::vector< CTxIn > vecTxIn
bool fSubtractFeeFromAmount
CWalletKey(int64_t nExpires=0)
bool fDenomConfCreditCached
bool SelectCoinsDark(CAmount nValueMin, CAmount nValueMax, std::vector< CTxIn > &vecTxInRet, CAmount &nValueRet, int nPrivateSendRoundsMin, int nPrivateSendRoundsMax) const
bool GetCollateralTxIn(CTxIn &txinRet, CAmount &nValueRet) const
bool SelectCoinsMinConf(const CAmount &nTargetValue, int nConfMine, int nConfTheirs, std::vector< COutput > vCoins, std::set< std::pair< const CWalletTx *, unsigned int > > &setCoinsRet, CAmount &nValueRet, bool fUseInstantSend=false) const
void ReserveKeyFromKeyPool(int64_t &nIndex, CKeyPool &keypool, bool fInternal)
static const CAmount nHighTransactionFeeWarning
-paytxfee will warn if called with a higher fee than this amount (in satoshis) per KB ...
void GenerateNewHDChain()
bool IsFromMe(const isminefilter &filter) const
CAmount GetImmatureCredit(bool fUseCache=true) const
CCriticalSection cs_wallet
bool CanSupportFeature(enum WalletFeature wf)
check whether we are allowed to upgrade (or already support) to the named feature ...
static const CAmount COIN
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.
bool LoadMinVersion(int nVersion)
bool AddToWallet(const CWalletTx &wtxIn, bool fFromLoadWallet, CWalletDB *pwalletdb)
CAmount GetUnconfirmedBalance() const
int64_t IncOrderPosNext(CWalletDB *pwalletdb=NULL)
bool GetOutpointAndKeysFromOutput(const COutput &out, COutPoint &outpointRet, CPubKey &pubKeyRet, CKey &keyRet)
Extract txin information and keys from output.
std::multimap< int64_t, TxPair > TxItems
bool AbandonTransaction(const uint256 &hashTx)
static const bool DEFAULT_WALLETBROADCAST
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey)
Add a key to the store.
std::map< std::string, std::string > StringMap
bool SelectCoinsByDenominations(int nDenom, CAmount nValueMin, CAmount nValueMax, std::vector< CTxIn > &vecTxInRet, std::vector< COutput > &vCoinsRet, CAmount &nValueRet, int nPrivateSendRoundsMin, int nPrivateSendRoundsMax)
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) ...
bool IsSpent(const uint256 &hash, unsigned int n) const
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
CAmount GetImmatureWatchOnlyCredit(const bool &fUseCache=true) const
bool fDebitCached
position in ordered transaction list
bool Unlock(const SecureString &strWalletPassphrase, bool fForMixingOnly=false)
bool fAnonymizedCreditCached
CAmount GetImmatureWatchOnlyBalance() const
std::string ToString() const
static const uint256 ABANDON_HASH
std::map< unsigned int, CMasterKey > MasterKeyMap
bool GetDecryptedHDChain(CHDChain &hdChainRet)
int GetRealOutpointPrivateSendRounds(const COutPoint &outpoint, int nRounds) const
const_iterator end() const
bool HasCollateralInputs(bool fOnlyConfirmed=true) const
CAmount GetAvailableCredit(bool fUseCache=true) const
bool AcceptToMemoryPool(bool fLimitFree=true, bool fRejectAbsurdFee=true)
bool GetBroadcastTransactions() const
const CWalletTx * GetWalletTx(const uint256 &hash) const
static void ReadOrderPos(int64_t &nOrderPos, mapValue_t &mapValue)
bool IsLockedCoin(uint256 hash, unsigned int n) const
std::set< uint256 > GetConflicts() const
COutput(const CWalletTx *txIn, int iIn, int nDepthIn, bool fSpendableIn, bool fSolvableIn)
int GetDepthInMainChain(bool enableIX=true) const
void Flush(bool shutdown=false)
Flush wallet (bitdb flush)
CWalletDB * pwalletdbEncryption
CAmount GetChange(const CTxOut &txout) const
std::pair< CWalletTx *, CAccountingEntry * > TxPair
bool fSendFreeTransactions
unsigned int nMasterKeyMaxID
bool AddToWalletIfInvolvingMe(const CTransaction &tx, const CBlock *pblock, bool fUpdate)
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
bool CommitTransaction(CWalletTx &wtxNew, CReserveKey &reservekey, CConnman *connman, std::string strCommand="tx")
CAmount GetNeedsToBeAnonymizedBalance(CAmount nMinBalance=0) const
bool TopUpKeyPool(unsigned int kpSize=0)
CAmount GetAnonymizableBalance(bool fSkipDenominated=false, bool fSkipUnconfirmed=true) const
static const unsigned int DEFAULT_KEYPOOL_SIZE
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const
GetPubKey implementation that also checks the mapHdPubKeys.
static const CAmount DEFAULT_DIP0001_FALLBACK_FEE
CAmount nAnonymizedCreditCached
int SetMerkleBranch(const CBlock &block)
bool LoadCScript(const CScript &redeemScript)
std::map< uint256, CWalletTx > mapWallet
bool DelAddressBook(const CTxDestination &address)
std::set< COutPoint > setWalletUTXO
const std::string strWalletFile
int nWalletMaxVersion
the maximum wallet format version: memory-only variable that specifies to what version this wallet ma...
int nWalletVersion
the current wallet version: clients below this version are not able to load the wallet ...
unsigned int nTimeReceived
CAmount GetChange() const
void DeriveNewChildKey(const CKeyMetadata &metadata, CKey &secretRet, uint32_t nAccountIndex, bool fInternal)
bool fBroadcastTransactions
bool IsInMainChain() const
bool fAnonymizableTallyCached
unsigned int nTxConfirmTarget
CAmount GetWatchOnlyBalance() const
CAmount GetDenominatedCredit(bool unconfirmed, bool fUseCache=true) const
bool AddCScript(const CScript &redeemScript)
Support for BIP 0013 : see https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki.
bool GetKey(const CKeyID &address, CKey &keyOut) const
GetKey implementation that can derive a HD private key on the fly.
bool fAvailableWatchCreditCached
boost::signals2::signal< void(CWallet *wallet, const uint256 &hashTx, ChangeType status)> NotifyTransactionChanged
bool SelectCoins(const CAmount &nTargetValue, std::set< std::pair< const CWalletTx *, unsigned int > > &setCoinsRet, CAmount &nValueRet, const CCoinControl *coinControl=NULL, AvailableCoinsType nCoinType=ALL_COINS, bool fUseInstantSend=true) const
static const CAmount MIN_CHANGE
minimum change amount
bool UpdatedTransaction(const uint256 &hashTx)
int GetVersion()
get the current wallet format (the oldest client version guaranteed to understand this wallet) ...
bool SetMinVersion(enum WalletFeature, CWalletDB *pwalletdbIn=NULL, bool fExplicit=false)
signify that a particular wallet feature is now used. this may change nWalletVersion and nWalletMaxVe...
std::vector< unsigned char, secure_allocator< unsigned char > > CPrivKey
bool IsChange(const CTxOut &txout) const
CPubKey GenerateNewKey(uint32_t nAccountIndex, bool fInternal)
#define AssertLockHeld(cs)
static const CAmount DEFAULT_DIP0001_TRANSACTION_MINFEE
DBErrors ZapWalletTx(std::vector< CWalletTx > &vWtx)
CAmount GetBalance() const
boost::signals2::signal< void(CWallet *wallet, const CTxDestination &address, const std::string &label, bool isMine, const std::string &purpose, ChangeType status)> NotifyAddressBookChanged
size_t KeypoolCountInternalKeys()
bool GetKeyFromPool(CPubKey &key, bool fInternal)
bool CreateTransaction(const std::vector< CRecipient > &vecSend, CWalletTx &wtxNew, CReserveKey &reservekey, CAmount &nFeeRet, int &nChangePosRet, std::string &strFailReason, const CCoinControl *coinControl=NULL, bool sign=true, AvailableCoinsType nCoinType=ALL_COINS, bool fUseInstantSend=false)
CAmount nDenomConfCreditCached
bool LoadKeyMetadata(const CPubKey &pubkey, const CKeyMetadata &metadata)
Load metadata (used by LoadWallet)
int64_t GetOldestKeyPoolTime()
CAmount nAvailableWatchCreditCached
uint64_t nEntryNo
position in ordered transaction list
std::list< CAccountingEntry > laccentries
bool fDenomUnconfCreditCached
CAmount nDenomUnconfCreditCached
bool AddWatchOnly(const CScript &dest)
Adds a watch-only address to the store, and saves it to disk.
std::map< CKeyID, CKeyMetadata > mapKeyMetadata
bool SetHDChain(const CHDChain &chain, bool memonly)
void UnlockCoin(COutPoint &output)
bool RemoveWatchOnly(const CScript &dest)
CWalletTx(const CWallet *pwalletIn, const CTransaction &txIn)
CAmount GetUnconfirmedWatchOnlyBalance() const
const_iterator begin() const
static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE
Largest (in bytes) free transaction we're willing to create.
int64_t GetTxTime() const
CAmount GetCredit(const CTxOut &txout, const isminefilter &filter) const
bool SetMaxVersion(int nVersion)
change which version we're allowed to upgrade to (note that this does not immediately imply upgrading...
std::vector< char > _ssExtra
boost::signals2::signal< void(const std::string &title, int nProgress)> ShowProgress
bool HaveKey(const CKeyID &address) const
HaveKey implementation that also checks the mapHdPubKeys.
float GetAverageAnonymizedRounds() const
static CFeeRate fallbackFee
bool fLargeWorkInvalidChainFound
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
unsigned int nTimeSmart
time received by this node
bool GetDestData(const CTxDestination &dest, const std::string &key, std::string *value) const
Look up a destination data tuple in the store, return true if found false otherwise.
bool fAnonymizableTallyCachedNonDenom
std::vector< uint256 > ResendWalletTransactionsBefore(int64_t nTime, CConnman *connman)
bool ConvertList(std::vector< CTxIn > vecTxIn, std::vector< CAmount > &vecAmounts)
static CAmount GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarget, const CTxMemPool &pool)
static const CAmount DEFAULT_TRANSACTION_MAXFEE
-maxtxfee default
void GetAllReserveKeys(std::set< CKeyID > &setAddress) const
bool bSpendZeroConfChange
static const bool DEFAULT_USE_HD_WALLET
if set, all keys will be derived by using BIP39/BIP44
CAmount GetDebit(const isminefilter &filter) const
filter decides which addresses will count towards the debit
std::vector< std::pair< std::string, std::string > > vOrderForm
static const CAmount CENT
static const CAmount DEFAULT_LEGACY_TRANSACTION_MINFEE
-mintxfee default
static const bool DEFAULT_SEND_FREE_TRANSACTIONS
Default for -sendfreetransactions.
bool SetCryptedHDChain(const CHDChain &chain, bool memonly)
bool fImmatureWatchCreditCached
static const CAmount DEFAULT_LEGACY_FALLBACK_FEE
-fallbackfee default
void GetAmounts(std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, CAmount &nFee, std::string &strSentAccount, const isminefilter &filter) const
std::map< CKeyID, CHDPubKey > mapHdPubKeys
CWalletTx(const CWallet *pwalletIn, const CMerkleTx &txIn)
CAmount GetDebit(const CTxIn &txin, const isminefilter &filter) const
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.
bool IsEquivalentTo(const CWalletTx &tx) const
bool IsDenominatedAmount(CAmount nInputAmount) const
void AddToSpends(const COutPoint &outpoint, const uint256 &wtxid)
void MarkConflicted(const uint256 &hashBlock, const uint256 &hashTx)
DBErrors LoadWallet(bool &fFirstRunRet)
bool CreateCollateralTransaction(CMutableTransaction &txCollateral, std::string &strReason)
bool EraseDestData(const CTxDestination &dest, const std::string &key)
Erases a destination data tuple in the store and on disk.
bool SelectCoinsGrouppedByAddresses(std::vector< CompactTallyItem > &vecTallyRet, bool fSkipDenominated=true, bool fAnonymizable=true, bool fSkipUnconfirmed=true) const
static const CAmount nHighTransactionMaxFeeWarning
-maxtxfee will warn if called with a higher fee than this amount (in satoshis)
std::string strFromAccount
size_t KeypoolCountExternalKeys()
static void WriteOrderPos(const int64_t &nOrderPos, mapValue_t &mapValue)
bool AddHDPubKey(const CExtPubKey &extPubKey, bool fInternal)
Adds a HDPubKey into the wallet(database)
void Init(const CWallet *pwalletIn)
std::set< COutPoint > setLockedCoins
bool GetReservedKey(CPubKey &pubkey, bool fInternalIn)
CAmount nImmatureWatchCreditCached
int ScanForWalletTransactions(CBlockIndex *pindexStart, bool fUpdate=false)
static vector< COutput > vCoins
bool IsCollateralAmount(CAmount nInputAmount) const
int GetOutpointPrivateSendRounds(const COutPoint &outpoint) const
bool GetBudgetSystemCollateralTX(CTransaction &tx, uint256 hash, CAmount amount, bool fUseInstantSend)
bool EncryptWallet(const SecureString &strWalletPassphrase)
isminetype IsMine(const CTxIn &txin) const
void ResetRequestCount(const uint256 &hash)
void MarkDirty()
make sure balances are recalculated
void GetScriptForMining(boost::shared_ptr< CReserveScript > &script)
static bool Verify(const std::string &walletFile, std::string &warningString, std::string &errorString)
Verify the wallet database and perform salvage if required.
void ResendWalletTransactions(int64_t nBestBlockTime, CConnman *connman)
CAmount GetDenominatedBalance(bool unconfirmed=false) const
void GetAccountAmounts(const std::string &strAccount, CAmount &nReceived, CAmount &nSent, CAmount &nFee, const isminefilter &filter) const
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
MasterKeyMap mapMasterKeys
void ReacceptWalletTransactions()
bool LoadKey(const CKey &key, const CPubKey &pubkey)
Adds a key to the store, without saving it to disk (used by LoadWallet)
std::vector< CompactTallyItem > vecAnonymizableTallyCached
#define LIMITED_STRING(obj, n)
iterator insert(iterator it, const char &x=char())
std::map< uint256, int > mapRequestCount
std::map< CTxDestination, CAmount > GetAddressBalances()
int64_t atoi64(const char *psz)
unsigned int fTimeReceivedIsTxTime
std::string i64tostr(int64_t n)
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
std::vector< CompactTallyItem > vecAnonymizableTallyCachedNonDenom
bool FundTransaction(CMutableTransaction &tx, CAmount &nFeeRet, int &nChangePosRet, std::string &strFailReason, bool includeWatching)
std::map< CTxDestination, CAddressBookData > mapAddressBook
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
bool IsDenominated(const COutPoint &outpoint) const
bool fAvailableCreditCached
bool GetMasternodeOutpointAndKeys(COutPoint &outpointRet, CPubKey &pubKeyRet, CKey &keyRet, std::string strTxHash="", std::string strOutputIndex="")
Get 1000DASH output and keys which can be used for the Masternode.
void SerializationOp(Stream &s, Operation ser_action, int nType, int nVersion)
CTxDestination destination
static CAmount GetRequiredFee(unsigned int nTxBytes)
bool LoadWatchOnly(const CScript &dest)
Adds a watch-only address to the store, without saving it to disk (used by LoadWallet) ...
bool WriteToDisk(CWalletDB *pwalletdb)
static const CAmount DEFAULT_TRANSACTION_FEE
-paytxfee default
bool LoadHDPubKey(const CHDPubKey &hdPubKey)
loads a HDPubKey into the wallets memory
bool fImmatureCreditCached
bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector< unsigned char > &vchCryptedSecret)
Adds an encrypted key to the store, and saves it to disk.
std::set< int64_t > setExternalKeyPool
void LockCoin(COutPoint &output)
void BindWallet(CWallet *pwalletIn)
void ListLockedCoins(std::vector< COutPoint > &vOutpts)
CReserveKey(CWallet *pwalletIn)
void Inventory(const uint256 &hash)
std::multimap< COutPoint, uint256 > TxSpends
CAmount GetImmatureBalance() const
CAmount nWatchCreditCached
void SyncMetaData(std::pair< TxSpends::iterator, TxSpends::iterator >)
int GetBlocksToMaturity() const
int GetDepthInMainChain(const CBlockIndex *&pindexRet, bool enableIX=true) const
CWallet(const std::string &strWalletFileIn)
std::set< int64_t > setInternalKeyPool
int64_t nKeysLeftSinceAutoBackup
CWalletTx(const CWallet *pwalletIn)
void LoadKeyPool(int nIndex, const CKeyPool &keypool)
bool RelayWalletTransaction(CConnman *connman, std::string strCommand="tx")
CAmount GetAnonymizedCredit(bool fUseCache=true) const
void GetKeyBirthTimes(std::map< CKeyID, int64_t > &mapKeyBirth) const
bool SetDefaultKey(const CPubKey &vchPubKey)
CAmount GetNormalizedAnonymizedBalance() const
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey)
Adds a key to the store, and saves it to disk.
CAmount GetAvailableWatchOnlyCredit(const bool &fUseCache=true) const
std::set< std::set< CTxDestination > > GetAddressGroupings()
std::map< std::string, std::string > mapValue_t
int GetRequestCount() const
void SyncTransaction(const CTransaction &tx, const CBlock *pblock)
void AvailableCoins(std::vector< COutput > &vCoins, bool fOnlyConfirmed=true, const CCoinControl *coinControl=NULL, bool fIncludeZeroValue=false, AvailableCoinsType nCoinType=ALL_COINS, bool fUseInstantSend=false) const