Jeiwan / blockchain_go

A simplified blockchain implementation in Golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValidateAddress Throws a Panic

PSalant726 opened this issue · comments

When creating a new blockchain, the current implementation of ValidateAddress panics:

$ blockchain_go createblockchain -address $NODE_ID
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
main.ValidateAddress(0x7ffeefbff78c, 0x4, 0xc0000a55b0)
	/Users/go-crypto/wallet.go:56 +0x202
main.(*CLI).createBlockchain(0xc0000c5f88, 0x7ffeefbff78c, 0x4, 0xc00001a048, 0x4)
	/Users/go-crypto/cli_createblockchain.go:9 +0x3f
main.(*CLI).Run(0xc0000c5f88)
	/Users/go-crypto/cli.go:117 +0x5ce
main.main()
	/Users/go-crypto/main.go:5 +0x2b

where

$ echo $NODE_ID
3000

Is there a potential quick fix here by changing:

// wallet.go
const addressChecksumLen = 4

?

The wallet was not created successfully - this was my own error 🙈