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

Fix invoke command #613

Merged
merged 8 commits into from
Jul 9, 2020
Merged
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
27 changes: 3 additions & 24 deletions neo-cli/CLI/MainService.Contracts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,35 +51,14 @@ private void OnDeployCommand(string filePath, string manifestPath = null)
[ConsoleCommand("invoke", Category = "Contract Commands")]
private void OnInvokeCommand(UInt160 scriptHash, string operation, JArray contractParameters = null, UInt160[] witnessAddress = null)
{
List<Cosigner> signCollection = new List<Cosigner>();

Cosigner[] cosigners = Array.Empty<Cosigner>();
if (witnessAddress != null && !NoWallet())
{
using (SnapshotView snapshot = Blockchain.Singleton.GetSnapshot())
{
UInt160[] accounts = CurrentWallet.GetAccounts().Where(p => !p.Lock && !p.WatchOnly).Select(p => p.ScriptHash).Where(p => NativeContract.GAS.BalanceOf(snapshot, p).Sign > 0).ToArray();
foreach (var signAccount in accounts)
{
if (witnessAddress is null)
{
break;
}
foreach (var witness in witnessAddress)
{
if (witness.Equals(signAccount))
{
signCollection.Add(new Cosigner() { Account = signAccount });
break;
}
}
}
}
}
cosigners = CurrentWallet.GetAccounts().Where(p => !p.Lock && !p.WatchOnly && witnessAddress.Contains(p.ScriptHash)).Select(p => new Cosigner() { Account = p.ScriptHash, Scopes = WitnessScope.CalledByEntry }).ToArray();

Transaction tx = new Transaction
{
Sender = UInt160.Zero,
Attributes = signCollection.ToArray(),
Attributes = cosigners,
Witnesses = Array.Empty<Witness>(),
};

Expand Down