Skip to content

Commit

Permalink
Improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon committed Jun 20, 2019
1 parent 071cee5 commit cd61b98
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions neo/Wallets/Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ public Transaction MakeTransaction(Snapshot snapshot, TransactionAttribute[] att
private Transaction MakeTransaction(Snapshot snapshot, TransactionAttribute[] attributes, byte[] script, List<(UInt160 Account, BigInteger Value)> balances_gas)
{
Random rand = new Random();
long priceBytes64 = ApplicationEngine.OpCodePrices[OpCode.PUSHBYTES64];
long priceBytes33 = ApplicationEngine.OpCodePrices[OpCode.PUSHBYTES33];
long priceCheckSig = InteropService.GetPrice(InteropService.Neo_Crypto_CheckSig, null);

foreach (var (account, value) in balances_gas)
{
Transaction tx = new Transaction
Expand Down Expand Up @@ -310,19 +314,24 @@ private Transaction MakeTransaction(Snapshot snapshot, TransactionAttribute[] at
if (script.IsSignatureContract())
{
size += 66 + script.GetVarSize();
tx.NetworkFee += ApplicationEngine.OpCodePrices[OpCode.PUSHBYTES64] + ApplicationEngine.OpCodePrices[OpCode.PUSHBYTES33] + InteropService.GetPrice(InteropService.Neo_Crypto_CheckSig, null);
tx.NetworkFee += priceBytes64 + priceBytes33 + priceCheckSig;
}
else if (script.IsMultiSigContract(out int m, out int n))
{
long feeM, feeN;
using (ScriptBuilder sb = new ScriptBuilder())
{
feeM = ApplicationEngine.OpCodePrices[(OpCode)sb.EmitPush(m).ToArray()[0]];
feeN = ApplicationEngine.OpCodePrices[(OpCode)sb.EmitPush(n).ToArray()[1]];
}

int size_inv = 65 * m;
size += IO.Helper.GetVarSize(size_inv) + size_inv + script.GetVarSize();
tx.NetworkFee += ApplicationEngine.OpCodePrices[OpCode.PUSHBYTES64] * m;
using (ScriptBuilder sb = new ScriptBuilder())
tx.NetworkFee += ApplicationEngine.OpCodePrices[(OpCode)sb.EmitPush(m).ToArray()[0]];
tx.NetworkFee += ApplicationEngine.OpCodePrices[OpCode.PUSHBYTES33] * n;
using (ScriptBuilder sb = new ScriptBuilder())
tx.NetworkFee += ApplicationEngine.OpCodePrices[(OpCode)sb.EmitPush(n).ToArray()[0]];
tx.NetworkFee += InteropService.GetPrice(InteropService.Neo_Crypto_CheckSig, null) * n;
tx.NetworkFee += priceBytes64 * m;
tx.NetworkFee += feeM;
tx.NetworkFee += priceBytes33 * n;
tx.NetworkFee += feeN;
tx.NetworkFee += priceCheckSig * n;
}
else
{
Expand Down

0 comments on commit cd61b98

Please sign in to comment.