Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Add delete address command #817

Merged
merged 4 commits into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion neo-cli/CLI/MainService.Contracts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void OnUpdateCommand(UInt160 scriptHash, string filePath, string manifes
Signer[] signers = Array.Empty<Signer>();

if (NoWallet()) return;
if (!NoWallet() && sender != null)
if (sender != null)
{
if (signerAccounts == null)
signerAccounts = new UInt160[1] { sender };
Expand Down
24 changes: 4 additions & 20 deletions neo-cli/CLI/MainService.Vote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ private void OnRegisterCandidateCommand(UInt160 account)
{
var testGas = NativeContract.NEO.GetRegisterPrice(NeoSystem.StoreView) + (BigInteger)Math.Pow(10, NativeContract.GAS.Decimals) * 10;

if (NoWallet())
{
Console.WriteLine("Need open wallet!");
return;
}
if (NoWallet()) return;

WalletAccount currentAccount = CurrentWallet.GetAccount(account);

Expand Down Expand Up @@ -73,11 +69,7 @@ private void OnRegisterCandidateCommand(UInt160 account)
[ConsoleCommand("unregister candidate", Category = "Vote Commands")]
private void OnUnregisterCandidateCommand(UInt160 account)
{
if (NoWallet())
{
Console.WriteLine("Need open wallet!");
return;
}
if (NoWallet()) return;

WalletAccount currentAccount = CurrentWallet.GetAccount(account);

Expand Down Expand Up @@ -114,11 +106,7 @@ private void OnUnregisterCandidateCommand(UInt160 account)
[ConsoleCommand("vote", Category = "Vote Commands")]
private void OnVoteCommand(UInt160 senderAccount, ECPoint publicKey)
{
if (NoWallet())
{
Console.WriteLine("Need open wallet!");
return;
}
if (NoWallet()) return;

byte[] script;
using (ScriptBuilder scriptBuilder = new ScriptBuilder())
Expand All @@ -137,11 +125,7 @@ private void OnVoteCommand(UInt160 senderAccount, ECPoint publicKey)
[ConsoleCommand("unvote", Category = "Vote Commands")]
private void OnUnvoteCommand(UInt160 senderAccount)
{
if (NoWallet())
{
Console.WriteLine("Need open wallet!");
return;
}
if (NoWallet()) return;

byte[] script;
using (ScriptBuilder scriptBuilder = new ScriptBuilder())
Expand Down
26 changes: 26 additions & 0 deletions neo-cli/CLI/MainService.Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,32 @@ private void OnCreateAddressCommand(ushort count = 1)
File.WriteAllLines(path, addresses);
}

/// <summary>
/// Process "delete address" command
/// </summary>
/// <param name="address">Address</param>
[ConsoleCommand("delete address", Category = "Wallet Commands")]
superboyiii marked this conversation as resolved.
Show resolved Hide resolved
private void OnDeleteAddressCommand(UInt160 address)
{
if (NoWallet()) return;

if (ReadUserInput($"Warning: Irrevocable operation!\nAre you sure to delete account {address.ToAddress(NeoSystem.Settings.AddressVersion)}? (no|yes)").IsYes())
{
if (CurrentWallet.DeleteAccount(address))
{
if (CurrentWallet is NEP6Wallet wallet)
{
wallet.Save();
}
Console.WriteLine($"Address {address} deleted.");
}
else
{
Console.WriteLine($"Address {address} doesn't exist.");
}
}
}

/// <summary>
/// Process "export key" command
/// </summary>
Expand Down