Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
NEP-6 (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Zhang authored Dec 12, 2017
1 parent 01ce716 commit ae3605e
Show file tree
Hide file tree
Showing 42 changed files with 480 additions and 1,255 deletions.
4 changes: 2 additions & 2 deletions neo-gui/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Neo.Core;
using Neo.Implementations.Blockchains.LevelDB;
using Neo.Implementations.Wallets.EntityFramework;
using Neo.Network;
using Neo.Properties;
using Neo.UI;
using Neo.Wallets;
using System;
using System.ComponentModel;
using System.Diagnostics;
Expand All @@ -19,7 +19,7 @@ namespace Neo
internal static class Program
{
public static LocalNode LocalNode;
public static UserWallet CurrentWallet;
public static Wallet CurrentWallet;
public static MainForm MainForm;

private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion neo-gui/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
[assembly: AssemblyVersion("2.4.*")]
[assembly: AssemblyVersion("2.5.*")]
//[assembly: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
6 changes: 3 additions & 3 deletions neo-gui/Properties/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions neo-gui/Properties/Strings.es-Es.resx
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,6 @@
<value>Abriendo ficheros de monederos antiguos, actualizar al nuevo formato?
Aviso: los ficheros actualizados no podran ser abiertos por clientes de versiones antiguas.</value>
</data>
<data name="MigrateWalletSucceedMessage" xml:space="preserve">
<value>Ficheros de monederos realojados. Los ficheros antiguos se guardaron automáticamente en:</value>
</data>
<data name="PasswordIncorrect" xml:space="preserve">
<value>Contraseña incorrecta</value>
</data>
Expand Down
2 changes: 1 addition & 1 deletion neo-gui/Properties/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
Note: updated files cannot be openned by clients in older versions!</value>
</data>
<data name="MigrateWalletSucceedMessage" xml:space="preserve">
<value>Wallet files relocated. Old files have been auto-saved at: </value>
<value>Wallet file relocated. New wallet file has been saved at: </value>
</data>
<data name="PasswordIncorrect" xml:space="preserve">
<value>Password Incorrect</value>
Expand Down
2 changes: 1 addition & 1 deletion neo-gui/Properties/Strings.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
注意,升级后将无法用旧版本的客户端打开该文件!</value>
</data>
<data name="MigrateWalletSucceedMessage" xml:space="preserve">
<value>钱包文件迁移成功,旧的文件已经自动保存到以下位置:</value>
<value>钱包文件迁移成功,新的钱包文件已经自动保存到以下位置:</value>
</data>
<data name="PasswordIncorrect" xml:space="preserve">
<value>密码错误!</value>
Expand Down
6 changes: 3 additions & 3 deletions neo-gui/UI/AssetRegisterDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public InvocationTransaction GetTransaction()
private void AssetRegisterDialog_Load(object sender, EventArgs e)
{
comboBox1.Items.AddRange(new object[] { AssetType.Share, AssetType.Token });
comboBox2.Items.AddRange(Program.CurrentWallet.GetContracts().Where(p => p.IsStandard).Select(p => Program.CurrentWallet.GetKey(p.PublicKeyHash).PublicKey).ToArray());
comboBox3.Items.AddRange(Program.CurrentWallet.GetContracts().Select(p => p.Address).ToArray());
comboBox4.Items.AddRange(Program.CurrentWallet.GetContracts().Select(p => p.Address).ToArray());
comboBox2.Items.AddRange(Program.CurrentWallet.GetAccounts().Where(p => !p.WatchOnly && p.Contract.IsStandard).Select(p => p.GetKey().PublicKey).ToArray());
comboBox3.Items.AddRange(Program.CurrentWallet.GetAccounts().Where(p => !p.WatchOnly).Select(p => p.Address).ToArray());
comboBox4.Items.AddRange(Program.CurrentWallet.GetAccounts().Where(p => !p.WatchOnly).Select(p => p.Address).ToArray());
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
Expand Down
10 changes: 4 additions & 6 deletions neo-gui/UI/CertificateRequestWizard.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Neo.Cryptography.ECC;
using CERTENROLLLib;
using Neo.Wallets;
using CERTENROLLLib;
using System;
using System.IO;
using System.Linq;
Expand All @@ -17,7 +16,7 @@ public CertificateRequestWizard()

private void CertificateRequestWizard_Load(object sender, EventArgs e)
{
comboBox1.Items.AddRange(Program.CurrentWallet.GetContracts().Where(p => p.IsStandard).Select(p => Program.CurrentWallet.GetKey(p.PublicKeyHash).PublicKey).ToArray());
comboBox1.Items.AddRange(Program.CurrentWallet.GetAccounts().Where(p => !p.WatchOnly && p.Contract.IsStandard).Select(p => p.GetKey()).ToArray());
}

private void textBox_TextChanged(object sender, EventArgs e)
Expand All @@ -28,9 +27,8 @@ private void textBox_TextChanged(object sender, EventArgs e)
private void button1_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() != DialogResult.OK) return;
ECPoint point = (ECPoint)comboBox1.SelectedItem;
KeyPair key = Program.CurrentWallet.GetKey(point);
byte[] pubkey = point.EncodePoint(false).Skip(1).ToArray();
KeyPair key = (KeyPair)comboBox1.SelectedItem;
byte[] pubkey = key.PublicKey.EncodePoint(false).Skip(1).ToArray();
byte[] prikey;
using (key.Decrypt())
{
Expand Down
5 changes: 3 additions & 2 deletions neo-gui/UI/ContractDetailsDialog.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using Neo.Wallets;
using Neo.SmartContract;
using Neo.Wallets;
using System.Windows.Forms;

namespace Neo.UI
{
internal partial class ContractDetailsDialog : Form
{
public ContractDetailsDialog(VerificationContract contract)
public ContractDetailsDialog(Contract contract)
{
InitializeComponent();
textBox1.Text = Wallet.ToAddress(contract.ScriptHash);
Expand Down
18 changes: 10 additions & 8 deletions neo-gui/UI/CreateLockAccountDialog.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Neo.Core;
using Neo.Cryptography.ECC;
using Neo.SmartContract;
using Neo.SmartContract;
using Neo.VM;
using Neo.Wallets;
using System;
Expand All @@ -14,23 +12,27 @@ internal partial class CreateLockAccountDialog : Form
public CreateLockAccountDialog()
{
InitializeComponent();
comboBox1.Items.AddRange(Program.CurrentWallet.GetContracts().Where(p => p.IsStandard).Select(p => Program.CurrentWallet.GetKey(p.PublicKeyHash).PublicKey).ToArray());
comboBox1.Items.AddRange(Program.CurrentWallet.GetAccounts().Where(p => !p.WatchOnly && p.Contract.IsStandard).Select(p => p.GetKey()).ToArray());
}

public VerificationContract GetContract()
public Contract GetContract()
{
ECPoint publicKey = (ECPoint)comboBox1.SelectedItem;
uint timestamp = dateTimePicker1.Value.ToTimestamp();
using (ScriptBuilder sb = new ScriptBuilder())
{
sb.EmitPush(publicKey);
sb.EmitPush(GetKey().PublicKey);
sb.EmitPush(timestamp);
// Lock 2.0 in mainnet tx:4e84015258880ced0387f34842b1d96f605b9cc78b308e1f0d876933c2c9134b
sb.EmitAppCall(UInt160.Parse("d3cce84d0800172d09c88ccad61130611bd047a4"));
return VerificationContract.Create(publicKey.EncodePoint(true).ToScriptHash(), new[] { ContractParameterType.Signature }, sb.ToArray());
return Contract.Create(new[] { ContractParameterType.Signature }, sb.ToArray());
}
}

public KeyPair GetKey()
{
return (KeyPair)comboBox1.SelectedItem;
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
button1.Enabled = comboBox1.SelectedIndex >= 0;
Expand Down
27 changes: 14 additions & 13 deletions neo-gui/UI/CreateMultiSigContractDialog.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
using Neo.Core;
using Neo.Cryptography.ECC;
using Neo.Cryptography.ECC;
using Neo.SmartContract;
using Neo.Wallets;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace Neo.UI
{
internal partial class CreateMultiSigContractDialog : Form
{
private ECPoint[] publicKeys;

public CreateMultiSigContractDialog()
{
InitializeComponent();
}

public VerificationContract GetContract()
public Contract GetContract()
{
publicKeys = listBox1.Items.OfType<string>().Select(p => ECPoint.DecodePoint(p.HexToBytes(), ECCurve.Secp256r1)).ToArray();
return Contract.CreateMultiSigContract((int)numericUpDown2.Value, publicKeys);
}

public KeyPair GetKey()
{
ECPoint[] publicKeys = listBox1.Items.OfType<string>().Select(p => ECPoint.DecodePoint(p.HexToBytes(), ECCurve.Secp256r1)).ToArray();
foreach (ECPoint publicKey in publicKeys)
{
KeyPair key = Program.CurrentWallet.GetKey(publicKey.EncodePoint(true).ToScriptHash());
if (key != null)
{
return VerificationContract.CreateMultiSigContract(key.PublicKeyHash, (int)numericUpDown2.Value, publicKeys);
}
}
return null;
HashSet<ECPoint> hashSet = new HashSet<ECPoint>(publicKeys);
return Program.CurrentWallet.GetAccounts().FirstOrDefault(p => p.HasKey && hashSet.Contains(p.GetKey().PublicKey))?.GetKey();
}

private void numericUpDown2_ValueChanged(object sender, EventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion neo-gui/UI/CreateWalletDialog.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion neo-gui/UI/CreateWalletDialog.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
<value>Wallet File:</value>
</data>
<data name="saveFileDialog1.Filter" xml:space="preserve">
<value>Wallet File|*.db3</value>
<value>Wallet File|*.json</value>
</data>
<data name="&gt;&gt;button1.Parent" xml:space="preserve">
<value>$this</value>
Expand Down
2 changes: 1 addition & 1 deletion neo-gui/UI/CreateWalletDialog.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
<value>确定</value>
</data>
<data name="saveFileDialog1.Filter" xml:space="preserve">
<value>钱包数据库|*.db3</value>
<value>钱包文件|*.json</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>483, 105</value>
Expand Down
2 changes: 1 addition & 1 deletion neo-gui/UI/ElectionDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public InvocationTransaction GetTransaction()

private void ElectionDialog_Load(object sender, EventArgs e)
{
comboBox1.Items.AddRange(Program.CurrentWallet.GetContracts().Where(p => p.IsStandard).Select(p => Program.CurrentWallet.GetKey(p.PublicKeyHash).PublicKey).ToArray());
comboBox1.Items.AddRange(Program.CurrentWallet.GetAccounts().Where(p => !p.WatchOnly && p.Contract.IsStandard).Select(p => p.GetKey().PublicKey).ToArray());
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion neo-gui/UI/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void SignAndShowInformation(Transaction tx)
if (context.Completed)
{
context.Verifiable.Scripts = context.GetScripts();
Program.CurrentWallet.SaveTransaction(tx);
Program.CurrentWallet.ApplyTransaction(tx);
Program.LocalNode.Relay(tx);
InformationBox.Show(tx.Hash.ToString(), Strings.SendTxSucceedMessage, Strings.SendTxSucceedTitle);
}
Expand Down
20 changes: 8 additions & 12 deletions neo-gui/UI/ImportCustomContractDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ae3605e

Please sign in to comment.