Merge branch 'feature/signMessage' into develop
This commit is contained in:
commit
b29971e4aa
28
FireWalletLite/DomainForm.Designer.cs
generated
28
FireWalletLite/DomainForm.Designer.cs
generated
@ -39,6 +39,8 @@
|
||||
buttonCancel = new Button();
|
||||
buttonFinalize = new Button();
|
||||
groupBoxSign = new GroupBox();
|
||||
textBoxSignature = new TextBox();
|
||||
buttonSign = new Button();
|
||||
textBoxSignMessage = new TextBox();
|
||||
labelSignMessage = new Label();
|
||||
groupBoxManage.SuspendLayout();
|
||||
@ -151,6 +153,8 @@
|
||||
//
|
||||
// groupBoxSign
|
||||
//
|
||||
groupBoxSign.Controls.Add(textBoxSignature);
|
||||
groupBoxSign.Controls.Add(buttonSign);
|
||||
groupBoxSign.Controls.Add(textBoxSignMessage);
|
||||
groupBoxSign.Controls.Add(labelSignMessage);
|
||||
groupBoxSign.Font = new Font("Segoe UI", 14F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
@ -161,13 +165,33 @@
|
||||
groupBoxSign.TabStop = false;
|
||||
groupBoxSign.Text = "Sign";
|
||||
//
|
||||
// textBoxSignature
|
||||
//
|
||||
textBoxSignature.Location = new Point(484, 56);
|
||||
textBoxSignature.Multiline = true;
|
||||
textBoxSignature.Name = "textBoxSignature";
|
||||
textBoxSignature.ReadOnly = true;
|
||||
textBoxSignature.Size = new Size(260, 156);
|
||||
textBoxSignature.TabIndex = 3;
|
||||
//
|
||||
// buttonSign
|
||||
//
|
||||
buttonSign.Location = new Point(606, 218);
|
||||
buttonSign.Name = "buttonSign";
|
||||
buttonSign.Size = new Size(138, 33);
|
||||
buttonSign.TabIndex = 2;
|
||||
buttonSign.Text = "Sign";
|
||||
buttonSign.UseVisualStyleBackColor = true;
|
||||
buttonSign.Click += buttonSign_Click;
|
||||
//
|
||||
// textBoxSignMessage
|
||||
//
|
||||
textBoxSignMessage.Location = new Point(6, 56);
|
||||
textBoxSignMessage.Multiline = true;
|
||||
textBoxSignMessage.Name = "textBoxSignMessage";
|
||||
textBoxSignMessage.Size = new Size(744, 195);
|
||||
textBoxSignMessage.Size = new Size(472, 156);
|
||||
textBoxSignMessage.TabIndex = 1;
|
||||
textBoxSignMessage.TextChanged += textBoxSignMessage_TextChanged;
|
||||
//
|
||||
// labelSignMessage
|
||||
//
|
||||
@ -216,5 +240,7 @@
|
||||
private GroupBox groupBoxSign;
|
||||
private TextBox textBoxSignMessage;
|
||||
private Label labelSignMessage;
|
||||
private Button buttonSign;
|
||||
private TextBox textBoxSignature;
|
||||
}
|
||||
}
|
@ -238,5 +238,60 @@ namespace FireWalletLite
|
||||
File.WriteAllText(Main.dir + "domains.json", domains.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private async void buttonSign_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (buttonSign.Text == "Save")
|
||||
{
|
||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
saveFileDialog.Filter = "Text File|*.txt";
|
||||
saveFileDialog.Title = "Save Signature";
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
JObject signature = new JObject();
|
||||
signature["domain"] = Domain;
|
||||
signature["message"] = textBoxSignMessage.Text;
|
||||
signature["signature"] = textBoxSignature.Text;
|
||||
signature["time"] = DateTime.Now.ToString();
|
||||
File.WriteAllText(saveFileDialog.FileName, signature.ToString());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (textBoxSignMessage.Text == "")
|
||||
{
|
||||
NotifyForm notify = new NotifyForm("Enter a message to sign");
|
||||
notify.ShowDialog();
|
||||
notify.Dispose();
|
||||
return;
|
||||
}
|
||||
string content = "{\"method\": \"signmessagewithname\", \"params\": [\"" + Domain + "\", \"" + textBoxSignMessage.Text + "\"]}";
|
||||
string response = await Main.APIPost("", true, content);
|
||||
if (response == "Error")
|
||||
{
|
||||
NotifyForm notify = new NotifyForm("Error signing message");
|
||||
notify.ShowDialog();
|
||||
notify.Dispose();
|
||||
return;
|
||||
}
|
||||
JObject jObject = JObject.Parse(response);
|
||||
if (jObject.ContainsKey("result"))
|
||||
{
|
||||
textBoxSignature.Text = jObject["result"].ToString();
|
||||
buttonSign.Text = "Save";
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.AddLog(response);
|
||||
NotifyForm notify = new NotifyForm("Error signing message");
|
||||
notify.ShowDialog();
|
||||
notify.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void textBoxSignMessage_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
buttonSign.Text = "Sign";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user