Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

Actions

Classes

struct  CompareByPriority
 

Functions

static void ApproximateBestSubset (const std::vector< CInputCoin > &vValue, const CAmount &nTotalLower, const CAmount &nTargetValue, std::vector< char > &vfBest, CAmount &nBest, int iterations=1000)
 
bool less_then_denom (const COutput &out1, const COutput &out2)
 
static int64_t GetOldestKeyInPool (const std::set< int64_t > &setKeyPool, WalletBatch &batch)
 
std::unordered_set< const CWalletTx *, WalletTxHasherCWallet::GetSpendableTXs () const
 
CAmount CWallet::GetBalance () const
 
CAmount CWallet::GetAnonymizableBalance (bool fSkipDenominated=false, bool fSkipUnconfirmed=true) const
 
CAmount CWallet::GetAnonymizedBalance (const CCoinControl *coinControl=nullptr) const
 
float CWallet::GetAverageAnonymizedRounds () const
 
CAmount CWallet::GetNormalizedAnonymizedBalance () const
 
CAmount CWallet::GetDenominatedBalance (bool unconfirmed=false) const
 
CAmount CWallet::GetUnconfirmedBalance () const
 
CAmount CWallet::GetImmatureBalance () const
 
CAmount CWallet::GetWatchOnlyBalance () const
 
CAmount CWallet::GetUnconfirmedWatchOnlyBalance () const
 
CAmount CWallet::GetImmatureWatchOnlyBalance () const
 
CAmount CWallet::GetLegacyBalance (const isminefilter &filter, int minDepth, const std::string *account, const bool fAddLocked) const
 
CAmount CWallet::GetAvailableBalance (const CCoinControl *coinControl=nullptr) const
 
void CWallet::AvailableCoins (std::vector< COutput > &vCoins, bool fOnlySafe=true, const CCoinControl *coinControl=nullptr, const CAmount &nMinimumAmount=1, const CAmount &nMaximumAmount=MAX_MONEY, const CAmount &nMinimumSumAmount=MAX_MONEY, const uint64_t nMaximumCount=0, const int nMinDepth=0, const int nMaxDepth=9999999) const
 populate vCoins with vector of available COutputs. More...
 
std::map< CTxDestination, std::vector< COutput > > CWallet::ListCoins () const
 Return list of available coins and locked coins grouped by non-change output address. More...
 
const CTxOutCWallet::FindNonChangeParentOutput (const CTransaction &tx, int output) const
 Find non-change parent output. More...
 
void CWallet::InitPrivateSendSalt ()
 Fetches PrivateSend salt from database or generates and saves a new one if no salt was found in the db. More...
 
bool CWallet::SelectCoinsMinConf (const CAmount &nTargetValue, int nConfMine, int nConfTheirs, uint64_t nMaxAncestors, std::vector< COutput > vCoins, std::set< CInputCoin > &setCoinsRet, CAmount &nValueRet, CoinType nCoinType=CoinType::ALL_COINS) const
 Shuffle and select coins until nTargetValue is reached while avoiding small change; This method is stochastic for some inputs and upon completion the coin set and corresponding actual target value is assembled. More...
 
bool CWallet::SelectCoins (const std::vector< COutput > &vAvailableCoins, const CAmount &nTargetValue, std::set< CInputCoin > &setCoinsRet, CAmount &nValueRet, const CCoinControl *coinControl=nullptr) const
 Select a set of coins such that nValueRet >= nTargetValue and at least all coins from coinControl are selected; Never select unconfirmed coins if they are not ours. More...
 
bool CWallet::FundTransaction (CMutableTransaction &tx, CAmount &nFeeRet, int &nChangePosInOut, std::string &strFailReason, bool lockUnspents, const std::set< int > &setSubtractFeeFromOutputs, CCoinControl)
 Insert additional inputs into the transaction by calling CreateTransaction();. More...
 
bool CWallet::SelectPSInOutPairsByDenominations (int nDenom, CAmount nValueMax, std::vector< std::pair< CTxDSIn, CTxOut > > &vecPSInOutPairsRet)
 
