コード例 #1
0
ファイル: XRCNetwork.cs プロジェクト: xrhodium/blockcore
        private Block CreateXRCGenesisBlock(XRCConsensusFactory consensusFactory, string message, uint nTime, uint nNonce, uint nBits, int nVersion, string pubKey)
        {
            //nTime = 1512043200 => Thursday, November 30, 2017 12:00:00 PM (born XRC)
            //nTime = 1527811200 => Friday, Jun 1, 2017 12:00:00 PM (born TestXRC)
            //nBits = 0x1d00ffff (it is exactly 0x1b = 27 bytes long) => 0x00ffff0000000000000000000000000000000000000000000000000000 => 1
            //nNonce = XTimes to trying to find a genesis block
            Transaction txNew = consensusFactory.CreateTransaction();

            txNew.Version = 2;
            if (txNew is IPosTransactionWithTime posTx)
            {
                posTx.Time = nTime;
            }
            txNew.AddInput(new TxIn()
            {
                ScriptSig = new Script(Op.GetPushOp(nBits), new Op()
                {
                    Code     = (OpcodeType)0x1,
                    PushData = new[] { (byte)4 }
                }, Op.GetPushOp(Encoders.ASCII.DecodeData(message)))
            });
            txNew.AddOutput(new TxOut()
            {
                Value        = Money.Zero,
                ScriptPubKey = Script.FromBytesUnsafe(Encoders.Hex.DecodeData(pubKey))
            });

            Block genesis = consensusFactory.CreateBlock();

            genesis.Header.BlockTime = Utils.UnixTimeToDateTime(nTime);
            genesis.Header.Bits      = nBits;
            genesis.Header.Nonce     = nNonce;
            genesis.Header.Version   = nVersion;
            genesis.Transactions.Add(txNew);
            genesis.Header.HashPrevBlock = uint256.Zero;
            genesis.UpdateMerkleRoot();
            return(genesis);
        }
コード例 #2
0
ファイル: XRCNetwork.cs プロジェクト: xrhodium/blockcore
        public Block CreateXRCGenesisBlock(XRCConsensusFactory consensusFactory, uint nTime, uint nNonce, uint nBits, int nVersion, string pubKey)
        {
            string message = "Release the Kraken!!! Zeus";

            return(CreateXRCGenesisBlock(consensusFactory, message, nTime, nNonce, nBits, nVersion, pubKey));
        }