Skip to content

Commit

Permalink
Add pending signature to ProcessInvokeWithWallet (#490)
Browse files Browse the repository at this point in the history
* Add pending signature

* Optimize

* Remove if
  • Loading branch information
shargon authored Jan 29, 2021
1 parent 18acf01 commit dc1ea40
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions src/RpcServer/RpcServer.Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,32 +169,33 @@ protected virtual JObject OpenWallet(JArray _params)

private void ProcessInvokeWithWallet(JObject result, Signers signers = null)
{
Transaction tx = null;
if (wallet != null && signers != null)
if (wallet == null || signers == null) return;

Signer[] witnessSigners = signers.GetSigners().ToArray();
UInt160 sender = signers.Size > 0 ? signers.GetSigners()[0].Account : null;
if (witnessSigners.Length <= 0) return;

Transaction tx;
try
{
Signer[] witnessSigners = signers.GetSigners().ToArray();
UInt160 sender = signers.Size > 0 ? signers.GetSigners()[0].Account : null;
if (witnessSigners.Count() > 0)
{
try
{
tx = wallet.MakeTransaction(Convert.FromBase64String(result["script"].AsString()), sender, witnessSigners);
}
catch (Exception e)
{
result["exception"] = GetExceptionMessage(e);
return;
}
ContractParametersContext context = new ContractParametersContext(tx);
wallet.Sign(context);
if (context.Completed)
tx.Witnesses = context.GetWitnesses();
else
tx = null;
}
tx = wallet.MakeTransaction(Convert.FromBase64String(result["script"].AsString()), sender, witnessSigners);
}
catch (Exception e)
{
result["exception"] = GetExceptionMessage(e);
return;
}
if (tx != null)
ContractParametersContext context = new ContractParametersContext(tx);
wallet.Sign(context);
if (context.Completed)
{
tx.Witnesses = context.GetWitnesses();
result["tx"] = Convert.ToBase64String(tx.ToArray());
}
else
{
result["pendingsignature"] = context.ToJson();
}
}

[RpcMethod]
Expand Down

0 comments on commit dc1ea40

Please sign in to comment.