utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CelerCA = []byte(`-----BEGIN CERTIFICATE-----
MIIE5DCCAsygAwIBAgIBATANBgkqhkiG9w0BAQsFADASMRAwDgYDVQQDEwdDZWxl
ckNBMB4XDTE5MDkxNzIwMTEyNFoXDTI5MDkxNzIwMTEyNFowEjEQMA4GA1UEAxMH
Q2VsZXJDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJMk0gwPrlv/
/8aVaKAoURvPMHEgpDyj8c08A55kjNlStgjtpBpBEfNiLg3nIBeyrrmt/9QXLexD
RxewLgm/9uUB/U1Q4ZBQdAdsSHTyU+wap1HKJ7GX1jhZMjY95vIfTbrSIbo2clym
zKlbwvvBlNYgweHz0YiyWUCsqi2wH++ybUNzmgs0qI+lE/Fg4k8sReVcix5rUvNF
na9tpvGdV9u+iZNlwkeb3Hp9Ank5MR0830LzG2uf95p+d0fXmfl92wxdAFWnEhWi
uPK4Zfqt2orTIpY1uhiDl4d4kf1p0Niowf9FNOHMURYbTQqFMGFLOZI7+dOPW8Wy
AfkcZcgBfEQ2rGkd3+kb8A2pOTBaFqG9HkspKe9d/dXKKZMW63nLU1MIERWmj2S+
uEBAObnNCpmWPDDFnUpNaACt76tqRP+jYaOaEdPp8svOB6mD47lQemb2SEuWd8oa
afbv/tS6rdRvJEPJ2PgHSzIrYG3cTrLrNDhjFa3CoPwilWtP414+AfvwZTRfjNWy
kcVjK8kurHmrhNzhYNC/rtaQquU2NwS0UYf7+sRLytgEK6+6HahHXJD7/6aRyzrm
1bwYANmgrWf7LfvEf4ezGb1m+qLU3B2/Lzh3HpEBw/ySTFXNHKtv7ZbsN+ccjez6
au3fgns4jO8nCF7rAJLChopKHMkGeLkdAgMBAAGjRTBDMA4GA1UdDwEB/wQEAwIB
BjASBgNVHRMBAf8ECDAGAQH/AgEAMB0GA1UdDgQWBBSoQm3esw5att/hencMPoPd
qhyvXTANBgkqhkiG9w0BAQsFAAOCAgEAIJATh5yJd7XzfnfM8f2MNKRbUWzdDhE8
AHPjtKoOCsKOyua41xIpPvM+emdg8oTOZdNRlaoDiO1/8DB7PU1k1iXFaZ/MrgeM
Cz8pP9MvXLSXmg039hYREWV7pFvdbqhvfnOU+pj/uMwif1pl6+CRDxxSdwqUNeJr
gmqbDFBvdRa5DQJm7rbIYpSMc5P/GHZcVgOb+g3y6iODaPL/VR7Uo1xVvxzjgxpI
09QcYiDNK5vPondgaoh7W3c+KuaEKO18G8TEN0NGFOadk5ZjJ9uq+8aGfy51qny8
SMOI5/wW+7HODeQmSqtaxVlhZdmWa/iIzya/NGe+5JhRKgBKN9BIysEiVc4i4ver
utwMnSqqDSCZKUD6FeJn+CUimDf9nb9xbsZ8a+5pw2D6/iaZ+mJd1Pv0vHX5NxMJ
36Rj0MMB9I1xY9C2/ugiP1a/JG+Ve4n1r4GX1S2MfYH/k8wYcs4cVLQ21nphvTW5
osJePOuWfBuWD77selYHU/PhlzNVq2bSWHDQlQJoQr12dGk0NiYAf0FtTWRQoMkq
nwCu157ZSeK2bWffJUcLnTFV63ftZmsqEjYHHVQrbthc+LBpTT4ZYOBerEfQfoKi
c6Z63v4v3R9WB5VYZWH7nh+lMJBPhhL1043iN4Be3Z27GJ0jKIPQAL2gfNiukuz/
D/qaayaXjbo=
-----END CERTIFICATE-----`)

CelerCA root CA file, generated via certstrap new CA file w/ 10yr expiration

View Source
var ErrHttpReponse = errors.New("http response error")

Functions

func BytesToBigInt

func BytesToBigInt(in []byte) *big.Int

func Dec2HexStr

func Dec2HexStr(dec string) string

Dec2HexStr decimal string to hex

func Float2Wei

func Float2Wei(f float64) *big.Int

float in 10e18 wei to wei

func GetAddressFromKeystore

func GetAddressFromKeystore(ksBytes []byte) (string, error)

func GetClientTlsConfig

func GetClientTlsConfig() *tls.Config

GetClientTlsConfig returns tls.Config with system and celerCA, for https interaction

func GetClientTlsOption

func GetClientTlsOption() grpc.DialOption

use for celer client dialing celer server/proxy support os ca and celer ca

func GetClientTlsOptionPermissive

func GetClientTlsOptionPermissive() grpc.DialOption

GetClientTlsOptionPermissive returns insecure transport credentials when the environment variable CELER_INSECURE_TLS is set ("1"/"true"). This is useful for local e2e tests where the server uses a self-signed localhost certificate that may not chain to CAs available to the client.

func GetTokenAddr

func GetTokenAddr(tokenInfo *entity.TokenInfo) ctype.Addr

GetTokenAddr returns token address

func GetTokenAddrStr

func GetTokenAddrStr(tokenInfo *entity.TokenInfo) string

