theQRL / zond

MIT License
10 stars 12 forks source link

zond-cli wallet list fails with wallet.json file containing more than 10 addresses #285

Closed fr1t2 closed 2 years ago

fr1t2 commented 2 years ago

Expected Behavior

./zond-cli wallet list should return a list of all addresses contained in the wallet with index, address, and balance printed to console.

1   0x20d3b46b6f8dceca60278bf19f58c3859465cdc5  0
2   0x202d32684da044f95790081d3b7faa67c52dd538  0
3   0x100500d675ce9ba29be44f2abb09a85cf6a97c3d  0
4   0x100500edb120720e9bca79ea769fe0a5a02febb9  0
5   0x100500176d7b913edcc8ce5309a335cb1ff7fc9d  0
6   0x200117c87b91da26b8c1aa823cad3b6ad30f7e8d  0
7   0x20bf1acdae054f4194e0c132b489e8f9099caf8c  0
8   0x1005009094f8c335059ab9b3ebc421e10c131de5  0
9   0x1005003ea6ed78d597e7411a8ddbc2dffd8839e5  0
10  0x1005007372c097245a20174d6738743f58c053e2  0
11  0x1005007372c097245a20174d6738743f58c053e2  0
...

Current Behavior

When the wallet contains more than 10 addresses, the printed list stops at index 10 and throws an error.

./zond-cli wallet list 

1   0x20d3b46b6f8dceca60278bf19f58c3859465cdc5  0
2   0x202d32684da044f95790081d3b7faa67c52dd538  0
3   0x100500d675ce9ba29be44f2abb09a85cf6a97c3d  0
4   0x100500edb120720e9bca79ea769fe0a5a02febb9  0
5   0x100500176d7b913edcc8ce5309a335cb1ff7fc9d  0
6   0x200117c87b91da26b8c1aa823cad3b6ad30f7e8d  0
7   0x20bf1acdae054f4194e0c132b489e8f9099caf8c  0
8   0x1005009094f8c335059ab9b3ebc421e10c131de5  0
9   0x1005003ea6ed78d597e7411a8ddbc2dffd8839e5  0
10  0x1005007372c097245a20174d6738743f58c053e2  0
panic: interface conversion: interface {} is nil, not map[string]interface {}

goroutine 1 [running]:
github.com/theQRL/zond/wallet.(*Wallet).reqBalance(0xb09360?, {0xc00002eff0, 0x2a})
    /home/ubuntu/NewZond/zond/wallet/wallet.go:113 +0x3c5
github.com/theQRL/zond/wallet.(*Wallet).List(0xc00019f8d0)
    /home/ubuntu/NewZond/zond/wallet/wallet.go:119 +0x69
github.com/theQRL/zond/cli/commands.getWalletSubCommands.func3(0xc00016fe30?)
    /home/ubuntu/NewZond/zond/cli/commands/wallet.go:49 +0x5a
github.com/urfave/cli/v2.(*Command).Run(0xc0000e7440, 0xc00011a4c0)
    /home/ubuntu/go/pkg/mod/github.com/urfave/cli/v2@v2.2.0/command.go:164 +0x5dc
github.com/urfave/cli/v2.(*App).RunAsSubcommand(0xc0000ca780, 0xc00011a240)
    /home/ubuntu/go/pkg/mod/github.com/urfave/cli/v2@v2.2.0/app.go:427 +0xcca
github.com/urfave/cli/v2.(*Command).startApp(0xc0000e7680, 0xc00011a240)
    /home/ubuntu/go/pkg/mod/github.com/urfave/cli/v2@v2.2.0/command.go:279 +0x72f
github.com/urfave/cli/v2.(*Com
[wallet.json.md](https://github.com/theQRL/zond/files/9528556/wallet.json.md)
mand).Run(0xc000166540?, 0x2?)
    /home/ubuntu/go/pkg/mod/github.com/urfave/cli/v2@v2.2.0/command.go:94 +0xba
github.com/urfave/cli/v2.(*App).RunContext(0xc0000ca600, {0xb0c570?, 0xc00002a650}, {0xc000024180, 0x3, 0x3})
    /home/ubuntu/go/pkg/mod/github.com/urfave/cli/v2@v2.2.0/app.go:306 +0xbfd
github.com/urfave/cli/v2.(*App).Run(...)
    /home/ubuntu/go/pkg/mod/github.com/urfave/cli/v2@v2.2.0/app.go:215
main.main()
    /home/ubuntu/NewZond/zond/cmd/zond-cli/zond-cli.go:30 +0xda

Steps to Reproduce

  1. Enter the command ./zond-cli wallet add-xmss or ./zond-cli wallet add-dilithium more than 10 times, creating 11+ addresses in a single wallet.json file
  2. Enter command ./zond-cli wallet list

Context (Environment)

lsb_release -a
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.7 LTS
Release:    16.04
Codename:   xenial
go version

go version go1.19.1 linux/amd64

wallet.json file attached re-named to wallet.json.md for GitHub file type restrictions

wallet.json.md

cyyber commented 2 years ago

Issue has been fixed in PR #301