本文整理汇总了C++中cryptonote::Currency::getBlockReward方法的典型用法代码示例。如果您正苦于以下问题:C++ Currency::getBlockReward方法的具体用法?C++ Currency::getBlockReward怎么用?C++ Currency::getBlockReward使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cryptonote::Currency
的用法示例。
在下文中一共展示了Currency::getBlockReward方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: constructMinerTxManually
bool constructMinerTxManually(const CryptoNote::Currency& currency, uint32_t height, uint64_t alreadyGeneratedCoins,
const AccountPublicAddress& minerAddress, Transaction& tx, uint64_t fee,
KeyPair* pTxKey/* = 0*/) {
KeyPair txkey;
txkey = KeyPair::generate();
add_tx_pub_key_to_extra(tx, txkey.pub);
if (0 != pTxKey) {
*pTxKey = txkey;
}
TransactionInputGenerate in;
in.height = height;
tx.vin.push_back(in);
// This will work, until size of constructed block is less then currency.blockGrantedFullRewardZone()
int64_t emissionChange;
uint64_t blockReward;
if (!currency.getBlockReward(0, 0, alreadyGeneratedCoins, fee, false, blockReward, emissionChange)) {
std::cerr << "Block is too big" << std::endl;
return false;
}
crypto::key_derivation derivation;
crypto::public_key outEphPublicKey;
crypto::generate_key_derivation(minerAddress.m_viewPublicKey, txkey.sec, derivation);
crypto::derive_public_key(derivation, 0, minerAddress.m_spendPublicKey, outEphPublicKey);
TransactionOutput out;
out.amount = blockReward;
out.target = TransactionOutputToKey(outEphPublicKey);
tx.vout.push_back(out);
tx.version = CURRENT_TRANSACTION_VERSION;
tx.unlockTime = height + currency.minedMoneyUnlockWindow();
return true;
}
示例2: constructMinerTxManually
bool constructMinerTxManually(const CryptoNote::Currency& currency, uint32_t height, uint64_t alreadyGeneratedCoins,
const AccountPublicAddress& minerAddress, Transaction& tx, uint64_t fee,
KeyPair* pTxKey/* = 0*/) {
KeyPair txkey = generateKeyPair();
addTransactionPublicKeyToExtra(tx.extra, txkey.publicKey);
if (0 != pTxKey) {
*pTxKey = txkey;
}
BaseInput in;
in.blockIndex = height;
tx.inputs.push_back(in);
// This will work, until size of constructed block is less then currency.blockGrantedFullRewardZone()
int64_t emissionChange;
uint64_t blockReward;
if (!currency.getBlockReward(0, 0, alreadyGeneratedCoins, fee, height, blockReward, emissionChange)) {
std::cerr << "Block is too big" << std::endl;
return false;
}
Crypto::KeyDerivation derivation;
Crypto::PublicKey outEphPublicKey;
Crypto::generate_key_derivation(minerAddress.viewPublicKey, txkey.secretKey, derivation);
Crypto::derive_public_key(derivation, 0, minerAddress.spendPublicKey, outEphPublicKey);
TransactionOutput out;
out.amount = blockReward;
out.target = KeyOutput{outEphPublicKey};
tx.outputs.push_back(out);
tx.version = TRANSACTION_VERSION_1;
tx.unlockTime = height + currency.minedMoneyUnlockWindow();
return true;
}