Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show First 20 Lines • Show All 228 Lines • ▼ Show 20 Lines | public: | ||||
void SetMerkleBranch(const CBlockIndex *pIndex, int posInBlock); | void SetMerkleBranch(const CBlockIndex *pIndex, int posInBlock); | ||||
/** | /** | ||||
* Return depth of transaction in blockchain: | * Return depth of transaction in blockchain: | ||||
* <0 : conflicts with a transaction this deep in the blockchain | * <0 : conflicts with a transaction this deep in the blockchain | ||||
* 0 : in memory pool, waiting to be included in a block | * 0 : in memory pool, waiting to be included in a block | ||||
* >=1 : this many blocks deep in the main chain | * >=1 : this many blocks deep in the main chain | ||||
*/ | */ | ||||
int GetDepthInMainChain() const; | int GetDepthInMainChain() const EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
bool IsInMainChain() const { return GetDepthInMainChain() > 0; } | bool IsInMainChain() const EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | ||||
return GetDepthInMainChain() > 0; | |||||
} | |||||
/** | /** | ||||
* @return number of blocks to maturity for this transaction: | * @return number of blocks to maturity for this transaction: | ||||
* 0 : is not a coinbase transaction, or is a mature coinbase transaction | * 0 : is not a coinbase transaction, or is a mature coinbase transaction | ||||
* >0 : is a coinbase transaction which matures in this many blocks | * >0 : is a coinbase transaction which matures in this many blocks | ||||
*/ | */ | ||||
int GetBlocksToMaturity() const; | int GetBlocksToMaturity() const EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
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; } | ||||
TxId GetId() const { return tx->GetId(); } | TxId GetId() const { return tx->GetId(); } | ||||
bool IsCoinBase() const { return tx->IsCoinBase(); } | bool IsCoinBase() const { return tx->IsCoinBase(); } | ||||
bool IsImmatureCoinBase() const; | bool IsImmatureCoinBase() const EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
}; | }; | ||||
// Get the marginal bytes of spending the specified output | // Get the marginal bytes of spending the specified output | ||||
int CalculateMaximumSignedInputSize(const CTxOut &txout, | int CalculateMaximumSignedInputSize(const CTxOut &txout, | ||||
const CWallet *pwallet); | const CWallet *pwallet); | ||||
/** | /** | ||||
* 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 | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | public: | ||||
void BindWallet(CWallet *pwalletIn) { | void BindWallet(CWallet *pwalletIn) { | ||||
pwallet = pwalletIn; | pwallet = pwalletIn; | ||||
MarkDirty(); | MarkDirty(); | ||||
} | } | ||||
//! filter decides which addresses will count towards the debit | //! filter decides which addresses will count towards the debit | ||||
Amount GetDebit(const isminefilter &filter) const; | Amount GetDebit(const isminefilter &filter) const; | ||||
Amount GetCredit(const isminefilter &filter) const; | Amount GetCredit(const isminefilter &filter) const | ||||
Amount GetImmatureCredit(bool fUseCache = true) const; | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
Amount GetAvailableCredit(bool fUseCache = true) const; | Amount GetImmatureCredit(bool fUseCache = true) const | ||||
Amount GetImmatureWatchOnlyCredit(const bool fUseCache = true) const; | EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
Amount GetAvailableWatchOnlyCredit(const bool fUseCache = true) const; | Amount GetAvailableCredit(bool fUseCache = true) const | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
Amount GetImmatureWatchOnlyCredit(const bool fUseCache = true) const | |||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
Amount GetAvailableWatchOnlyCredit(const bool fUseCache = true) const | |||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
Amount GetChange() const; | Amount GetChange() const; | ||||
// Get the marginal bytes if spending the specified output from this | // Get the marginal bytes if spending the specified output from this | ||||
// transaction | // transaction | ||||
int GetSpendSize(unsigned int out) const { | int GetSpendSize(unsigned int out) const { | ||||
return CalculateMaximumSignedInputSize(tx->vout[out], pwallet); | return CalculateMaximumSignedInputSize(tx->vout[out], pwallet); | ||||
} | } | ||||
void GetAmounts(std::list<COutputEntry> &listReceived, | void GetAmounts(std::list<COutputEntry> &listReceived, | ||||
std::list<COutputEntry> &listSent, Amount &nFee, | std::list<COutputEntry> &listSent, Amount &nFee, | ||||
std::string &strSentAccount, | std::string &strSentAccount, | ||||
const isminefilter &filter) const; | const isminefilter &filter) const; | ||||
bool IsFromMe(const isminefilter &filter) const { | bool IsFromMe(const isminefilter &filter) const { | ||||
return GetDebit(filter) > Amount::zero(); | return GetDebit(filter) > Amount::zero(); | ||||
} | } | ||||
// True if only scriptSigs are different | // True if only scriptSigs are different | ||||
bool IsEquivalentTo(const CWalletTx &tx) const; | bool IsEquivalentTo(const CWalletTx &tx) const; | ||||
bool InMempool() const; | bool InMempool() const; | ||||
bool IsTrusted() const; | bool IsTrusted() const EXCLUSIVE_LOCKS_REQUIRED(cs_main); | ||||
int64_t GetTxTime() const; | int64_t GetTxTime() const; | ||||
// RelayWalletTransaction may only be called if fBroadcastTransactions! | // RelayWalletTransaction may only be called if fBroadcastTransactions! | ||||
bool RelayWalletTransaction(CConnman *connman); | bool RelayWalletTransaction(CConnman *connman) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
/** | /** | ||||
* Pass this transaction to the mempool. Fails if absolute fee exceeds | * Pass this transaction to the mempool. Fails if absolute fee exceeds | ||||
* absurd fee. | * absurd fee. | ||||
*/ | */ | ||||
bool AcceptToMemoryPool(const Amount nAbsurdFee, CValidationState &state); | bool AcceptToMemoryPool(const Amount nAbsurdFee, CValidationState &state) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
std::set<TxId> GetConflicts() const; | std::set<TxId> GetConflicts() const; | ||||
}; | }; | ||||
class COutput { | class COutput { | ||||
public: | public: | ||||
const CWalletTx *tx; | const CWalletTx *tx; | ||||
int i; | int i; | ||||
▲ Show 20 Lines • Show All 354 Lines • ▼ Show 20 Lines | public: | ||||
void AvailableCoins(std::vector<COutput> &vCoins, bool fOnlySafe = true, | void AvailableCoins(std::vector<COutput> &vCoins, bool fOnlySafe = true, | ||||
const CCoinControl *coinControl = nullptr, | const CCoinControl *coinControl = nullptr, | ||||
const Amount nMinimumAmount = SATOSHI, | const Amount nMinimumAmount = SATOSHI, | ||||
const Amount nMaximumAmount = MAX_MONEY, | const Amount nMaximumAmount = MAX_MONEY, | ||||
const Amount nMinimumSumAmount = MAX_MONEY, | const Amount nMinimumSumAmount = MAX_MONEY, | ||||
const uint64_t nMaximumCount = 0, | const uint64_t nMaximumCount = 0, | ||||
const int nMinDepth = 0, | const int nMinDepth = 0, | ||||
const int nMaxDepth = 9999999) const | const int nMaxDepth = 9999999) const | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | EXCLUSIVE_LOCKS_REQUIRED(cs_main, cs_wallet); | ||||
/** | /** | ||||
* Return list of available coins and locked coins grouped by non-change | * Return list of available coins and locked coins grouped by non-change | ||||
* output address. | * output address. | ||||
*/ | */ | ||||
std::map<CTxDestination, std::vector<COutput>> ListCoins() const; | std::map<CTxDestination, std::vector<COutput>> ListCoins() const; | ||||
/** | /** | ||||
Show All 11 Lines | public: | ||||
bool SelectCoinsMinConf(const Amount nTargetValue, | bool SelectCoinsMinConf(const Amount nTargetValue, | ||||
const CoinEligibilityFilter &eligibility_filter, | const CoinEligibilityFilter &eligibility_filter, | ||||
std::vector<OutputGroup> groups, | std::vector<OutputGroup> groups, | ||||
std::set<CInputCoin> &setCoinsRet, | std::set<CInputCoin> &setCoinsRet, | ||||
Amount &nValueRet, | Amount &nValueRet, | ||||
const CoinSelectionParams &coin_selection_params, | const CoinSelectionParams &coin_selection_params, | ||||
bool &bnb_used) const; | bool &bnb_used) const; | ||||
bool IsSpent(const COutPoint &outpoint) const; | bool IsSpent(const COutPoint &outpoint) const | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
std::vector<OutputGroup> GroupOutputs(const std::vector<COutput> &outputs, | std::vector<OutputGroup> GroupOutputs(const std::vector<COutput> &outputs, | ||||
bool single_coin) const; | bool single_coin) const; | ||||
bool IsLockedCoin(const COutPoint &outpoint) const | bool IsLockedCoin(const COutPoint &outpoint) const | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||||
void LockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | void LockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||||
void UnlockCoin(const COutPoint &output) | void UnlockCoin(const COutPoint &output) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | int64_t RescanFromTime(int64_t startTime, | ||||
const WalletRescanReserver &reserver, bool update); | const WalletRescanReserver &reserver, bool update); | ||||
CBlockIndex *ScanForWalletTransactions(CBlockIndex *pindexStart, | CBlockIndex *ScanForWalletTransactions(CBlockIndex *pindexStart, | ||||
CBlockIndex *pindexStop, | CBlockIndex *pindexStop, | ||||
const WalletRescanReserver &reserver, | const WalletRescanReserver &reserver, | ||||
bool fUpdate = false); | bool fUpdate = false); | ||||
void TransactionRemovedFromMempool(const CTransactionRef &ptx) override; | void TransactionRemovedFromMempool(const CTransactionRef &ptx) override; | ||||
void ReacceptWalletTransactions(); | void ReacceptWalletTransactions(); | ||||
void ResendWalletTransactions(int64_t nBestBlockTime, | void ResendWalletTransactions(int64_t nBestBlockTime, | ||||
CConnman *connman) override; | CConnman *connman) override | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
// ResendWalletTransactionsBefore may only be called if | // ResendWalletTransactionsBefore may only be called if | ||||
// fBroadcastTransactions! | // fBroadcastTransactions! | ||||
std::vector<uint256> ResendWalletTransactionsBefore(int64_t nTime, | std::vector<uint256> ResendWalletTransactionsBefore(int64_t nTime, | ||||
CConnman *connman); | CConnman *connman) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
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; | ||||
Amount GetLegacyBalance(const isminefilter &filter, int minDepth, | Amount GetLegacyBalance(const isminefilter &filter, int minDepth, | ||||
const std::string *account) const; | const std::string *account) const; | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | public: | ||||
void MarkReserveKeysAsUsed(int64_t keypool_id) | void MarkReserveKeysAsUsed(int64_t keypool_id) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||||
const std::map<CKeyID, int64_t> &GetAllReserveKeys() const { | const std::map<CKeyID, int64_t> &GetAllReserveKeys() const { | ||||
return m_pool_key_to_index; | return m_pool_key_to_index; | ||||
} | } | ||||
std::set<std::set<CTxDestination>> GetAddressGroupings() | std::set<std::set<CTxDestination>> GetAddressGroupings() | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); | ||||
std::map<CTxDestination, Amount> GetAddressBalances(); | std::map<CTxDestination, Amount> GetAddressBalances() | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main); | |||||
std::set<CTxDestination> GetLabelAddresses(const std::string &label) const; | std::set<CTxDestination> GetLabelAddresses(const std::string &label) const; | ||||
isminetype IsMine(const CTxIn &txin) const; | isminetype IsMine(const CTxIn &txin) const; | ||||
/** | /** | ||||
* Returns amount of debit if the input matches the filter, otherwise | * Returns amount of debit if the input matches the filter, otherwise | ||||
* returns 0 | * returns 0 | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | public: | ||||
bool SetHDMasterKey(const CPubKey &key); | bool SetHDMasterKey(const CPubKey &key); | ||||
/** | /** | ||||
* Blocks until the wallet state is up-to-date to /at least/ the current | * Blocks until the wallet state is up-to-date to /at least/ the current | ||||
* chain at the time this function is entered. | * chain at the time this function is entered. | ||||
* Obviously holding cs_main/cs_wallet when going into this call may cause | * Obviously holding cs_main/cs_wallet when going into this call may cause | ||||
* deadlock | * deadlock | ||||
*/ | */ | ||||
void BlockUntilSyncedToCurrentChain() LOCKS_EXCLUDED(cs_wallet); | void BlockUntilSyncedToCurrentChain() LOCKS_EXCLUDED(cs_main, cs_wallet); | ||||
/** | /** | ||||
* Explicitly make the wallet learn the related scripts for outputs to the | * Explicitly make the wallet learn the related scripts for outputs to the | ||||
* given key. This is purely to make the wallet file compatible with older | * given key. This is purely to make the wallet file compatible with older | ||||
* software, as CBasicKeyStore automatically does this implicitly for all | * software, as CBasicKeyStore automatically does this implicitly for all | ||||
* keys now. | * keys now. | ||||
*/ | */ | ||||
void LearnRelatedScripts(const CPubKey &key, OutputType); | void LearnRelatedScripts(const CPubKey &key, OutputType); | ||||
▲ Show 20 Lines • Show All 126 Lines • Show Last 20 Lines |