コード例 #1
0
void
CAuxpowBuilder::setCoinbase (const CScript& scr)
{
  CMutableTransaction mtx;
  mtx.vin.resize (1);
  mtx.vin[0].prevout.SetNull ();
  mtx.vin[0].scriptSig = scr;

  parentBlock.vtx.clear ();
  parentBlock.vtx.push_back (mtx);
  parentBlock.hashMerkleRoot = parentBlock.ComputeMerkleRoot ();
}
コード例 #2
0
ファイル: auxpow.cpp プロジェクト: bankonme/namecoin-core
/* This used to be in CBlock but was removed upstream.  We need it
   at least for unit testing, thus moved here.  */
static void
GetMerkleBranch (const CBlock& block, int nIndex,
                 std::vector<uint256>& vMerkleBranch)
{
  std::vector<uint256> vMerkleTree;
  block.ComputeMerkleRoot (vMerkleTree);
  int j = 0;
  for (int nSize = block.vtx.size (); nSize > 1; nSize = (nSize + 1) / 2)
    {
      const int i = std::min (nIndex ^ 1, nSize - 1);
      vMerkleBranch.push_back (vMerkleTree[j + i]);
      nIndex >>= 1;
      j += nSize;
    }
}
コード例 #3
0
static CBlock CreateGenesisBlock(const CScript& genesisInputScript, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
    CMutableTransaction txNew;
    txNew.nVersion = 1;
    txNew.vin.resize(1);
    txNew.vout.resize(1);
    txNew.vin[0].scriptSig = genesisInputScript;
    txNew.vout[0].nValue = genesisReward;
    txNew.vout[0].scriptPubKey = genesisOutputScript;

    CBlock genesis;
    genesis.nTime    = nTime;
    genesis.nBits    = nBits;
    genesis.nNonce   = nNonce;
    genesis.nVersion.SetGenesisVersion(nVersion);
    genesis.vtx.push_back(txNew);
    genesis.hashPrevBlock.SetNull();
    genesis.hashMerkleRoot = genesis.ComputeMerkleRoot();
    return genesis;
}
コード例 #4
0
ファイル: chainparams.cpp プロジェクト: jn2840/bitcoin
static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
    CMutableTransaction txNew;
    txNew.nVersion = 1;
    txNew.vin.resize(1);
    txNew.vout.resize(1);
    txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
    txNew.vout[0].nValue = genesisReward;
    txNew.vout[0].scriptPubKey = genesisOutputScript;

    CBlock genesis;
    genesis.nTime    = nTime;
    genesis.nBits    = nBits;
    genesis.nNonce   = nNonce;
    genesis.nVersion = nVersion;
    genesis.vtx.push_back(txNew);
    genesis.hashPrevBlock.SetNull();
    genesis.hashMerkleRoot = genesis.ComputeMerkleRoot();
    return genesis;
}