Help us shape the future of Go! Take the 2026 Go Developer Survey

ava

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2019 License: MIT Imports: 13 Imported by: 0

README

ava

Cryptocurrency Addresses Validator

Installation

Install the package using

$ go get github.com/LanfordCai/ava
Usage

To use the package import it in your *.go code

import "github.com/LanfordCai/ava"
Example

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
	result := validator.ValidateAddress(address, isTestnet)

	fmt.Printf("Address is valid?: %t\n", result.IsValid)
	fmt.Printf("Extra message: %s\n", result.Msg)
}

Notice

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.

TODO
  • Validate bech32 addresses for Bitcoin/BitcoinCash
License

The ava is an open-source software licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Validator

type Validator interface {
	ValidateAddress(addr string, isTestnet bool) common.ValidationResult
}

Validator - Address validator

func NewValidator

func NewValidator(chainName string) (Validator, error)

NewValidator - Create address validator according to given chain name

Directories

Path Synopsis
internal
pkg
eos
ethereum
https://ethereum.stackexchange.com/questions/1374/how-can-i-check-if-an-ethereum-address-is-valid
https://ethereum.stackexchange.com/questions/1374/how-can-i-check-if-an-ethereum-address-is-valid
neo
sia

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL