Example #1
0
        public Block CreateNextBlockWithCoinbase(BitcoinAddress address, int height, DateTimeOffset now)
        {
            if (address == null)
            {
                throw new ArgumentNullException("address");
            }
            Block block = new Block();

            block.Header.Nonce         = RandomUtils.GetUInt32();
            block.Header.HashPrevBlock = this.GetHash();
            block.Header.BlockTime     = now;
            var tx = block.AddTransaction(new Transaction());

            tx.AddInput(new TxIn()
            {
                ScriptSig = new Script(Op.GetPushOp(RandomUtils.GetBytes(30)))
            });
            tx.Outputs.Add(new TxOut(address.Network.GetReward(height), address)
            {
                Value = address.Network.GetReward(height)
            });
            return(block);
        }