GetTokenAddrStr returns string for tokenInfo

func GetTokenInfoFromAddress

func GetTokenInfoFromAddress(tkaddr ctype.Addr) *entity.TokenInfo

GetTokenInfoFromAddress returns TokenInfo from tkaddr only support ERC20 for now

func GetTsAndSig

func GetTsAndSig(sign func([]byte) []byte) (ts uint64, sig []byte)

GetTsAndSig returns current time and signature of current time using sign param passed in.

func Hex2DecStr

func Hex2DecStr(hex string) string

Hex2DecStr hex string to decimal

func HttpPost

func HttpPost(url string, input interface{}) ([]byte, error)

func IsLoopbackTarget added in v1.1.0

func IsLoopbackTarget(target string) bool

func IsPermissiveClientTLS added in v1.1.0

func IsPermissiveClientTLS() bool

func NewOnChainCompatibleSigner added in v1.1.0

func NewOnChainCompatibleSigner(signer eth.Signer) eth.Signer

func Pad

func Pad(origin []byte, n int) []byte

left padding

func PbToJSONHexBytes

func PbToJSONHexBytes(pb proto.Message) (string, error)

PbToJSONHexBytes historically used a custom marshaler to render bytes in hex. It is now log-only and uses the same tolerant JSON path as PbToJSONString.

func PbToJSONString

func PbToJSONString(pb proto.Message) (string, error)

PbToJSONString marshals a protobuf msg to json string.

This is primarily used for logging/debugging; it is intentionally tolerant of unknown google.protobuf.Any type URLs by falling back to an opaque base64-encoded representation.

func PrintAccountAmtPair

func PrintAccountAmtPair(pair *entity.AccountAmtPair) string

func PrintByteArrays

func PrintByteArrays(array [][]byte) string

func PrintChannelInitializer

func PrintChannelInitializer(initializer *entity.PaymentChannelInitializer) string

func PrintCondition

func PrintCondition(cond *entity.Condition) string

func PrintConditionalPay

func PrintConditionalPay(pay *entity.ConditionalPay) string

func PrintConditions

func PrintConditions(conds []*entity.Condition) string

func PrintCooperativeWithdrawInfo

func PrintCooperativeWithdrawInfo(withdrawal *entity.CooperativeWithdrawInfo) string

func PrintPayIdList

func PrintPayIdList(paylist *entity.PayIdList) string

func PrintPayPath

func PrintPayPath(payPath *rpc.PayPath, payID ctype.PayIDType) string

func PrintRoutingUpdate

func PrintRoutingUpdate(update *rpc.RoutingUpdate) string

func PrintSimplexChannel

func PrintSimplexChannel(simplex *entity.SimplexPaymentChannel) string

func PrintToken

func PrintToken(tokenInfo *entity.TokenInfo) string

func PrintTokenAddr

func PrintTokenAddr(tkaddr ctype.Addr) string

func PrintTokenDistribution

func PrintTokenDistribution(dist *entity.TokenDistribution) string

func PrintTokenInfo

func PrintTokenInfo(token *entity.TokenInfo) string

func PrintTokenTransfer

func PrintTokenTransfer(transfer *entity.TokenTransfer) string

func PrintTransferFunc

func PrintTransferFunc(transfer *entity.TransferFunction) string

func QueryDeposit

func QueryDeposit(adminHostPort string, depositID string) (*rpc.QueryDepositResponse, error)

func QueryPeerOsps

func QueryPeerOsps(adminHostPort string) (*rpc.PeerOspsResponse, error)

func RecvRoutingInfo

func RecvRoutingInfo(adminHostPort string, info *rpc.RoutingRequest) error

HTTP request to send the routing info to the listener/routing server.

func RequestBuildRoutingTable

func RequestBuildRoutingTable(adminHostPort string, tokenAddr ctype.Addr) error

func RequestDeposit

func RequestDeposit(
	adminHostPort string, peerAddr, tokenAddr ctype.Addr, amount *big.Int, toPeer bool, maxWaitSec uint64) (string, error)

func RequestOpenChannel

func RequestOpenChannel(adminHostPort string, peerAddr, tokenAddr ctype.Addr, peerDeposit, selfDeposit *big.Int) error

func RequestRegisterStream

func RequestRegisterStream(adminHostPort string, peerAddr ctype.Addr, peerHostPort string) error

func RequestSendToken

func RequestSendToken(
	adminHostPort string, receiver, tokenAddr ctype.Addr, amount *big.Int, dstNetId uint64) (ctype.PayIDType, error)

func RequestSendTokenWithNote

func RequestSendTokenWithNote(
	adminHostPort string,
	receiver, tokenAddr ctype.Addr, amount *big.Int, dstNetId uint64,
	noteTypeUrl string, noteValueByte []byte) (ctype.PayIDType, error)

func TryLock

func TryLock(m *sync.Mutex) bool

func Uint64ToBytes

func Uint64ToBytes(i uint64) []byte

Uint64ToBytes converts uint to bytes in big-endian order.

func UnmarshalDelegationDescription

func UnmarshalDelegationDescription(proof *rpc.DelegationProof) (*rpc.DelegationDescription, error)

func ValidateAndFormatAddress

func ValidateAndFormatAddress(address string) (ctype.Addr, error)

func Wei2BigInt

func Wei2BigInt(wei string) *big.Int

convert decimal wei string to big.Int

func WrapLocalTLSDialError added in v1.1.0

func WrapLocalTLSDialError(target string, err error) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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