(tokens);
76 |
77 | while (checks > 0 && tokenList.Count > 0)
78 | {
79 | switch (tokenList[0])
80 | {
81 | case CommandSpaceToken _:
82 | {
83 | tokenList.RemoveAt(0);
84 | break;
85 | }
86 | case CommandQuoteToken _:
87 | {
88 | quoted = !quoted;
89 | tokenList.RemoveAt(0);
90 | break;
91 | }
92 | case CommandStringToken str:
93 | {
94 | if (Verbs[^checks] != str.Value.ToLowerInvariant())
95 | {
96 | consumedArgs = 0;
97 | return false;
98 | }
99 |
100 | checks--;
101 | tokenList.RemoveAt(0);
102 | break;
103 | }
104 | }
105 | }
106 |
107 | if (quoted && tokenList.Count > 0 && tokenList[0].Type == CommandTokenType.Quote)
108 | {
109 | tokenList.RemoveAt(0);
110 | }
111 |
112 | // Trim start
113 |
114 | while (tokenList.Count > 0 && tokenList[0].Type == CommandTokenType.Space) tokenList.RemoveAt(0);
115 |
116 | consumedArgs = tokens.Length - tokenList.Count;
117 | return checks == 0;
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/Neo.ConsoleService/ConsoleHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Neo.ConsoleService
4 | {
5 | public static class ConsoleHelper
6 | {
7 | private static readonly ConsoleColorSet InfoColor = new(ConsoleColor.Cyan);
8 | private static readonly ConsoleColorSet WarningColor = new(ConsoleColor.Yellow);
9 | private static readonly ConsoleColorSet ErrorColor = new(ConsoleColor.Red);
10 |
11 | ///
12 | /// Info handles message in the format of "[tag]:[message]",
13 | /// avoid using Info if the `tag` is too long
14 | ///
15 | /// The log message in pairs of (tag, message)
16 | public static void Info(params string[] values)
17 | {
18 | var currentColor = new ConsoleColorSet();
19 |
20 | for (int i = 0; i < values.Length; i++)
21 | {
22 | if (i % 2 == 0)
23 | InfoColor.Apply();
24 | else
25 | currentColor.Apply();
26 | Console.Write(values[i]);
27 | }
28 | currentColor.Apply();
29 | Console.WriteLine();
30 | }
31 |
32 | ///
33 | /// Use warning if something unexpected happens
34 | /// or the execution result is not correct.
35 | /// Also use warning if you just want to remind
36 | /// user of doing something.
37 | ///
38 | /// Warning message
39 | public static void Warning(string msg)
40 | {
41 | Log("Warning", WarningColor, msg);
42 | }
43 |
44 | ///
45 | /// Use Error if the verification or input format check fails
46 | /// or exception that breaks the execution of interactive
47 | /// command throws.
48 | ///
49 | /// Error message
50 | public static void Error(string msg)
51 | {
52 | Log("Error", ErrorColor, msg);
53 | }
54 |
55 | private static void Log(string tag, ConsoleColorSet colorSet, string msg)
56 | {
57 | var currentColor = new ConsoleColorSet();
58 |
59 | colorSet.Apply();
60 | Console.Write($"{tag}: ");
61 | currentColor.Apply();
62 | Console.WriteLine(msg);
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/Neo.ConsoleService/Neo.ConsoleService.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2015-2023 The Neo Project
5 | 1.2.0
6 | The Neo Project
7 | net7.0
8 | https://github.com/neo-project/neo-node
9 | MIT
10 | git
11 | https://github.com/neo-project/neo-node.git
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/Neo.ConsoleService/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The Neo.ConsoleService is free software distributed under the MIT
4 | // software license, see the accompanying file LICENSE in the main directory
5 | // of the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System.Runtime.CompilerServices;
12 |
13 | [assembly: InternalsVisibleTo("Neo.ConsoleService.Tests")]
14 |
--------------------------------------------------------------------------------
/Neo.ConsoleService/ServiceProxy.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The Neo.ConsoleService is free software distributed under the MIT
4 | // software license, see the accompanying file LICENSE in the main directory
5 | // of the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System.ServiceProcess;
12 |
13 | namespace Neo.ConsoleService
14 | {
15 | internal class ServiceProxy : ServiceBase
16 | {
17 | private readonly ConsoleServiceBase _service;
18 |
19 | public ServiceProxy(ConsoleServiceBase service)
20 | {
21 | this._service = service;
22 | }
23 |
24 | protected override void OnStart(string[] args)
25 | {
26 | _service.OnStart(args);
27 | }
28 |
29 | protected override void OnStop()
30 | {
31 | _service.OnStop();
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | # ARCHIVED
19 |
20 | This repository was merged into https://github.com/neo-project/neo, newer (post-3.6) node versions can be obtained from it.
21 |
22 | ---
23 |
24 | Currently, neo-cli and neo-gui are integrated into one repository. You can enter the corresponding folder and follow the instructions to run each node.
25 |
26 | ## Prerequisites
27 |
28 | You will need Window, Linux or macOS. Ubuntu LTS 14, 16 and 18 are supported.
29 |
30 | Install [.NET Core](https://www.microsoft.com/net/download/core).
31 |
32 | On Linux, install the LevelDB and SQLite3 dev packages. E.g. on Ubuntu or Fedora:
33 |
34 | ```sh
35 | sudo apt-get install libleveldb-dev sqlite3 libsqlite3-dev libunwind8-dev # Ubuntu
36 | sudo dnf install leveldb-devel sqlite sqlite-devel libunwind-devel # Fedora
37 | ```
38 |
39 | On macOS, install the LevelDB package. E.g. install via Homebrew:
40 |
41 | ```
42 | brew install --ignore-dependencies --build-from-source leveldb
43 | ```
44 |
45 | On Windows, use the [Neo version of LevelDB](https://github.com/neo-project/leveldb).
46 |
47 | ## Download pre-compiled binaries
48 |
49 | See also [official docs](https://docs.neo.org/docs/en-us/node/introduction.html). Download and unzip the [latest release](https://github.com/neo-project/neo-node/releases).
50 |
51 | On Linux, you can type the command:
52 |
53 | ```sh
54 | ./neo-cli
55 | ```
56 |
57 | On Windows, you can just double click the exe to run the node.
58 |
59 | ## Compile from source
60 |
61 | Clone the neo-node repository.
62 |
63 | For neo-cli, you can type the following commands:
64 |
65 | ```sh
66 | cd neo-node/neo-cli
67 | dotnet restore
68 | dotnet publish -c Release
69 | ```
70 | Next, you should enter the working directory (i.e. /bin/Debug, /bin/Release) and paste the `libleveldb.dll` here. In addition, you need to create `Plugins` folder and put the `LevelDBStore` or `RocksDBStore` or other supported storage engine, as well as the configuration file, in the Plugins folder.
71 |
72 | Assuming you are in the working directory:
73 |
74 | ```sh
75 | dotnet neo-cli.dll
76 | ```
77 |
78 | For neo-gui, you just need to enter the `neo-node/neo-gui` folder and follow the above steps to run the node.
79 |
80 | ## Build into Docker
81 |
82 | Clone the neo-node repository.
83 |
84 | ```sh
85 | cd neo-node
86 | docker build -t neo-cli .
87 | docker run -p 10332:10332 -p 10333:10333 --name=neo-cli-mainnet neo-cli
88 | ```
89 |
90 | After start the container successfully, use the following scripts to open neo-cli interactive window:
91 |
92 | ```sh
93 | docker exec -it neo-cli-mainnet /bin/bash
94 | screen -r node
95 | ```
96 |
97 | ## Logging
98 |
99 | To enable logs in neo-cli, you need to add the ApplicationLogs plugin. Please check [here](https://github.com/neo-project/neo-modules.git) for more information.
100 |
101 |
102 | ## Bootstrapping the network.
103 | In order to synchronize the network faster, please check [here](https://docs.neo.org/docs/en-us/node/syncblocks.html).
104 |
105 |
106 | ## Usage
107 |
108 | For more information about these two nodes, you can refer to [documentation](https://docs.neo.org/docs/en-us/node/introduction.html) to try out more features.
109 |
110 |
--------------------------------------------------------------------------------
/neo-cli/CLI/ConsolePercent.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-cli is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System;
12 |
13 | namespace Neo.CLI
14 | {
15 | public class ConsolePercent : IDisposable
16 | {
17 | #region Variables
18 |
19 | private readonly long _maxValue;
20 | private long _value;
21 | private decimal _lastFactor;
22 | private string _lastPercent;
23 |
24 | private readonly int _x, _y;
25 |
26 | private bool _inputRedirected;
27 |
28 | #endregion
29 |
30 | #region Properties
31 |
32 | ///
33 | /// Value
34 | ///
35 | public long Value
36 | {
37 | get => _value;
38 | set
39 | {
40 | if (value == _value) return;
41 |
42 | _value = Math.Min(value, _maxValue);
43 | Invalidate();
44 | }
45 | }
46 |
47 | ///
48 | /// Maximum value
49 | ///
50 | public long MaxValue
51 | {
52 | get => _maxValue;
53 | init
54 | {
55 | if (value == _maxValue) return;
56 |
57 | _maxValue = value;
58 |
59 | if (_value > _maxValue)
60 | _value = _maxValue;
61 |
62 | Invalidate();
63 | }
64 | }
65 |
66 | ///
67 | /// Percent
68 | ///
69 | public decimal Percent
70 | {
71 | get
72 | {
73 | if (_maxValue == 0) return 0;
74 | return (_value * 100M) / _maxValue;
75 | }
76 | }
77 |
78 | #endregion
79 |
80 | ///
81 | /// Constructor
82 | ///
83 | /// Value
84 | /// Maximum value
85 | public ConsolePercent(long value = 0, long maxValue = 100)
86 | {
87 | _inputRedirected = Console.IsInputRedirected;
88 | _lastFactor = -1;
89 | _x = _inputRedirected ? 0 : Console.CursorLeft;
90 | _y = _inputRedirected ? 0 : Console.CursorTop;
91 |
92 | MaxValue = maxValue;
93 | Value = value;
94 | Invalidate();
95 | }
96 |
97 | ///
98 | /// Invalidate
99 | ///
100 | public void Invalidate()
101 | {
102 | var factor = Math.Round((Percent / 100M), 1);
103 | var percent = Percent.ToString("0.0").PadLeft(5, ' ');
104 |
105 | if (_lastFactor == factor && _lastPercent == percent)
106 | {
107 | return;
108 | }
109 |
110 | _lastFactor = factor;
111 | _lastPercent = percent;
112 |
113 | var fill = string.Empty.PadLeft((int)(10 * factor), '■');
114 | var clean = string.Empty.PadLeft(10 - fill.Length, _inputRedirected ? '□' : '■');
115 |
116 | if (_inputRedirected)
117 | {
118 | Console.WriteLine("[" + fill + clean + "] (" + percent + "%)");
119 | }
120 | else
121 | {
122 | Console.SetCursorPosition(_x, _y);
123 |
124 | var prevColor = Console.ForegroundColor;
125 |
126 | Console.ForegroundColor = ConsoleColor.White;
127 | Console.Write("[");
128 | Console.ForegroundColor = Percent > 50 ? ConsoleColor.Green : ConsoleColor.DarkGreen;
129 | Console.Write(fill);
130 | Console.ForegroundColor = ConsoleColor.White;
131 | Console.Write(clean + "] (" + percent + "%)");
132 |
133 | Console.ForegroundColor = prevColor;
134 | }
135 | }
136 |
137 | ///
138 | /// Free console
139 | ///
140 | public void Dispose()
141 | {
142 | Console.WriteLine("");
143 | }
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/neo-cli/CLI/Helper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-cli is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System;
12 | using Neo.SmartContract.Manifest;
13 |
14 | namespace Neo.CLI
15 | {
16 | internal static class Helper
17 | {
18 | public static bool IsYes(this string input)
19 | {
20 | if (input == null) return false;
21 |
22 | input = input.ToLowerInvariant();
23 |
24 | return input == "yes" || input == "y";
25 | }
26 |
27 | public static string ToBase64String(this byte[] input) => System.Convert.ToBase64String(input);
28 |
29 | public static void IsScriptValid(this ReadOnlyMemory script, ContractAbi abi)
30 | {
31 | try
32 | {
33 | SmartContract.Helper.Check(script.ToArray(), abi);
34 | }
35 | catch (Exception e)
36 | {
37 | throw new FormatException($"Bad Script or Manifest Format: {e.Message}");
38 | }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/neo-cli/CLI/MainService.NEP17.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-cli is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.ConsoleService;
12 | using Neo.Json;
13 | using Neo.Network.P2P.Payloads;
14 | using Neo.SmartContract;
15 | using Neo.SmartContract.Native;
16 | using Neo.VM.Types;
17 | using Neo.Wallets;
18 | using System;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using Array = System.Array;
22 |
23 | namespace Neo.CLI
24 | {
25 | partial class MainService
26 | {
27 | ///
28 | /// Process "transfer" command
29 | ///
30 | /// Script hash
31 | /// To
32 | /// Amount
33 | /// From
34 | /// Data
35 | /// Signer's accounts
36 | [ConsoleCommand("transfer", Category = "NEP17 Commands")]
37 | private void OnTransferCommand(UInt160 tokenHash, UInt160 to, decimal amount, UInt160 from = null, string data = null, UInt160[] signersAccounts = null)
38 | {
39 | var snapshot = NeoSystem.StoreView;
40 | var asset = new AssetDescriptor(snapshot, NeoSystem.Settings, tokenHash);
41 | var value = new BigDecimal(amount, asset.Decimals);
42 |
43 | if (NoWallet()) return;
44 |
45 | Transaction tx;
46 | try
47 | {
48 | tx = CurrentWallet.MakeTransaction(snapshot, new[]
49 | {
50 | new TransferOutput
51 | {
52 | AssetId = tokenHash,
53 | Value = value,
54 | ScriptHash = to,
55 | Data = data
56 | }
57 | }, from: from, cosigners: signersAccounts?.Select(p => new Signer
58 | {
59 | // default access for transfers should be valid only for first invocation
60 | Scopes = WitnessScope.CalledByEntry,
61 | Account = p
62 | })
63 | .ToArray() ?? Array.Empty());
64 | }
65 | catch (InvalidOperationException e)
66 | {
67 | ConsoleHelper.Error(GetExceptionMessage(e));
68 | return;
69 | }
70 | if (!ReadUserInput("Relay tx(no|yes)").IsYes())
71 | {
72 | return;
73 | }
74 | SignAndSendTx(snapshot, tx);
75 | }
76 |
77 | ///
78 | /// Process "balanceOf" command
79 | ///
80 | /// Script hash
81 | /// Address
82 | [ConsoleCommand("balanceOf", Category = "NEP17 Commands")]
83 | private void OnBalanceOfCommand(UInt160 tokenHash, UInt160 address)
84 | {
85 | var arg = new JObject
86 | {
87 | ["type"] = "Hash160",
88 | ["value"] = address.ToString()
89 | };
90 |
91 | var asset = new AssetDescriptor(NeoSystem.StoreView, NeoSystem.Settings, tokenHash);
92 |
93 | if (!OnInvokeWithResult(tokenHash, "balanceOf", out StackItem balanceResult, null, new JArray(arg))) return;
94 |
95 | var balance = new BigDecimal(((PrimitiveType)balanceResult).GetInteger(), asset.Decimals);
96 |
97 | Console.WriteLine();
98 | ConsoleHelper.Info($"{asset.AssetName} balance: ", $"{balance}");
99 | }
100 |
101 | ///
102 | /// Process "name" command
103 | ///
104 | /// Script hash
105 | [ConsoleCommand("name", Category = "NEP17 Commands")]
106 | private void OnNameCommand(UInt160 tokenHash)
107 | {
108 | ContractState contract = NativeContract.ContractManagement.GetContract(NeoSystem.StoreView, tokenHash);
109 | if (contract == null) Console.WriteLine($"Contract hash not exist: {tokenHash}");
110 | else ConsoleHelper.Info("Result: ", contract.Manifest.Name);
111 | }
112 |
113 | ///
114 | /// Process "decimals" command
115 | ///
116 | /// Script hash
117 | [ConsoleCommand("decimals", Category = "NEP17 Commands")]
118 | private void OnDecimalsCommand(UInt160 tokenHash)
119 | {
120 | if (!OnInvokeWithResult(tokenHash, "decimals", out StackItem result)) return;
121 |
122 | ConsoleHelper.Info("Result: ", $"{((PrimitiveType)result).GetInteger()}");
123 | }
124 |
125 | ///
126 | /// Process "totalSupply" command
127 | ///
128 | /// Script hash
129 | [ConsoleCommand("totalSupply", Category = "NEP17 Commands")]
130 | private void OnTotalSupplyCommand(UInt160 tokenHash)
131 | {
132 | if (!OnInvokeWithResult(tokenHash, "totalSupply", out StackItem result)) return;
133 |
134 | var asset = new AssetDescriptor(NeoSystem.StoreView, NeoSystem.Settings, tokenHash);
135 | var totalSupply = new BigDecimal(((PrimitiveType)result).GetInteger(), asset.Decimals);
136 |
137 | ConsoleHelper.Info("Result: ", $"{totalSupply}");
138 | }
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/neo-cli/CLI/MainService.Native.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-cli is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.ConsoleService;
12 | using Neo.SmartContract.Native;
13 | using System;
14 | using System.Linq;
15 |
16 | namespace Neo.CLI
17 | {
18 | partial class MainService
19 | {
20 | ///
21 | /// Process "list nativecontract" command
22 | ///
23 | [ConsoleCommand("list nativecontract", Category = "Native Contract")]
24 | private void OnListNativeContract()
25 | {
26 | NativeContract.Contracts.ToList().ForEach(p => ConsoleHelper.Info($"\t{p.Name,-20}", $"{p.Hash}"));
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/neo-cli/CLI/MainService.Node.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-cli is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Akka.Actor;
12 | using Neo.ConsoleService;
13 | using Neo.Network.P2P;
14 | using Neo.Network.P2P.Payloads;
15 | using Neo.SmartContract.Native;
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Linq;
19 | using System.Threading;
20 | using System.Threading.Tasks;
21 |
22 | namespace Neo.CLI
23 | {
24 | partial class MainService
25 | {
26 | ///
27 | /// Process "show pool" command
28 | ///
29 | [ConsoleCommand("show pool", Category = "Node Commands", Description = "Show the current state of the mempool")]
30 | private void OnShowPoolCommand(bool verbose = false)
31 | {
32 | int verifiedCount, unverifiedCount;
33 | if (verbose)
34 | {
35 | NeoSystem.MemPool.GetVerifiedAndUnverifiedTransactions(
36 | out IEnumerable verifiedTransactions,
37 | out IEnumerable unverifiedTransactions);
38 | ConsoleHelper.Info("Verified Transactions:");
39 | foreach (Transaction tx in verifiedTransactions)
40 | Console.WriteLine($" {tx.Hash} {tx.GetType().Name} {tx.NetworkFee} GAS_NetFee");
41 | ConsoleHelper.Info("Unverified Transactions:");
42 | foreach (Transaction tx in unverifiedTransactions)
43 | Console.WriteLine($" {tx.Hash} {tx.GetType().Name} {tx.NetworkFee} GAS_NetFee");
44 |
45 | verifiedCount = verifiedTransactions.Count();
46 | unverifiedCount = unverifiedTransactions.Count();
47 | }
48 | else
49 | {
50 | verifiedCount = NeoSystem.MemPool.VerifiedCount;
51 | unverifiedCount = NeoSystem.MemPool.UnVerifiedCount;
52 | }
53 | Console.WriteLine($"total: {NeoSystem.MemPool.Count}, verified: {verifiedCount}, unverified: {unverifiedCount}");
54 | }
55 |
56 | ///
57 | /// Process "show state" command
58 | ///
59 | [ConsoleCommand("show state", Category = "Node Commands", Description = "Show the current state of the node")]
60 | private void OnShowStateCommand()
61 | {
62 | var cancel = new CancellationTokenSource();
63 |
64 | Console.CursorVisible = false;
65 | Console.Clear();
66 |
67 | Task broadcast = Task.Run(async () =>
68 | {
69 | while (!cancel.Token.IsCancellationRequested)
70 | {
71 | NeoSystem.LocalNode.Tell(Message.Create(MessageCommand.Ping, PingPayload.Create(NativeContract.Ledger.CurrentIndex(NeoSystem.StoreView))));
72 | await Task.Delay(NeoSystem.Settings.TimePerBlock, cancel.Token);
73 | }
74 | });
75 | Task task = Task.Run(async () =>
76 | {
77 | int maxLines = 0;
78 | while (!cancel.Token.IsCancellationRequested)
79 | {
80 | uint height = NativeContract.Ledger.CurrentIndex(NeoSystem.StoreView);
81 | uint headerHeight = NeoSystem.HeaderCache.Last?.Index ?? height;
82 |
83 | Console.SetCursorPosition(0, 0);
84 | WriteLineWithoutFlicker($"block: {height}/{headerHeight} connected: {LocalNode.ConnectedCount} unconnected: {LocalNode.UnconnectedCount}", Console.WindowWidth - 1);
85 |
86 | int linesWritten = 1;
87 | foreach (RemoteNode node in LocalNode.GetRemoteNodes().OrderByDescending(u => u.LastBlockIndex).Take(Console.WindowHeight - 2).ToArray())
88 | {
89 | ConsoleHelper.Info(" ip: ",
90 | $"{node.Remote.Address,-15}\t",
91 | "port: ",
92 | $"{node.Remote.Port,-5}\t",
93 | "listen: ",
94 | $"{node.ListenerTcpPort,-5}\t",
95 | "height: ",
96 | $"{node.LastBlockIndex,-7}");
97 | linesWritten++;
98 | }
99 |
100 | maxLines = Math.Max(maxLines, linesWritten);
101 |
102 | while (linesWritten < maxLines)
103 | {
104 | WriteLineWithoutFlicker("", Console.WindowWidth - 1);
105 | maxLines--;
106 | }
107 |
108 | await Task.Delay(500, cancel.Token);
109 | }
110 | });
111 | ReadLine();
112 | cancel.Cancel();
113 | try { Task.WaitAll(task, broadcast); } catch { }
114 | Console.WriteLine();
115 | Console.CursorVisible = true;
116 | }
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/neo-cli/Extensions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-cli is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System.Linq;
12 | using System.Reflection;
13 |
14 | namespace Neo
15 | {
16 | ///
17 | /// Extension methods
18 | ///
19 | internal static class Extensions
20 | {
21 | public static string GetVersion(this Assembly assembly)
22 | {
23 | CustomAttributeData attribute = assembly.CustomAttributes.FirstOrDefault(p => p.AttributeType == typeof(AssemblyInformationalVersionAttribute));
24 | if (attribute == null) return assembly.GetName().Version.ToString(3);
25 | return (string)attribute.ConstructorArguments[0].Value;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/neo-cli/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-cli is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.CLI;
12 |
13 | namespace Neo
14 | {
15 | static class Program
16 | {
17 | static void Main(string[] args)
18 | {
19 | var mainService = new MainService();
20 | mainService.Run(args);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/neo-cli/Settings.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-cli is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Microsoft.Extensions.Configuration;
12 | using Neo.Network.P2P;
13 | using System.Threading;
14 |
15 | namespace Neo
16 | {
17 | public class Settings
18 | {
19 | public LoggerSettings Logger { get; }
20 | public StorageSettings Storage { get; }
21 | public P2PSettings P2P { get; }
22 | public UnlockWalletSettings UnlockWallet { get; }
23 |
24 | static Settings _default;
25 |
26 | static bool UpdateDefault(IConfiguration configuration)
27 | {
28 | var settings = new Settings(configuration.GetSection("ApplicationConfiguration"));
29 | return null == Interlocked.CompareExchange(ref _default, settings, null);
30 | }
31 |
32 | public static bool Initialize(IConfiguration configuration)
33 | {
34 | return UpdateDefault(configuration);
35 | }
36 |
37 | public static Settings Default
38 | {
39 | get
40 | {
41 | if (_default == null)
42 | {
43 | IConfigurationRoot config = new ConfigurationBuilder().AddJsonFile("config.json", optional: true).Build();
44 | Initialize(config);
45 | }
46 |
47 | return _default;
48 | }
49 | }
50 |
51 | public Settings(IConfigurationSection section)
52 | {
53 | this.Logger = new LoggerSettings(section.GetSection("Logger"));
54 | this.Storage = new StorageSettings(section.GetSection("Storage"));
55 | this.P2P = new P2PSettings(section.GetSection("P2P"));
56 | this.UnlockWallet = new UnlockWalletSettings(section.GetSection("UnlockWallet"));
57 | }
58 | }
59 |
60 | public class LoggerSettings
61 | {
62 | public string Path { get; }
63 | public bool ConsoleOutput { get; }
64 | public bool Active { get; }
65 |
66 | public LoggerSettings(IConfigurationSection section)
67 | {
68 | this.Path = section.GetValue("Path", "Logs");
69 | this.ConsoleOutput = section.GetValue("ConsoleOutput", false);
70 | this.Active = section.GetValue("Active", false);
71 | }
72 | }
73 |
74 | public class StorageSettings
75 | {
76 | public string Engine { get; }
77 | public string Path { get; }
78 |
79 | public StorageSettings(IConfigurationSection section)
80 | {
81 | this.Engine = section.GetValue("Engine", "LevelDBStore");
82 | this.Path = section.GetValue("Path", "Data_LevelDB_{0}");
83 | }
84 | }
85 |
86 | public class P2PSettings
87 | {
88 | public ushort Port { get; }
89 | public ushort WsPort { get; }
90 | public int MinDesiredConnections { get; }
91 | public int MaxConnections { get; }
92 | public int MaxConnectionsPerAddress { get; }
93 |
94 | public P2PSettings(IConfigurationSection section)
95 | {
96 | this.Port = ushort.Parse(section.GetValue("Port", "10333"));
97 | this.WsPort = ushort.Parse(section.GetValue("WsPort", "10334"));
98 | this.MinDesiredConnections = section.GetValue("MinDesiredConnections", Peer.DefaultMinDesiredConnections);
99 | this.MaxConnections = section.GetValue("MaxConnections", Peer.DefaultMaxConnections);
100 | this.MaxConnectionsPerAddress = section.GetValue("MaxConnectionsPerAddress", 3);
101 | }
102 | }
103 |
104 | public class UnlockWalletSettings
105 | {
106 | public string Path { get; }
107 | public string Password { get; }
108 | public bool IsActive { get; }
109 |
110 | public UnlockWalletSettings(IConfigurationSection section)
111 | {
112 | if (section.Exists())
113 | {
114 | this.Path = section.GetValue("Path", "");
115 | this.Password = section.GetValue("Password", "");
116 | this.IsActive = bool.Parse(section.GetValue("IsActive", "false"));
117 | }
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/neo-cli/config.fs.mainnet.json:
--------------------------------------------------------------------------------
1 | {
2 | "ApplicationConfiguration": {
3 | "Logger": {
4 | "Path": "Logs",
5 | "ConsoleOutput": false,
6 | "Active": false
7 | },
8 | "Storage": {
9 | "Engine": "LevelDBStore",
10 | "Path": "Data_LevelDB_{0}"
11 | },
12 | "P2P": {
13 | "Port": 40333,
14 | "WsPort": 40334,
15 | "MinDesiredConnections": 10,
16 | "MaxConnections": 40,
17 | "MaxConnectionsPerAddress": 3
18 | },
19 | "UnlockWallet": {
20 | "Path": "",
21 | "Password": "",
22 | "IsActive": false
23 | }
24 | },
25 | "ProtocolConfiguration": {
26 | "Network": 91414437,
27 | "AddressVersion": 53,
28 | "MillisecondsPerBlock": 15000,
29 | "MaxTransactionsPerBlock": 512,
30 | "MemoryPoolMaxTransactions": 50000,
31 | "MaxTraceableBlocks": 2102400,
32 | "InitialGasDistribution": 5200000000000000,
33 | "ValidatorsCount": 7,
34 | "StandbyCommittee": [
35 | "026fa34ec057d74c2fdf1a18e336d0bd597ea401a0b2ad57340d5c220d09f44086",
36 | "039a9db2a30942b1843db673aeb0d4fd6433f74cec1d879de6343cb9fcf7628fa4",
37 | "0366d255e7ce23ea6f7f1e4bedf5cbafe598705b47e6ec213ef13b2f0819e8ab33",
38 | "023f9cb7bbe154d529d5c719fdc39feaa831a43ae03d2a4280575b60f52fa7bc52",
39 | "039ba959e0ab6dc616df8b803692f1c30ba9071b76b05535eb994bf5bbc402ad5f",
40 | "035a2a18cddafa25ad353dea5e6730a1b9fcb4b918c4a0303c4387bb9c3b816adf",
41 | "031f4d9c66f2ec348832c48fd3a16dfaeb59e85f557ae1e07f6696d0375c64f97b"
42 | ],
43 | "SeedList": [
44 | "morph1.fs.neo.org:40333",
45 | "morph2.fs.neo.org:40333",
46 | "morph3.fs.neo.org:40333",
47 | "morph4.fs.neo.org:40333",
48 | "morph5.fs.neo.org:40333",
49 | "morph6.fs.neo.org:40333",
50 | "morph7.fs.neo.org:40333"
51 | ]
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/neo-cli/config.fs.testnet.json:
--------------------------------------------------------------------------------
1 | {
2 | "ApplicationConfiguration": {
3 | "Logger": {
4 | "Path": "Logs",
5 | "ConsoleOutput": false,
6 | "Active": false
7 | },
8 | "Storage": {
9 | "Engine": "LevelDBStore",
10 | "Path": "Data_LevelDB_{0}"
11 | },
12 | "P2P": {
13 | "Port": 50333,
14 | "WsPort": 50334,
15 | "MinDesiredConnections": 10,
16 | "MaxConnections": 40,
17 | "MaxConnectionsPerAddress": 3
18 | },
19 | "UnlockWallet": {
20 | "Path": "",
21 | "Password": "",
22 | "IsActive": false
23 | }
24 | },
25 | "ProtocolConfiguration": {
26 | "Network": 91466898,
27 | "AddressVersion": 53,
28 | "MillisecondsPerBlock": 15000,
29 | "MaxTransactionsPerBlock": 512,
30 | "MemoryPoolMaxTransactions": 50000,
31 | "MaxTraceableBlocks": 2102400,
32 | "InitialGasDistribution": 5200000000000000,
33 | "ValidatorsCount": 7,
34 | "StandbyCommittee": [
35 | "02082828ec6efc92e5e7790da851be72d2091a961c1ac9a1772acbf181ac56b831",
36 | "02b2bcf7e09c0237ab6ef21808e6f7546329823bc6b43488335bd357aea443fabe",
37 | "03577029a5072ebbab12d2495b59e2cf27afb37f9640c1c1354f1bdd221e6fb82d",
38 | "03e6ea086e4b42fa5f0535179862db7eea7e44644e5e9608d6131aa48868c12cfc",
39 | "0379328ab4907ea7c47f61e5c9d2c78c39dc9d1c4341ca496376070a0a5e20131e",
40 | "02f8af6440dfe0e676ae2bb6727e5cc31a6f2459e29f48e85428862b7577dbc203",
41 | "02e19c0634c85d35937699cdeaa10595ec2e18bfe86ba0494cf6c5c6861c66b97d"
42 | ],
43 | "SeedList": [
44 | "morph01.testnet.fs.neo.org:50333",
45 | "morph02.testnet.fs.neo.org:50333",
46 | "morph03.testnet.fs.neo.org:50333",
47 | "morph04.testnet.fs.neo.org:50333",
48 | "morph05.testnet.fs.neo.org:50333",
49 | "morph06.testnet.fs.neo.org:50333",
50 | "morph07.testnet.fs.neo.org:50333"
51 | ]
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/neo-cli/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "ApplicationConfiguration": {
3 | "Logger": {
4 | "Path": "Logs",
5 | "ConsoleOutput": false,
6 | "Active": false
7 | },
8 | "Storage": {
9 | "Engine": "LevelDBStore",
10 | "Path": "Data_LevelDB_{0}"
11 | },
12 | "P2P": {
13 | "Port": 10333,
14 | "WsPort": 10334,
15 | "MinDesiredConnections": 10,
16 | "MaxConnections": 40,
17 | "MaxConnectionsPerAddress": 3
18 | },
19 | "UnlockWallet": {
20 | "Path": "",
21 | "Password": "",
22 | "IsActive": false
23 | }
24 | },
25 | "ProtocolConfiguration": {
26 | "Network": 860833102,
27 | "AddressVersion": 53,
28 | "MillisecondsPerBlock": 15000,
29 | "MaxTransactionsPerBlock": 512,
30 | "MemoryPoolMaxTransactions": 50000,
31 | "MaxTraceableBlocks": 2102400,
32 | "Hardforks": {
33 | "HF_Aspidochelone": 1730000,
34 | "HF_Basilisk": 4120000
35 | },
36 | "InitialGasDistribution": 5200000000000000,
37 | "ValidatorsCount": 7,
38 | "StandbyCommittee": [
39 | "03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c",
40 | "02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093",
41 | "03b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a",
42 | "02ca0e27697b9c248f6f16e085fd0061e26f44da85b58ee835c110caa5ec3ba554",
43 | "024c7b7fb6c310fccf1ba33b082519d82964ea93868d676662d4a59ad548df0e7d",
44 | "02aaec38470f6aad0042c6e877cfd8087d2676b0f516fddd362801b9bd3936399e",
45 | "02486fd15702c4490a26703112a5cc1d0923fd697a33406bd5a1c00e0013b09a70",
46 | "023a36c72844610b4d34d1968662424011bf783ca9d984efa19a20babf5582f3fe",
47 | "03708b860c1de5d87f5b151a12c2a99feebd2e8b315ee8e7cf8aa19692a9e18379",
48 | "03c6aa6e12638b36e88adc1ccdceac4db9929575c3e03576c617c49cce7114a050",
49 | "03204223f8c86b8cd5c89ef12e4f0dbb314172e9241e30c9ef2293790793537cf0",
50 | "02a62c915cf19c7f19a50ec217e79fac2439bbaad658493de0c7d8ffa92ab0aa62",
51 | "03409f31f0d66bdc2f70a9730b66fe186658f84a8018204db01c106edc36553cd0",
52 | "0288342b141c30dc8ffcde0204929bb46aed5756b41ef4a56778d15ada8f0c6654",
53 | "020f2887f41474cfeb11fd262e982051c1541418137c02a0f4961af911045de639",
54 | "0222038884bbd1d8ff109ed3bdef3542e768eef76c1247aea8bc8171f532928c30",
55 | "03d281b42002647f0113f36c7b8efb30db66078dfaaa9ab3ff76d043a98d512fde",
56 | "02504acbc1f4b3bdad1d86d6e1a08603771db135a73e61c9d565ae06a1938cd2ad",
57 | "0226933336f1b75baa42d42b71d9091508b638046d19abd67f4e119bf64a7cfb4d",
58 | "03cdcea66032b82f5c30450e381e5295cae85c5e6943af716cc6b646352a6067dc",
59 | "02cd5a5547119e24feaa7c2a0f37b8c9366216bab7054de0065c9be42084003c8a"
60 | ],
61 | "SeedList": [
62 | "seed1.neo.org:10333",
63 | "seed2.neo.org:10333",
64 | "seed3.neo.org:10333",
65 | "seed4.neo.org:10333",
66 | "seed5.neo.org:10333"
67 | ]
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/neo-cli/config.mainnet.json:
--------------------------------------------------------------------------------
1 | {
2 | "ApplicationConfiguration": {
3 | "Logger": {
4 | "Path": "Logs",
5 | "ConsoleOutput": false,
6 | "Active": false
7 | },
8 | "Storage": {
9 | "Engine": "LevelDBStore",
10 | "Path": "Data_LevelDB_{0}"
11 | },
12 | "P2P": {
13 | "Port": 10333,
14 | "WsPort": 10334,
15 | "MinDesiredConnections": 10,
16 | "MaxConnections": 40,
17 | "MaxConnectionsPerAddress": 3
18 | },
19 | "UnlockWallet": {
20 | "Path": "",
21 | "Password": "",
22 | "IsActive": false
23 | }
24 | },
25 | "ProtocolConfiguration": {
26 | "Network": 860833102,
27 | "AddressVersion": 53,
28 | "MillisecondsPerBlock": 15000,
29 | "MaxTransactionsPerBlock": 512,
30 | "MemoryPoolMaxTransactions": 50000,
31 | "MaxTraceableBlocks": 2102400,
32 | "Hardforks": {
33 | "HF_Aspidochelone": 1730000,
34 | "HF_Basilisk": 4120000
35 | },
36 | "InitialGasDistribution": 5200000000000000,
37 | "ValidatorsCount": 7,
38 | "StandbyCommittee": [
39 | "03b209fd4f53a7170ea4444e0cb0a6bb6a53c2bd016926989cf85f9b0fba17a70c",
40 | "02df48f60e8f3e01c48ff40b9b7f1310d7a8b2a193188befe1c2e3df740e895093",
41 | "03b8d9d5771d8f513aa0869b9cc8d50986403b78c6da36890638c3d46a5adce04a",
42 | "02ca0e27697b9c248f6f16e085fd0061e26f44da85b58ee835c110caa5ec3ba554",
43 | "024c7b7fb6c310fccf1ba33b082519d82964ea93868d676662d4a59ad548df0e7d",
44 | "02aaec38470f6aad0042c6e877cfd8087d2676b0f516fddd362801b9bd3936399e",
45 | "02486fd15702c4490a26703112a5cc1d0923fd697a33406bd5a1c00e0013b09a70",
46 | "023a36c72844610b4d34d1968662424011bf783ca9d984efa19a20babf5582f3fe",
47 | "03708b860c1de5d87f5b151a12c2a99feebd2e8b315ee8e7cf8aa19692a9e18379",
48 | "03c6aa6e12638b36e88adc1ccdceac4db9929575c3e03576c617c49cce7114a050",
49 | "03204223f8c86b8cd5c89ef12e4f0dbb314172e9241e30c9ef2293790793537cf0",
50 | "02a62c915cf19c7f19a50ec217e79fac2439bbaad658493de0c7d8ffa92ab0aa62",
51 | "03409f31f0d66bdc2f70a9730b66fe186658f84a8018204db01c106edc36553cd0",
52 | "0288342b141c30dc8ffcde0204929bb46aed5756b41ef4a56778d15ada8f0c6654",
53 | "020f2887f41474cfeb11fd262e982051c1541418137c02a0f4961af911045de639",
54 | "0222038884bbd1d8ff109ed3bdef3542e768eef76c1247aea8bc8171f532928c30",
55 | "03d281b42002647f0113f36c7b8efb30db66078dfaaa9ab3ff76d043a98d512fde",
56 | "02504acbc1f4b3bdad1d86d6e1a08603771db135a73e61c9d565ae06a1938cd2ad",
57 | "0226933336f1b75baa42d42b71d9091508b638046d19abd67f4e119bf64a7cfb4d",
58 | "03cdcea66032b82f5c30450e381e5295cae85c5e6943af716cc6b646352a6067dc",
59 | "02cd5a5547119e24feaa7c2a0f37b8c9366216bab7054de0065c9be42084003c8a"
60 | ],
61 | "SeedList": [
62 | "seed1.neo.org:10333",
63 | "seed2.neo.org:10333",
64 | "seed3.neo.org:10333",
65 | "seed4.neo.org:10333",
66 | "seed5.neo.org:10333"
67 | ]
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/neo-cli/config.testnet.json:
--------------------------------------------------------------------------------
1 | {
2 | "ApplicationConfiguration": {
3 | "Logger": {
4 | "Path": "Logs",
5 | "ConsoleOutput": false,
6 | "Active": false
7 | },
8 | "Storage": {
9 | "Engine": "LevelDBStore",
10 | "Path": "Data_LevelDB_{0}"
11 | },
12 | "P2P": {
13 | "Port": 20333,
14 | "WsPort": 20334,
15 | "MinDesiredConnections": 10,
16 | "MaxConnections": 40,
17 | "MaxConnectionsPerAddress": 3
18 | },
19 | "UnlockWallet": {
20 | "Path": "",
21 | "Password": "",
22 | "IsActive": false
23 | }
24 | },
25 | "ProtocolConfiguration": {
26 | "Network": 894710606,
27 | "AddressVersion": 53,
28 | "MillisecondsPerBlock": 15000,
29 | "MaxTransactionsPerBlock": 5000,
30 | "MemoryPoolMaxTransactions": 50000,
31 | "MaxTraceableBlocks": 2102400,
32 | "Hardforks": {
33 | "HF_Aspidochelone": 210000,
34 | "HF_Basilisk": 2680000
35 | },
36 | "InitialGasDistribution": 5200000000000000,
37 | "ValidatorsCount": 7,
38 | "StandbyCommittee": [
39 | "023e9b32ea89b94d066e649b124fd50e396ee91369e8e2a6ae1b11c170d022256d",
40 | "03009b7540e10f2562e5fd8fac9eaec25166a58b26e412348ff5a86927bfac22a2",
41 | "02ba2c70f5996f357a43198705859fae2cfea13e1172962800772b3d588a9d4abd",
42 | "03408dcd416396f64783ac587ea1e1593c57d9fea880c8a6a1920e92a259477806",
43 | "02a7834be9b32e2981d157cb5bbd3acb42cfd11ea5c3b10224d7a44e98c5910f1b",
44 | "0214baf0ceea3a66f17e7e1e839ea25fd8bed6cd82e6bb6e68250189065f44ff01",
45 | "030205e9cefaea5a1dfc580af20c8d5aa2468bb0148f1a5e4605fc622c80e604ba",
46 | "025831cee3708e87d78211bec0d1bfee9f4c85ae784762f042e7f31c0d40c329b8",
47 | "02cf9dc6e85d581480d91e88e8cbeaa0c153a046e89ded08b4cefd851e1d7325b5",
48 | "03840415b0a0fcf066bcc3dc92d8349ebd33a6ab1402ef649bae00e5d9f5840828",
49 | "026328aae34f149853430f526ecaa9cf9c8d78a4ea82d08bdf63dd03c4d0693be6",
50 | "02c69a8d084ee7319cfecf5161ff257aa2d1f53e79bf6c6f164cff5d94675c38b3",
51 | "0207da870cedb777fceff948641021714ec815110ca111ccc7a54c168e065bda70",
52 | "035056669864feea401d8c31e447fb82dd29f342a9476cfd449584ce2a6165e4d7",
53 | "0370c75c54445565df62cfe2e76fbec4ba00d1298867972213530cae6d418da636",
54 | "03957af9e77282ae3263544b7b2458903624adc3f5dee303957cb6570524a5f254",
55 | "03d84d22b8753cf225d263a3a782a4e16ca72ef323cfde04977c74f14873ab1e4c",
56 | "02147c1b1d5728e1954958daff2f88ee2fa50a06890a8a9db3fa9e972b66ae559f",
57 | "03c609bea5a4825908027e4ab217e7efc06e311f19ecad9d417089f14927a173d5",
58 | "0231edee3978d46c335e851c76059166eb8878516f459e085c0dd092f0f1d51c21",
59 | "03184b018d6b2bc093e535519732b3fd3f7551c8cffaf4621dd5a0b89482ca66c9"
60 | ],
61 | "SeedList": [
62 | "seed1t5.neo.org:20333",
63 | "seed2t5.neo.org:20333",
64 | "seed3t5.neo.org:20333",
65 | "seed4t5.neo.org:20333",
66 | "seed5t5.neo.org:20333"
67 | ]
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/neo-cli/neo-cli.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2016-2023 The Neo Project
5 | Neo.CLI
6 | 3.6.2
7 | The Neo Project
8 | net7.0
9 | neo-cli
10 | Exe
11 | Neo.CLI
12 | Neo
13 | The Neo Project
14 | Neo.CLI
15 | Neo.CLI
16 | neo.ico
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | PreserveNewest
26 | PreserveNewest
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/neo-cli/neo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo-project/neo-node/4e7fecce249e31ee06eb46366cca9dd2e76150bc/neo-cli/neo.ico
--------------------------------------------------------------------------------
/neo-gui/GUI/BulkPayDialog.Designer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | namespace Neo.GUI
12 | {
13 | partial class BulkPayDialog
14 | {
15 | ///
16 | /// Required designer variable.
17 | ///
18 | private System.ComponentModel.IContainer components = null;
19 |
20 | ///
21 | /// Clean up any resources being used.
22 | ///
23 | /// true if managed resources should be disposed; otherwise, false.
24 | protected override void Dispose(bool disposing)
25 | {
26 | if (disposing && (components != null))
27 | {
28 | components.Dispose();
29 | }
30 | base.Dispose(disposing);
31 | }
32 |
33 | #region Windows Form Designer generated code
34 |
35 | ///
36 | /// Required method for Designer support - do not modify
37 | /// the contents of this method with the code editor.
38 | ///
39 | private void InitializeComponent()
40 | {
41 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BulkPayDialog));
42 | this.textBox3 = new System.Windows.Forms.TextBox();
43 | this.label4 = new System.Windows.Forms.Label();
44 | this.comboBox1 = new System.Windows.Forms.ComboBox();
45 | this.label3 = new System.Windows.Forms.Label();
46 | this.button1 = new System.Windows.Forms.Button();
47 | this.groupBox1 = new System.Windows.Forms.GroupBox();
48 | this.textBox1 = new System.Windows.Forms.TextBox();
49 | this.groupBox1.SuspendLayout();
50 | this.SuspendLayout();
51 | //
52 | // textBox3
53 | //
54 | resources.ApplyResources(this.textBox3, "textBox3");
55 | this.textBox3.Name = "textBox3";
56 | this.textBox3.ReadOnly = true;
57 | //
58 | // label4
59 | //
60 | resources.ApplyResources(this.label4, "label4");
61 | this.label4.Name = "label4";
62 | //
63 | // comboBox1
64 | //
65 | resources.ApplyResources(this.comboBox1, "comboBox1");
66 | this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
67 | this.comboBox1.FormattingEnabled = true;
68 | this.comboBox1.Name = "comboBox1";
69 | this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
70 | //
71 | // label3
72 | //
73 | resources.ApplyResources(this.label3, "label3");
74 | this.label3.Name = "label3";
75 | //
76 | // button1
77 | //
78 | resources.ApplyResources(this.button1, "button1");
79 | this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
80 | this.button1.Name = "button1";
81 | this.button1.UseVisualStyleBackColor = true;
82 | //
83 | // groupBox1
84 | //
85 | resources.ApplyResources(this.groupBox1, "groupBox1");
86 | this.groupBox1.Controls.Add(this.textBox1);
87 | this.groupBox1.Name = "groupBox1";
88 | this.groupBox1.TabStop = false;
89 | //
90 | // textBox1
91 | //
92 | this.textBox1.AcceptsReturn = true;
93 | resources.ApplyResources(this.textBox1, "textBox1");
94 | this.textBox1.Name = "textBox1";
95 | this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
96 | //
97 | // BulkPayDialog
98 | //
99 | resources.ApplyResources(this, "$this");
100 | this.AcceptButton = this.button1;
101 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
102 | this.Controls.Add(this.groupBox1);
103 | this.Controls.Add(this.textBox3);
104 | this.Controls.Add(this.label4);
105 | this.Controls.Add(this.comboBox1);
106 | this.Controls.Add(this.label3);
107 | this.Controls.Add(this.button1);
108 | this.MaximizeBox = false;
109 | this.MinimizeBox = false;
110 | this.Name = "BulkPayDialog";
111 | this.ShowInTaskbar = false;
112 | this.groupBox1.ResumeLayout(false);
113 | this.groupBox1.PerformLayout();
114 | this.ResumeLayout(false);
115 | this.PerformLayout();
116 |
117 | }
118 |
119 | #endregion
120 |
121 | private System.Windows.Forms.TextBox textBox3;
122 | private System.Windows.Forms.Label label4;
123 | private System.Windows.Forms.ComboBox comboBox1;
124 | private System.Windows.Forms.Label label3;
125 | private System.Windows.Forms.Button button1;
126 | private System.Windows.Forms.GroupBox groupBox1;
127 | private System.Windows.Forms.TextBox textBox1;
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/neo-gui/GUI/BulkPayDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Wallets;
12 | using System;
13 | using System.Linq;
14 | using System.Windows.Forms;
15 | using static Neo.Program;
16 |
17 | namespace Neo.GUI
18 | {
19 | internal partial class BulkPayDialog : Form
20 | {
21 | public BulkPayDialog(AssetDescriptor asset = null)
22 | {
23 | InitializeComponent();
24 | if (asset == null)
25 | {
26 | foreach (UInt160 assetId in NEP5Watched)
27 | {
28 | try
29 | {
30 | comboBox1.Items.Add(new AssetDescriptor(Service.NeoSystem.StoreView, Service.NeoSystem.Settings, assetId));
31 | }
32 | catch (ArgumentException)
33 | {
34 | continue;
35 | }
36 | }
37 | }
38 | else
39 | {
40 | comboBox1.Items.Add(asset);
41 | comboBox1.SelectedIndex = 0;
42 | comboBox1.Enabled = false;
43 | }
44 | }
45 |
46 | public TxOutListBoxItem[] GetOutputs()
47 | {
48 | AssetDescriptor asset = (AssetDescriptor)comboBox1.SelectedItem;
49 | return textBox1.Lines.Where(p => !string.IsNullOrWhiteSpace(p)).Select(p =>
50 | {
51 | string[] line = p.Split(new[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries);
52 | return new TxOutListBoxItem
53 | {
54 | AssetName = asset.AssetName,
55 | AssetId = asset.AssetId,
56 | Value = BigDecimal.Parse(line[1], asset.Decimals),
57 | ScriptHash = line[0].ToScriptHash(Service.NeoSystem.Settings.AddressVersion)
58 | };
59 | }).Where(p => p.Value.Value != 0).ToArray();
60 | }
61 |
62 | private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
63 | {
64 | if (comboBox1.SelectedItem is AssetDescriptor asset)
65 | {
66 | textBox3.Text = Service.CurrentWallet.GetAvailable(Service.NeoSystem.StoreView, asset.AssetId).ToString();
67 | }
68 | else
69 | {
70 | textBox3.Text = "";
71 | }
72 | textBox1_TextChanged(this, EventArgs.Empty);
73 | }
74 |
75 | private void textBox1_TextChanged(object sender, EventArgs e)
76 | {
77 | button1.Enabled = comboBox1.SelectedIndex >= 0 && textBox1.TextLength > 0;
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/neo-gui/GUI/ChangePasswordDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System;
12 | using System.Windows.Forms;
13 |
14 | namespace Neo.GUI
15 | {
16 | internal partial class ChangePasswordDialog : Form
17 | {
18 | public string OldPassword
19 | {
20 | get
21 | {
22 | return textBox1.Text;
23 | }
24 | set
25 | {
26 | textBox1.Text = value;
27 | }
28 | }
29 |
30 | public string NewPassword
31 | {
32 | get
33 | {
34 | return textBox2.Text;
35 | }
36 | set
37 | {
38 | textBox2.Text = value;
39 | textBox3.Text = value;
40 | }
41 | }
42 |
43 | public ChangePasswordDialog()
44 | {
45 | InitializeComponent();
46 | }
47 |
48 | private void textBox_TextChanged(object sender, EventArgs e)
49 | {
50 | button1.Enabled = textBox1.TextLength > 0 && textBox2.TextLength > 0 && textBox3.Text == textBox2.Text;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/neo-gui/GUI/ConsoleForm.Designer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | namespace Neo.GUI
12 | {
13 | partial class ConsoleForm
14 | {
15 | ///
16 | /// Required designer variable.
17 | ///
18 | private System.ComponentModel.IContainer components = null;
19 |
20 | ///
21 | /// Clean up any resources being used.
22 | ///
23 | /// true if managed resources should be disposed; otherwise, false.
24 | protected override void Dispose(bool disposing)
25 | {
26 | if (disposing && (components != null))
27 | {
28 | components.Dispose();
29 | }
30 | base.Dispose(disposing);
31 | }
32 |
33 | #region Windows Form Designer generated code
34 |
35 | ///
36 | /// Required method for Designer support - do not modify
37 | /// the contents of this method with the code editor.
38 | ///
39 | private void InitializeComponent()
40 | {
41 | this.textBox1 = new System.Windows.Forms.TextBox();
42 | this.textBox2 = new System.Windows.Forms.TextBox();
43 | this.SuspendLayout();
44 | //
45 | // textBox1
46 | //
47 | this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
48 | | System.Windows.Forms.AnchorStyles.Left)
49 | | System.Windows.Forms.AnchorStyles.Right)));
50 | this.textBox1.Location = new System.Drawing.Point(12, 12);
51 | this.textBox1.Font = new System.Drawing.Font("Consolas", 11.0f);
52 | this.textBox1.MaxLength = 1048576;
53 | this.textBox1.Multiline = true;
54 | this.textBox1.Name = "textBox1";
55 | this.textBox1.ReadOnly = true;
56 | this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
57 | this.textBox1.Size = new System.Drawing.Size(609, 367);
58 | this.textBox1.TabIndex = 1;
59 | //
60 | // textBox2
61 | //
62 | this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
63 | | System.Windows.Forms.AnchorStyles.Right)));
64 | this.textBox2.Location = new System.Drawing.Point(12, 385);
65 | this.textBox2.Font = new System.Drawing.Font("Consolas", 11.0f);
66 | this.textBox2.Name = "textBox2";
67 | this.textBox2.Size = new System.Drawing.Size(609, 21);
68 | this.textBox2.TabIndex = 0;
69 | this.textBox2.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox2_KeyDown);
70 | //
71 | // ConsoleForm
72 | //
73 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
74 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
75 | this.ClientSize = new System.Drawing.Size(633, 418);
76 | this.Controls.Add(this.textBox2);
77 | this.Controls.Add(this.textBox1);
78 | this.Name = "ConsoleForm";
79 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
80 | this.Text = "Console";
81 | this.ResumeLayout(false);
82 | this.PerformLayout();
83 |
84 | }
85 |
86 | #endregion
87 |
88 | private System.Windows.Forms.TextBox textBox1;
89 | private System.Windows.Forms.TextBox textBox2;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/neo-gui/GUI/ConsoleForm.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System;
12 | using System.IO;
13 | using System.Threading;
14 | using System.Windows.Forms;
15 |
16 | namespace Neo.GUI
17 | {
18 | internal partial class ConsoleForm : Form
19 | {
20 | private Thread thread;
21 | private readonly QueueReader queue = new QueueReader();
22 |
23 | public ConsoleForm()
24 | {
25 | InitializeComponent();
26 | }
27 |
28 | protected override void OnHandleCreated(EventArgs e)
29 | {
30 | base.OnHandleCreated(e);
31 | Console.SetOut(new TextBoxWriter(textBox1));
32 | Console.SetIn(queue);
33 | thread = new Thread(Program.Service.RunConsole);
34 | thread.Start();
35 | }
36 |
37 | protected override void OnFormClosing(FormClosingEventArgs e)
38 | {
39 | queue.Enqueue($"exit{Environment.NewLine}");
40 | thread.Join();
41 | Console.SetIn(new StreamReader(Console.OpenStandardInput()));
42 | Console.SetOut(new StreamWriter(Console.OpenStandardOutput()));
43 | base.OnFormClosing(e);
44 | }
45 |
46 | private void textBox2_KeyDown(object sender, KeyEventArgs e)
47 | {
48 | if (e.KeyCode == Keys.Enter)
49 | {
50 | e.SuppressKeyPress = true;
51 | string line = $"{textBox2.Text}{Environment.NewLine}";
52 | textBox1.AppendText(Program.Service.ReadingPassword ? "***" : line);
53 | switch (textBox2.Text.ToLower())
54 | {
55 | case "clear":
56 | textBox1.Clear();
57 | break;
58 | case "exit":
59 | Close();
60 | return;
61 | }
62 | queue.Enqueue(line);
63 | textBox2.Clear();
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/neo-gui/GUI/CreateMultiSigContractDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Cryptography.ECC;
12 | using Neo.SmartContract;
13 | using Neo.Wallets;
14 | using System;
15 | using System.Collections.Generic;
16 | using System.Linq;
17 | using System.Windows.Forms;
18 | using static Neo.Program;
19 |
20 | namespace Neo.GUI
21 | {
22 | internal partial class CreateMultiSigContractDialog : Form
23 | {
24 | private ECPoint[] publicKeys;
25 |
26 | public CreateMultiSigContractDialog()
27 | {
28 | InitializeComponent();
29 | }
30 |
31 | public Contract GetContract()
32 | {
33 | publicKeys = listBox1.Items.OfType().Select(p => ECPoint.DecodePoint(p.HexToBytes(), ECCurve.Secp256r1)).ToArray();
34 | return Contract.CreateMultiSigContract((int)numericUpDown2.Value, publicKeys);
35 | }
36 |
37 | public KeyPair GetKey()
38 | {
39 | HashSet hashSet = new HashSet(publicKeys);
40 | return Service.CurrentWallet.GetAccounts().FirstOrDefault(p => p.HasKey && hashSet.Contains(p.GetKey().PublicKey))?.GetKey();
41 | }
42 |
43 | private void numericUpDown2_ValueChanged(object sender, EventArgs e)
44 | {
45 | button6.Enabled = numericUpDown2.Value > 0;
46 | }
47 |
48 | private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
49 | {
50 | button5.Enabled = listBox1.SelectedIndices.Count > 0;
51 | }
52 |
53 | private void textBox5_TextChanged(object sender, EventArgs e)
54 | {
55 | button4.Enabled = textBox5.TextLength > 0;
56 | }
57 |
58 | private void button4_Click(object sender, EventArgs e)
59 | {
60 | listBox1.Items.Add(textBox5.Text);
61 | textBox5.Clear();
62 | numericUpDown2.Maximum = listBox1.Items.Count;
63 | }
64 |
65 | private void button5_Click(object sender, EventArgs e)
66 | {
67 | listBox1.Items.RemoveAt(listBox1.SelectedIndex);
68 | numericUpDown2.Maximum = listBox1.Items.Count;
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/neo-gui/GUI/CreateWalletDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System;
12 | using System.Windows.Forms;
13 |
14 | namespace Neo.GUI
15 | {
16 | internal partial class CreateWalletDialog : Form
17 | {
18 | public CreateWalletDialog()
19 | {
20 | InitializeComponent();
21 | }
22 |
23 | public string Password
24 | {
25 | get
26 | {
27 | return textBox2.Text;
28 | }
29 | set
30 | {
31 | textBox2.Text = value;
32 | textBox3.Text = value;
33 | }
34 | }
35 |
36 | public string WalletPath
37 | {
38 | get
39 | {
40 | return textBox1.Text;
41 | }
42 | set
43 | {
44 | textBox1.Text = value;
45 | }
46 | }
47 |
48 | private void textBox_TextChanged(object sender, EventArgs e)
49 | {
50 | if (textBox1.TextLength == 0 || textBox2.TextLength == 0 || textBox3.TextLength == 0)
51 | {
52 | button2.Enabled = false;
53 | return;
54 | }
55 | if (textBox2.Text != textBox3.Text)
56 | {
57 | button2.Enabled = false;
58 | return;
59 | }
60 | button2.Enabled = true;
61 | }
62 |
63 | private void button1_Click(object sender, EventArgs e)
64 | {
65 | if (saveFileDialog1.ShowDialog() == DialogResult.OK)
66 | {
67 | textBox1.Text = saveFileDialog1.FileName;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/neo-gui/GUI/DeployContractDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.SmartContract;
12 | using Neo.SmartContract.Native;
13 | using Neo.VM;
14 | using System;
15 | using System.IO;
16 | using System.Windows.Forms;
17 |
18 | namespace Neo.GUI
19 | {
20 | internal partial class DeployContractDialog : Form
21 | {
22 | public DeployContractDialog()
23 | {
24 | InitializeComponent();
25 | }
26 |
27 | public byte[] GetScript()
28 | {
29 | byte[] script = textBox8.Text.HexToBytes();
30 | string manifest = "";
31 | using ScriptBuilder sb = new ScriptBuilder();
32 | sb.EmitDynamicCall(NativeContract.ContractManagement.Hash, "deploy", script, manifest);
33 | return sb.ToArray();
34 | }
35 |
36 | private void textBox_TextChanged(object sender, EventArgs e)
37 | {
38 | button2.Enabled = textBox1.TextLength > 0
39 | && textBox2.TextLength > 0
40 | && textBox3.TextLength > 0
41 | && textBox4.TextLength > 0
42 | && textBox5.TextLength > 0
43 | && textBox8.TextLength > 0;
44 | try
45 | {
46 | textBox9.Text = textBox8.Text.HexToBytes().ToScriptHash().ToString();
47 | }
48 | catch (FormatException)
49 | {
50 | textBox9.Text = "";
51 | }
52 | }
53 |
54 | private void button1_Click(object sender, EventArgs e)
55 | {
56 | if (openFileDialog1.ShowDialog() != DialogResult.OK) return;
57 | textBox8.Text = File.ReadAllBytes(openFileDialog1.FileName).ToHexString();
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/neo-gui/GUI/DeveloperToolsForm.ContractParameters.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Akka.Actor;
12 | using Neo.Ledger;
13 | using Neo.Network.P2P.Payloads;
14 | using Neo.Properties;
15 | using Neo.SmartContract;
16 | using Neo.Wallets;
17 | using System;
18 | using System.Collections.Generic;
19 | using System.Linq;
20 | using System.Windows.Forms;
21 | using static Neo.Program;
22 |
23 | namespace Neo.GUI
24 | {
25 | partial class DeveloperToolsForm
26 | {
27 | private ContractParametersContext context;
28 |
29 | private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
30 | {
31 | if (listBox1.SelectedIndex < 0) return;
32 | listBox2.Items.Clear();
33 | if (Service.CurrentWallet == null) return;
34 | UInt160 hash = ((string)listBox1.SelectedItem).ToScriptHash(Service.NeoSystem.Settings.AddressVersion);
35 | var parameters = context.GetParameters(hash);
36 | if (parameters == null)
37 | {
38 | var parameterList = Service.CurrentWallet.GetAccount(hash).Contract.ParameterList;
39 | if (parameterList != null)
40 | {
41 | var pList = new List();
42 | for (int i = 0; i < parameterList.Length; i++)
43 | {
44 | pList.Add(new ContractParameter(parameterList[i]));
45 | context.Add(Service.CurrentWallet.GetAccount(hash).Contract, i, null);
46 | }
47 | }
48 | }
49 | listBox2.Items.AddRange(context.GetParameters(hash).ToArray());
50 | button4.Visible = context.Completed;
51 | }
52 |
53 | private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
54 | {
55 | if (listBox2.SelectedIndex < 0) return;
56 | textBox1.Text = listBox2.SelectedItem.ToString();
57 | textBox2.Clear();
58 | }
59 |
60 | private void button1_Click(object sender, EventArgs e)
61 | {
62 | string input = InputBox.Show("ParametersContext", "ParametersContext");
63 | if (string.IsNullOrEmpty(input)) return;
64 | try
65 | {
66 | context = ContractParametersContext.Parse(input, Service.NeoSystem.StoreView);
67 | }
68 | catch (FormatException ex)
69 | {
70 | MessageBox.Show(ex.Message);
71 | return;
72 | }
73 | listBox1.Items.Clear();
74 | listBox2.Items.Clear();
75 | textBox1.Clear();
76 | textBox2.Clear();
77 | listBox1.Items.AddRange(context.ScriptHashes.Select(p => p.ToAddress(Service.NeoSystem.Settings.AddressVersion)).ToArray());
78 | button2.Enabled = true;
79 | button4.Visible = context.Completed;
80 | }
81 |
82 | private void button2_Click(object sender, EventArgs e)
83 | {
84 | InformationBox.Show(context.ToString(), "ParametersContext", "ParametersContext");
85 | }
86 |
87 | private void button3_Click(object sender, EventArgs e)
88 | {
89 | if (listBox1.SelectedIndex < 0) return;
90 | if (listBox2.SelectedIndex < 0) return;
91 | ContractParameter parameter = (ContractParameter)listBox2.SelectedItem;
92 | parameter.SetValue(textBox2.Text);
93 | listBox2.Items[listBox2.SelectedIndex] = parameter;
94 | textBox1.Text = textBox2.Text;
95 | button4.Visible = context.Completed;
96 | }
97 |
98 | private void button4_Click(object sender, EventArgs e)
99 | {
100 | if (!(context.Verifiable is Transaction tx))
101 | {
102 | MessageBox.Show("Only support to broadcast transaction.");
103 | return;
104 | }
105 | tx.Witnesses = context.GetWitnesses();
106 | Blockchain.RelayResult reason = Service.NeoSystem.Blockchain.Ask(tx).Result;
107 | if (reason.Result == VerifyResult.Succeed)
108 | {
109 | InformationBox.Show(tx.Hash.ToString(), Strings.RelaySuccessText, Strings.RelaySuccessTitle);
110 | }
111 | else
112 | {
113 | MessageBox.Show($"Transaction cannot be broadcast: {reason}");
114 | }
115 | }
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/neo-gui/GUI/DeveloperToolsForm.TxBuilder.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.GUI.Wrappers;
12 | using Neo.SmartContract;
13 | using System;
14 |
15 | namespace Neo.GUI
16 | {
17 | partial class DeveloperToolsForm
18 | {
19 | private void InitializeTxBuilder()
20 | {
21 | propertyGrid1.SelectedObject = new TransactionWrapper();
22 | }
23 |
24 | private void propertyGrid1_SelectedObjectsChanged(object sender, EventArgs e)
25 | {
26 | splitContainer1.Panel2.Enabled = propertyGrid1.SelectedObject != null;
27 | }
28 |
29 | private void button8_Click(object sender, EventArgs e)
30 | {
31 | TransactionWrapper wrapper = (TransactionWrapper)propertyGrid1.SelectedObject;
32 | ContractParametersContext context = new ContractParametersContext(Program.Service.NeoSystem.StoreView, wrapper.Unwrap(), Program.Service.NeoSystem.Settings.Network);
33 | InformationBox.Show(context.ToString(), "ParametersContext", "ParametersContext");
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/neo-gui/GUI/DeveloperToolsForm.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System.Windows.Forms;
12 |
13 | namespace Neo.GUI
14 | {
15 | internal partial class DeveloperToolsForm : Form
16 | {
17 | public DeveloperToolsForm()
18 | {
19 | InitializeComponent();
20 | InitializeTxBuilder();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/neo-gui/GUI/ElectionDialog.Designer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | namespace Neo.GUI
12 | {
13 | partial class ElectionDialog
14 | {
15 | ///
16 | /// Required designer variable.
17 | ///
18 | private System.ComponentModel.IContainer components = null;
19 |
20 | ///
21 | /// Clean up any resources being used.
22 | ///
23 | /// true if managed resources should be disposed; otherwise, false.
24 | protected override void Dispose(bool disposing)
25 | {
26 | if (disposing && (components != null))
27 | {
28 | components.Dispose();
29 | }
30 | base.Dispose(disposing);
31 | }
32 |
33 | #region Windows Form Designer generated code
34 |
35 | ///
36 | /// Required method for Designer support - do not modify
37 | /// the contents of this method with the code editor.
38 | ///
39 | private void InitializeComponent()
40 | {
41 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ElectionDialog));
42 | this.label1 = new System.Windows.Forms.Label();
43 | this.comboBox1 = new System.Windows.Forms.ComboBox();
44 | this.button1 = new System.Windows.Forms.Button();
45 | this.SuspendLayout();
46 | //
47 | // label1
48 | //
49 | resources.ApplyResources(this.label1, "label1");
50 | this.label1.Name = "label1";
51 | //
52 | // comboBox1
53 | //
54 | resources.ApplyResources(this.comboBox1, "comboBox1");
55 | this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
56 | this.comboBox1.FormattingEnabled = true;
57 | this.comboBox1.Name = "comboBox1";
58 | this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
59 | //
60 | // button1
61 | //
62 | resources.ApplyResources(this.button1, "button1");
63 | this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
64 | this.button1.Name = "button1";
65 | this.button1.UseVisualStyleBackColor = true;
66 | //
67 | // ElectionDialog
68 | //
69 | this.AcceptButton = this.button1;
70 | resources.ApplyResources(this, "$this");
71 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
72 | this.Controls.Add(this.button1);
73 | this.Controls.Add(this.comboBox1);
74 | this.Controls.Add(this.label1);
75 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
76 | this.MaximizeBox = false;
77 | this.MinimizeBox = false;
78 | this.Name = "ElectionDialog";
79 | this.ShowInTaskbar = false;
80 | this.Load += new System.EventHandler(this.ElectionDialog_Load);
81 | this.ResumeLayout(false);
82 | this.PerformLayout();
83 |
84 | }
85 |
86 | #endregion
87 |
88 | private System.Windows.Forms.Label label1;
89 | private System.Windows.Forms.ComboBox comboBox1;
90 | private System.Windows.Forms.Button button1;
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/neo-gui/GUI/ElectionDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Cryptography.ECC;
12 | using Neo.IO;
13 | using Neo.SmartContract.Native;
14 | using Neo.VM;
15 | using System;
16 | using System.Linq;
17 | using System.Windows.Forms;
18 | using static Neo.Program;
19 | using static Neo.SmartContract.Helper;
20 |
21 | namespace Neo.GUI
22 | {
23 | public partial class ElectionDialog : Form
24 | {
25 | public ElectionDialog()
26 | {
27 | InitializeComponent();
28 | }
29 |
30 | public byte[] GetScript()
31 | {
32 | ECPoint pubkey = (ECPoint)comboBox1.SelectedItem;
33 | using ScriptBuilder sb = new ScriptBuilder();
34 | sb.EmitDynamicCall(NativeContract.NEO.Hash, "registerValidator", pubkey);
35 | return sb.ToArray();
36 | }
37 |
38 | private void ElectionDialog_Load(object sender, EventArgs e)
39 | {
40 | comboBox1.Items.AddRange(Service.CurrentWallet.GetAccounts().Where(p => !p.WatchOnly && IsSignatureContract(p.Contract.Script)).Select(p => p.GetKey().PublicKey).ToArray());
41 | }
42 |
43 | private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
44 | {
45 | if (comboBox1.SelectedIndex >= 0)
46 | {
47 | button1.Enabled = true;
48 | }
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/neo-gui/GUI/Helper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Akka.Actor;
12 | using Neo.Network.P2P;
13 | using Neo.Network.P2P.Payloads;
14 | using Neo.Properties;
15 | using Neo.SmartContract;
16 | using System;
17 | using System.Collections.Generic;
18 | using System.Windows.Forms;
19 | using static Neo.Program;
20 |
21 | namespace Neo.GUI
22 | {
23 | internal static class Helper
24 | {
25 | private static readonly Dictionary tool_forms = new Dictionary();
26 |
27 | private static void Helper_FormClosing(object sender, FormClosingEventArgs e)
28 | {
29 | tool_forms.Remove(sender.GetType());
30 | }
31 |
32 | public static void Show() where T : Form, new()
33 | {
34 | Type t = typeof(T);
35 | if (!tool_forms.ContainsKey(t))
36 | {
37 | tool_forms.Add(t, new T());
38 | tool_forms[t].FormClosing += Helper_FormClosing;
39 | }
40 | tool_forms[t].Show();
41 | tool_forms[t].Activate();
42 | }
43 |
44 | public static void SignAndShowInformation(Transaction tx)
45 | {
46 | if (tx == null)
47 | {
48 | MessageBox.Show(Strings.InsufficientFunds);
49 | return;
50 | }
51 | ContractParametersContext context;
52 | try
53 | {
54 | context = new ContractParametersContext(Service.NeoSystem.StoreView, tx, Program.Service.NeoSystem.Settings.Network);
55 | }
56 | catch (InvalidOperationException)
57 | {
58 | MessageBox.Show(Strings.UnsynchronizedBlock);
59 | return;
60 | }
61 | Service.CurrentWallet.Sign(context);
62 | if (context.Completed)
63 | {
64 | tx.Witnesses = context.GetWitnesses();
65 | Service.NeoSystem.Blockchain.Tell(tx);
66 | InformationBox.Show(tx.Hash.ToString(), Strings.SendTxSucceedMessage, Strings.SendTxSucceedTitle);
67 | }
68 | else
69 | {
70 | InformationBox.Show(context.ToString(), Strings.IncompletedSignatureMessage, Strings.IncompletedSignatureTitle);
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/neo-gui/GUI/ImportCustomContractDialog.Designer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | namespace Neo.GUI
12 | {
13 | partial class ImportCustomContractDialog
14 | {
15 | ///
16 | /// Required designer variable.
17 | ///
18 | private System.ComponentModel.IContainer components = null;
19 |
20 | ///
21 | /// Clean up any resources being used.
22 | ///
23 | /// true if managed resources should be disposed; otherwise, false.
24 | protected override void Dispose(bool disposing)
25 | {
26 | if (disposing && (components != null))
27 | {
28 | components.Dispose();
29 | }
30 | base.Dispose(disposing);
31 | }
32 |
33 | #region Windows Form Designer generated code
34 |
35 | ///
36 | /// Required method for Designer support - do not modify
37 | /// the contents of this method with the code editor.
38 | ///
39 | private void InitializeComponent()
40 | {
41 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImportCustomContractDialog));
42 | this.label1 = new System.Windows.Forms.Label();
43 | this.label2 = new System.Windows.Forms.Label();
44 | this.textBox1 = new System.Windows.Forms.TextBox();
45 | this.textBox2 = new System.Windows.Forms.TextBox();
46 | this.groupBox1 = new System.Windows.Forms.GroupBox();
47 | this.button1 = new System.Windows.Forms.Button();
48 | this.button2 = new System.Windows.Forms.Button();
49 | this.textBox3 = new System.Windows.Forms.TextBox();
50 | this.groupBox1.SuspendLayout();
51 | this.SuspendLayout();
52 | //
53 | // label1
54 | //
55 | resources.ApplyResources(this.label1, "label1");
56 | this.label1.Name = "label1";
57 | //
58 | // label2
59 | //
60 | resources.ApplyResources(this.label2, "label2");
61 | this.label2.Name = "label2";
62 | //
63 | // textBox1
64 | //
65 | resources.ApplyResources(this.textBox1, "textBox1");
66 | this.textBox1.Name = "textBox1";
67 | this.textBox1.TextChanged += new System.EventHandler(this.Input_Changed);
68 | //
69 | // textBox2
70 | //
71 | resources.ApplyResources(this.textBox2, "textBox2");
72 | this.textBox2.Name = "textBox2";
73 | this.textBox2.TextChanged += new System.EventHandler(this.Input_Changed);
74 | //
75 | // groupBox1
76 | //
77 | resources.ApplyResources(this.groupBox1, "groupBox1");
78 | this.groupBox1.Controls.Add(this.textBox2);
79 | this.groupBox1.Name = "groupBox1";
80 | this.groupBox1.TabStop = false;
81 | //
82 | // button1
83 | //
84 | resources.ApplyResources(this.button1, "button1");
85 | this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
86 | this.button1.Name = "button1";
87 | this.button1.UseVisualStyleBackColor = true;
88 | //
89 | // button2
90 | //
91 | resources.ApplyResources(this.button2, "button2");
92 | this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
93 | this.button2.Name = "button2";
94 | this.button2.UseVisualStyleBackColor = true;
95 | //
96 | // textBox3
97 | //
98 | resources.ApplyResources(this.textBox3, "textBox3");
99 | this.textBox3.Name = "textBox3";
100 | //
101 | // ImportCustomContractDialog
102 | //
103 | this.AcceptButton = this.button1;
104 | resources.ApplyResources(this, "$this");
105 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
106 | this.CancelButton = this.button2;
107 | this.Controls.Add(this.textBox3);
108 | this.Controls.Add(this.button2);
109 | this.Controls.Add(this.button1);
110 | this.Controls.Add(this.groupBox1);
111 | this.Controls.Add(this.textBox1);
112 | this.Controls.Add(this.label2);
113 | this.Controls.Add(this.label1);
114 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
115 | this.MaximizeBox = false;
116 | this.MinimizeBox = false;
117 | this.Name = "ImportCustomContractDialog";
118 | this.ShowInTaskbar = false;
119 | this.groupBox1.ResumeLayout(false);
120 | this.groupBox1.PerformLayout();
121 | this.ResumeLayout(false);
122 | this.PerformLayout();
123 |
124 | }
125 |
126 | #endregion
127 |
128 | private System.Windows.Forms.Label label1;
129 | private System.Windows.Forms.Label label2;
130 | private System.Windows.Forms.TextBox textBox1;
131 | private System.Windows.Forms.TextBox textBox2;
132 | private System.Windows.Forms.GroupBox groupBox1;
133 | private System.Windows.Forms.Button button1;
134 | private System.Windows.Forms.Button button2;
135 | private System.Windows.Forms.TextBox textBox3;
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/neo-gui/GUI/ImportCustomContractDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.SmartContract;
12 | using Neo.Wallets;
13 | using System;
14 | using System.Linq;
15 | using System.Windows.Forms;
16 |
17 | namespace Neo.GUI
18 | {
19 | internal partial class ImportCustomContractDialog : Form
20 | {
21 | public Contract GetContract()
22 | {
23 | ContractParameterType[] parameterList = textBox1.Text.HexToBytes().Select(p => (ContractParameterType)p).ToArray();
24 | byte[] redeemScript = textBox2.Text.HexToBytes();
25 | return Contract.Create(parameterList, redeemScript);
26 | }
27 |
28 | public KeyPair GetKey()
29 | {
30 | if (textBox3.TextLength == 0) return null;
31 | byte[] privateKey;
32 | try
33 | {
34 | privateKey = Wallet.GetPrivateKeyFromWIF(textBox3.Text);
35 | }
36 | catch (FormatException)
37 | {
38 | privateKey = textBox3.Text.HexToBytes();
39 | }
40 | return new KeyPair(privateKey);
41 | }
42 |
43 | public ImportCustomContractDialog()
44 | {
45 | InitializeComponent();
46 | }
47 |
48 | private void Input_Changed(object sender, EventArgs e)
49 | {
50 | button1.Enabled = textBox1.TextLength > 0 && textBox2.TextLength > 0;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/neo-gui/GUI/ImportPrivateKeyDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System;
12 | using System.Windows.Forms;
13 |
14 | namespace Neo.GUI
15 | {
16 | internal partial class ImportPrivateKeyDialog : Form
17 | {
18 | public ImportPrivateKeyDialog()
19 | {
20 | InitializeComponent();
21 | }
22 |
23 | public string[] WifStrings
24 | {
25 | get
26 | {
27 | return textBox1.Lines;
28 | }
29 | set
30 | {
31 | textBox1.Lines = value;
32 | }
33 | }
34 |
35 | private void textBox1_TextChanged(object sender, EventArgs e)
36 | {
37 | button1.Enabled = textBox1.TextLength > 0;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/neo-gui/GUI/ImportPrivateKeyDialog.designer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | namespace Neo.GUI
12 | {
13 | partial class ImportPrivateKeyDialog
14 | {
15 | ///
16 | /// Required designer variable.
17 | ///
18 | private System.ComponentModel.IContainer components = null;
19 |
20 | ///
21 | /// Clean up any resources being used.
22 | ///
23 | /// true if managed resources should be disposed; otherwise, false.
24 | protected override void Dispose(bool disposing)
25 | {
26 | if (disposing && (components != null))
27 | {
28 | components.Dispose();
29 | }
30 | base.Dispose(disposing);
31 | }
32 |
33 | #region Windows Form Designer generated code
34 |
35 | ///
36 | /// Required method for Designer support - do not modify
37 | /// the contents of this method with the code editor.
38 | ///
39 | private void InitializeComponent()
40 | {
41 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImportPrivateKeyDialog));
42 | this.textBox1 = new System.Windows.Forms.TextBox();
43 | this.button1 = new System.Windows.Forms.Button();
44 | this.button2 = new System.Windows.Forms.Button();
45 | this.groupBox1 = new System.Windows.Forms.GroupBox();
46 | this.groupBox1.SuspendLayout();
47 | this.SuspendLayout();
48 | //
49 | // textBox1
50 | //
51 | resources.ApplyResources(this.textBox1, "textBox1");
52 | this.textBox1.Name = "textBox1";
53 | this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
54 | //
55 | // button1
56 | //
57 | resources.ApplyResources(this.button1, "button1");
58 | this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
59 | this.button1.Name = "button1";
60 | this.button1.UseVisualStyleBackColor = true;
61 | //
62 | // button2
63 | //
64 | resources.ApplyResources(this.button2, "button2");
65 | this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
66 | this.button2.Name = "button2";
67 | this.button2.UseVisualStyleBackColor = true;
68 | //
69 | // groupBox1
70 | //
71 | resources.ApplyResources(this.groupBox1, "groupBox1");
72 | this.groupBox1.Controls.Add(this.textBox1);
73 | this.groupBox1.Name = "groupBox1";
74 | this.groupBox1.TabStop = false;
75 | //
76 | // ImportPrivateKeyDialog
77 | //
78 | this.AcceptButton = this.button1;
79 | resources.ApplyResources(this, "$this");
80 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
81 | this.CancelButton = this.button2;
82 | this.Controls.Add(this.groupBox1);
83 | this.Controls.Add(this.button2);
84 | this.Controls.Add(this.button1);
85 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
86 | this.MaximizeBox = false;
87 | this.MinimizeBox = false;
88 | this.Name = "ImportPrivateKeyDialog";
89 | this.ShowInTaskbar = false;
90 | this.groupBox1.ResumeLayout(false);
91 | this.groupBox1.PerformLayout();
92 | this.ResumeLayout(false);
93 |
94 | }
95 |
96 | #endregion
97 | private System.Windows.Forms.TextBox textBox1;
98 | private System.Windows.Forms.Button button1;
99 | private System.Windows.Forms.Button button2;
100 | private System.Windows.Forms.GroupBox groupBox1;
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/neo-gui/GUI/InformationBox.Designer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | namespace Neo.GUI
12 | {
13 | partial class InformationBox
14 | {
15 | ///
16 | /// Required designer variable.
17 | ///
18 | private System.ComponentModel.IContainer components = null;
19 |
20 | ///
21 | /// Clean up any resources being used.
22 | ///
23 | /// true if managed resources should be disposed; otherwise, false.
24 | protected override void Dispose(bool disposing)
25 | {
26 | if (disposing && (components != null))
27 | {
28 | components.Dispose();
29 | }
30 | base.Dispose(disposing);
31 | }
32 |
33 | #region Windows Form Designer generated code
34 |
35 | ///
36 | /// Required method for Designer support - do not modify
37 | /// the contents of this method with the code editor.
38 | ///
39 | private void InitializeComponent()
40 | {
41 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InformationBox));
42 | this.textBox1 = new System.Windows.Forms.TextBox();
43 | this.button1 = new System.Windows.Forms.Button();
44 | this.button2 = new System.Windows.Forms.Button();
45 | this.label1 = new System.Windows.Forms.Label();
46 | this.SuspendLayout();
47 | //
48 | // textBox1
49 | //
50 | resources.ApplyResources(this.textBox1, "textBox1");
51 | this.textBox1.Name = "textBox1";
52 | this.textBox1.ReadOnly = true;
53 | //
54 | // button1
55 | //
56 | resources.ApplyResources(this.button1, "button1");
57 | this.button1.Name = "button1";
58 | this.button1.UseVisualStyleBackColor = true;
59 | this.button1.Click += new System.EventHandler(this.button1_Click);
60 | //
61 | // button2
62 | //
63 | resources.ApplyResources(this.button2, "button2");
64 | this.button2.DialogResult = System.Windows.Forms.DialogResult.OK;
65 | this.button2.Name = "button2";
66 | this.button2.UseVisualStyleBackColor = true;
67 | //
68 | // label1
69 | //
70 | resources.ApplyResources(this.label1, "label1");
71 | this.label1.Name = "label1";
72 | //
73 | // InformationBox
74 | //
75 | this.AcceptButton = this.button2;
76 | resources.ApplyResources(this, "$this");
77 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
78 | this.CancelButton = this.button2;
79 | this.Controls.Add(this.label1);
80 | this.Controls.Add(this.button2);
81 | this.Controls.Add(this.button1);
82 | this.Controls.Add(this.textBox1);
83 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
84 | this.MaximizeBox = false;
85 | this.MinimizeBox = false;
86 | this.Name = "InformationBox";
87 | this.ShowInTaskbar = false;
88 | this.ResumeLayout(false);
89 | this.PerformLayout();
90 |
91 | }
92 |
93 | #endregion
94 |
95 | private System.Windows.Forms.TextBox textBox1;
96 | private System.Windows.Forms.Button button1;
97 | private System.Windows.Forms.Button button2;
98 | private System.Windows.Forms.Label label1;
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/neo-gui/GUI/InformationBox.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System.Windows.Forms;
12 |
13 | namespace Neo.GUI
14 | {
15 | internal partial class InformationBox : Form
16 | {
17 | public InformationBox()
18 | {
19 | InitializeComponent();
20 | }
21 |
22 | public static DialogResult Show(string text, string message = null, string title = null)
23 | {
24 | using InformationBox box = new InformationBox();
25 | box.textBox1.Text = text;
26 | if (message != null)
27 | {
28 | box.label1.Text = message;
29 | }
30 | if (title != null)
31 | {
32 | box.Text = title;
33 | }
34 | return box.ShowDialog();
35 | }
36 |
37 | private void button1_Click(object sender, System.EventArgs e)
38 | {
39 | textBox1.SelectAll();
40 | textBox1.Copy();
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/neo-gui/GUI/InputBox.Designer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | namespace Neo.GUI
12 | {
13 | partial class InputBox
14 | {
15 | ///
16 | /// Required designer variable.
17 | ///
18 | private System.ComponentModel.IContainer components = null;
19 |
20 | ///
21 | /// Clean up any resources being used.
22 | ///
23 | /// true if managed resources should be disposed; otherwise, false.
24 | protected override void Dispose(bool disposing)
25 | {
26 | if (disposing && (components != null))
27 | {
28 | components.Dispose();
29 | }
30 | base.Dispose(disposing);
31 | }
32 |
33 | #region Windows Form Designer generated code
34 |
35 | ///
36 | /// Required method for Designer support - do not modify
37 | /// the contents of this method with the code editor.
38 | ///
39 | private void InitializeComponent()
40 | {
41 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InputBox));
42 | this.textBox1 = new System.Windows.Forms.TextBox();
43 | this.groupBox1 = new System.Windows.Forms.GroupBox();
44 | this.button1 = new System.Windows.Forms.Button();
45 | this.button2 = new System.Windows.Forms.Button();
46 | this.groupBox1.SuspendLayout();
47 | this.SuspendLayout();
48 | //
49 | // textBox1
50 | //
51 | resources.ApplyResources(this.textBox1, "textBox1");
52 | this.textBox1.Name = "textBox1";
53 | //
54 | // groupBox1
55 | //
56 | resources.ApplyResources(this.groupBox1, "groupBox1");
57 | this.groupBox1.Controls.Add(this.textBox1);
58 | this.groupBox1.Name = "groupBox1";
59 | this.groupBox1.TabStop = false;
60 | //
61 | // button1
62 | //
63 | resources.ApplyResources(this.button1, "button1");
64 | this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
65 | this.button1.Name = "button1";
66 | this.button1.UseVisualStyleBackColor = true;
67 | //
68 | // button2
69 | //
70 | resources.ApplyResources(this.button2, "button2");
71 | this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
72 | this.button2.Name = "button2";
73 | this.button2.UseVisualStyleBackColor = true;
74 | //
75 | // InputBox
76 | //
77 | this.AcceptButton = this.button1;
78 | resources.ApplyResources(this, "$this");
79 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
80 | this.CancelButton = this.button2;
81 | this.Controls.Add(this.button2);
82 | this.Controls.Add(this.button1);
83 | this.Controls.Add(this.groupBox1);
84 | this.MaximizeBox = false;
85 | this.MinimizeBox = false;
86 | this.Name = "InputBox";
87 | this.ShowIcon = false;
88 | this.ShowInTaskbar = false;
89 | this.groupBox1.ResumeLayout(false);
90 | this.groupBox1.PerformLayout();
91 | this.ResumeLayout(false);
92 |
93 | }
94 |
95 | #endregion
96 |
97 | private System.Windows.Forms.TextBox textBox1;
98 | private System.Windows.Forms.GroupBox groupBox1;
99 | private System.Windows.Forms.Button button1;
100 | private System.Windows.Forms.Button button2;
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/neo-gui/GUI/InputBox.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System.Windows.Forms;
12 |
13 | namespace Neo.GUI
14 | {
15 | internal partial class InputBox : Form
16 | {
17 | private InputBox(string text, string caption, string content)
18 | {
19 | InitializeComponent();
20 | this.Text = caption;
21 | groupBox1.Text = text;
22 | textBox1.Text = content;
23 | }
24 |
25 | public static string Show(string text, string caption, string content = "")
26 | {
27 | using InputBox dialog = new InputBox(text, caption, content);
28 | if (dialog.ShowDialog() != DialogResult.OK) return null;
29 | return dialog.textBox1.Text;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/neo-gui/GUI/InvokeContractDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Json;
12 | using Neo.Network.P2P.Payloads;
13 | using Neo.Properties;
14 | using Neo.SmartContract;
15 | using Neo.VM;
16 | using System;
17 | using System.IO;
18 | using System.Linq;
19 | using System.Text;
20 | using System.Windows.Forms;
21 | using static Neo.Program;
22 |
23 | namespace Neo.GUI
24 | {
25 | internal partial class InvokeContractDialog : Form
26 | {
27 | private readonly Transaction tx;
28 | private JObject abi;
29 | private UInt160 script_hash;
30 | private ContractParameter[] parameters;
31 |
32 | public InvokeContractDialog()
33 | {
34 | InitializeComponent();
35 | }
36 |
37 | public InvokeContractDialog(Transaction tx) : this()
38 | {
39 | this.tx = tx;
40 | tabControl1.SelectedTab = tabPage2;
41 | textBox6.Text = tx.Script.Span.ToHexString();
42 | textBox6.ReadOnly = true;
43 | }
44 |
45 | public InvokeContractDialog(byte[] script) : this()
46 | {
47 | tabControl1.SelectedTab = tabPage2;
48 | textBox6.Text = script.ToHexString();
49 | }
50 |
51 | public Transaction GetTransaction()
52 | {
53 | byte[] script = textBox6.Text.Trim().HexToBytes();
54 | return tx ?? Service.CurrentWallet.MakeTransaction(Service.NeoSystem.StoreView, script);
55 | }
56 |
57 | private void UpdateScript()
58 | {
59 | using ScriptBuilder sb = new ScriptBuilder();
60 | sb.EmitDynamicCall(script_hash, (string)comboBox1.SelectedItem, parameters);
61 | textBox6.Text = sb.ToArray().ToHexString();
62 | }
63 |
64 | private void textBox6_TextChanged(object sender, EventArgs e)
65 | {
66 | button3.Enabled = false;
67 | button5.Enabled = textBox6.TextLength > 0;
68 | }
69 |
70 | private void button5_Click(object sender, EventArgs e)
71 | {
72 | byte[] script;
73 | try
74 | {
75 | script = textBox6.Text.Trim().HexToBytes();
76 | }
77 | catch (FormatException ex)
78 | {
79 | MessageBox.Show(ex.Message);
80 | return;
81 | }
82 | Transaction tx_test = tx ?? new Transaction
83 | {
84 | Signers = new Signer[0],
85 | Attributes = new TransactionAttribute[0],
86 | Script = script,
87 | Witnesses = new Witness[0]
88 | };
89 | using ApplicationEngine engine = ApplicationEngine.Run(tx_test.Script, Service.NeoSystem.StoreView, container: tx_test);
90 | StringBuilder sb = new StringBuilder();
91 | sb.AppendLine($"VM State: {engine.State}");
92 | sb.AppendLine($"Gas Consumed: {engine.GasConsumed}");
93 | sb.AppendLine($"Evaluation Stack: {new JArray(engine.ResultStack.Select(p => p.ToParameter().ToJson()))}");
94 | textBox7.Text = sb.ToString();
95 | if (engine.State != VMState.FAULT)
96 | {
97 | label7.Text = engine.GasConsumed + " gas";
98 | button3.Enabled = true;
99 | }
100 | else
101 | {
102 | MessageBox.Show(Strings.ExecutionFailed);
103 | }
104 | }
105 |
106 | private void button6_Click(object sender, EventArgs e)
107 | {
108 | if (openFileDialog1.ShowDialog() != DialogResult.OK) return;
109 | textBox6.Text = File.ReadAllBytes(openFileDialog1.FileName).ToHexString();
110 | }
111 |
112 | private void button7_Click(object sender, EventArgs e)
113 | {
114 | if (openFileDialog2.ShowDialog() != DialogResult.OK) return;
115 | abi = (JObject)JToken.Parse(File.ReadAllText(openFileDialog2.FileName));
116 | script_hash = UInt160.Parse(abi["hash"].AsString());
117 | textBox8.Text = script_hash.ToString();
118 | comboBox1.Items.Clear();
119 | comboBox1.Items.AddRange(((JArray)abi["functions"]).Select(p => p["name"].AsString()).Where(p => p != abi["entrypoint"].AsString()).ToArray());
120 | textBox9.Clear();
121 | button8.Enabled = false;
122 | }
123 |
124 | private void button8_Click(object sender, EventArgs e)
125 | {
126 | using (ParametersEditor dialog = new ParametersEditor(parameters))
127 | {
128 | dialog.ShowDialog();
129 | }
130 | UpdateScript();
131 | }
132 |
133 | private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
134 | {
135 | if (!(comboBox1.SelectedItem is string method)) return;
136 | JArray functions = (JArray)abi["functions"];
137 | var function = functions.First(p => p["name"].AsString() == method);
138 | JArray _params = (JArray)function["parameters"];
139 | parameters = _params.Select(p => new ContractParameter(p["type"].AsEnum())).ToArray();
140 | textBox9.Text = string.Join(", ", _params.Select(p => p["name"].AsString()));
141 | button8.Enabled = parameters.Length > 0;
142 | UpdateScript();
143 | }
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/neo-gui/GUI/OpenWalletDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System;
12 | using System.Windows.Forms;
13 |
14 | namespace Neo.GUI
15 | {
16 | internal partial class OpenWalletDialog : Form
17 | {
18 | public OpenWalletDialog()
19 | {
20 | InitializeComponent();
21 | }
22 |
23 | public string Password
24 | {
25 | get
26 | {
27 | return textBox2.Text;
28 | }
29 | set
30 | {
31 | textBox2.Text = value;
32 | }
33 | }
34 |
35 | public string WalletPath
36 | {
37 | get
38 | {
39 | return textBox1.Text;
40 | }
41 | set
42 | {
43 | textBox1.Text = value;
44 | }
45 | }
46 |
47 | private void textBox_TextChanged(object sender, EventArgs e)
48 | {
49 | if (textBox1.TextLength == 0 || textBox2.TextLength == 0)
50 | {
51 | button2.Enabled = false;
52 | return;
53 | }
54 | button2.Enabled = true;
55 | }
56 |
57 | private void button1_Click(object sender, EventArgs e)
58 | {
59 | if (openFileDialog1.ShowDialog() == DialogResult.OK)
60 | {
61 | textBox1.Text = openFileDialog1.FileName;
62 | }
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/neo-gui/GUI/OpenWalletDialog.designer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | namespace Neo.GUI
12 | {
13 | partial class OpenWalletDialog
14 | {
15 | ///
16 | /// Required designer variable.
17 | ///
18 | private System.ComponentModel.IContainer components = null;
19 |
20 | ///
21 | /// Clean up any resources being used.
22 | ///
23 | /// true if managed resources should be disposed; otherwise, false.
24 | protected override void Dispose(bool disposing)
25 | {
26 | if (disposing && (components != null))
27 | {
28 | components.Dispose();
29 | }
30 | base.Dispose(disposing);
31 | }
32 |
33 | #region Windows Form Designer generated code
34 |
35 | ///
36 | /// Required method for Designer support - do not modify
37 | /// the contents of this method with the code editor.
38 | ///
39 | private void InitializeComponent()
40 | {
41 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OpenWalletDialog));
42 | this.button2 = new System.Windows.Forms.Button();
43 | this.textBox2 = new System.Windows.Forms.TextBox();
44 | this.label2 = new System.Windows.Forms.Label();
45 | this.button1 = new System.Windows.Forms.Button();
46 | this.textBox1 = new System.Windows.Forms.TextBox();
47 | this.label1 = new System.Windows.Forms.Label();
48 | this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
49 | this.SuspendLayout();
50 | //
51 | // button2
52 | //
53 | resources.ApplyResources(this.button2, "button2");
54 | this.button2.DialogResult = System.Windows.Forms.DialogResult.OK;
55 | this.button2.Name = "button2";
56 | this.button2.UseVisualStyleBackColor = true;
57 | //
58 | // textBox2
59 | //
60 | resources.ApplyResources(this.textBox2, "textBox2");
61 | this.textBox2.Name = "textBox2";
62 | this.textBox2.UseSystemPasswordChar = true;
63 | this.textBox2.TextChanged += new System.EventHandler(this.textBox_TextChanged);
64 | //
65 | // label2
66 | //
67 | resources.ApplyResources(this.label2, "label2");
68 | this.label2.Name = "label2";
69 | //
70 | // button1
71 | //
72 | resources.ApplyResources(this.button1, "button1");
73 | this.button1.Name = "button1";
74 | this.button1.UseVisualStyleBackColor = true;
75 | this.button1.Click += new System.EventHandler(this.button1_Click);
76 | //
77 | // textBox1
78 | //
79 | resources.ApplyResources(this.textBox1, "textBox1");
80 | this.textBox1.Name = "textBox1";
81 | this.textBox1.ReadOnly = true;
82 | this.textBox1.TextChanged += new System.EventHandler(this.textBox_TextChanged);
83 | //
84 | // label1
85 | //
86 | resources.ApplyResources(this.label1, "label1");
87 | this.label1.Name = "label1";
88 | //
89 | // openFileDialog1
90 | //
91 | this.openFileDialog1.DefaultExt = "json";
92 | resources.ApplyResources(this.openFileDialog1, "openFileDialog1");
93 | //
94 | // OpenWalletDialog
95 | //
96 | this.AcceptButton = this.button2;
97 | resources.ApplyResources(this, "$this");
98 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
99 | this.Controls.Add(this.button2);
100 | this.Controls.Add(this.textBox2);
101 | this.Controls.Add(this.label2);
102 | this.Controls.Add(this.button1);
103 | this.Controls.Add(this.textBox1);
104 | this.Controls.Add(this.label1);
105 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
106 | this.MaximizeBox = false;
107 | this.MinimizeBox = false;
108 | this.Name = "OpenWalletDialog";
109 | this.ShowInTaskbar = false;
110 | this.ResumeLayout(false);
111 | this.PerformLayout();
112 |
113 | }
114 |
115 | #endregion
116 |
117 | private System.Windows.Forms.Button button2;
118 | private System.Windows.Forms.TextBox textBox2;
119 | private System.Windows.Forms.Label label2;
120 | private System.Windows.Forms.Button button1;
121 | private System.Windows.Forms.TextBox textBox1;
122 | private System.Windows.Forms.Label label1;
123 | private System.Windows.Forms.OpenFileDialog openFileDialog1;
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/neo-gui/GUI/PayToDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Wallets;
12 | using System;
13 | using System.Windows.Forms;
14 | using static Neo.Program;
15 |
16 | namespace Neo.GUI
17 | {
18 | internal partial class PayToDialog : Form
19 | {
20 | public PayToDialog(AssetDescriptor asset = null, UInt160 scriptHash = null)
21 | {
22 | InitializeComponent();
23 | if (asset is null)
24 | {
25 | foreach (UInt160 assetId in NEP5Watched)
26 | {
27 | try
28 | {
29 | comboBox1.Items.Add(new AssetDescriptor(Service.NeoSystem.StoreView, Service.NeoSystem.Settings, assetId));
30 | }
31 | catch (ArgumentException)
32 | {
33 | continue;
34 | }
35 | }
36 | }
37 | else
38 | {
39 | comboBox1.Items.Add(asset);
40 | comboBox1.SelectedIndex = 0;
41 | comboBox1.Enabled = false;
42 | }
43 | if (scriptHash != null)
44 | {
45 | textBox1.Text = scriptHash.ToAddress(Service.NeoSystem.Settings.AddressVersion);
46 | textBox1.ReadOnly = true;
47 | }
48 | }
49 |
50 | public TxOutListBoxItem GetOutput()
51 | {
52 | AssetDescriptor asset = (AssetDescriptor)comboBox1.SelectedItem;
53 | return new TxOutListBoxItem
54 | {
55 | AssetName = asset.AssetName,
56 | AssetId = asset.AssetId,
57 | Value = BigDecimal.Parse(textBox2.Text, asset.Decimals),
58 | ScriptHash = textBox1.Text.ToScriptHash(Service.NeoSystem.Settings.AddressVersion)
59 | };
60 | }
61 |
62 | private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
63 | {
64 | if (comboBox1.SelectedItem is AssetDescriptor asset)
65 | {
66 | textBox3.Text = Service.CurrentWallet.GetAvailable(Service.NeoSystem.StoreView, asset.AssetId).ToString();
67 | }
68 | else
69 | {
70 | textBox3.Text = "";
71 | }
72 | textBox_TextChanged(this, EventArgs.Empty);
73 | }
74 |
75 | private void textBox_TextChanged(object sender, EventArgs e)
76 | {
77 | if (comboBox1.SelectedIndex < 0 || textBox1.TextLength == 0 || textBox2.TextLength == 0)
78 | {
79 | button1.Enabled = false;
80 | return;
81 | }
82 | try
83 | {
84 | textBox1.Text.ToScriptHash(Service.NeoSystem.Settings.AddressVersion);
85 | }
86 | catch (FormatException)
87 | {
88 | button1.Enabled = false;
89 | return;
90 | }
91 | AssetDescriptor asset = (AssetDescriptor)comboBox1.SelectedItem;
92 | if (!BigDecimal.TryParse(textBox2.Text, asset.Decimals, out BigDecimal amount))
93 | {
94 | button1.Enabled = false;
95 | return;
96 | }
97 | if (amount.Sign <= 0)
98 | {
99 | button1.Enabled = false;
100 | return;
101 | }
102 | button1.Enabled = true;
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/neo-gui/GUI/QueueReader.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System.Collections.Generic;
12 | using System.IO;
13 | using System.Threading;
14 |
15 | namespace Neo.GUI
16 | {
17 | internal class QueueReader : TextReader
18 | {
19 | private readonly Queue queue = new Queue();
20 | private string current;
21 | private int index;
22 |
23 | public void Enqueue(string str)
24 | {
25 | queue.Enqueue(str);
26 | }
27 |
28 | public override int Peek()
29 | {
30 | while (string.IsNullOrEmpty(current))
31 | {
32 | while (!queue.TryDequeue(out current))
33 | Thread.Sleep(100);
34 | index = 0;
35 | }
36 | return current[index];
37 | }
38 |
39 | public override int Read()
40 | {
41 | int c = Peek();
42 | if (c != -1)
43 | if (++index >= current.Length)
44 | current = null;
45 | return c;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/neo-gui/GUI/SigningDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Cryptography;
12 | using Neo.Properties;
13 | using Neo.Wallets;
14 | using System;
15 | using System.Linq;
16 | using System.Text;
17 | using System.Windows.Forms;
18 | using static Neo.Program;
19 |
20 | namespace Neo.GUI
21 | {
22 | internal partial class SigningDialog : Form
23 | {
24 | private class WalletEntry
25 | {
26 | public WalletAccount Account;
27 |
28 | public override string ToString()
29 | {
30 | if (!string.IsNullOrEmpty(Account.Label))
31 | {
32 | return $"[{Account.Label}] " + Account.Address;
33 | }
34 | return Account.Address;
35 | }
36 | }
37 |
38 |
39 | public SigningDialog()
40 | {
41 | InitializeComponent();
42 |
43 | cmbFormat.SelectedIndex = 0;
44 | cmbAddress.Items.AddRange(Service.CurrentWallet.GetAccounts()
45 | .Where(u => u.HasKey)
46 | .Select(u => new WalletEntry() { Account = u })
47 | .ToArray());
48 |
49 | if (cmbAddress.Items.Count > 0)
50 | {
51 | cmbAddress.SelectedIndex = 0;
52 | }
53 | else
54 | {
55 | textBox2.Enabled = false;
56 | button1.Enabled = false;
57 | }
58 | }
59 |
60 | private void button1_Click(object sender, EventArgs e)
61 | {
62 | if (textBox1.Text == "")
63 | {
64 | MessageBox.Show(Strings.SigningFailedNoDataMessage);
65 | return;
66 | }
67 |
68 | byte[] raw, signedData;
69 | try
70 | {
71 | switch (cmbFormat.SelectedIndex)
72 | {
73 | case 0: raw = Encoding.UTF8.GetBytes(textBox1.Text); break;
74 | case 1: raw = textBox1.Text.HexToBytes(); break;
75 | default: return;
76 | }
77 | }
78 | catch (Exception err)
79 | {
80 | MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
81 | return;
82 | }
83 |
84 | var account = (WalletEntry)cmbAddress.SelectedItem;
85 | var keys = account.Account.GetKey();
86 |
87 | try
88 | {
89 | signedData = Crypto.Sign(raw, keys.PrivateKey, keys.PublicKey.EncodePoint(false).Skip(1).ToArray());
90 | }
91 | catch (Exception err)
92 | {
93 | MessageBox.Show(err.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
94 | return;
95 | }
96 |
97 | textBox2.Text = signedData?.ToHexString();
98 | }
99 |
100 | private void button2_Click(object sender, EventArgs e)
101 | {
102 | textBox2.SelectAll();
103 | textBox2.Copy();
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/neo-gui/GUI/SigningTxDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Akka.Actor;
12 | using Neo.Network.P2P;
13 | using Neo.Network.P2P.Payloads;
14 | using Neo.Properties;
15 | using Neo.SmartContract;
16 | using System;
17 | using System.Windows.Forms;
18 | using static Neo.Program;
19 |
20 | namespace Neo.GUI
21 | {
22 | internal partial class SigningTxDialog : Form
23 | {
24 | public SigningTxDialog()
25 | {
26 | InitializeComponent();
27 | }
28 |
29 | private void button1_Click(object sender, EventArgs e)
30 | {
31 | if (textBox1.Text == "")
32 | {
33 | MessageBox.Show(Strings.SigningFailedNoDataMessage);
34 | return;
35 | }
36 | ContractParametersContext context = ContractParametersContext.Parse(textBox1.Text, Service.NeoSystem.StoreView);
37 | if (!Service.CurrentWallet.Sign(context))
38 | {
39 | MessageBox.Show(Strings.SigningFailedKeyNotFoundMessage);
40 | return;
41 | }
42 | textBox2.Text = context.ToString();
43 | if (context.Completed) button4.Visible = true;
44 | }
45 |
46 | private void button2_Click(object sender, EventArgs e)
47 | {
48 | textBox2.SelectAll();
49 | textBox2.Copy();
50 | }
51 |
52 | private void button4_Click(object sender, EventArgs e)
53 | {
54 | ContractParametersContext context = ContractParametersContext.Parse(textBox2.Text, Service.NeoSystem.StoreView);
55 | if (!(context.Verifiable is Transaction tx))
56 | {
57 | MessageBox.Show("Only support to broadcast transaction.");
58 | return;
59 | }
60 | tx.Witnesses = context.GetWitnesses();
61 | Service.NeoSystem.Blockchain.Tell(tx);
62 | InformationBox.Show(tx.Hash.ToString(), Strings.RelaySuccessText, Strings.RelaySuccessTitle);
63 | button4.Visible = false;
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/neo-gui/GUI/TextBoxWriter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System;
12 | using System.IO;
13 | using System.Text;
14 | using System.Windows.Forms;
15 |
16 | namespace Neo.GUI
17 | {
18 | internal class TextBoxWriter : TextWriter
19 | {
20 | private readonly TextBoxBase textBox;
21 |
22 | public override Encoding Encoding => Encoding.UTF8;
23 |
24 | public TextBoxWriter(TextBoxBase textBox)
25 | {
26 | this.textBox = textBox;
27 | }
28 |
29 | public override void Write(char value)
30 | {
31 | textBox.Invoke(new Action(() => { textBox.Text += value; }));
32 | }
33 |
34 | public override void Write(string value)
35 | {
36 | textBox.Invoke(new Action(textBox.AppendText), value);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/neo-gui/GUI/TransferDialog.Designer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | namespace Neo.GUI
12 | {
13 | partial class TransferDialog
14 | {
15 | ///
16 | /// Required designer variable.
17 | ///
18 | private System.ComponentModel.IContainer components = null;
19 |
20 | ///
21 | /// Clean up any resources being used.
22 | ///
23 | /// true if managed resources should be disposed; otherwise, false.
24 | protected override void Dispose(bool disposing)
25 | {
26 | if (disposing && (components != null))
27 | {
28 | components.Dispose();
29 | }
30 | base.Dispose(disposing);
31 | }
32 |
33 | #region Windows Form Designer generated code
34 |
35 | ///
36 | /// Required method for Designer support - do not modify
37 | /// the contents of this method with the code editor.
38 | ///
39 | private void InitializeComponent()
40 | {
41 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TransferDialog));
42 | this.groupBox3 = new System.Windows.Forms.GroupBox();
43 | this.txOutListBox1 = new Neo.GUI.TxOutListBox();
44 | this.button4 = new System.Windows.Forms.Button();
45 | this.button3 = new System.Windows.Forms.Button();
46 | this.groupBox1 = new System.Windows.Forms.GroupBox();
47 | this.comboBoxFrom = new System.Windows.Forms.ComboBox();
48 | this.labelFrom = new System.Windows.Forms.Label();
49 | this.groupBox3.SuspendLayout();
50 | this.groupBox1.SuspendLayout();
51 | this.SuspendLayout();
52 | //
53 | // groupBox3
54 | //
55 | resources.ApplyResources(this.groupBox3, "groupBox3");
56 | this.groupBox3.Controls.Add(this.txOutListBox1);
57 | this.groupBox3.Name = "groupBox3";
58 | this.groupBox3.TabStop = false;
59 | //
60 | // txOutListBox1
61 | //
62 | resources.ApplyResources(this.txOutListBox1, "txOutListBox1");
63 | this.txOutListBox1.Asset = null;
64 | this.txOutListBox1.Name = "txOutListBox1";
65 | this.txOutListBox1.ReadOnly = false;
66 | this.txOutListBox1.ScriptHash = null;
67 | this.txOutListBox1.ItemsChanged += new System.EventHandler(this.txOutListBox1_ItemsChanged);
68 | //
69 | // button4
70 | //
71 | resources.ApplyResources(this.button4, "button4");
72 | this.button4.DialogResult = System.Windows.Forms.DialogResult.Cancel;
73 | this.button4.Name = "button4";
74 | this.button4.UseVisualStyleBackColor = true;
75 | //
76 | // button3
77 | //
78 | resources.ApplyResources(this.button3, "button3");
79 | this.button3.DialogResult = System.Windows.Forms.DialogResult.OK;
80 | this.button3.Name = "button3";
81 | this.button3.UseVisualStyleBackColor = true;
82 | //
83 | // groupBox1
84 | //
85 | resources.ApplyResources(this.groupBox1, "groupBox1");
86 | this.groupBox1.Controls.Add(this.comboBoxFrom);
87 | this.groupBox1.Controls.Add(this.labelFrom);
88 | this.groupBox1.Name = "groupBox1";
89 | this.groupBox1.TabStop = false;
90 | //
91 | // comboBoxFrom
92 | //
93 | resources.ApplyResources(this.comboBoxFrom, "comboBoxFrom");
94 | this.comboBoxFrom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
95 | this.comboBoxFrom.FormattingEnabled = true;
96 | this.comboBoxFrom.Name = "comboBoxFrom";
97 | //
98 | // labelFrom
99 | //
100 | resources.ApplyResources(this.labelFrom, "labelFrom");
101 | this.labelFrom.Name = "labelFrom";
102 | //
103 | // TransferDialog
104 | //
105 | resources.ApplyResources(this, "$this");
106 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
107 | this.Controls.Add(this.groupBox1);
108 | this.Controls.Add(this.button4);
109 | this.Controls.Add(this.button3);
110 | this.Controls.Add(this.groupBox3);
111 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
112 | this.MaximizeBox = false;
113 | this.Name = "TransferDialog";
114 | this.ShowInTaskbar = false;
115 | this.groupBox3.ResumeLayout(false);
116 | this.groupBox1.ResumeLayout(false);
117 | this.groupBox1.PerformLayout();
118 | this.ResumeLayout(false);
119 |
120 | }
121 |
122 | #endregion
123 | private System.Windows.Forms.GroupBox groupBox3;
124 | private System.Windows.Forms.Button button4;
125 | private System.Windows.Forms.Button button3;
126 | private TxOutListBox txOutListBox1;
127 | private System.Windows.Forms.GroupBox groupBox1;
128 | private System.Windows.Forms.ComboBox comboBoxFrom;
129 | private System.Windows.Forms.Label labelFrom;
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/neo-gui/GUI/TransferDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Network.P2P.Payloads;
12 | using Neo.SmartContract;
13 | using Neo.Wallets;
14 | using System;
15 | using System.Linq;
16 | using System.Windows.Forms;
17 | using static Neo.Program;
18 |
19 | namespace Neo.GUI
20 | {
21 | public partial class TransferDialog : Form
22 | {
23 | public TransferDialog()
24 | {
25 | InitializeComponent();
26 | comboBoxFrom.Items.AddRange(Service.CurrentWallet.GetAccounts().Where(p => !p.WatchOnly).Select(p => p.Address).ToArray());
27 | }
28 |
29 | public Transaction GetTransaction()
30 | {
31 | TransferOutput[] outputs = txOutListBox1.Items.ToArray();
32 | UInt160 from = comboBoxFrom.SelectedItem is null ? null : ((string)comboBoxFrom.SelectedItem).ToScriptHash(Service.NeoSystem.Settings.AddressVersion);
33 | return Service.CurrentWallet.MakeTransaction(Service.NeoSystem.StoreView, outputs, from);
34 | }
35 |
36 | private void txOutListBox1_ItemsChanged(object sender, EventArgs e)
37 | {
38 | button3.Enabled = txOutListBox1.ItemCount > 0;
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/neo-gui/GUI/TxOutListBox.Designer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | namespace Neo.GUI
12 | {
13 | partial class TxOutListBox
14 | {
15 | ///
16 | /// 必需的设计器变量。
17 | ///
18 | private System.ComponentModel.IContainer components = null;
19 |
20 | ///
21 | /// 清理所有正在使用的资源。
22 | ///
23 | /// 如果应释放托管资源,为 true;否则为 false。
24 | protected override void Dispose(bool disposing)
25 | {
26 | if (disposing && (components != null))
27 | {
28 | components.Dispose();
29 | }
30 | base.Dispose(disposing);
31 | }
32 |
33 | #region 组件设计器生成的代码
34 |
35 | ///
36 | /// 设计器支持所需的方法 - 不要修改
37 | /// 使用代码编辑器修改此方法的内容。
38 | ///
39 | private void InitializeComponent()
40 | {
41 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TxOutListBox));
42 | this.listBox1 = new System.Windows.Forms.ListBox();
43 | this.panel1 = new System.Windows.Forms.Panel();
44 | this.button1 = new System.Windows.Forms.Button();
45 | this.button2 = new System.Windows.Forms.Button();
46 | this.button3 = new System.Windows.Forms.Button();
47 | this.panel1.SuspendLayout();
48 | this.SuspendLayout();
49 | //
50 | // listBox1
51 | //
52 | resources.ApplyResources(this.listBox1, "listBox1");
53 | this.listBox1.Name = "listBox1";
54 | this.listBox1.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
55 | this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
56 | //
57 | // panel1
58 | //
59 | resources.ApplyResources(this.panel1, "panel1");
60 | this.panel1.Controls.Add(this.button1);
61 | this.panel1.Controls.Add(this.button2);
62 | this.panel1.Controls.Add(this.button3);
63 | this.panel1.Name = "panel1";
64 | //
65 | // button1
66 | //
67 | resources.ApplyResources(this.button1, "button1");
68 | this.button1.Image = global::Neo.Properties.Resources.add;
69 | this.button1.Name = "button1";
70 | this.button1.UseVisualStyleBackColor = true;
71 | this.button1.Click += new System.EventHandler(this.button1_Click);
72 | //
73 | // button2
74 | //
75 | resources.ApplyResources(this.button2, "button2");
76 | this.button2.Image = global::Neo.Properties.Resources.remove;
77 | this.button2.Name = "button2";
78 | this.button2.UseVisualStyleBackColor = true;
79 | this.button2.Click += new System.EventHandler(this.button2_Click);
80 | //
81 | // button3
82 | //
83 | resources.ApplyResources(this.button3, "button3");
84 | this.button3.Image = global::Neo.Properties.Resources.add2;
85 | this.button3.Name = "button3";
86 | this.button3.UseVisualStyleBackColor = true;
87 | this.button3.Click += new System.EventHandler(this.button3_Click);
88 | //
89 | // TxOutListBox
90 | //
91 | resources.ApplyResources(this, "$this");
92 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
93 | this.Controls.Add(this.panel1);
94 | this.Controls.Add(this.listBox1);
95 | this.Name = "TxOutListBox";
96 | this.panel1.ResumeLayout(false);
97 | this.ResumeLayout(false);
98 |
99 | }
100 |
101 | #endregion
102 |
103 | private System.Windows.Forms.ListBox listBox1;
104 | private System.Windows.Forms.Panel panel1;
105 | private System.Windows.Forms.Button button1;
106 | private System.Windows.Forms.Button button2;
107 | private System.Windows.Forms.Button button3;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/neo-gui/GUI/TxOutListBox.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Wallets;
12 | using System;
13 | using System.Collections.Generic;
14 | using System.ComponentModel;
15 | using System.Linq;
16 | using System.Windows.Forms;
17 |
18 | namespace Neo.GUI
19 | {
20 | [DefaultEvent(nameof(ItemsChanged))]
21 | internal partial class TxOutListBox : UserControl
22 | {
23 | public event EventHandler ItemsChanged;
24 |
25 | public AssetDescriptor Asset { get; set; }
26 |
27 | public int ItemCount => listBox1.Items.Count;
28 |
29 | public IEnumerable Items => listBox1.Items.OfType();
30 |
31 | public bool ReadOnly
32 | {
33 | get
34 | {
35 | return !panel1.Enabled;
36 | }
37 | set
38 | {
39 | panel1.Enabled = !value;
40 | }
41 | }
42 |
43 | private UInt160 _script_hash = null;
44 | public UInt160 ScriptHash
45 | {
46 | get
47 | {
48 | return _script_hash;
49 | }
50 | set
51 | {
52 | _script_hash = value;
53 | button3.Enabled = value == null;
54 | }
55 | }
56 |
57 | public TxOutListBox()
58 | {
59 | InitializeComponent();
60 | }
61 |
62 | public void Clear()
63 | {
64 | if (listBox1.Items.Count > 0)
65 | {
66 | listBox1.Items.Clear();
67 | button2.Enabled = false;
68 | ItemsChanged?.Invoke(this, EventArgs.Empty);
69 | }
70 | }
71 |
72 | private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
73 | {
74 | button2.Enabled = listBox1.SelectedIndices.Count > 0;
75 | }
76 |
77 | private void button1_Click(object sender, EventArgs e)
78 | {
79 | using PayToDialog dialog = new PayToDialog(asset: Asset, scriptHash: ScriptHash);
80 | if (dialog.ShowDialog() != DialogResult.OK) return;
81 | listBox1.Items.Add(dialog.GetOutput());
82 | ItemsChanged?.Invoke(this, EventArgs.Empty);
83 | }
84 |
85 | private void button2_Click(object sender, EventArgs e)
86 | {
87 | while (listBox1.SelectedIndices.Count > 0)
88 | {
89 | listBox1.Items.RemoveAt(listBox1.SelectedIndices[0]);
90 | }
91 | ItemsChanged?.Invoke(this, EventArgs.Empty);
92 | }
93 |
94 | private void button3_Click(object sender, EventArgs e)
95 | {
96 | using BulkPayDialog dialog = new BulkPayDialog(Asset);
97 | if (dialog.ShowDialog() != DialogResult.OK) return;
98 | listBox1.Items.AddRange(dialog.GetOutputs());
99 | ItemsChanged?.Invoke(this, EventArgs.Empty);
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/neo-gui/GUI/TxOutListBoxItem.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Wallets;
12 |
13 | namespace Neo.GUI
14 | {
15 | internal class TxOutListBoxItem : TransferOutput
16 | {
17 | public string AssetName;
18 |
19 | public override string ToString()
20 | {
21 | return $"{ScriptHash.ToAddress(Program.Service.NeoSystem.Settings.AddressVersion)}\t{Value}\t{AssetName}";
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/neo-gui/GUI/UpdateDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Properties;
12 | using System;
13 | using System.Diagnostics;
14 | using System.IO;
15 | using System.IO.Compression;
16 | using System.Linq;
17 | using System.Net.Http;
18 | using System.Windows.Forms;
19 | using System.Xml.Linq;
20 |
21 | namespace Neo.GUI
22 | {
23 | internal partial class UpdateDialog : Form
24 | {
25 | private readonly HttpClient http = new();
26 | private readonly string download_url;
27 | private string download_path;
28 |
29 | public UpdateDialog(XDocument xdoc)
30 | {
31 | InitializeComponent();
32 | Version latest = Version.Parse(xdoc.Element("update").Attribute("latest").Value);
33 | textBox1.Text = latest.ToString();
34 | XElement release = xdoc.Element("update").Elements("release").First(p => p.Attribute("version").Value == latest.ToString());
35 | textBox2.Text = release.Element("changes").Value.Replace("\n", Environment.NewLine);
36 | download_url = release.Attribute("file").Value;
37 | }
38 |
39 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
40 | {
41 | Process.Start("https://neo.org/");
42 | }
43 |
44 | private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
45 | {
46 | Process.Start(download_url);
47 | }
48 |
49 | private async void button2_Click(object sender, EventArgs e)
50 | {
51 | button1.Enabled = false;
52 | button2.Enabled = false;
53 | download_path = "update.zip";
54 | using (Stream responseStream = await http.GetStreamAsync(download_url))
55 | using (FileStream fileStream = new(download_path, FileMode.Create, FileAccess.Write, FileShare.None))
56 | {
57 | await responseStream.CopyToAsync(fileStream);
58 | }
59 | DirectoryInfo di = new DirectoryInfo("update");
60 | if (di.Exists) di.Delete(true);
61 | di.Create();
62 | ZipFile.ExtractToDirectory(download_path, di.Name);
63 | FileSystemInfo[] fs = di.GetFileSystemInfos();
64 | if (fs.Length == 1 && fs[0] is DirectoryInfo directory)
65 | {
66 | directory.MoveTo("update2");
67 | di.Delete();
68 | Directory.Move("update2", di.Name);
69 | }
70 | File.WriteAllBytes("update.bat", Resources.UpdateBat);
71 | Close();
72 | if (Program.MainForm != null) Program.MainForm.Close();
73 | Process.Start("update.bat");
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/neo-gui/GUI/ViewContractDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.SmartContract;
12 | using System.Linq;
13 | using System.Windows.Forms;
14 | using Neo.Wallets;
15 |
16 | namespace Neo.GUI
17 | {
18 | public partial class ViewContractDialog : Form
19 | {
20 | public ViewContractDialog(Contract contract)
21 | {
22 | InitializeComponent();
23 | textBox1.Text = contract.ScriptHash.ToAddress(Program.Service.NeoSystem.Settings.AddressVersion);
24 | textBox2.Text = contract.ScriptHash.ToString();
25 | textBox3.Text = contract.ParameterList.Cast().ToArray().ToHexString();
26 | textBox4.Text = contract.Script.ToHexString();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/neo-gui/GUI/ViewPrivateKeyDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Wallets;
12 | using System.Windows.Forms;
13 |
14 | namespace Neo.GUI
15 | {
16 | internal partial class ViewPrivateKeyDialog : Form
17 | {
18 | public ViewPrivateKeyDialog(WalletAccount account)
19 | {
20 | InitializeComponent();
21 | KeyPair key = account.GetKey();
22 | textBox3.Text = account.Address;
23 | textBox4.Text = key.PublicKey.EncodePoint(true).ToHexString();
24 | textBox1.Text = key.PrivateKey.ToHexString();
25 | textBox2.Text = key.Export();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/neo-gui/GUI/VotingDialog.Designer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | namespace Neo.GUI
12 | {
13 | partial class VotingDialog
14 | {
15 | ///
16 | /// Required designer variable.
17 | ///
18 | private System.ComponentModel.IContainer components = null;
19 |
20 | ///
21 | /// Clean up any resources being used.
22 | ///
23 | /// true if managed resources should be disposed; otherwise, false.
24 | protected override void Dispose(bool disposing)
25 | {
26 | if (disposing && (components != null))
27 | {
28 | components.Dispose();
29 | }
30 | base.Dispose(disposing);
31 | }
32 |
33 | #region Windows Form Designer generated code
34 |
35 | ///
36 | /// Required method for Designer support - do not modify
37 | /// the contents of this method with the code editor.
38 | ///
39 | private void InitializeComponent()
40 | {
41 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VotingDialog));
42 | this.label1 = new System.Windows.Forms.Label();
43 | this.groupBox1 = new System.Windows.Forms.GroupBox();
44 | this.textBox1 = new System.Windows.Forms.TextBox();
45 | this.button1 = new System.Windows.Forms.Button();
46 | this.button2 = new System.Windows.Forms.Button();
47 | this.groupBox1.SuspendLayout();
48 | this.SuspendLayout();
49 | //
50 | // label1
51 | //
52 | resources.ApplyResources(this.label1, "label1");
53 | this.label1.Name = "label1";
54 | //
55 | // groupBox1
56 | //
57 | resources.ApplyResources(this.groupBox1, "groupBox1");
58 | this.groupBox1.Controls.Add(this.textBox1);
59 | this.groupBox1.Name = "groupBox1";
60 | this.groupBox1.TabStop = false;
61 | //
62 | // textBox1
63 | //
64 | resources.ApplyResources(this.textBox1, "textBox1");
65 | this.textBox1.AcceptsReturn = true;
66 | this.textBox1.Name = "textBox1";
67 | //
68 | // button1
69 | //
70 | resources.ApplyResources(this.button1, "button1");
71 | this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
72 | this.button1.Name = "button1";
73 | this.button1.UseVisualStyleBackColor = true;
74 | //
75 | // button2
76 | //
77 | resources.ApplyResources(this.button2, "button2");
78 | this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
79 | this.button2.Name = "button2";
80 | this.button2.UseVisualStyleBackColor = true;
81 | //
82 | // VotingDialog
83 | //
84 | resources.ApplyResources(this, "$this");
85 | this.AcceptButton = this.button1;
86 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
87 | this.CancelButton = this.button2;
88 | this.Controls.Add(this.button2);
89 | this.Controls.Add(this.button1);
90 | this.Controls.Add(this.groupBox1);
91 | this.Controls.Add(this.label1);
92 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
93 | this.MaximizeBox = false;
94 | this.MinimizeBox = false;
95 | this.Name = "VotingDialog";
96 | this.ShowInTaskbar = false;
97 | this.groupBox1.ResumeLayout(false);
98 | this.groupBox1.PerformLayout();
99 | this.ResumeLayout(false);
100 |
101 | }
102 |
103 | #endregion
104 |
105 | private System.Windows.Forms.Label label1;
106 | private System.Windows.Forms.GroupBox groupBox1;
107 | private System.Windows.Forms.Button button1;
108 | private System.Windows.Forms.Button button2;
109 | private System.Windows.Forms.TextBox textBox1;
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/neo-gui/GUI/VotingDialog.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Cryptography.ECC;
12 | using Neo.IO;
13 | using Neo.SmartContract;
14 | using Neo.SmartContract.Native;
15 | using Neo.VM;
16 | using Neo.Wallets;
17 | using System.Linq;
18 | using System.Windows.Forms;
19 |
20 | namespace Neo.GUI
21 | {
22 | internal partial class VotingDialog : Form
23 | {
24 | private readonly UInt160 script_hash;
25 |
26 | public byte[] GetScript()
27 | {
28 | ECPoint[] pubkeys = textBox1.Lines.Select(p => ECPoint.Parse(p, ECCurve.Secp256r1)).ToArray();
29 | using ScriptBuilder sb = new ScriptBuilder();
30 | sb.EmitDynamicCall(NativeContract.NEO.Hash, "vote", new ContractParameter
31 | {
32 | Type = ContractParameterType.Hash160,
33 | Value = script_hash
34 | }, new ContractParameter
35 | {
36 | Type = ContractParameterType.Array,
37 | Value = pubkeys.Select(p => new ContractParameter
38 | {
39 | Type = ContractParameterType.PublicKey,
40 | Value = p
41 | }).ToArray()
42 | });
43 | return sb.ToArray();
44 | }
45 |
46 | public VotingDialog(UInt160 script_hash)
47 | {
48 | InitializeComponent();
49 | this.script_hash = script_hash;
50 | label1.Text = script_hash.ToAddress(Program.Service.NeoSystem.Settings.AddressVersion);
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/neo-gui/GUI/Wrappers/HexConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System;
12 | using System.ComponentModel;
13 | using System.Globalization;
14 |
15 | namespace Neo.GUI.Wrappers
16 | {
17 | internal class HexConverter : TypeConverter
18 | {
19 | public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
20 | {
21 | if (sourceType == typeof(string))
22 | return true;
23 | return false;
24 | }
25 |
26 | public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
27 | {
28 | if (destinationType == typeof(string))
29 | return true;
30 | return false;
31 | }
32 |
33 | public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
34 | {
35 | if (value is string s)
36 | return s.HexToBytes();
37 | throw new NotSupportedException();
38 | }
39 |
40 | public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
41 | {
42 | if (destinationType != typeof(string))
43 | throw new NotSupportedException();
44 | if (!(value is byte[] array)) return null;
45 | return array.ToHexString();
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/neo-gui/GUI/Wrappers/ScriptEditor.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System;
12 | using System.ComponentModel;
13 | using System.IO;
14 | using System.Windows.Forms;
15 | using System.Windows.Forms.Design;
16 |
17 | namespace Neo.GUI.Wrappers
18 | {
19 | internal class ScriptEditor : FileNameEditor
20 | {
21 | public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
22 | {
23 | string path = (string)base.EditValue(context, provider, null);
24 | if (path == null) return null;
25 | return File.ReadAllBytes(path);
26 | }
27 |
28 | protected override void InitializeDialog(OpenFileDialog openFileDialog)
29 | {
30 | base.InitializeDialog(openFileDialog);
31 | openFileDialog.DefaultExt = "avm";
32 | openFileDialog.Filter = "NeoContract|*.avm";
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/neo-gui/GUI/Wrappers/SignerWrapper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Cryptography.ECC;
12 | using Neo.Network.P2P.Payloads;
13 | using System.Collections.Generic;
14 | using System.ComponentModel;
15 |
16 | namespace Neo.GUI.Wrappers
17 | {
18 | internal class SignerWrapper
19 | {
20 | [TypeConverter(typeof(UIntBaseConverter))]
21 | public UInt160 Account { get; set; }
22 | public WitnessScope Scopes { get; set; }
23 | public List AllowedContracts { get; set; } = new List();
24 | public List AllowedGroups { get; set; } = new List();
25 |
26 | public Signer Unwrap()
27 | {
28 | return new Signer
29 | {
30 | Account = Account,
31 | Scopes = Scopes,
32 | AllowedContracts = AllowedContracts.ToArray(),
33 | AllowedGroups = AllowedGroups.ToArray()
34 | };
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/neo-gui/GUI/Wrappers/TransactionAttributeWrapper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.IO;
12 | using Neo.Network.P2P.Payloads;
13 | using System.ComponentModel;
14 |
15 | namespace Neo.GUI.Wrappers
16 | {
17 | internal class TransactionAttributeWrapper
18 | {
19 | public TransactionAttributeType Usage { get; set; }
20 | [TypeConverter(typeof(HexConverter))]
21 | public byte[] Data { get; set; }
22 |
23 | public TransactionAttribute Unwrap()
24 | {
25 | MemoryReader reader = new(Data);
26 | return TransactionAttribute.DeserializeFrom(ref reader);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/neo-gui/GUI/Wrappers/TransactionWrapper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Network.P2P.Payloads;
12 | using System.Collections.Generic;
13 | using System.ComponentModel;
14 | using System.Drawing.Design;
15 | using System.Linq;
16 |
17 | namespace Neo.GUI.Wrappers
18 | {
19 | internal class TransactionWrapper
20 | {
21 | [Category("Basic")]
22 | public byte Version { get; set; }
23 | [Category("Basic")]
24 | public uint Nonce { get; set; }
25 | [Category("Basic")]
26 | public List Signers { get; set; }
27 | [Category("Basic")]
28 | public long SystemFee { get; set; }
29 | [Category("Basic")]
30 | public long NetworkFee { get; set; }
31 | [Category("Basic")]
32 | public uint ValidUntilBlock { get; set; }
33 | [Category("Basic")]
34 | public List Attributes { get; set; } = new List();
35 | [Category("Basic")]
36 | [Editor(typeof(ScriptEditor), typeof(UITypeEditor))]
37 | [TypeConverter(typeof(HexConverter))]
38 | public byte[] Script { get; set; }
39 | [Category("Basic")]
40 | public List Witnesses { get; set; } = new List();
41 |
42 | public Transaction Unwrap()
43 | {
44 | return new Transaction
45 | {
46 | Version = Version,
47 | Nonce = Nonce,
48 | Signers = Signers.Select(p => p.Unwrap()).ToArray(),
49 | SystemFee = SystemFee,
50 | NetworkFee = NetworkFee,
51 | ValidUntilBlock = ValidUntilBlock,
52 | Attributes = Attributes.Select(p => p.Unwrap()).ToArray(),
53 | Script = Script,
54 | Witnesses = Witnesses.Select(p => p.Unwrap()).ToArray()
55 | };
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/neo-gui/GUI/Wrappers/UIntBaseConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using System;
12 | using System.ComponentModel;
13 | using System.Globalization;
14 |
15 | namespace Neo.GUI.Wrappers
16 | {
17 | internal class UIntBaseConverter : TypeConverter
18 | {
19 | public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
20 | {
21 | if (sourceType == typeof(string))
22 | return true;
23 | return false;
24 | }
25 |
26 | public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
27 | {
28 | if (destinationType == typeof(string))
29 | return true;
30 | return false;
31 | }
32 |
33 | public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
34 | {
35 | if (value is string s)
36 | return context.PropertyDescriptor.PropertyType.GetMethod("Parse").Invoke(null, new[] { s });
37 | throw new NotSupportedException();
38 | }
39 |
40 | public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
41 | {
42 | if (destinationType != typeof(string))
43 | throw new NotSupportedException();
44 |
45 | return value switch
46 | {
47 | UInt160 i => i.ToString(),
48 | UInt256 i => i.ToString(),
49 | _ => null,
50 | };
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/neo-gui/GUI/Wrappers/WitnessWrapper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.Network.P2P.Payloads;
12 | using System.ComponentModel;
13 | using System.Drawing.Design;
14 |
15 | namespace Neo.GUI.Wrappers
16 | {
17 | internal class WitnessWrapper
18 | {
19 | [Editor(typeof(ScriptEditor), typeof(UITypeEditor))]
20 | [TypeConverter(typeof(HexConverter))]
21 | public byte[] InvocationScript { get; set; }
22 | [Editor(typeof(ScriptEditor), typeof(UITypeEditor))]
23 | [TypeConverter(typeof(HexConverter))]
24 | public byte[] VerificationScript { get; set; }
25 |
26 | public Witness Unwrap()
27 | {
28 | return new Witness
29 | {
30 | InvocationScript = InvocationScript,
31 | VerificationScript = VerificationScript
32 | };
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/neo-gui/IO/Actors/EventWrapper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Akka.Actor;
12 | using System;
13 |
14 | namespace Neo.IO.Actors
15 | {
16 | internal class EventWrapper : UntypedActor
17 | {
18 | private readonly Action callback;
19 |
20 | public EventWrapper(Action callback)
21 | {
22 | this.callback = callback;
23 | Context.System.EventStream.Subscribe(Self, typeof(T));
24 | }
25 |
26 | protected override void OnReceive(object message)
27 | {
28 | if (message is T obj) callback(obj);
29 | }
30 |
31 | protected override void PostStop()
32 | {
33 | Context.System.EventStream.Unsubscribe(Self);
34 | base.PostStop();
35 | }
36 |
37 | public static Props Props(Action callback)
38 | {
39 | return Akka.Actor.Props.Create(() => new EventWrapper(callback));
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/neo-gui/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | using Neo.CLI;
12 | using Neo.GUI;
13 | using Neo.SmartContract.Native;
14 | using System;
15 | using System.IO;
16 | using System.Reflection;
17 | using System.Windows.Forms;
18 | using System.Xml.Linq;
19 |
20 | namespace Neo
21 | {
22 | static class Program
23 | {
24 | public static MainService Service = new MainService();
25 | public static MainForm MainForm;
26 | public static UInt160[] NEP5Watched = { NativeContract.NEO.Hash, NativeContract.GAS.Hash };
27 |
28 | private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
29 | {
30 | using FileStream fs = new FileStream("error.log", FileMode.Create, FileAccess.Write, FileShare.None);
31 | using StreamWriter w = new StreamWriter(fs);
32 | if (e.ExceptionObject is Exception ex)
33 | {
34 | PrintErrorLogs(w, ex);
35 | }
36 | else
37 | {
38 | w.WriteLine(e.ExceptionObject.GetType());
39 | w.WriteLine(e.ExceptionObject);
40 | }
41 | }
42 |
43 | ///
44 | /// The main entry point for the application.
45 | ///
46 | [STAThread]
47 | static void Main(string[] args)
48 | {
49 | AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
50 | Application.SetHighDpiMode(HighDpiMode.SystemAware);
51 | Application.EnableVisualStyles();
52 | Application.SetCompatibleTextRenderingDefault(false);
53 | XDocument xdoc = null;
54 | try
55 | {
56 | xdoc = XDocument.Load("https://raw.githubusercontent.com/neo-project/neo-gui/master/update.xml");
57 | }
58 | catch { }
59 | if (xdoc != null)
60 | {
61 | Version version = Assembly.GetExecutingAssembly().GetName().Version;
62 | Version minimum = Version.Parse(xdoc.Element("update").Attribute("minimum").Value);
63 | if (version < minimum)
64 | {
65 | using UpdateDialog dialog = new UpdateDialog(xdoc);
66 | dialog.ShowDialog();
67 | return;
68 | }
69 | }
70 | Service.Start(args);
71 | Application.Run(MainForm = new MainForm(xdoc));
72 | Service.Stop();
73 | }
74 |
75 | private static void PrintErrorLogs(StreamWriter writer, Exception ex)
76 | {
77 | writer.WriteLine(ex.GetType());
78 | writer.WriteLine(ex.Message);
79 | writer.WriteLine(ex.StackTrace);
80 | if (ex is AggregateException ex2)
81 | {
82 | foreach (Exception inner in ex2.InnerExceptions)
83 | {
84 | writer.WriteLine();
85 | PrintErrorLogs(writer, inner);
86 | }
87 | }
88 | else if (ex.InnerException != null)
89 | {
90 | writer.WriteLine();
91 | PrintErrorLogs(writer, ex.InnerException);
92 | }
93 | }
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/neo-gui/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2016-2023 The Neo Project.
2 | //
3 | // The neo-gui is free software distributed under the MIT software
4 | // license, see the accompanying file LICENSE in the main directory of
5 | // the project or http://www.opensource.org/licenses/mit-license.php
6 | // for more details.
7 | //
8 | // Redistribution and use in source and binary forms with or without
9 | // modifications are permitted.
10 |
11 | //------------------------------------------------------------------------------
12 | //
13 | // 此代码由工具生成。
14 | // 运行时版本:4.0.30319.42000
15 | //
16 | // 对此文件的更改可能会导致不正确的行为,并且如果
17 | // 重新生成代码,这些更改将会丢失。
18 | //
19 | //------------------------------------------------------------------------------
20 |
21 | namespace Neo.Properties {
22 | using System;
23 |
24 |
25 | ///
26 | /// 一个强类型的资源类,用于查找本地化的字符串等。
27 | ///
28 | // 此类是由 StronglyTypedResourceBuilder
29 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
30 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
31 | // (以 /str 作为命令选项),或重新生成 VS 项目。
32 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
33 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
34 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
35 | internal class Resources {
36 |
37 | private static global::System.Resources.ResourceManager resourceMan;
38 |
39 | private static global::System.Globalization.CultureInfo resourceCulture;
40 |
41 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
42 | internal Resources() {
43 | }
44 |
45 | ///
46 | /// 返回此类使用的缓存的 ResourceManager 实例。
47 | ///
48 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
49 | internal static global::System.Resources.ResourceManager ResourceManager {
50 | get {
51 | if (object.ReferenceEquals(resourceMan, null)) {
52 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Neo.Properties.Resources", typeof(Resources).Assembly);
53 | resourceMan = temp;
54 | }
55 | return resourceMan;
56 | }
57 | }
58 |
59 | ///
60 | /// 重写当前线程的 CurrentUICulture 属性
61 | /// 重写当前线程的 CurrentUICulture 属性。
62 | ///
63 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
64 | internal static global::System.Globalization.CultureInfo Culture {
65 | get {
66 | return resourceCulture;
67 | }
68 | set {
69 | resourceCulture = value;
70 | }
71 | }
72 |
73 | ///
74 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
75 | ///
76 | internal static System.Drawing.Bitmap add {
77 | get {
78 | object obj = ResourceManager.GetObject("add", resourceCulture);
79 | return ((System.Drawing.Bitmap)(obj));
80 | }
81 | }
82 |
83 | ///
84 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
85 | ///
86 | internal static System.Drawing.Bitmap add2 {
87 | get {
88 | object obj = ResourceManager.GetObject("add2", resourceCulture);
89 | return ((System.Drawing.Bitmap)(obj));
90 | }
91 | }
92 |
93 | ///
94 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
95 | ///
96 | internal static System.Drawing.Bitmap remark {
97 | get {
98 | object obj = ResourceManager.GetObject("remark", resourceCulture);
99 | return ((System.Drawing.Bitmap)(obj));
100 | }
101 | }
102 |
103 | ///
104 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
105 | ///
106 | internal static System.Drawing.Bitmap remove {
107 | get {
108 | object obj = ResourceManager.GetObject("remove", resourceCulture);
109 | return ((System.Drawing.Bitmap)(obj));
110 | }
111 | }
112 |
113 | ///
114 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
115 | ///
116 | internal static System.Drawing.Bitmap search {
117 | get {
118 | object obj = ResourceManager.GetObject("search", resourceCulture);
119 | return ((System.Drawing.Bitmap)(obj));
120 | }
121 | }
122 |
123 | ///
124 | /// 查找 System.Byte[] 类型的本地化资源。
125 | ///
126 | internal static byte[] UpdateBat {
127 | get {
128 | object obj = ResourceManager.GetObject("UpdateBat", resourceCulture);
129 | return ((byte[])(obj));
130 | }
131 | }
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/neo-gui/Resources/add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo-project/neo-node/4e7fecce249e31ee06eb46366cca9dd2e76150bc/neo-gui/Resources/add.png
--------------------------------------------------------------------------------
/neo-gui/Resources/add2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo-project/neo-node/4e7fecce249e31ee06eb46366cca9dd2e76150bc/neo-gui/Resources/add2.png
--------------------------------------------------------------------------------
/neo-gui/Resources/remark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo-project/neo-node/4e7fecce249e31ee06eb46366cca9dd2e76150bc/neo-gui/Resources/remark.png
--------------------------------------------------------------------------------
/neo-gui/Resources/remove.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo-project/neo-node/4e7fecce249e31ee06eb46366cca9dd2e76150bc/neo-gui/Resources/remove.png
--------------------------------------------------------------------------------
/neo-gui/Resources/search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo-project/neo-node/4e7fecce249e31ee06eb46366cca9dd2e76150bc/neo-gui/Resources/search.png
--------------------------------------------------------------------------------
/neo-gui/Resources/update.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | set "taskname=neo-gui.exe"
3 | echo waiting...
4 | :wait
5 | ping 127.0.1 -n 3 >nul
6 | tasklist | find "%taskname%" /i >nul 2>nul
7 | if "%errorlevel%" NEQ "1" goto wait
8 | echo updating...
9 | copy /Y update\* *
10 | rmdir /S /Q update
11 | del /F /Q update.zip
12 | start %taskname%
13 | del /F /Q update.bat
14 |
--------------------------------------------------------------------------------
/neo-gui/neo-gui.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 2016-2023 The Neo Project
5 | Neo.GUI
6 | 3.6.2
7 | The Neo Project
8 | WinExe
9 | net7.0-windows
10 | true
11 | Neo
12 | true
13 | The Neo Project
14 | Neo.GUI
15 | Neo.GUI
16 | neo.ico
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | DeveloperToolsForm.cs
30 |
31 |
32 | DeveloperToolsForm.cs
33 |
34 |
35 | True
36 | True
37 | Resources.resx
38 |
39 |
40 | True
41 | True
42 | Strings.resx
43 |
44 |
45 |
46 |
47 |
48 | ResXFileCodeGenerator
49 | Resources.Designer.cs
50 |
51 |
52 | ResXFileCodeGenerator
53 | Strings.Designer.cs
54 |
55 |
56 | Strings.resx
57 |
58 |
59 | Strings.resx
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/neo-gui/neo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/neo-project/neo-node/4e7fecce249e31ee06eb46366cca9dd2e76150bc/neo-gui/neo.ico
--------------------------------------------------------------------------------
/neo-node.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29519.87
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "neo-cli", "neo-cli\neo-cli.csproj", "{900CA179-AEF0-43F3-9833-5DB060272D8E}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "neo-gui", "neo-gui\neo-gui.csproj", "{1CF672B6-B5A1-47D2-8CE9-C54BC05FA6E7}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.ConsoleService.Tests", "tests\Neo.ConsoleService.Tests\Neo.ConsoleService.Tests.csproj", "{CC845558-D7C2-412D-8014-15699DFBA530}"
11 | EndProject
12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Neo.ConsoleService", "Neo.ConsoleService\Neo.ConsoleService.csproj", "{8D2BC669-11AC-42DB-BE75-FD53FA2475C6}"
13 | EndProject
14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{62F4DC79-BE3D-4E60-B402-8D5F9C4BB2D9}"
15 | EndProject
16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{705EBADA-05F7-45D1-9D63-D399E87525DB}"
17 | EndProject
18 | Global
19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
20 | Debug|Any CPU = Debug|Any CPU
21 | Release|Any CPU = Release|Any CPU
22 | EndGlobalSection
23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
24 | {900CA179-AEF0-43F3-9833-5DB060272D8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {900CA179-AEF0-43F3-9833-5DB060272D8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {900CA179-AEF0-43F3-9833-5DB060272D8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {900CA179-AEF0-43F3-9833-5DB060272D8E}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {1CF672B6-B5A1-47D2-8CE9-C54BC05FA6E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {1CF672B6-B5A1-47D2-8CE9-C54BC05FA6E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {1CF672B6-B5A1-47D2-8CE9-C54BC05FA6E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {1CF672B6-B5A1-47D2-8CE9-C54BC05FA6E7}.Release|Any CPU.Build.0 = Release|Any CPU
32 | {CC845558-D7C2-412D-8014-15699DFBA530}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {CC845558-D7C2-412D-8014-15699DFBA530}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {CC845558-D7C2-412D-8014-15699DFBA530}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {CC845558-D7C2-412D-8014-15699DFBA530}.Release|Any CPU.Build.0 = Release|Any CPU
36 | {8D2BC669-11AC-42DB-BE75-FD53FA2475C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
37 | {8D2BC669-11AC-42DB-BE75-FD53FA2475C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
38 | {8D2BC669-11AC-42DB-BE75-FD53FA2475C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
39 | {8D2BC669-11AC-42DB-BE75-FD53FA2475C6}.Release|Any CPU.Build.0 = Release|Any CPU
40 | EndGlobalSection
41 | GlobalSection(SolutionProperties) = preSolution
42 | HideSolutionNode = FALSE
43 | EndGlobalSection
44 | GlobalSection(NestedProjects) = preSolution
45 | {900CA179-AEF0-43F3-9833-5DB060272D8E} = {705EBADA-05F7-45D1-9D63-D399E87525DB}
46 | {1CF672B6-B5A1-47D2-8CE9-C54BC05FA6E7} = {705EBADA-05F7-45D1-9D63-D399E87525DB}
47 | {CC845558-D7C2-412D-8014-15699DFBA530} = {62F4DC79-BE3D-4E60-B402-8D5F9C4BB2D9}
48 | {8D2BC669-11AC-42DB-BE75-FD53FA2475C6} = {705EBADA-05F7-45D1-9D63-D399E87525DB}
49 | EndGlobalSection
50 | GlobalSection(ExtensibilityGlobals) = postSolution
51 | SolutionGuid = {6C1293A1-8EC4-44E8-9EE9-67892696FE26}
52 | EndGlobalSection
53 | EndGlobal
54 |
--------------------------------------------------------------------------------
/tests/Neo.ConsoleService.Tests/CommandTokenTest.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using System.Linq;
3 |
4 | namespace Neo.ConsoleService.Tests
5 | {
6 | [TestClass]
7 | public class CommandTokenTest
8 | {
9 | [TestMethod]
10 | public void Test1()
11 | {
12 | var cmd = " ";
13 | var args = CommandToken.Parse(cmd).ToArray();
14 |
15 | AreEqual(args, new CommandSpaceToken(0, 1));
16 | Assert.AreEqual(cmd, CommandToken.ToString(args));
17 | }
18 |
19 | [TestMethod]
20 | public void Test2()
21 | {
22 | var cmd = "show state";
23 | var args = CommandToken.Parse(cmd).ToArray();
24 |
25 | AreEqual(args, new CommandStringToken(0, "show"), new CommandSpaceToken(4, 2), new CommandStringToken(6, "state"));
26 | Assert.AreEqual(cmd, CommandToken.ToString(args));
27 | }
28 |
29 | [TestMethod]
30 | public void Test3()
31 | {
32 | var cmd = "show \"hello world\"";
33 | var args = CommandToken.Parse(cmd).ToArray();
34 |
35 | AreEqual(args,
36 | new CommandStringToken(0, "show"),
37 | new CommandSpaceToken(4, 1),
38 | new CommandQuoteToken(5, '"'),
39 | new CommandStringToken(6, "hello world"),
40 | new CommandQuoteToken(17, '"')
41 | );
42 | Assert.AreEqual(cmd, CommandToken.ToString(args));
43 | }
44 |
45 | [TestMethod]
46 | public void Test4()
47 | {
48 | var cmd = "show \"'\"";
49 | var args = CommandToken.Parse(cmd).ToArray();
50 |
51 | AreEqual(args,
52 | new CommandStringToken(0, "show"),
53 | new CommandSpaceToken(4, 1),
54 | new CommandQuoteToken(5, '"'),
55 | new CommandStringToken(6, "'"),
56 | new CommandQuoteToken(7, '"')
57 | );
58 | Assert.AreEqual(cmd, CommandToken.ToString(args));
59 | }
60 |
61 | [TestMethod]
62 | public void Test5()
63 | {
64 | var cmd = "show \"123\\\"456\"";
65 | var args = CommandToken.Parse(cmd).ToArray();
66 |
67 | AreEqual(args,
68 | new CommandStringToken(0, "show"),
69 | new CommandSpaceToken(4, 1),
70 | new CommandQuoteToken(5, '"'),
71 | new CommandStringToken(6, "123\\\"456"),
72 | new CommandQuoteToken(14, '"')
73 | );
74 | Assert.AreEqual(cmd, CommandToken.ToString(args));
75 | }
76 |
77 | private void AreEqual(CommandToken[] args, params CommandToken[] compare)
78 | {
79 | Assert.AreEqual(compare.Length, args.Length);
80 |
81 | for (int x = 0; x < args.Length; x++)
82 | {
83 | var a = args[x];
84 | var b = compare[x];
85 |
86 | Assert.AreEqual(a.Type, b.Type);
87 | Assert.AreEqual(a.Value, b.Value);
88 | Assert.AreEqual(a.Offset, b.Offset);
89 | }
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/tests/Neo.ConsoleService.Tests/Neo.ConsoleService.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | neo_cli.Tests
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------