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

CI00151 #111

Merged
merged 5 commits into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion ApplicationLogs/ApplicationLogs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00044" />
<PackageReference Include="Neo" Version="3.0.0-CI00151" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions ApplicationLogs/LogReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void OnPersist(Snapshot snapshot, IReadOnlyList<Blockchain.ApplicationExe
foreach (var appExec in applicationExecutedList)
{
JObject json = new JObject();
json["txid"] = appExec.Transaction.Hash.ToString();
json["txid"] = appExec.Transaction?.Hash.ToString();
shargon marked this conversation as resolved.
Show resolved Hide resolved
json["trigger"] = appExec.Trigger;
json["vmstate"] = appExec.VMState;
json["gas_consumed"] = appExec.GasConsumed.ToString();
Expand All @@ -78,7 +78,7 @@ public void OnPersist(Snapshot snapshot, IReadOnlyList<Blockchain.ApplicationExe
}
return notification;
}).ToArray();
writeBatch.Put(appExec.Transaction.Hash.ToArray(), json.ToString());
writeBatch.Put((appExec.Transaction?.Hash ?? snapshot.PersistingBlock.Hash).ToArray(), json.ToString());
}
db.Write(WriteOptions.Default, writeBatch);
}
Expand Down
2 changes: 1 addition & 1 deletion CoreMetrics/CoreMetrics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00122" />
<PackageReference Include="Neo" Version="3.0.0-CI00151" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion ImportBlocks/ImportBlocks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00044" />
<PackageReference Include="Neo" Version="3.0.0-CI00151" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion RpcNep5Tracker/RpcNep5Tracker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00122" />
<PackageReference Include="Neo" Version="3.0.0-CI00151" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion RpcSecurity/RpcSecurity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00044" />
<PackageReference Include="Neo" Version="3.0.0-CI00151" />
</ItemGroup>

</Project>
50 changes: 13 additions & 37 deletions RpcWallet/RpcWallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ public JObject OnProcess(HttpContext context, string method, JArray _params)
{
return GetUnclaimedGas();
}
case "getwalletheight":
{
return GetWalletHeight();
}
case "importprivkey":
{
string privkey = _params[0].AsString();
Expand All @@ -70,8 +66,7 @@ public JObject OnProcess(HttpContext context, string method, JArray _params)
UInt160 from = _params[1].AsString().ToScriptHash();
UInt160 to = _params[2].AsString().ToScriptHash();
string value = _params[3].AsString();
long fee = _params.Count >= 5 ? long.Parse(_params[4].AsString()) : 0;
return SendFrom(assetId, from, to, value, fee);
return SendFrom(assetId, from, to, value);
}
case "sendmany":
{
Expand All @@ -82,17 +77,15 @@ public JObject OnProcess(HttpContext context, string method, JArray _params)
from = _params[0].AsString().ToScriptHash();
to_start = 1;
}
JArray to = (JArray)_params[to_start + 0];
long fee = _params.Count >= to_start + 2 ? long.Parse(_params[to_start + 1].AsString()) : 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to attach ScopedSignatures, but maybe in other pull request

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do in another PR, scoped was not merged, right?

return SendMany(from, to, fee);
JArray to = (JArray)_params[to_start];
return SendMany(from, to);
}
case "sendtoaddress":
{
UInt160 assetId = UInt160.Parse(_params[0].AsString());
UInt160 scriptHash = _params[1].AsString().ToScriptHash();
string value = _params[2].AsString();
long fee = _params.Count >= 4 ? long.Parse(_params[3].AsString()) : 0;
return SendToAddress(assetId, scriptHash, value, fee);
return SendToAddress(assetId, scriptHash, value);
}
default:
return null;
Expand All @@ -115,11 +108,7 @@ private void ProcessInvoke(JObject result)
{
if (Wallet != null)
{
Transaction tx = new Transaction
{
Script = result["script"].AsString().HexToBytes()
};
Wallet.FillTransaction(tx);
Transaction tx = Wallet.MakeTransaction(result["script"].AsString().HexToBytes());
ContractParametersContext context = new ContractParametersContext(tx);
Wallet.Sign(context);
if (context.Completed)
Expand All @@ -143,7 +132,6 @@ private JObject SignAndRelay(Transaction tx)
if (context.Completed)
{
tx.Witnesses = context.GetWitnesses();
Wallet.ApplyTransaction(tx);
System.LocalNode.Tell(new LocalNode.Relay { Inventory = tx });
return tx.ToJson();
}
Expand Down Expand Up @@ -189,12 +177,6 @@ private JObject GetUnclaimedGas()
return gas.ToString();
}

private JObject GetWalletHeight()
{
CheckWallet();
return (Wallet.WalletHeight > 0) ? Wallet.WalletHeight - 1 : 0;
}

private JObject ImportPrivKey(string privkey)
{
CheckWallet();
Expand Down Expand Up @@ -224,24 +206,22 @@ private JObject ListAddress()
}).ToArray();
}