bool CWallet::SelectCoinsGroupedByAddresses (std::vector< CompactTallyItem > &vecTallyRet, bool fSkipDenominated=true, bool fAnonymizable=true, bool fSkipUnconfirmed=true, int nMaxOupointsPerAddress=-1) const
 
bool CWallet::SelectDenominatedAmounts (CAmount nValueMax, std::set< CAmount > &setAmountsRet) const
 
bool CWallet::GetCollateralTxDSIn (CTxDSIn &txdsinRet, CAmount &nValueRet) const
 
bool CWallet::GetMasternodeOutpointAndKeys (COutPoint &outpointRet, CPubKey &pubKeyRet, CKey &keyRet, const std::string &strTxHash="", const std::string &strOutputIndex="")
 Get 1000DASH output and keys which can be used for the Masternode. More...
 
bool CWallet::GetOutpointAndKeysFromOutput (const COutput &out, COutPoint &outpointRet, CPubKey &pubKeyRet, CKey &keyRet)
 Extract txin information and keys from output. More...
 
int CWallet::CountInputsWithAmount (CAmount nInputAmount) const
 
bool CWallet::HasCollateralInputs (bool fOnlyConfirmed=true) const
 
bool CWallet::CreateCollateralTransaction (CMutableTransaction &txCollateral, std::string &strReason)
 
bool CWallet::GetBudgetSystemCollateralTX (CWalletTx &tx, uint256 hash, CAmount amount, const COutPoint &outpoint=COutPoint())
 
bool CWallet::CreateTransaction (const std::vector< CRecipient > &vecSend, CWalletTx &wtxNew, CReserveKey &reservekey, CAmount &nFeeRet, int &nChangePosInOut, std::string &strFailReason, const CCoinControl &coin_control, bool sign=true, int nExtraPayloadSize=0)
 Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also create the change output, when needed. More...
 
bool CWallet::CommitTransaction (CWalletTx &wtxNew, CReserveKey &reservekey, CConnman *connman, CValidationState &state)
 Call after CreateTransaction unless you want to abort. More...
 
void CWallet::ListAccountCreditDebit (const std::string &strAccount, std::list< CAccountingEntry > &entries)
 
bool CWallet::AddAccountingEntry (const CAccountingEntry &)
 
bool CWallet::AddAccountingEntry (const CAccountingEntry &, WalletBatch *batch)
 
DBErrors CWallet::LoadWallet (bool &fFirstRunRet)
 
void CWallet::AutoLockMasternodeCollaterals ()
 
DBErrors CWallet::ZapSelectTx (std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut)
 
DBErrors CWallet::ZapWalletTx (std::vector< CWalletTx > &vWtx)
 
bool CWallet::SetAddressBook (const CTxDestination &address, const std::string &strName, const std::string &purpose)
 
bool CWallet::DelAddressBook (const CTxDestination &address)
 
const std::string & CWallet::GetAccountName (const CScript &scriptPubKey) const
 
bool CWallet::NewKeyPool ()
 Mark old keypool keys as used, and generate all new keys. More...
 
size_t CWallet::KeypoolCountExternalKeys ()
 
void CWallet::LoadKeyPool (int64_t nIndex, const CKeyPool &keypool)
 
size_t CWallet::KeypoolCountInternalKeys ()
 
bool CWallet::TopUpKeyPool (unsigned int kpSize=0)
 
void CWallet::ReserveKeyFromKeyPool (int64_t &nIndex, CKeyPool &keypool, bool fInternal)
 
void CWallet::KeepKey (int64_t nIndex)
 
void CWallet::ReturnKey (int64_t nIndex, bool fInternal, const CPubKey &pubkey)
 
bool CWallet::GetKeyFromPool (CPubKey &key, bool fInternal)
 
int64_t CWallet::GetOldestKeyPoolTime ()
 
std::map< CTxDestination, CAmountCWallet::GetAddressBalances ()
 
std::set< std::set< CTxDestination > > CWallet::GetAddressGroupings ()
 
