Beispiel #1
0
        public static void SignAndShowInformation(Transaction tx)
        {
            if (tx == null)
            {
                MessageBox.Show(LanHelper.LocalLanguage("Insufficient funds, transaction cannot be initiated."));
                return;
            }
            ContractParametersContext context;

            try
            {
                context = new ContractParametersContext(tx);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show(LanHelper.LocalLanguage("Blockchain unsynchronized, transaction cannot be sent."));
                return;
            }
            Program.CurrentWallet.Sign(context);
            if (context.Completed)
            {
                tx.Witnesses = context.GetWitnesses();
                Program.CurrentWallet.ApplyTransaction(tx);
                Program.OXSystem.LocalNode.Tell(new LocalNode.Relay {
                    Inventory = tx
                });
                InformationBox.Show(tx.Hash.ToString(), LanHelper.LocalLanguage("Transaction sent, TXID:"), LanHelper.LocalLanguage("Transaction successful"));
            }
            else
            {
                InformationBox.Show(context.ToString(), LanHelper.LocalLanguage("Transaction initiated, but the signature is incomplete."), LanHelper.LocalLanguage("Incomplete signature"));
            }
        }
Beispiel #2
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, LanHelper.LocalLanguage("Transaction request generated, please send it to the counterparty or merge it with the counterparty's request."), LanHelper.LocalLanguage("Trade Request"));
            tabControl1.SelectedTab = tabPage2;
        }
Beispiel #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            ContractParametersContext context = ContractParametersContext.Parse(textBox2.Text);

            if (!(context.Verifiable is Transaction tx))
            {
                MessageBox.Show("Only support to broadcast transaction.");
                return;
            }
            tx.Witnesses = context.GetWitnesses();
            Program.OXSystem.LocalNode.Tell(new LocalNode.Relay {
                Inventory = tx
            });
            InformationBox.Show(tx.Hash.ToString(), LanHelper.LocalLanguage("Data broadcast success, the hash is shown as follows:"), LanHelper.LocalLanguage("Broadcast Success"));
            button4.Visible = false;
        }
Beispiel #4
0
 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());
     }
 }
Beispiel #5
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)
            {
                ContractTransaction tx = (ContractTransaction)context.Verifiable;
                tx.Witnesses = context.GetWitnesses();
                Program.CurrentWallet.ApplyTransaction(tx);
                Program.OXSystem.LocalNode.Tell(new LocalNode.Relay {
                    Inventory = tx
                });
                InformationBox.Show(tx.Hash.ToString(), LanHelper.LocalLanguage("Transaction sent, this is the TXID:"), LanHelper.LocalLanguage("Trade Success"));
            }
            else
            {
                InformationBox.Show(context.ToString(), LanHelper.LocalLanguage("Transaction generated, please send the following information to the counterparty for signing:"), LanHelper.LocalLanguage("Need Signature"));
            }
        }