Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show First 20 Lines • Show All 238 Lines • ▼ Show 20 Lines | public: | ||||
*/ | */ | ||||
bool AcceptToMemoryPool(const Amount nAbsurdFee, CValidationState &state); | bool AcceptToMemoryPool(const Amount nAbsurdFee, CValidationState &state); | ||||
bool hashUnset() const { | bool hashUnset() const { | ||||
return (hashBlock.IsNull() || hashBlock == ABANDON_HASH); | return (hashBlock.IsNull() || hashBlock == ABANDON_HASH); | ||||
} | } | ||||
bool isAbandoned() const { return (hashBlock == ABANDON_HASH); } | bool isAbandoned() const { return (hashBlock == ABANDON_HASH); } | ||||
void setAbandoned() { hashBlock = ABANDON_HASH; } | void setAbandoned() { hashBlock = ABANDON_HASH; } | ||||
const uint256 &GetId() const { return tx->GetHash(); } | const TxHash &GetHash() const { return tx->GetHash(); } | ||||
bool IsCoinBase() const { return tx->IsCoinBase(); } | bool IsCoinBase() const { return tx->IsCoinBase(); } | ||||
}; | }; | ||||
/** | /** | ||||
* A transaction with a bunch of additional info that only the owner cares | * A transaction with a bunch of additional info that only the owner cares | ||||
* about. It includes any unrecorded transactions needed to link it back to the | * about. It includes any unrecorded transactions needed to link it back to the | ||||
* block chain. | * block chain. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 164 Lines • ▼ Show 20 Lines | public: | ||||
bool InMempool() const; | bool InMempool() const; | ||||
bool IsTrusted() const; | bool IsTrusted() const; | ||||
int64_t GetTxTime() const; | int64_t GetTxTime() const; | ||||
int GetRequestCount() const; | int GetRequestCount() const; | ||||
bool RelayWalletTransaction(CConnman *connman); | bool RelayWalletTransaction(CConnman *connman); | ||||
std::set<uint256> GetConflicts() const; | std::set<TxHash> GetConflicts() const; | ||||
}; | }; | ||||
class COutput { | class COutput { | ||||
public: | public: | ||||
const CWalletTx *tx; | const CWalletTx *tx; | ||||
int i; | int i; | ||||
int nDepth; | int nDepth; | ||||
bool fSpendable; | bool fSpendable; | ||||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | private: | ||||
int64_t nNextResend; | int64_t nNextResend; | ||||
int64_t nLastResend; | int64_t nLastResend; | ||||
bool fBroadcastTransactions; | bool fBroadcastTransactions; | ||||
/** | /** | ||||
* Used to keep track of spent outpoints, and detect and report conflicts | * Used to keep track of spent outpoints, and detect and report conflicts | ||||
* (double-spends or mutated transactions where the mutant gets mined). | * (double-spends or mutated transactions where the mutant gets mined). | ||||
*/ | */ | ||||
typedef std::multimap<COutPoint, uint256> TxSpends; | typedef std::multimap<COutPoint, TxHash> TxSpends; | ||||
TxSpends mapTxSpends; | TxSpends mapTxSpends; | ||||
void AddToSpends(const COutPoint &outpoint, const uint256 &wtxid); | void AddToSpends(const COutPoint &outpoint, const TxHash &wtxid); | ||||
void AddToSpends(const uint256 &wtxid); | void AddToSpends(const TxHash &wtxid); | ||||
/* Mark a transaction (and its in-wallet descendants) as conflicting with a | /* Mark a transaction (and its in-wallet descendants) as conflicting with a | ||||
* particular block. */ | * particular block. */ | ||||
void MarkConflicted(const uint256 &hashBlock, const uint256 &hashTx); | void MarkConflicted(const uint256 &hashBlock, const TxHash &hashTx); | ||||
void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>); | void SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator>); | ||||
/* the HD chain data model (external chain counters) */ | /* the HD chain data model (external chain counters) */ | ||||
CHDChain hdChain; | CHDChain hdChain; | ||||
bool fFileBacked; | bool fFileBacked; | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | void SetNull() { | ||||
pwalletdbEncryption = nullptr; | pwalletdbEncryption = nullptr; | ||||
nOrderPosNext = 0; | nOrderPosNext = 0; | ||||
nNextResend = 0; | nNextResend = 0; | ||||
nLastResend = 0; | nLastResend = 0; | ||||
nTimeFirstKey = 0; | nTimeFirstKey = 0; | ||||
fBroadcastTransactions = false; | fBroadcastTransactions = false; | ||||
} | } | ||||
std::map<uint256, CWalletTx> mapWallet; | std::map<TxHash, CWalletTx> mapWallet; | ||||
std::list<CAccountingEntry> laccentries; | std::list<CAccountingEntry> laccentries; | ||||
typedef std::pair<CWalletTx *, CAccountingEntry *> TxPair; | typedef std::pair<CWalletTx *, CAccountingEntry *> TxPair; | ||||
typedef std::multimap<int64_t, TxPair> TxItems; | typedef std::multimap<int64_t, TxPair> TxItems; | ||||
TxItems wtxOrdered; | TxItems wtxOrdered; | ||||
int64_t nOrderPosNext; | int64_t nOrderPosNext; | ||||
std::map<uint256, int> mapRequestCount; | std::map<TxHash, int> mapRequestCount; | ||||
std::map<CTxDestination, CAddressBookData> mapAddressBook; | std::map<CTxDestination, CAddressBookData> mapAddressBook; | ||||
CPubKey vchDefaultKey; | CPubKey vchDefaultKey; | ||||
std::set<COutPoint> setLockedCoins; | std::set<COutPoint> setLockedCoins; | ||||
const CWalletTx *GetWalletTx(const uint256 &hash) const; | const CWalletTx *GetWalletTx(const TxHash &hash) const; | ||||
//! check whether we are allowed to upgrade (or already support) to the | //! check whether we are allowed to upgrade (or already support) to the | ||||
//! named feature | //! named feature | ||||
bool CanSupportFeature(enum WalletFeature wf) { | bool CanSupportFeature(enum WalletFeature wf) { | ||||
AssertLockHeld(cs_wallet); | AssertLockHeld(cs_wallet); | ||||
return nWalletMaxVersion >= wf; | return nWalletMaxVersion >= wf; | ||||
} | } | ||||
Show All 12 Lines | public: | ||||
* assembled. | * assembled. | ||||
*/ | */ | ||||
bool SelectCoinsMinConf( | bool SelectCoinsMinConf( | ||||
const Amount nTargetValue, int nConfMine, int nConfTheirs, | const Amount nTargetValue, int nConfMine, int nConfTheirs, | ||||
uint64_t nMaxAncestors, std::vector<COutput> vCoins, | uint64_t nMaxAncestors, std::vector<COutput> vCoins, | ||||
std::set<std::pair<const CWalletTx *, unsigned int>> &setCoinsRet, | std::set<std::pair<const CWalletTx *, unsigned int>> &setCoinsRet, | ||||
Amount &nValueRet) const; | Amount &nValueRet) const; | ||||
bool IsSpent(const uint256 &hash, unsigned int n) const; | bool IsSpent(const TxHash &hash, unsigned int n) const; | ||||
bool IsLockedCoin(uint256 hash, unsigned int n) const; | bool IsLockedCoin(TxHash hash, unsigned int n) const; | ||||
void LockCoin(const COutPoint &output); | void LockCoin(const COutPoint &output); | ||||
void UnlockCoin(const COutPoint &output); | void UnlockCoin(const COutPoint &output); | ||||
void UnlockAllCoins(); | void UnlockAllCoins(); | ||||
void ListLockedCoins(std::vector<COutPoint> &vOutpts); | void ListLockedCoins(std::vector<COutPoint> &vOutpts); | ||||
/** | /** | ||||
* keystore implementation | * keystore implementation | ||||
* Generate a new key | * Generate a new key | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | public: | ||||
bool AddToWalletIfInvolvingMe(const CTransaction &tx, | bool AddToWalletIfInvolvingMe(const CTransaction &tx, | ||||
const CBlockIndex *pIndex, int posInBlock, | const CBlockIndex *pIndex, int posInBlock, | ||||
bool fUpdate); | bool fUpdate); | ||||
CBlockIndex *ScanForWalletTransactions(CBlockIndex *pindexStart, | CBlockIndex *ScanForWalletTransactions(CBlockIndex *pindexStart, | ||||
bool fUpdate = false); | bool fUpdate = false); | ||||
void ReacceptWalletTransactions(); | void ReacceptWalletTransactions(); | ||||
void ResendWalletTransactions(int64_t nBestBlockTime, | void ResendWalletTransactions(int64_t nBestBlockTime, | ||||
CConnman *connman) override; | CConnman *connman) override; | ||||
std::vector<uint256> ResendWalletTransactionsBefore(int64_t nTime, | std::vector<TxHash> ResendWalletTransactionsBefore(int64_t nTime, | ||||
CConnman *connman); | CConnman *connman); | ||||
Amount GetBalance() const; | Amount GetBalance() const; | ||||
Amount GetUnconfirmedBalance() const; | Amount GetUnconfirmedBalance() const; | ||||
Amount GetImmatureBalance() const; | Amount GetImmatureBalance() const; | ||||
Amount GetWatchOnlyBalance() const; | Amount GetWatchOnlyBalance() const; | ||||
Amount GetUnconfirmedWatchOnlyBalance() const; | Amount GetUnconfirmedWatchOnlyBalance() const; | ||||
Amount GetImmatureWatchOnlyBalance() const; | Amount GetImmatureWatchOnlyBalance() const; | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | public: | ||||
/** Returns whether all of the inputs match the filter */ | /** Returns whether all of the inputs match the filter */ | ||||
bool IsAllFromMe(const CTransaction &tx, const isminefilter &filter) const; | bool IsAllFromMe(const CTransaction &tx, const isminefilter &filter) const; | ||||
Amount GetCredit(const CTransaction &tx, const isminefilter &filter) const; | Amount GetCredit(const CTransaction &tx, const isminefilter &filter) const; | ||||
Amount GetChange(const CTransaction &tx) const; | Amount GetChange(const CTransaction &tx) const; | ||||
void SetBestChain(const CBlockLocator &loc) override; | void SetBestChain(const CBlockLocator &loc) override; | ||||
DBErrors LoadWallet(bool &fFirstRunRet); | DBErrors LoadWallet(bool &fFirstRunRet); | ||||
DBErrors ZapWalletTx(std::vector<CWalletTx> &vWtx); | DBErrors ZapWalletTx(std::vector<CWalletTx> &vWtx); | ||||
DBErrors ZapSelectTx(std::vector<uint256> &vHashIn, | DBErrors ZapSelectTx(std::vector<TxHash> &vHashIn, | ||||
std::vector<uint256> &vHashOut); | std::vector<TxHash> &vHashOut); | ||||
bool SetAddressBook(const CTxDestination &address, | bool SetAddressBook(const CTxDestination &address, | ||||
const std::string &strName, const std::string &purpose); | const std::string &strName, const std::string &purpose); | ||||
bool DelAddressBook(const CTxDestination &address); | bool DelAddressBook(const CTxDestination &address); | ||||
void UpdatedTransaction(const uint256 &hashTx) override; | void UpdatedTransaction(const TxHash &hashTx) override; | ||||
void Inventory(const uint256 &hash) override { | void Inventory(const uint256 &hash) override { | ||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
std::map<uint256, int>::iterator mi = mapRequestCount.find(hash); | std::map<TxHash, int>::iterator mi = mapRequestCount.find(hash); | ||||
if (mi != mapRequestCount.end()) { | if (mi != mapRequestCount.end()) { | ||||
(*mi).second++; | (*mi).second++; | ||||
} | } | ||||
} | } | ||||
void GetScriptForMining(std::shared_ptr<CReserveScript> &script) override; | void GetScriptForMining(std::shared_ptr<CReserveScript> &script) override; | ||||
void ResetRequestCount(const uint256 &hash) override { | void ResetRequestCount(const uint256 &hash) override { | ||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
mapRequestCount[hash] = 0; | mapRequestCount[TxHash(hash)] = 0; | ||||
}; | }; | ||||
unsigned int GetKeyPoolSize() { | unsigned int GetKeyPoolSize() { | ||||
// setKeyPool | // setKeyPool | ||||
AssertLockHeld(cs_wallet); | AssertLockHeld(cs_wallet); | ||||
return setKeyPool.size(); | return setKeyPool.size(); | ||||
} | } | ||||
Show All 12 Lines | public: | ||||
//! understand this wallet) | //! understand this wallet) | ||||
int GetVersion() { | int GetVersion() { | ||||
LOCK(cs_wallet); | LOCK(cs_wallet); | ||||
return nWalletVersion; | return nWalletVersion; | ||||
} | } | ||||
//! Get wallet transactions that conflict with given transaction (spend same | //! Get wallet transactions that conflict with given transaction (spend same | ||||
//! outputs) | //! outputs) | ||||
std::set<uint256> GetConflicts(const uint256 &txid) const; | std::set<TxHash> GetConflicts(const TxHash &txid) const; | ||||
//! Check if a given transaction has any of its outputs spent by another | //! Check if a given transaction has any of its outputs spent by another | ||||
//! transaction in the wallet | //! transaction in the wallet | ||||
bool HasWalletSpend(const uint256 &txid) const; | bool HasWalletSpend(const TxHash &txid) const; | ||||
//! Flush wallet (bitdb flush) | //! Flush wallet (bitdb flush) | ||||
void Flush(bool shutdown = false); | void Flush(bool shutdown = false); | ||||
//! Verify the wallet database and perform salvage if required | //! Verify the wallet database and perform salvage if required | ||||
static bool Verify(); | static bool Verify(); | ||||
/** | /** | ||||
* Address book entry changed. | * Address book entry changed. | ||||
* @note called with lock cs_wallet held. | * @note called with lock cs_wallet held. | ||||
*/ | */ | ||||
boost::signals2::signal<void(CWallet *wallet, const CTxDestination &address, | boost::signals2::signal<void(CWallet *wallet, const CTxDestination &address, | ||||
const std::string &label, bool isMine, | const std::string &label, bool isMine, | ||||
const std::string &purpose, ChangeType status)> | const std::string &purpose, ChangeType status)> | ||||
NotifyAddressBookChanged; | NotifyAddressBookChanged; | ||||
/** | /** | ||||
* Wallet transaction added, removed or updated. | * Wallet transaction added, removed or updated. | ||||
* @note called with lock cs_wallet held. | * @note called with lock cs_wallet held. | ||||
*/ | */ | ||||
boost::signals2::signal<void(CWallet *wallet, const uint256 &hashTx, | boost::signals2::signal<void(CWallet *wallet, const TxHash &hashTx, | ||||
ChangeType status)> | ChangeType status)> | ||||
NotifyTransactionChanged; | NotifyTransactionChanged; | ||||
/** Show progress e.g. for rescan */ | /** Show progress e.g. for rescan */ | ||||
boost::signals2::signal<void(const std::string &title, int nProgress)> | boost::signals2::signal<void(const std::string &title, int nProgress)> | ||||
ShowProgress; | ShowProgress; | ||||
/** Watch-only address added */ | /** Watch-only address added */ | ||||
boost::signals2::signal<void(bool fHaveWatchOnly)> NotifyWatchonlyChanged; | boost::signals2::signal<void(bool fHaveWatchOnly)> NotifyWatchonlyChanged; | ||||
/** Inquire whether this wallet broadcasts transactions. */ | /** Inquire whether this wallet broadcasts transactions. */ | ||||
bool GetBroadcastTransactions() const { return fBroadcastTransactions; } | bool GetBroadcastTransactions() const { return fBroadcastTransactions; } | ||||
/** Set whether this wallet broadcasts transactions. */ | /** Set whether this wallet broadcasts transactions. */ | ||||
void SetBroadcastTransactions(bool broadcast) { | void SetBroadcastTransactions(bool broadcast) { | ||||
fBroadcastTransactions = broadcast; | fBroadcastTransactions = broadcast; | ||||
} | } | ||||
/** | /** | ||||
* Mark a transaction (and it in-wallet descendants) as abandoned so its | * Mark a transaction (and it in-wallet descendants) as abandoned so its | ||||
* inputs may be respent. | * inputs may be respent. | ||||
*/ | */ | ||||
bool AbandonTransaction(const uint256 &hashTx); | bool AbandonTransaction(const TxHash &hashTx); | ||||
/** | /** | ||||
* Mark a transaction as replaced by another transaction (e.g., BIP 125). | * Mark a transaction as replaced by another transaction (e.g., BIP 125). | ||||
*/ | */ | ||||
bool MarkReplaced(const uint256 &originalHash, const uint256 &newHash); | bool MarkReplaced(const TxHash &originalHash, const TxHash &newHash); | ||||
/* Returns the wallets help message */ | /* Returns the wallets help message */ | ||||
static std::string GetWalletHelpString(bool showDebug); | static std::string GetWalletHelpString(bool showDebug); | ||||
/** | /** | ||||
* Initializes the wallet, returns a new CWallet instance or a null pointer | * Initializes the wallet, returns a new CWallet instance or a null pointer | ||||
* in case of an error. | * in case of an error. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |