Skip to content

Commit

Permalink
Add CheckWitness to func invokefunction (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiao-Jin authored Apr 13, 2020
1 parent 01948ba commit 12dcef0
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/RpcServer/RpcServer.SmartContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,20 @@ private JObject InvokeFunction(JArray _params)
UInt160 script_hash = UInt160.Parse(_params[0].AsString());
string operation = _params[1].AsString();
ContractParameter[] args = _params.Count >= 3 ? ((JArray)_params[2]).Select(p => ContractParameter.FromJson(p)).ToArray() : new ContractParameter[0];
CheckWitnessHashes checkWitnessHashes = _params.Count >= 4 ? new CheckWitnessHashes(((JArray)_params[3]).Select(u => UInt160.Parse(u.AsString())).ToArray()) : null;
byte[] script;
using (ScriptBuilder sb = new ScriptBuilder())
{
script = sb.EmitAppCall(script_hash, operation, args).ToArray();
}
return GetInvokeResult(script);
return GetInvokeResult(script, checkWitnessHashes);
}

[RpcMethod]
private JObject InvokeScript(JArray _params)
{
byte[] script = _params[0].AsString().HexToBytes();
CheckWitnessHashes checkWitnessHashes = null;
if (_params.Count > 1)
{
UInt160[] scriptHashesForVerifying = _params.Skip(1).Select(u => UInt160.Parse(u.AsString())).ToArray();
checkWitnessHashes = new CheckWitnessHashes(scriptHashesForVerifying);
}
CheckWitnessHashes checkWitnessHashes = _params.Count >= 2 ? new CheckWitnessHashes(((JArray)_params[1]).Select(u => UInt160.Parse(u.AsString())).ToArray()) : null;
return GetInvokeResult(script, checkWitnessHashes);
}
}
Expand Down

0 comments on commit 12dcef0

Please sign in to comment.