Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update oracleservice wallet #473

Merged
merged 7 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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 src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI01159" />
<PackageReference Include="Neo" Version="3.0.0-CI01161" />
</ItemGroup>

</Project>
24 changes: 9 additions & 15 deletions src/OracleService/OracleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Neo.Network.P2P.Payloads;
using Neo.Persistence;
using Neo.SmartContract;
using Neo.SmartContract.Manifest;
using Neo.SmartContract.Native;
using Neo.VM;
using Neo.Wallets;
Expand All @@ -32,7 +33,7 @@ public class OracleService : Plugin, IPersistencePlugin
{
private const int RefreshInterval = 1000 * 60 * 3;

private NEP6Wallet wallet;
private Wallet wallet;
private readonly ConcurrentDictionary<ulong, OracleTask> pendingQueue = new ConcurrentDictionary<ulong, OracleTask>();
private readonly ConcurrentDictionary<ulong, DateTime> finishedCache = new ConcurrentDictionary<ulong, DateTime>();
private Timer timer;
Expand Down Expand Up @@ -73,24 +74,16 @@ public override void Dispose()
private void OnStart()
{
if (started) return;
string password = GetService<ConsoleServiceBase>().ReadUserInput("password", true);
if (password.Length == 0)
{
Console.WriteLine("Cancelled");
return;
}

wallet = new NEP6Wallet(Settings.Default.Wallet);
try
var walletProvider = GetService<IWalletProvider>();
if (walletProvider is null)
{
wallet.Unlock(password);
}
catch (System.Security.Cryptography.CryptographicException)
{
Console.WriteLine($"Failed to open wallet");
Console.WriteLine("Please open wallet first!");
return;
}

wallet = walletProvider.GetWallet();

using (var snapshot = Blockchain.Singleton.GetSnapshot())
{
if (!CheckOracleAvaiblable(snapshot, out ECPoint[] oracles)) throw new ArgumentException("The oracle service is unavailable");
Expand Down Expand Up @@ -341,7 +334,8 @@ public static Transaction CreateResponseTx(StoreView snapshot, OracleRequest req

var oracleContract = NativeContract.ContractManagement.GetContract(snapshot, NativeContract.Oracle.Hash);
var engine = ApplicationEngine.Create(TriggerType.Verification, tx, snapshot.Clone());
engine.LoadContract(oracleContract, "verify", CallFlags.None, true);
ContractMethodDescriptor md = oracleContract.Manifest.Abi.GetMethod("verify", -1);
engine.LoadContract(oracleContract, md, CallFlags.None);
engine.Push("verify");
if (engine.Execute() != VMState.HALT) return null;
tx.NetworkFee += engine.GasConsumed;
Expand Down