std::set< CTxDestinationCWallet::GetAccountAddresses (const std::string &strAccount) const
 
bool CReserveKey::GetReservedKey (CPubKey &pubkey, bool fInternalIn)
 
void CReserveKey::KeepKey ()
 
void CReserveKey::ReturnKey ()
 
void CWallet::MarkReserveKeysAsUsed (int64_t keypool_id)
 Marks all keys in the keypool up to and including reserve_key as used. More...
 
void CWallet::GetScriptForMining (std::shared_ptr< CReserveScript > &script)
 
void CWallet::LockCoin (const COutPoint &output)
 
void CWallet::UnlockCoin (const COutPoint &output)
 
void CWallet::UnlockAllCoins ()
 
bool CWallet::IsLockedCoin (uint256 hash, unsigned int n) const
 
void CWallet::ListLockedCoins (std::vector< COutPoint > &vOutpts) const
 
void CWallet::ListProTxCoins (std::vector< COutPoint > &vOutpts)
 

Detailed Description

Function Documentation

◆ AddAccountingEntry() [1/2]

bool CWallet::AddAccountingEntry ( const CAccountingEntry acentry)

Definition at line 4140 of file wallet.cpp.

References CWallet::database.

Referenced by CWallet::AccountMove().

◆ AddAccountingEntry() [2/2]

bool CWallet::AddAccountingEntry ( const CAccountingEntry acentry,
WalletBatch batch 
)

◆ ApproximateBestSubset()

static void ApproximateBestSubset ( const std::vector< CInputCoin > &  vValue,
const CAmount nTotalLower,
const CAmount nTargetValue,
std::vector< char > &  vfBest,
CAmount nBest,
int  iterations = 1000 
)
static

Definition at line 2949 of file wallet.cpp.

References FastRandomContext::randbool().

Referenced by CWallet::SelectCoinsMinConf().

◆ AutoLockMasternodeCollaterals()

void CWallet::AutoLockMasternodeCollaterals ( )

◆ AvailableCoins()

◆ CommitTransaction()

◆ CountInputsWithAmount()

int CWallet::CountInputsWithAmount ( CAmount  nInputAmount) const

Definition at line 3559 of file wallet.cpp.

References cs_main, CWallet::cs_wallet, LOCK2, CWallet::mapWallet, and CWallet::setWalletUTXO.

◆ CreateCollateralTransaction()

◆ CreateTransaction()

bool CWallet::CreateTransaction ( const std::vector< CRecipient > &  vecSend,
CWalletTx wtxNew,
CReserveKey reservekey,
CAmount nFeeRet,
int &  nChangePosInOut,
std::string &  strFailReason,
const CCoinControl coin_control,
bool  sign = true,
int  nExtraPayloadSize = 0 
)

Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also create the change output, when needed.

Note
passing nChangePosInOut as -1 will result in setting a random position

Definition at line 3658 of file wallet.cpp.

