coincodec

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

README

go-coincodec

Tag License GoDoc Travis CI codecov.io

Go utility library to provide movement between string and binary representation of multpile different cryptocurrency coin formats.

Table of Contents

Install

go-coincodec is a standard Go module which can be installed with:

go get github.com/wealdtech/go-coincodec

Usage

Example
import (
    "bytes"
    "encoding/hex"
    "errors"

    slip44 "github.com/wealdtech/go-slip44"
    cc "github.com/wealdtech/go-coincodec"
)

func main() {
    bytes, err := cc.ToBytes("0x0102030405060708090A0b0c0d0e0f1011121314", slip44.ETHER)
    if err != nil {
        panic(err)
    }

    str, err := cc.ToString(bytes, slip44.ETHER)
    if err != nil {
        panic(err)
    }

    fmt.Printf("%s\n", str)
}

Maintainers

Jim McDonald: @mcdee.

Contribute

Contributions welcome. Please check out the issues.

If you are adding a new coin type please try to follow the following rules:

  • use the existing ether.go and ether_test.go as templates
  • ensure you have 100% code coverage with your tests
  • try not to import large amounts of code; consider copying the relevant code rather than bringing in an entire project to use the address conversion functions

License

Apache-2.0 © 2019 Weald Technology Trading Ltd

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BNBDecodeToBytes

func BNBDecodeToBytes(input string) ([]byte, error)

BNBDecodeToBytes converts the input string to a byte array

func BNBEncodeToString

func BNBEncodeToString(bytes []byte) (string, error)

BNBEncodeToString converts the input byte array to a string representation of the BNB address.

func Bech32DecodeToBytes

func Bech32DecodeToBytes(input string, hrp string) ([]byte, error)

func Bech32EncodeToString

func Bech32EncodeToString(bytes []byte, hrp string) (string, error)

func EtherToBytes

func EtherToBytes(input string) ([]byte, error)

EtherToBytes converts the input string to a byte array.

func EtherToString

func EtherToString(input []byte) (string, error)

EtherToString converts the input byte array to a string representation of the Ethereum address.

func ToBytes

func ToBytes(input string, coinType uint32) ([]byte, error)

ToBytes converts the input string to a byte array for the given coin type.

func ToString

func ToString(input []byte, coinType uint32) (string, error)

ToString converts the input byte array to a string representation of the given coin type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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