0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ビットコインの半減期の仕組み

Posted at

#はじめに
もうすぐビットコインの半減期ですね(2020.5.5現在).半減期を前にその仕組みについて整理したいと思います.

#ソースコード
https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L1238

CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
    int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
    // Force block reward to zero when right shift is undefined.
    if (halvings >= 64)
        return 0;

    CAmount nSubsidy = 50 * COIN;
    // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
    nSubsidy >>= halvings;
    return nSubsidy;
}

nSubsidyがマイニング報酬です.初期設定は50BTCとなっており,halvings分右シフトすることによって半分になっていきます.

consensusParams.nSubsidyHalvingIntervalが210000に設定されているので,halvingsはブロック高が210000増加する毎に1つずつ増えていきます.
ブロック生成間隔が約10分なので,210000 / 144 = 1458.3日,即ち約4年に1回ずつ半減期は訪れます.

    // Create coinbase transaction.
    CMutableTransaction coinbaseTx;
    coinbaseTx.vin.resize(1);
    coinbaseTx.vin[0].prevout.SetNull();
    coinbaseTx.vout.resize(1);
    coinbaseTx.vout[0].scriptPubKey = scriptPubKeyIn;
    coinbaseTx.vout[0].nValue = nFees + GetBlockSubsidy(nHeight, chainparams.GetConsensus());
    coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0;
    pblock->vtx[0] = MakeTransactionRef(std::move(coinbaseTx));
    pblocktemplate->vchCoinbaseCommitment = GenerateCoinbaseCommitment(*pblock, pindexPrev, chainparams.GetConsensus());
    pblocktemplate->vTxFees[0] = -nFees;

coinbaseトランザクションに先ほどのマイニング報酬が代入されていることが読み取れます.

参考

ブロック高419999,420000のコインベーストランザクションから,マイニング報酬が変化している様子が読み取れます.
https://www.blockchain.com/btc/block/419999
https://www.blockchain.com/btc/block/420000

次の半減期はブロック高630000で行われ,マイニング報酬は12.5BTCから6.25BTCに変化します.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?