ava

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: MIT Imports: 18 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
	isValid, msg :=validator.ValidateAddress(address, isTestnet)

	fmt.Printf("Address is valid?: %t\n", isValid)
	fmt.Printf("Extra message: %s\n", 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

View Source
var ErrUnsupportedChain = errors.New("Given chain is unsupported yet")

ErrUnsupportedChain - the give chain is unsupported yet

Functions

This section is empty.

Types

type Validator

type Validator interface {
	ValidateAddress(addr string, isTestnet bool) (isValid bool, msg string)
}

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