Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang committed Apr 22, 2019
1 parent 435e3c7 commit 30bde20
Showing 1 changed file with 39 additions and 54 deletions.
93 changes: 39 additions & 54 deletions RpcWallet/RpcWallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,36 +313,31 @@ private JObject SendFrom(UIntBase assetId, UInt160 from, UInt160 to, string valu

ContractParametersContext transContext = new ContractParametersContext(tx);
Wallet.Sign(transContext);
if (transContext.Completed)
if (!transContext.Completed)
return transContext.ToJson();
tx.Witnesses = transContext.GetWitnesses();
if (tx.Size > 1024)
{
tx.Witnesses = transContext.GetWitnesses();
if (tx.Size > 1024)
Fixed8 calFee = Fixed8.FromDecimal(tx.Size * 0.00001m + 0.001m);
if (fee < calFee)
{
Fixed8 calFee = Fixed8.FromDecimal(tx.Size * 0.00001m + 0.001m);
if (fee < calFee)
fee = calFee;
tx = Wallet.MakeTransaction(null, new[]
{
fee = calFee;
tx = Wallet.MakeTransaction(null, new[]
{
new TransferOutput
{
AssetId = assetId,
Value = amount,
ScriptHash = to
}
}, from: from, change_address: change_address, fee: fee);
if (tx == null)
throw new RpcException(-300, "Insufficient funds");
}
if (tx == null)
throw new RpcException(-300, "Insufficient funds");
}
if (fee > Settings.Default.MaxFee)
throw new RpcException(-301, "The necessary fee is more than the Max_fee, this transaction is failed. Please increase your Max_fee value.");
return SignAndRelay(tx);
}
else
{
return transContext.ToJson();
}
if (fee > Settings.Default.MaxFee)
throw new RpcException(-301, "The necessary fee is more than the Max_fee, this transaction is failed. Please increase your Max_fee value.");
return SignAndRelay(tx);
}

private JObject SendMany(UInt160 from, JArray to, Fixed8 fee, UInt160 change_address)
Expand Down Expand Up @@ -372,28 +367,23 @@ private JObject SendMany(UInt160 from, JArray to, Fixed8 fee, UInt160 change_add

ContractParametersContext transContext = new ContractParametersContext(tx);
Wallet.Sign(transContext);
if (transContext.Completed)
if (!transContext.Completed)
return transContext.ToJson();
tx.Witnesses = transContext.GetWitnesses();
if (tx.Size > 1024)
{
tx.Witnesses = transContext.GetWitnesses();
if (tx.Size > 1024)
Fixed8 calFee = Fixed8.FromDecimal(tx.Size * 0.00001m + 0.001m);
if (fee < calFee)
{
Fixed8 calFee = Fixed8.FromDecimal(tx.Size * 0.00001m + 0.001m);
if (fee < calFee)
{
fee = calFee;
tx = Wallet.MakeTransaction(null, outputs, from: from, change_address: change_address, fee: fee);
if (tx == null)
throw new RpcException(-300, "Insufficient funds");
}
fee = calFee;
tx = Wallet.MakeTransaction(null, outputs, from: from, change_address: change_address, fee: fee);
if (tx == null)
throw new RpcException(-300, "Insufficient funds");
}
if (fee > Settings.Default.MaxFee)
throw new RpcException(-301, "The necessary fee is more than the Max_fee, this transaction is failed. Please increase your Max_fee value.");
return SignAndRelay(tx);
}
else
{
return transContext.ToJson();
}
if (fee > Settings.Default.MaxFee)
throw new RpcException(-301, "The necessary fee is more than the Max_fee, this transaction is failed. Please increase your Max_fee value.");
return SignAndRelay(tx);
}

private JObject SendToAddress(UIntBase assetId, UInt160 scriptHash, string value, Fixed8 fee, UInt160 change_address)
Expand All @@ -419,36 +409,31 @@ private JObject SendToAddress(UIntBase assetId, UInt160 scriptHash, string value

ContractParametersContext transContext = new ContractParametersContext(tx);
Wallet.Sign(transContext);
if(transContext.Completed)
if (!transContext.Completed)
return transContext.ToJson();
tx.Witnesses = transContext.GetWitnesses();
if (tx.Size > 1024)
{
tx.Witnesses = transContext.GetWitnesses();
if (tx.Size > 1024)
Fixed8 calFee = Fixed8.FromDecimal(tx.Size * 0.00001m + 0.001m);
if (fee < calFee)
{
Fixed8 calFee = Fixed8.FromDecimal(tx.Size * 0.00001m + 0.001m);
if (fee < calFee)
fee = calFee;
tx = Wallet.MakeTransaction(null, new[]
{
fee = calFee;
tx = Wallet.MakeTransaction(null, new[]
{
new TransferOutput
{
AssetId = assetId,
Value = amount,
ScriptHash = scriptHash
}
}, change_address: change_address, fee: fee);
if (tx == null)
throw new RpcException(-300, "Insufficient funds");
}
if (tx == null)
throw new RpcException(-300, "Insufficient funds");
}
if (fee > Settings.Default.MaxFee)
throw new RpcException(-301, "The necessary fee is more than the Max_fee, this transaction is failed. Please increase your Max_fee value.");
return SignAndRelay(tx);
}
else
{
return transContext.ToJson();
}
if (fee > Settings.Default.MaxFee)
throw new RpcException(-301, "The necessary fee is more than the Max_fee, this transaction is failed. Please increase your Max_fee value.");
return SignAndRelay(tx);
}
}
}

0 comments on commit 30bde20

Please sign in to comment.