References _(), CWallet::AvailableCoins(), CWalletTx::BindWallet(), CTxMemPool::CalculateMemPoolAncestors(), chainActive, CTxMemPool::cs, cs_main, CWallet::cs_wallet, EstimationResult::decay, DEFAULT_ANCESTOR_LIMIT, DEFAULT_ANCESTOR_SIZE_LIMIT, DEFAULT_DESCENDANT_LIMIT, DEFAULT_DESCENDANT_SIZE_LIMIT, DEFAULT_WALLET_REJECT_LONG_CHAINS, FeeCalculation::desiredTarget, CCoinControl::destChange, dustRelayFee, EstimatorBucket::end, FeeCalculation::est, EstimationResult::fail, feeEstimator, CWalletTx::fFromMe, CWalletTx::fTimeReceivedIsTxTime, gArgs, ArgsManager::GetArg(), ArgsManager::GetBoolArg(), GetDiscardRate(), CFeeRate::GetFee(), CPubKey::GetID(), GetMinimumFee(), GetRandInt(), CReserveKey::GetReservedKey(), GetScriptForDestination(), GetSerializeSize(), GetSizeOfCompactSize(), CChain::Height(), EstimatorBucket::inMempool, IsDust(), EstimatorBucket::leftMempool, LOCK, LOCK2, LOCKTIME_THRESHOLD, LogPrintf, CCoinControl::m_discard_feerate, MakeTransactionRef(), CWalletTx::mapValue, MAX_STANDARD_TX_SIZE, mempool, minRelayTxFee, CCoinControl::nCoinType, CMutableTransaction::nLockTime, CTxOut::nValue, ONLY_FULLY_MIXED, ONLY_NONDENOMINATED, EstimationResult::pass, ProduceSignature(), PROTOCOL_VERSION, FeeCalculation::reason, FeeCalculation::returnedTarget, CReserveKey::ReturnKey(), CWallet::SelectCoins(), CTxIn::SEQUENCE_FINAL, SER_NETWORK, CMerkleTx::SetTx(), SIGHASH_ALL, EstimatorBucket::start, StringForFeeReason(), EstimatorBucket::totalConfirmed, CMerkleTx::tx, UpdateTransaction(), CMutableTransaction::vin, CMutableTransaction::vout, and EstimatorBucket::withinTarget.

Referenced by CTransactionBuilder::Commit(), CWallet::FundTransaction(), CWallet::GetBudgetSystemCollateralTX(), WalletModel::prepareTransaction(), sendmany(), and SendMoney().

◆ DelAddressBook()

◆ FindNonChangeParentOutput()

const CTxOut & CWallet::FindNonChangeParentOutput ( const CTransaction tx,
int  output 
) const

Find non-change parent output.

Definition at line 2917 of file wallet.cpp.

References COutPoint::hash, CWallet::IsChange(), CWallet::IsMine(), CWallet::mapWallet, COutPoint::n, CTransaction::vin, and CTransaction::vout.

Referenced by CWallet::ListCoins().

◆ FundTransaction()

bool CWallet::FundTransaction ( CMutableTransaction tx,
CAmount nFeeRet,
int &  nChangePosInOut,
std::string &  strFailReason,
bool  lockUnspents,
const std::set< int > &  setSubtractFeeFromOutputs,
CCoinControl  coinControl 
)

◆ GetAccountAddresses()

std::set< CTxDestination > CWallet::GetAccountAddresses ( const std::string &  strAccount) const

◆ GetAccountName()

const std::string & CWallet::GetAccountName ( const CScript scriptPubKey) const

◆ GetAddressBalances()

◆ GetAddressGroupings()

◆ GetAnonymizableBalance()

◆ GetAnonymizedBalance()

CAmount CWallet::GetAnonymizedBalance ( const CCoinControl coinControl = nullptr) const

◆ GetAvailableBalance()

CAmount CWallet::GetAvailableBalance ( const CCoinControl coinControl = nullptr) const

Definition at line 2760 of file wallet.cpp.

References CWallet::AvailableCoins(), cs_main, CWallet::cs_wallet, LOCK2, and vCoins.

Referenced by WalletModel::getBalance().

◆ GetAverageAnonymizedRounds()

◆ GetBalance()

CAmount CWallet::GetBalance ( ) const

◆ GetBudgetSystemCollateralTX()

bool CWallet::GetBudgetSystemCollateralTX ( CWalletTx tx,
uint256  hash,
CAmount  amount,
const COutPoint outpoint = COutPoint() 
)

◆ GetCollateralTxDSIn()

bool CWallet::GetCollateralTxDSIn ( CTxDSIn txdsinRet,
CAmount nValueRet 
) const

◆ GetDenominatedBalance()

CAmount CWallet::GetDenominatedBalance ( bool  unconfirmed = false) const

◆ GetImmatureBalance()

CAmount CWallet::GetImmatureBalance ( ) const

◆ GetImmatureWatchOnlyBalance()

CAmount CWallet::GetImmatureWatchOnlyBalance ( ) const

◆ GetKeyFromPool()