private JObject SendFrom(UInt160 assetId, UInt160 from, UInt160 to, string value, long fee)
private JObject SendFrom(UInt160 assetId, UInt160 from, UInt160 to, string value)
{
CheckWallet();
AssetDescriptor descriptor = new AssetDescriptor(assetId);
BigDecimal amount = BigDecimal.Parse(value, descriptor.Decimals);
if (amount.Sign <= 0)
throw new RpcException(-32602, "Invalid params");
if (fee < 0)
throw new RpcException(-32602, "Invalid params");
Transaction tx = Wallet.MakeTransaction(null, new[]
Transaction tx = Wallet.MakeTransaction(new[]
{
new TransferOutput
{
AssetId = assetId,
Value = amount,
ScriptHash = to
}
}, from: from, net_fee: fee);
}, from);
if (tx == null)
throw new RpcException(-300, "Insufficient funds");

Expand All @@ -261,7 +241,7 @@ private JObject SendFrom(UInt160 assetId, UInt160 from, UInt160 to, string value
return SignAndRelay(tx);
}

private JObject SendMany(UInt160 from, JArray to, long fee)
private JObject SendMany(UInt160 from, JArray to)
{
CheckWallet();
if (to.Count == 0)
Expand All @@ -280,9 +260,7 @@ private JObject SendMany(UInt160 from, JArray to, long fee)
if (outputs[i].Value.Sign <= 0)
throw new RpcException(-32602, "Invalid params");
}
if (fee < 0)
throw new RpcException(-32602, "Invalid params");
Transaction tx = Wallet.MakeTransaction(null, outputs, from: from, net_fee: fee);
Transaction tx = Wallet.MakeTransaction(outputs, from);
if (tx == null)
throw new RpcException(-300, "Insufficient funds");

Expand All @@ -302,24 +280,22 @@ private JObject SendMany(UInt160 from, JArray to, long fee)
return SignAndRelay(tx);
}

private JObject SendToAddress(UInt160 assetId, UInt160 scriptHash, string value, long fee)
private JObject SendToAddress(UInt160 assetId, UInt160 scriptHash, string value)
{
CheckWallet();
AssetDescriptor descriptor = new AssetDescriptor(assetId);
BigDecimal amount = BigDecimal.Parse(value, descriptor.Decimals);
if (amount.Sign <= 0)
throw new RpcException(-32602, "Invalid params");
if (fee < 0)
throw new RpcException(-32602, "Invalid params");
Transaction tx = Wallet.MakeTransaction(null, new[]
Transaction tx = Wallet.MakeTransaction(new[]
{
new TransferOutput
{
AssetId = assetId,
Value = amount,
ScriptHash = scriptHash
}
}, net_fee: fee);
});
if (tx == null)
throw new RpcException(-300, "Insufficient funds");

Expand Down
2 changes: 1 addition & 1 deletion RpcWallet/RpcWallet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00044" />
<PackageReference Include="Neo" Version="3.0.0-CI00151" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion StatesDumper/StatesDumper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00044" />
<PackageReference Include="Neo" Version="3.0.0-CI00151" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion SystemLog/SystemLog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00150" />
<PackageReference Include="Neo" Version="3.0.0-CI00151" />
</ItemGroup>

<ItemGroup>
Expand Down