本文整理汇总了C++中CWallet::GetBalance方法的典型用法代码示例。如果您正苦于以下问题:C++ CWallet::GetBalance方法的具体用法?C++ CWallet::GetBalance怎么用?C++ CWallet::GetBalance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CWallet
的用法示例。
在下文中一共展示了CWallet::GetBalance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTotBalance
qint64 WalletModel::getTotBalance() const
{
qint64 nTotBalance = 0;
BOOST_FOREACH(const wallet_map::value_type& item, pWalletManager->GetWalletMap())
{
CWallet* pwallet = pWalletManager->GetWallet(item.first.c_str()).get();
nTotBalance+=pwallet->GetBalance();
}
return nTotBalance;
}
示例2: CreateCoinStake
bool CreateCoinStake( CBlock &blocknew, CKey &key,
vector<const CWalletTx*> &StakeInputs, uint64_t &CoinAge,
CWallet &wallet, CBlockIndex* pindexPrev )
{
int64_t CoinWeight;
CBigNum StakeKernelHash;
CTxDB txdb("r");
int64_t StakeWeightSum = 0;
double StakeValueSum = 0;
int64_t StakeWeightMin=MAX_MONEY;
int64_t StakeWeightMax=0;
uint64_t StakeCoinAgeSum=0;
double StakeDiffSum = 0;
double StakeDiffMax = 0;
CTransaction &txnew = blocknew.vtx[1]; // second tx is coinstake
//initialize the transaction
txnew.nTime = blocknew.nTime & (~STAKE_TIMESTAMP_MASK);
txnew.vin.clear();
txnew.vout.clear();
// Choose coins to use
set <pair <const CWalletTx*,unsigned int> > CoinsToStake;
int64_t BalanceToStake = wallet.GetBalance();
int64_t nValueIn = 0;
//Request all the coins here, check reserve later
if ( BalanceToStake<=0
|| !wallet.SelectCoinsForStaking(BalanceToStake*2, txnew.nTime, CoinsToStake, nValueIn) )
{
LOCK(MinerStatus.lock);
MinerStatus.ReasonNotStaking+=_("No coins; ");
if (fDebug) LogPrintf("CreateCoinStake: %s",MinerStatus.ReasonNotStaking);
return false;
}
BalanceToStake -= nReserveBalance;
if(fDebug2) LogPrintf("\nCreateCoinStake: Staking nTime/16= %d Bits= %u",
txnew.nTime/16,blocknew.nBits);
for(const auto& pcoin : CoinsToStake)
{
const CTransaction &CoinTx =*pcoin.first; //transaction that produced this coin
unsigned int CoinTxN =pcoin.second; //index of this coin inside it
CTxIndex txindex;
{
LOCK2(cs_main, wallet.cs_wallet);
if (!txdb.ReadTxIndex(pcoin.first->GetHash(), txindex))
continue; //error?
}
CBlock CoinBlock; //Block which contains CoinTx
{
LOCK2(cs_main, wallet.cs_wallet);
if (!CoinBlock.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false))
continue;
}
// only count coins meeting min age requirement
if (CoinBlock.GetBlockTime() + nStakeMinAge > txnew.nTime)
continue;
if (CoinTx.vout[CoinTxN].nValue > BalanceToStake)
continue;
{
int64_t nStakeValue= CoinTx.vout[CoinTxN].nValue;
StakeValueSum += nStakeValue /(double)COIN;
//crazy formula...
// todo: clean this
// todo reuse calculated value for interst
CBigNum bn = CBigNum(nStakeValue) * (blocknew.nTime-CoinTx.nTime) / CENT;
bn = bn * CENT / COIN / (24 * 60 * 60);
StakeCoinAgeSum += bn.getuint64();
}
if(blocknew.nVersion==7)
{
NetworkTimer();
CoinWeight = CalculateStakeWeightV3(CoinTx,CoinTxN,GlobalCPUMiningCPID);
StakeKernelHash= CalculateStakeHashV3(CoinBlock,CoinTx,CoinTxN,txnew.nTime,GlobalCPUMiningCPID,mdPORNonce);
}
else
{
uint64_t StakeModifier = 0;
if(!FindStakeModifierRev(StakeModifier,pindexPrev))
continue;
CoinWeight = CalculateStakeWeightV8(CoinTx,CoinTxN,GlobalCPUMiningCPID);
StakeKernelHash= CalculateStakeHashV8(CoinBlock,CoinTx,CoinTxN,txnew.nTime,StakeModifier,GlobalCPUMiningCPID);
}
CBigNum StakeTarget;
StakeTarget.SetCompact(blocknew.nBits);
StakeTarget*=CoinWeight;
StakeWeightSum += CoinWeight;
StakeWeightMin=std::min(StakeWeightMin,CoinWeight);
StakeWeightMax=std::max(StakeWeightMax,CoinWeight);
double StakeKernelDiff = GetBlockDifficulty(StakeKernelHash.GetCompact())*CoinWeight;
//.........这里部分代码省略.........