◆ GetLegacyBalance()

◆ GetMasternodeOutpointAndKeys()

bool CWallet::GetMasternodeOutpointAndKeys ( COutPoint outpointRet,
CPubKey pubKeyRet,
CKey keyRet,
const std::string &  strTxHash = "",
const std::string &  strOutputIndex = "" 
)

Get 1000DASH output and keys which can be used for the Masternode.

Definition at line 3501 of file wallet.cpp.

References atoi(), CWallet::AvailableCoins(), fImporting, fReindex, CWallet::GetOutpointAndKeysFromOutput(), LogPrintf, CCoinControl::nCoinType, ONLY_MASTERNODE_COLLATERAL, and uint256S().

◆ GetNormalizedAnonymizedBalance()

◆ GetOldestKeyInPool()

static int64_t GetOldestKeyInPool ( const std::set< int64_t > &  setKeyPool,
WalletBatch batch 
)
static

◆ GetOldestKeyPoolTime()

int64_t CWallet::GetOldestKeyPoolTime ( )

◆ GetOutpointAndKeysFromOutput()

bool CWallet::GetOutpointAndKeysFromOutput ( const COutput out,
COutPoint outpointRet,
CPubKey pubKeyRet,
CKey keyRet 
)

Extract txin information and keys from output.

Definition at line 3531 of file wallet.cpp.

References ExtractDestination(), fImporting, fReindex, CMerkleTx::GetHash(), CWallet::GetKey(), CKey::GetPubKey(), COutput::i, LogPrintf, CMerkleTx::tx, and COutput::tx.

Referenced by CWallet::GetMasternodeOutpointAndKeys().

◆ GetReservedKey()

◆ GetScriptForMining()

void CWallet::GetScriptForMining ( std::shared_ptr< CReserveScript > &  script)

Definition at line 4781 of file wallet.cpp.

References OP_CHECKSIG, and ToByteVector().

◆ GetSpendableTXs()

◆ GetUnconfirmedBalance()

CAmount CWallet::GetUnconfirmedBalance ( ) const

◆ GetUnconfirmedWatchOnlyBalance()

CAmount CWallet::GetUnconfirmedWatchOnlyBalance ( ) const

◆ GetWatchOnlyBalance()

CAmount CWallet::GetWatchOnlyBalance ( ) const

Definition at line 2678 of file wallet.cpp.

References cs_main, CWallet::cs_wallet, CWallet::GetSpendableTXs(), and LOCK2.

Referenced by WalletModel::getWatchBalance().

◆ HasCollateralInputs()

bool CWallet::HasCollateralInputs ( bool  fOnlyConfirmed = true) const

◆ InitPrivateSendSalt()

void CWallet::InitPrivateSendSalt ( )
private

Fetches PrivateSend salt from database or generates and saves a new one if no salt was found in the db.

Definition at line 2934 of file wallet.cpp.

References CWallet::database, GetRandHash(), base_blob< BITS >::IsNull(), and CWallet::nPrivateSendSalt.

Referenced by CWallet::LoadWallet().

◆ IsLockedCoin()

bool CWallet::IsLockedCoin ( uint256  hash,
unsigned int  n 
) const

◆ KeepKey() [1/2]

void CWallet::KeepKey ( int64_t  nIndex)

◆ KeepKey() [2/2]

◆ KeypoolCountExternalKeys()

size_t CWallet::KeypoolCountExternalKeys ( )

◆ KeypoolCountInternalKeys()

size_t CWallet::KeypoolCountInternalKeys ( )

Definition at line 4385 of file wallet.cpp.

References AssertLockHeld(), CWallet::cs_wallet, and CWallet::setInternalKeyPool.

Referenced by getwalletinfo().

◆ less_then_denom()

bool less_then_denom ( const COutput out1,
const COutput out2 
)

◆ ListAccountCreditDebit()

void CWallet::ListAccountCreditDebit ( const std::string &  strAccount,
std::list< CAccountingEntry > &  entries 
)

Definition at line 4135 of file wallet.cpp.

