Cryptocurrency Addresses Validator
Install the package using
$ go get github.com/LanfordCai/ava
To use the package import it in your *.go
code
import "github.com/LanfordCai/ava"
Validate a Bitcoin
address
At first, setup enabled address type:
export AVA_BITCOIN_ENABLED_ADDR_TYPES="P2PKH,P2SH"
And then, write some code:
package main
import (
"fmt"
"github.com/LanfordCai/ava"
)
func main() {
validator, err := ava.NewValidator("Bitcoin")
if err != nil {
panic(err.Error())
}
address := "19JeUHUvw23fwKeK1zZD4moKyxj1xn4Kxi"
isTestnet := false
isValid, msg :=validator.ValidateAddress(address, isTestnet)
fmt.Printf("Address is valid?: %t\n", isValid)
fmt.Printf("Extra message: %s\n", msg)
}
For EOS
addresses(account name), ava
only valid it's format. A valid result doesn't mean the account has been registered on the blockchain.
- Validate bech32 addresses for Bitcoin/BitcoinCash
The ava is an open-source software licensed under the MIT License.