private void button8_Click(object sender, EventArgs e)
        {
            TransactionWrapper        wrapper = (TransactionWrapper)propertyGrid1.SelectedObject;
            ContractParametersContext context = new ContractParametersContext(wrapper.Unwrap());

            InformationBox.Show(context.ToString(), "ParametersContext", "ParametersContext");
        }
Example #2
0
        public static void SignAndShowInformation(Transaction tx)
        {
            if (tx == null)
            {
                MessageBox.Show(Strings.InsufficientFunds);
                return;
            }
            ContractParametersContext context;

            try
            {
                context = new ContractParametersContext(tx);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show(Strings.UnsynchronizedBlock);
                return;
            }
            Program.CurrentWallet.Sign(context);
            if (context.Completed)
            {
                context.Verifiable.Witnesses = context.GetWitnesses();
                Program.CurrentWallet.ApplyTransaction(tx);
                Program.BhpSystem.LocalNode.Tell(new LocalNode.Relay {
                    Inventory = tx
                });

                string txt = GetTxHashData(tx).ToHexString() + "\n" + tx.Hash.ToString();
                InformationBox.Show(txt, Strings.SendTxSucceedMessage, Strings.SendTxSucceedTitle);
            }
            else
            {
                InformationBox.Show(context.ToString(), Strings.IncompletedSignatureMessage, Strings.IncompletedSignatureTitle);
            }
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            ContractTransaction tx = Program.CurrentWallet.MakeTransaction(new ContractTransaction
            {
                Outputs = txOutListBox1.Items.Select(p => p.ToTxOutput()).ToArray()
            }, fee: Fixed8.Zero);

            textBox3.Text = RequestToJson(tx).ToString();
            InformationBox.Show(textBox3.Text, Strings.TradeRequestCreatedMessage, Strings.TradeRequestCreatedCaption);
            tabControl1.SelectedTab = tabPage2;
        }
        private void button4_Click(object sender, EventArgs e)
        {
            ContractParametersContext context = ContractParametersContext.Parse(textBox2.Text);

            context.Verifiable.Witnesses = context.GetWitnesses();
            IInventory inventory = (IInventory)context.Verifiable;

            Program.BhpSystem.LocalNode.Tell(new LocalNode.Relay {
                Inventory = inventory
            });
            InformationBox.Show(inventory.Hash.ToString(), Strings.RelaySuccessText, Strings.RelaySuccessTitle);
            button4.Visible = false;
        }
        private void button4_Click(object sender, EventArgs e)
        {
            context.Verifiable.Witnesses = context.GetWitnesses();
            IInventory        inventory = (IInventory)context.Verifiable;
            RelayResultReason reason    = Program.BhpSystem.Blockchain.Ask <RelayResultReason>(inventory).Result;

            if (reason == RelayResultReason.Succeed)
            {
                InformationBox.Show(inventory.Hash.ToString(), Strings.RelaySuccessText, Strings.RelaySuccessTitle);
            }
            else
            {
                MessageBox.Show($"Transaction cannot be broadcast: {reason}");
            }
        }
 public static DialogResult Show(string text, string message = null, string title = null)
 {
     using (InformationBox box = new InformationBox())
     {
         box.textBox1.Text = text;
         if (message != null)
         {
             box.label1.Text = message;
         }
         if (title != null)
         {
             box.Text = title;
         }
         return(box.ShowDialog());
     }
 }
Example #7
0
        private void button3_Click(object sender, EventArgs e)
        {
            ContractParametersContext context;
            JObject json1 = JObject.Parse(textBox2.Text);

            if (json1.ContainsProperty("hex"))
            {
                context = ContractParametersContext.FromJson(json1);
            }
            else
            {
                ContractTransaction tx1 = JsonToRequest(json1);
                ContractTransaction tx2 = JsonToRequest(JObject.Parse(textBox3.Text));
                context = new ContractParametersContext(new ContractTransaction
                {
                    Attributes = new TransactionAttribute[0],
                    Inputs     = tx1.Inputs.Concat(tx2.Inputs).ToArray(),
                    Outputs    = tx1.Outputs.Concat(tx2.Outputs).ToArray()
                });
            }
            Program.CurrentWallet.Sign(context);
            if (context.Completed)
            {
                context.Verifiable.Witnesses = context.GetWitnesses();
                ContractTransaction tx = (ContractTransaction)context.Verifiable;
                Program.CurrentWallet.ApplyTransaction(tx);
                Program.BhpSystem.LocalNode.Tell(new LocalNode.Relay {
                    Inventory = tx
                });
                InformationBox.Show(tx.Hash.ToString(), Strings.TradeSuccessMessage, Strings.TradeSuccessCaption);
            }
            else
            {
                InformationBox.Show(context.ToString(), Strings.TradeNeedSignatureMessage, Strings.TradeNeedSignatureCaption);
            }
        }
 private void button2_Click(object sender, EventArgs e)
 {
     InformationBox.Show(context.ToString(), "ParametersContext", "ParametersContext");
 }