References CWallet::database, and WalletBatch::ListAccountCreditDebit().

Referenced by GetResults().

◆ ListCoins()

std::map< CTxDestination, std::vector< COutput > > CWallet::ListCoins ( ) const

Return list of available coins and locked coins grouped by non-change output address.

Definition at line 2871 of file wallet.cpp.

References CWallet::AvailableCoins(), cs_main, CWallet::cs_wallet, ExtractDestination(), CWallet::FindNonChangeParentOutput(), CWallet::IsMine(), ISMINE_SPENDABLE, CWallet::ListLockedCoins(), LOCK2, CWallet::mapWallet, and CTxOut::scriptPubKey.

Referenced by WalletModel::listCoins().

◆ ListLockedCoins()

void CWallet::ListLockedCoins ( std::vector< COutPoint > &  vOutpts) const

◆ ListProTxCoins()

void CWallet::ListProTxCoins ( std::vector< COutPoint > &  vOutpts)

◆ LoadKeyPool()

◆ LoadWallet()

◆ LockCoin()

◆ MarkReserveKeysAsUsed()

void CWallet::MarkReserveKeysAsUsed ( int64_t  keypool_id)

◆ NewKeyPool()

◆ ReserveKeyFromKeyPool()

◆ ReturnKey() [1/2]

void CWallet::ReturnKey ( int64_t  nIndex,
bool  fInternal,
const CPubKey pubkey 
)

◆ ReturnKey() [2/2]

◆ SelectCoins()

bool CWallet::SelectCoins ( const std::vector< COutput > &  vAvailableCoins,
const CAmount nTargetValue,
std::set< CInputCoin > &  setCoinsRet,
CAmount nValueRet,
const CCoinControl coinControl = nullptr 
) const
private

◆ SelectCoinsGroupedByAddresses()

◆ SelectCoinsMinConf()

bool CWallet::SelectCoinsMinConf ( const CAmount nTargetValue,
int  nConfMine,
int  nConfTheirs,
uint64_t  nMaxAncestors,
std::vector< COutput vCoins,
std::set< CInputCoin > &  setCoinsRet,
CAmount nValueRet,
CoinType  nCoinType = CoinType::ALL_COINS 
) const

Shuffle and select coins until nTargetValue is reached while avoiding small change; This method is stochastic for some inputs and upon completion the coin set and corresponding actual target value is assembled.

Definition at line 3025 of file wallet.cpp.

References ApproximateBestSubset(), FormatMoney(), CMerkleTx::GetHash(), GetRandInt(), CPrivateSend::IsDenominatedAmount(), CWalletTx::IsFromMe(), CMerkleTx::IsLockedByInstantSend(), ISMINE_ALL, less_then_denom(), LogPrint, maxTxFee, mempool, MIN_CHANGE, CTxOut::nValue, ONLY_FULLY_MIXED, BCLog::SELECTCOINS, CTxMemPool::TransactionWithinChainLimit(), CMerkleTx::tx, CInputCoin::txout, and vCoins.

Referenced by BOOST_AUTO_TEST_CASE(), CoinSelection(), and CWallet::SelectCoins().

◆ SelectDenominatedAmounts()

bool CWallet::SelectDenominatedAmounts ( CAmount  nValueMax,
std::set< CAmount > &  setAmountsRet 
) const

◆ SelectPSInOutPairsByDenominations()

bool CWallet::SelectPSInOutPairsByDenominations ( int  nDenom,
CAmount  nValueMax,
std::vector< std::pair< CTxDSIn, CTxOut > > &  vecPSInOutPairsRet 
)

◆ SetAddressBook()

◆ TopUpKeyPool()

◆ UnlockAllCoins()

void CWallet::UnlockAllCoins ( )

Definition at line 4814 of file wallet.cpp.

References AssertLockHeld(), CWallet::cs_wallet, and CWallet::setLockedCoins.

Referenced by lockunspent().

◆ UnlockCoin()

◆ ZapSelectTx()

◆ ZapWalletTx()

Released under the MIT license