static void Mining(BhpSystem system) { Fixed8 amount_netfee = Fixed8.Zero; Fixed8 transaction_fee = Fixed8.Zero; ulong nonce = 100156895; BRC6Wallet wallet = new BRC6Wallet(new Bhp.Wallets.WalletIndexer(@"walletindex"), @"D:\BHP\Test\t1.json"); wallet.Unlock("1"); wallet.WalletTransaction += Wallet_WalletTransaction; MiningTransaction miningTransaction = new MiningTransaction(); MinerTransaction tx = miningTransaction.MakeMinerTransaction(wallet, 1000, nonce, Fixed8.Zero, Fixed8.Zero); Console.WriteLine(tx.ToJson()); Console.WriteLine("\n Staring Sign......"); ContractParametersContext context = new ContractParametersContext(tx); wallet.Sign(context); if (context.Completed) { Console.WriteLine("\n Sign successfully."); context.Verifiable.Witnesses = context.GetWitnesses(); string hexString = GetTxHashData(context.Verifiable).ToHexString(); Console.WriteLine($"\n {hexString}"); system.LocalNode.Tell(new LocalNode.Relay { Inventory = tx }); RelayResultReason reason = system.Blockchain.Ask <RelayResultReason>(tx).Result; Console.WriteLine("\n relay tx: " + reason); } Console.ReadLine(); }
public void ToJson() { uut.Attributes = new TransactionAttribute[0]; uut.Inputs = new CoinReference[0]; uut.Outputs = new TransactionOutput[0]; uut.Scripts = new Witness[0]; uut.Nonce = 42; JObject jObj = uut.ToJson(); jObj.Should().NotBeNull(); jObj["txid"].AsString().Should().Be("0xe42ca5744eda6de2e1a2bdc2ed98fa7b967b13cd3aa2605c95fff37261f07ef6"); jObj["size"].AsNumber().Should().Be(10); jObj["type"].AsString().Should().Be("MinerTransaction"); jObj["version"].AsNumber().Should().Be(0); ((JArray)jObj["attributes"]).Count.Should().Be(0); ((JArray)jObj["vin"]).Count.Should().Be(0); ((JArray)jObj["vout"]).Count.Should().Be(0); jObj["sys_fee"].AsNumber().Should().Be(0); jObj["net_fee"].AsNumber().Should().Be(0); ((JArray)jObj["scripts"]).Count.Should().Be(0); jObj["nonce"].AsNumber().Should().Be(42); }