ctype

package
v0.0.0-...-ab58f20 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

util package to handle various types and hex string, bytes etc

Index

Constants

This section is empty.

Variables

View Source
var (
	// ZeroAddr is all 0s
	ZeroAddr Addr
	// ZeroAddrHex is string of 20 0s
	ZeroAddrHex = Addr2Hex(ZeroAddr)
	// ZeroPayID is all 0s
	ZeroPayID PayIDType
	// ZeroPayIDHex is string of 32 0s
	ZeroPayIDHex = PayID2Hex(ZeroPayID)
	// ZeroBigInt is big.NewInt(0)
	ZeroBigInt = big.NewInt(0)
	// ZeroCid is all 0s
	ZeroCid CidType
)

Functions

func Addr2Hex

func Addr2Hex(a Addr) string

Addr2Hex returns hex without 0x

func Bytes2Hex

func Bytes2Hex(b []byte) string

Bytes2Hex returns hex string without 0x prefix

func Cid2Hex

func Cid2Hex(p CidType) string

Cid2Hex returns hex without 0x prefix

func Hex2Bytes

func Hex2Bytes(s string) (b []byte)

Hex2Bytes supports hex string with or without 0x prefix Calls hex.DecodeString directly and ignore err similar to ec.FromHex but better

func PayID2Hex

func PayID2Hex(p PayIDType) string

PayID2Hex returns hex without 0x prefix

Types

type Addr

type Addr = ec.Address

Addr is alias to geth common.Address

func Bytes2Addr

func Bytes2Addr(b []byte) Addr

Bytes2Addr returns Address from b Addr.Bytes() does the reverse

func Hex2Addr

func Hex2Addr(s string) Addr

Hex2Addr accepts hex string with or without 0x prefix and return Addr

type CidType

type CidType = ec.Hash

CidType is the type for payment channel ID Note we need to change all cid.Hex() to Cid2Hex() because Hash.Hex() has 0x prefix

func Bytes2Cid

func Bytes2Cid(b []byte) CidType

Bytes2Cid converts bytes to CidType

func Hex2Cid

func Hex2Cid(s string) CidType

Hex2Cid accepts hex string with or without 0x prefix and return CidType

type PayIDType

type PayIDType = ec.Hash

PayIDType is the ID type for pays

func Bytes2PayID

func Bytes2PayID(b []byte) PayIDType

Bytes2PayID converts bytes to PayIDType type

func Hex2PayID

func Hex2PayID(s string) PayIDType

Hex2PayID accepts hex string with or without 0x prefix and return PayIDType

func Pay2PayID

func Pay2PayID(pay *entity.ConditionalPay) PayIDType

Pay2PayID converts structured pay data to PayID

func PayBytes2PayID

func PayBytes2PayID(payBytes []byte) PayIDType

PayBytes2PayID converts marshaled pay bytes to PayID

Jump to

Keyboard shortcuts

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