Skip to content

Commit

Permalink
Change if
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon authored Feb 26, 2020
1 parent 6822adb commit b960338
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions src/neo/Wallets/Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,31 +383,34 @@ public bool Sign(ContractParametersContext context)
{
WalletAccount account = GetAccount(scriptHash);
if (account is null) continue;
if (account.HasKey)

// Try to sign self-contained multiSig

Contract multiSigContract = account.Contract;

if (multiSigContract != null &&
multiSigContract.Script.IsMultiSigContract(out int m, out ECPoint[] points))
{
KeyPair key = account.GetKey();
byte[] signature = context.Verifiable.Sign(key);
fSuccess |= context.AddSignature(account.Contract, key.PublicKey, signature);
foreach (var point in points)
{
account = GetAccount(point);
if (account?.HasKey != true) continue;
KeyPair key = account.GetKey();
byte[] signature = context.Verifiable.Sign(key);
fSuccess |= context.AddSignature(multiSigContract, key.PublicKey, signature);
if (fSuccess) m--;
if (context.Completed || m <= 0) break;
}
}
else
{
// Try to sign self-contained multiSig

Contract multiSigContract = account.Contract;
// Try to sign with regular accounts

if (multiSigContract != null &&
multiSigContract.Script.IsMultiSigContract(out int m, out ECPoint[] points))
if (account.HasKey)
{
foreach (var point in points)
{
account = GetAccount(point);
if (account?.HasKey != true) continue;
KeyPair key = account.GetKey();
byte[] signature = context.Verifiable.Sign(key);
fSuccess |= context.AddSignature(multiSigContract, key.PublicKey, signature);
if (fSuccess) m--;
if (context.Completed || m <= 0) break;
}
KeyPair key = account.GetKey();
byte[] signature = context.Verifiable.Sign(key);
fSuccess |= context.AddSignature(account.Contract, key.PublicKey, signature);
}
}
}
Expand Down

0 comments on commit b960338

Please sign in to comment.