本文整理汇总了C++中CWallet::GetKey方法的典型用法代码示例。如果您正苦于以下问题:C++ CWallet::GetKey方法的具体用法?C++ CWallet::GetKey怎么用?C++ CWallet::GetKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CWallet
的用法示例。
在下文中一共展示了CWallet::GetKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateCoinStake
//.........这里部分代码省略.........
StakeTarget.SetCompact(blocknew.nBits);
StakeTarget*=CoinWeight;
StakeWeightSum += CoinWeight;
StakeWeightMin=std::min(StakeWeightMin,CoinWeight);
StakeWeightMax=std::max(StakeWeightMax,CoinWeight);
double StakeKernelDiff = GetBlockDifficulty(StakeKernelHash.GetCompact())*CoinWeight;
StakeDiffSum += StakeKernelDiff;
StakeDiffMax = std::max(StakeDiffMax,StakeKernelDiff);
if (fDebug2) {
int64_t RSA_WEIGHT = GetRSAWeightByBlock(GlobalCPUMiningCPID);
LogPrintf(
"CreateCoinStake: V%d Time %.f, Por_Nonce %.f, Bits %jd, Weight %jd\n"
" RSA_WEIGHT %.f\n"
" Stk %72s\n"
" Trg %72s\n"
" Diff %0.7f of %0.7f\n",
blocknew.nVersion,
(double)txnew.nTime, mdPORNonce,
(intmax_t)blocknew.nBits,(intmax_t)CoinWeight,
(double)RSA_WEIGHT,
StakeKernelHash.GetHex().c_str(), StakeTarget.GetHex().c_str(),
StakeKernelDiff, GetBlockDifficulty(blocknew.nBits)
);
}
if( StakeKernelHash <= StakeTarget )
{
// Found a kernel
LogPrintf("\nCreateCoinStake: Found Kernel;\n");
blocknew.nNonce= mdPORNonce;
vector<valtype> vSolutions;
txnouttype whichType;
CScript scriptPubKeyOut;
CScript scriptPubKeyKernel;
scriptPubKeyKernel = CoinTx.vout[CoinTxN].scriptPubKey;
if (!Solver(scriptPubKeyKernel, whichType, vSolutions))
{
LogPrintf("CreateCoinStake: failed to parse kernel\n");
break;
}
if (whichType == TX_PUBKEYHASH) // pay to address type
{
// convert to pay to public key type
if (!wallet.GetKey(uint160(vSolutions[0]), key))
{
LogPrintf("CreateCoinStake: failed to get key for kernel type=%d\n", whichType);
break; // unable to find corresponding public key
}
scriptPubKeyOut << key.GetPubKey() << OP_CHECKSIG;
}
else if (whichType == TX_PUBKEY) // pay to public key type
{
valtype& vchPubKey = vSolutions[0];
if (!wallet.GetKey(Hash160(vchPubKey), key)
|| key.GetPubKey() != vchPubKey)
{
LogPrintf("CreateCoinStake: failed to get key for kernel type=%d\n", whichType);
break; // unable to find corresponding public key
}
scriptPubKeyOut = scriptPubKeyKernel;
}
else
{
LogPrintf("CreateCoinStake: no support for kernel type=%d\n", whichType);
break; // only support pay to public key and pay to address
}
txnew.vin.push_back(CTxIn(CoinTx.GetHash(), CoinTxN));
StakeInputs.push_back(pcoin.first);
if (!txnew.GetCoinAge(txdb, CoinAge))
return error("CreateCoinStake: failed to calculate coin age");
int64_t nCredit = CoinTx.vout[CoinTxN].nValue;
txnew.vout.push_back(CTxOut(0, CScript())); // First Must be empty
txnew.vout.push_back(CTxOut(nCredit, scriptPubKeyOut));
//txnew.vout.push_back(CTxOut(0, scriptPubKeyOut));
LogPrintf("CreateCoinStake: added kernel type=%d credit=%f\n", whichType,CoinToDouble(nCredit));
LOCK(MinerStatus.lock);
MinerStatus.KernelsFound++;
MinerStatus.KernelDiffMax = 0;
MinerStatus.KernelDiffSum = StakeDiffSum;
return true;
}
}
LOCK(MinerStatus.lock);
MinerStatus.WeightSum = StakeWeightSum;
MinerStatus.ValueSum = StakeValueSum;
MinerStatus.WeightMin=StakeWeightMin;
MinerStatus.WeightMax=StakeWeightMax;
MinerStatus.CoinAgeSum=StakeCoinAgeSum;
MinerStatus.KernelDiffMax = std::max(MinerStatus.KernelDiffMax,StakeDiffMax);
MinerStatus.KernelDiffSum = StakeDiffSum;
MinerStatus.nLastCoinStakeSearchInterval= txnew.nTime;
return false;
}