validator

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2018 License: MIT Imports: 3 Imported by: 0

README

Build Status Coverage Status Go Report Card GoDoc

BTC ADDRESS VALIDATOR

FROM: http://rosettacode.org/wiki/Bitcoin/address_validation#Go

DATED: 5 FEB 2018

USAGE

ok, err := validator.ValidA58([]byte("1NrxWfPM3w8GVXBkY2LpGy983wRxX45LMc"))

LICENSE

The MIT License (MIT)

Copyright (c) 2018 Adam Hanna

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidA58

func ValidA58(a58 []byte) (ok bool, err error)

ValidA58 validates a base58 encoded bitcoin address. An address is valid if it can be decoded into a 25 byte address, the version number is 0, and the checksum validates. Return value ok will be true for valid addresses. If ok is false, the address is invalid and the error value may indicate why.

Types

type A25

type A25 [25]byte

A25 is a type for a 25 byte (not base58 encoded) bitcoin address.

func (*A25) ComputeChecksum

func (a *A25) ComputeChecksum() (c [4]byte)

ComputeChecksum returns a four byte checksum computed from the first 21 bytes of the address. The embedded checksum is not updated.

func (*A25) EmbeddedChecksum

func (a *A25) EmbeddedChecksum() (c [4]byte)

EmbeddedChecksum returns the checksum

func (*A25) Set58

func (a *A25) Set58(s []byte) error

Set58 takes a base58 encoded address and decodes it into the receiver. Errors are returned if the argument is not valid base58 or if the decoded value does not fit in the 25 byte address. The address is not otherwise checked for validity.

func (*A25) Version

func (a *A25) Version() byte

Version returns the address version

Jump to

Keyboard shortcuts

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