本文整理匯總了C#中Block.UpdateMerkleRoot方法的典型用法代碼示例。如果您正苦於以下問題:C# Block.UpdateMerkleRoot方法的具體用法?C# Block.UpdateMerkleRoot怎麽用?C# Block.UpdateMerkleRoot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Block
的用法示例。
在下文中一共展示了Block.UpdateMerkleRoot方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CanCreateBrainAddress
//[Trait("UnitTest", "UnitTest")]
public void CanCreateBrainAddress()
{
var repo = new NoSqlBlockRepository();
var chain = new ConcurrentChain();
Block b = new Block();
b.Transactions.Add(new Transaction());
b.Transactions.Add(new Transaction()
{
Outputs =
{
new TxOut(),
new TxOut(Money.Zero,BitcoinAddress.Create("15sYbVpRh6dyWycZMwPdxJWD4xbfxReeHe"))
}
});
b.UpdateMerkleRoot();
repo.PutAsync(b).Wait();
chain.SetTip(b.Header);
MnemonicReference address = MnemonicReference.CreateAsync(chain, repo, 0, 1, 1).Result;
MnemonicReference address2 = MnemonicReference.ParseAsync(chain, repo, Wordlist.English, address.ToString(Wordlist.English)).Result;
Assert.Equal(address.ToString(), address2.ToString());
chain = new ConcurrentChain(Network.Main);
var block = Network.Main.GetGenesis();
var mnemo = MnemonicReference.Create(chain, block.Transactions[0], block, 0);
}
示例2: FindBlock
public Block FindBlock()
{
Block b = new Block();
b.Transactions.Add(new Transaction()
{
Inputs =
{
new TxIn(new Script(RandomUtils.GetBytes(32)))
}
});
foreach(var tx in Mempool)
b.Transactions.Add(tx.Value);
b.Header.BlockTime = DateTimeOffset.UtcNow;
b.UpdateMerkleRoot();
b.Header.HashPrevBlock = Chain.Tip.HashBlock;
Chain.SetTip(b.Header);
Mempool.Clear();
if(NewBlock != null)
NewBlock(b);
return b;
}
示例3: Test
private void Test(int blockHeight, int txIndex, int txCount, int txOutIndex, int txOutCount)
{
var repo = new NoSqlBlockRepository();
var chain = new MockChain();
var block = new Block();
Transaction relevantTx = null;
for(int i = 0 ; i < txCount ; i++)
{
var tx = block.AddTransaction(new Transaction());
if(i == txIndex)
{
relevantTx = tx;
for(int ii = 0 ; ii < txOutCount ; ii++)
{
var txout = tx.AddOutput(new TxOut());
if(ii == txOutIndex)
txout.Value = Money.Coins(1.0m);
}
}
}
block.UpdateMerkleRoot();
chain.Return(block.Header, blockHeight);
repo.PutAsync(block).Wait();
var address = MnemonicReference.CreateAsync(chain, repo, blockHeight, txIndex, txOutIndex).Result;
var address2 = MnemonicReference.ParseAsync(chain, repo, Wordlist.English, address.ToString()).Result;
Assert.Equal(address.ToString(), address2.ToString());
Assert.Equal(Money.Coins(1.0m), address.Output.Value);
Assert.Equal(Money.Coins(1.0m), address2.Output.Value);
var merkleBlock = block.Filter(relevantTx.GetHash());
var address3 = MnemonicReference.Parse(chain, Wordlist.English, address.ToString(), relevantTx, merkleBlock);
Assert.Equal(address.ToString(), address3.ToString());
}