Documentation
¶
Index ¶
- Variables
- func APex(data common.Address) string
- func APex2(data common.Address) string
- func BPex(data []byte) string
- func BigIntTo32Bytes(i *big.Int) []byte
- func BytesToString(b []byte) string
- func CalcChannelID(token, tokensNetwork, p1, p2 common.Address) common.Hash
- func Decrypt(src, key []byte) ([]byte, error)
- func DeepCopy(dst, src interface{}) error
- func Ecrecover(hash common.Hash, signature []byte) (addr common.Address, err error)
- func Encrypt(src, key []byte) ([]byte, error)
- func Exists(dir string) bool
- func GetHomePath() string
- func HPex(data common.Hash) string
- func HexToAddress(addr string) (address common.Address, err error)
- func HexToAddressWithoutValidation(addr string) (address common.Address, err error)
- func IsValidPositiveInt256(i *big.Int) bool
- func IsValidUint256(i *big.Int) bool
- func MakePrivateKeyAddress() (*ecdsa.PrivateKey, common.Address)
- func MyCallerFuncHandler(h log.Handler) log.Handler
- func MyStreamHandler(wr io.Writer) log.Handler
- func NewRandomAddress() common.Address
- func NewRandomHash() common.Hash
- func NewRandomInt(n int) int
- func NewRandomInt64() int64
- func PasswordDecrypt(encpass string) (pass string, err error)
- func PasswordEncrypt(pass string) (encstr string, err error)
- func Pex(data []byte) string
- func PrintStack()
- func PubkeyToAddress(pubkey []byte) common.Address
- func Random(n int) []byte
- func RandomString(n int) string
- func ReadBigInt(reader io.Reader) *big.Int
- func ReadVarInt(r io.Reader) (uint64, error)
- func Sha3(data ...[]byte) common.Hash
- func ShaSecret(data []byte) common.Hash
- func SignData(privKey *ecdsa.PrivateKey, data []byte) (sig []byte, err error)
- func Stack() []byte
- func StringInterface(i interface{}, depth int) string
- func StringInterface1(i interface{}) string
- func StringToBytes(s string) []byte
- func SystemExit(code int)
- func ToJSONFormat(v interface{}) string
- func WriteVarInt(w io.Writer, val uint64) error
- type AsyncResult
- type DebugLock
Constants ¶
This section is empty.
Variables ¶
var BigInt0 = big.NewInt(0)
BigInt0 as name
var EmptyAddress = common.Address{}
EmptyAddress all zero,invalid
var EmptyHash = common.Hash{}
EmptyHash all zero,invalid
var MaxBigUInt256, _ = new(big.Int).SetString("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 0)
MaxBigUInt256 as name
var RandSrc = rand.NewSource(time.Now().UnixNano())
RandSrc random source from math
Functions ¶
func BigIntTo32Bytes ¶
BigIntTo32Bytes convert a big int to bytes
func BytesToString ¶
BytesToString accepts bytes and returns their string presentation instead of string() this method doesn't generate memory allocations, BUT it is not safe to use anywhere because it points this helps on 0 memory allocations
func CalcChannelID ¶
CalcChannelID 计算ChannelID的方式,注意与合约上计算方式保持完全一致.
func HexToAddress ¶
HexToAddress convert hex encoded address string to common.Address, and verify it is in accordance with EIP55
func HexToAddressWithoutValidation ¶
HexToAddressWithoutValidation disable EIP55 validation
func IsValidPositiveInt256 ¶
IsValidPositiveInt256 returns true if i is a valid positive int256
func IsValidUint256 ¶
IsValidUint256 retuns true if i is a valid uint256
func MakePrivateKeyAddress ¶
func MakePrivateKeyAddress() (*ecdsa.PrivateKey, common.Address)
MakePrivateKeyAddress generate a private key and it's address
func MyCallerFuncHandler ¶
MyCallerFuncHandler handler for log
func MyStreamHandler ¶
MyStreamHandler handler for log
func NewRandomAddress ¶
NewRandomAddress generate a address,there maybe no corresponding priv key
func NewRandomHash ¶
NewRandomHash generate random hash,for testonly
func NewRandomInt ¶
NewRandomInt generate a random int ,not more than n
func PasswordDecrypt ¶
PasswordDecrypt decrypt arguments --password-file for arguments --password-file usage
func PasswordEncrypt ¶
PasswordEncrypt encrypt accounts password to base64 encoding for arguments --password-file use
func PubkeyToAddress ¶
PubkeyToAddress convert pubkey bin to address
func Random ¶
Random takes a parameter (int) and returns random slice of byte ex: var randomstrbytes []byte; randomstrbytes = utils.Random(32)
func RandomString ¶
RandomString accepts a number(10 for example) and returns a random string using simple but fairly safe random algorithm
func ReadVarInt ¶
ReadVarInt reads a variable length integer from r and returns it as a uint64.
func SignData ¶
func SignData(privKey *ecdsa.PrivateKey, data []byte) (sig []byte, err error)
SignData sign with ethereum format
func Stack ¶
func Stack() []byte
Stack returns a formatted stack trace of the goroutine that calls it. It calls runtime.Stack with a large enough buffer to capture the entire trace.
func StringInterface ¶
StringInterface use spew to string any object with max `depth`,it's not thread safe.
func StringInterface1 ¶
func StringInterface1(i interface{}) string
StringInterface1 use spew to string any object with depth 1,it's not thread safe.
func StringToBytes ¶
StringToBytes accepts string and returns their []byte presentation instead of byte() this method doesn't generate memory allocations, BUT it is not safe to use anywhere because it points this helps on 0 memory allocations
Types ¶
type AsyncResult ¶
type AsyncResult struct { Result chan error Tag interface{} LockSecretHash common.Hash // only for /api/1/transfer use, return LockSecretHash to caller }
AsyncResult is designed for async notify and Tag can be save anything by user.
func NewAsyncResultWithError ¶
func NewAsyncResultWithError(err error) *AsyncResult
NewAsyncResultWithError create AsyncResult with result