Exemple #1
0
 public static KzUInt256 ComputeMerkleRoot(IEnumerable <KzTransaction> txs)
 {
     using (var mt = new KzMerkleTree())
     {
         mt.AddTransactions(txs);
         return(mt.GetMerkleRoot());
     }
 }
Exemple #2
0
        KzBlock CreateGenesisBlock(string pszTimestamp,
                                   KzScript genesisOutputScript,
                                   UInt32 nTime, UInt32 nNonce,
                                   UInt32 nBits, Int32 nVersion,
                                   Int64 genesisReward)
        {
            var txs = new KzTransaction[] {
                new KzTransaction(
                    version: 1,
                    vin: new KzTxIn[] {
                    new KzTxIn(
                        prevout: new KzOutPoint(KzUInt256.Zero, -1),
                        scriptSig: new KzScript(""),
                        sequence: 0)
                },
                    vout: new KzTxOut[] {
                    new KzTxOut(
                        value: 0,
                        scriptPub: new KzScript("")
                        )
                },
                    lockTime: 0
                    )
            };
            var hashMerkleRoot = KzMerkleTree.ComputeMerkleRoot(txs);
            var genesis        = new KzBlock(
                txs: txs,
                version: 1,
                hashPrevBlock: KzUInt256.Zero,
                hashMerkleRoot: hashMerkleRoot,
                time: 1231006506,
                bits: 0x1d00ffff,
                nonce: 2083236893
                );

            return(genesis);
        }
Exemple #3
0
 KzUInt256 ComputeMerkleRoot() => KzMerkleTree.ComputeMerkleRoot(_txs);