Example #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     Block block = new Block
     {
         PrevBlock = UInt256.Zero,
         Timestamp = DateTime.Now.ToTimestamp(),
         Height = 0,
         Nonce = 2083236893, //向比特币致敬
         NextMiner = Contract.CreateMultiSigContract(Blockchain.GetMinSignatureCount(Blockchain.StandbyMiners.Length), Blockchain.StandbyMiners).ScriptHash,
         Transactions = new Transaction[]
         {
             new GenerationTransaction
             {
                 Nonce = 0,
                 Inputs = new TransactionInput[0],
                 Outputs = new TransactionOutput[0],
                 Scripts = { }
             },
             textBox3.Text.HexToBytes().AsSerializable<RegisterTransaction>()
         }
     };
     block.RebuildMerkleRoot();
     SignatureContext context = new SignatureContext(block.Header);
     InformationBox.Show(context.ToString(), "创世区块头签名上下文");
 }
Example #2
0
 private async Task ShowInformationAsync(SignatureContext context)
 {
     if (context.Completed)
     {
         context.Signable.Scripts = context.GetScripts();
         Transaction tx = (Transaction)context.Signable;
         await Program.LocalNode.RelayAsync(tx);
         InformationBox.Show(tx.Hash.ToString(), "交易已发送,这是交易编号(TXID):", "交易成功");
     }
     else
     {
         InformationBox.Show(context.ToString(), "交易构造完成,但没有足够的签名:", "签名不完整");
     }
 }
Example #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     RegisterTransaction antshare = new RegisterTransaction
     {
         AssetType = AssetType.AntShare,
         Name = "[{'lang':'zh-CN','name':'小蚁股'},{'lang':'en','name':'AntShare'}]",
         Amount = Fixed8.FromDecimal(numericUpDown1.Value),
         Issuer = textBox1.Text.ToScriptHash(),
         Admin = textBox2.Text.ToScriptHash(),
         Inputs = new TransactionInput[0],
         Outputs = new TransactionOutput[0]
     };
     SignatureContext context = new SignatureContext(antshare);
     InformationBox.Show(context.ToString(), "小蚁股签名上下文");
 }
Example #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            RegisterTransaction antshare = new RegisterTransaction
            {
                AssetType = AssetType.AntShare,
#if TESTNET
                Name = "[{'lang':'zh-CN','name':'小蚁股(测试)'},{'lang':'en','name':'AntShare(TestNet)'}]",
#else
                Name = "[{'lang':'zh-CN','name':'小蚁股'},{'lang':'en','name':'AntShare'}]",
#endif
                Amount = Fixed8.FromDecimal(numericUpDown1.Value),
                Issuer = ECPoint.Parse(textBox1.Text, ECCurve.Secp256r1),
                Admin = Wallet.ToScriptHash(textBox2.Text),
                Attributes = new TransactionAttribute[0],
                Inputs = new TransactionInput[0],
                Outputs = new TransactionOutput[0]
            };
            SignatureContext context = new SignatureContext(antshare);
            InformationBox.Show(context.ToString(), "小蚁股签名上下文:");
        }
Example #5
0
 private void 资产分发IToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (IssueDialog dialog = new IssueDialog())
     {
         if (dialog.ShowDialog() != DialogResult.OK) return;
         IssueTransaction tx = dialog.GetTransaction();
         if (tx == null) return;
         //TODO: 检查是否符合规则,如是否超过总量、分发方式是否符合约定等;
         SignatureContext context = new SignatureContext(tx);
         Program.CurrentWallet.Sign(context);
         if (context.Completed)
         {
             context.Signable.Scripts = context.GetScripts();
             InformationBox.Show(context.Signable.ToArray().ToHexString(), "分发交易构造完成,并已完整签名,可以广播。");
         }
         else
         {
             InformationBox.Show(context.ToString(), "分发交易构造完成,但签名信息还不完整。");
         }
     }
 }