Skip to content

Commit

Permalink
fix Wallet.GetAvailable (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang committed Nov 1, 2018
1 parent ca17193 commit a64ca72
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions neo/Wallets/Wallet.cs
Expand Up @@ -103,9 +103,12 @@ public BigDecimal GetAvailable(UIntBase asset_id)
UInt160[] accounts = GetAccounts().Where(p => !p.WatchOnly).Select(p => p.ScriptHash).ToArray();
using (ScriptBuilder sb = new ScriptBuilder())
{
sb.EmitPush(0);
foreach (UInt160 account in accounts)
{
sb.EmitAppCall(asset_id_160, "balanceOf", account);
sb.Emit(OpCode.DEPTH, OpCode.PACK);
sb.Emit(OpCode.ADD);
}
sb.EmitAppCall(asset_id_160, "decimals");
script = sb.ToArray();
}
Expand Down Expand Up @@ -306,9 +309,12 @@ public Transaction MakeTransaction(List<TransactionAttribute> attributes, IEnume
byte[] script;
using (ScriptBuilder sb2 = new ScriptBuilder())
{
sb2.EmitPush(0);
foreach (UInt160 account in accounts)
{
sb2.EmitAppCall(output.AssetId, "balanceOf", account);
sb2.Emit(OpCode.DEPTH, OpCode.PACK);
sb2.Emit(OpCode.ADD);
}
script = sb2.ToArray();
}
ApplicationEngine engine = ApplicationEngine.Run(script, extraGAS: Fixed8.FromDecimal(0.2m) * accounts.Length);
Expand Down

0 comments on commit a64ca72

Please sign in to comment.