예제 #1
0
        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();
        }