panic: runtime error: invalid memory address or nil pointer dereference
micolezzz163 opened this issue · comments
blockchain_go send -from 1AmVdDvvQ977oVCpUqz7zAPUEiXKrX5avR -to 1L8SGeGZsLonjfAvh5hKGcocs1dvJMubvn -amount 6 -mine
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1057338]
goroutine 1 [running]:
main.Wallets.GetWallet(...)
/Users/zhengzhixiong/workspace_go/src/blockchain_go/cli_send.go:24
main.(*CLI).send(0xc420053f70, 0x7ffeefbff6d9, 0x22, 0x7ffeefbff700, 0x22, 0x6, 0xc420018018, 0x4, 0x11ca201)
/Users/zhengzhixiong/workspace_go/src/blockchain_go/cli_send.go:24 +0x1cd
main.(*CLI).Run(0xc4200bbf70)
/Users/zhengzhixiong/workspace_go/src/blockchain_go/cli.go:144 +0x711
main.main()
/Users/zhengzhixiong/workspace_go/src/blockchain_go/main.go:5 +0x2b
zhengzhixiongdeMacBook-Pro-4:blockchain_go zhengzhixiong$
What problem? Please help me to solve it!
It seems that you're trying to send money from a nonexistent address.
Try blockchain_go listaddresses
to se available addresses in current node's wallet.
You may try to change Wallets.go to check if requested address exists in the wallet and raise error if not found.
// GetWallet returns a Wallet by its address
func (ws Wallets) GetWallet(address string) Wallet {
wallet := ws.Wallets[address]
if wallet == nil {
log.Panic("ERROR: Address not found in your wallet")
}
return *wallet
}