client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CelerClient

type CelerClient struct {
	// contains filtered or unexported fields
}

CelerClient implements main functionalities

func NewCelerClient

func NewCelerClient(
	keyStore string, passPhrase string, profile common.CProfile, clientCallback clientCallbackAdapter) (*CelerClient, error)

func NewCelerClientWithExternalSigner

func NewCelerClientWithExternalSigner(
	address ctype.Addr, signer eth.Signer, profile common.CProfile,
	clientCallback clientCallbackAdapter) (*CelerClient, error)

func (*CelerClient) AddBooleanPay

func (c *CelerClient) AddBooleanPay(
	xfer *entity.TokenTransfer, conds []*entity.Condition, resolveDeadline uint64, note *any.Any, dstNetId uint64) (ctype.PayIDType, error)

AddBooleanPay creates a condpay based on args, and call cnode to send CondPayRequest returns payId or err

func (*CelerClient) ClearCallbacks

func (c *CelerClient) ClearCallbacks()

ClearCallbacks set c.onClientEvent to nil so no more callbacks will be triggered. This has to be a different func instead of within Close is in Init if client failed, we call close but still want the init failed callback to trigger so mobile knows. But in celersdk Destroy API, we want to cleanup everything

func (*CelerClient) Close

func (c *CelerClient) Close()

Close tries to close db and networking then set c.cNode to nil so all future code to access c.cNode.xxx will panic TODO: a cleaner solution is to have a close only (ie no data) signal chan all components must honor and exit cleanly

func (*CelerClient) ConfirmBooleanPay

func (c *CelerClient) ConfirmBooleanPay(payID ctype.PayIDType) error

func (*CelerClient) ConfirmOnChainResolvedPays

func (c *CelerClient) ConfirmOnChainResolvedPays(token *entity.TokenInfo) error

func (*CelerClient) ConfirmSettlePaymentChannel

func (c *CelerClient) ConfirmSettlePaymentChannel(token *entity.TokenInfo) error

ConfirmSettlePaymentChannel confirm settle and close a payment channel on-chain

func (*CelerClient) ConfirmWithdraw

func (c *CelerClient) ConfirmWithdraw(token *entity.TokenInfo) error

func (*CelerClient) CooperativeWithdraw

func (c *CelerClient) CooperativeWithdraw(
	tokenAddr ctype.Addr, amount *big.Int, callback cooperativewithdraw.Callback) (string, error)

func (*CelerClient) DeleteAppChannel

func (c *CelerClient) DeleteAppChannel(cid string) error

DeleteAppChannel removes the app channel info from the in memory map

func (*CelerClient) Deposit

func (c *CelerClient) Deposit(
	tokenAddr ctype.Addr, amt *big.Int, cb deposit.DepositCallback) (string, error)

func (*CelerClient) GetAllPayments

func (c *CelerClient) GetAllPayments() ([]*celersdkintf.Payment, error)

GetAllPayments returns all payments info

func (*CelerClient) GetAppChannel

func (c *CelerClient) GetAppChannel(cid string) *app.AppChannel

func (*CelerClient) GetAppChannelDeployedAddr

func (c *CelerClient) GetAppChannelDeployedAddr(cid string) (ctype.Addr, error)

GetAppChannelDeployedAddr get the depolyed address of a app channel returns error if it's an undeployed virtual contract channel

func (*CelerClient) GetBalance

func (c *CelerClient) GetBalance(cid ctype.CidType) (*common.ChannelBalance, error)

func (*CelerClient) GetChannelState

func (c *CelerClient) GetChannelState(tkAddr ctype.Addr) string

func (*CelerClient) GetCondPayInfoFromRegistry

func (c *CelerClient) GetCondPayInfoFromRegistry(payID ctype.PayIDType) (*big.Int, uint64, error)

func (*CelerClient) GetCurrentBlockNumber

func (c *CelerClient) GetCurrentBlockNumber() *big.Int

GetCurrentBlockNumber returns the current block number

func (*CelerClient) GetCurrentBlockNumberUint64

func (c *CelerClient) GetCurrentBlockNumberUint64() uint64

GetCurrentBlockNumber returns the current block number

func (*CelerClient) GetDAL

func (c *CelerClient) GetDAL() *storage.DAL

GetDAL is simple helper so sdk layer can call GetSerializedDatabase

func (*CelerClient) GetFeeMgrEth

func (c *CelerClient) GetFeeMgrEth() string

Return the FeeMgr's Eth address.

Note: for now this returns the Eth address of the OSP server that the client is connected to. In the future when multiple OSP Eth addresses could be used, and assuming a single FeeMgr across all OSPs, then this function should be changed to return the FeeMgr's Eth address which would be configured separately in the profile.

func (*CelerClient) GetIncomingPaymentStatus

func (c *CelerClient) GetIncomingPaymentStatus(payID ctype.PayIDType) int

get incoming payment sdk level status

func (*CelerClient) GetMyEthAddr

func (c *CelerClient) GetMyEthAddr() ctype.Addr

GetMyEthAddr returns eth addr of this client.

func (*CelerClient) GetOutgoingPaymentStatus

func (c *CelerClient) GetOutgoingPaymentStatus(payID ctype.PayIDType) int

get outgoing payment sdk level status

func (*CelerClient) GetPayment

func (c *CelerClient) GetPayment(payID ctype.PayIDType) (*celersdkintf.Payment, error)

GetPayment returns the related payment info of a specified payment ID

func (*CelerClient) GetRpcClientToOsp

func (c *CelerClient) GetRpcClientToOsp() (rpc.RpcClient, error)

GetRpcClientToOsp returns rpc client to osp.

func (*CelerClient) GetSettleFinalizedTime

func (c *CelerClient) GetSettleFinalizedTime(token *entity.TokenInfo) (*big.Int, error)

func (*CelerClient) GetSgnGuardRequest

func (c *CelerClient) GetSgnGuardRequest(token *entity.TokenInfo) (*cnode.SgnRequest, error)

func (*CelerClient) GetSgnSubscription

func (c *CelerClient) GetSgnSubscription() (*cnode.SgnSubscription, error)

func (*CelerClient) GetTokenBalance

func (c *CelerClient) GetTokenBalance(tokenAddr ctype.Addr) (*big.Int, *big.Int, *big.Int, error)

GetTokenBalance returns ERC20 avaialble, locked and maxReceiving capacity Note that the returned balance is based on local knowledge

func (*CelerClient) HandleDestinationUnreachable

func (r *CelerClient) HandleDestinationUnreachable(payID ctype.PayIDType, pay *entity.ConditionalPay, note *any.Any)

func (*CelerClient) HandleReceivingDone

func (c *CelerClient) HandleReceivingDone(
	payID ctype.PayIDType,
	pay *entity.ConditionalPay,
	note *any.Any,
	reason rpc.PaymentSettleReason)

func (*CelerClient) HandleReceivingStart

func (c *CelerClient) HandleReceivingStart(payID ctype.PayIDType, pay *entity.ConditionalPay, note *any.Any)

func (*CelerClient) HandleSendComplete

func (r *CelerClient) HandleSendComplete(
	payID ctype.PayIDType,
	pay *entity.ConditionalPay,
	note *any.Any,
	reason rpc.PaymentSettleReason)

func (*CelerClient) HandleSendFail

func (r *CelerClient) HandleSendFail(payID ctype.PayIDType, pay *entity.ConditionalPay, note *any.Any, errMsg string)

func (*CelerClient) HasPendingOpenChanRequest

func (c *CelerClient) HasPendingOpenChanRequest(tk *entity.TokenInfo) bool

func (*CelerClient) InstantiateChannelForToken

func (c *CelerClient) InstantiateChannelForToken(token *entity.TokenInfo, appcb clientCallbackAdapter) error

func (*CelerClient) IntendSettlePaymentChannel

func (c *CelerClient) IntendSettlePaymentChannel(token *entity.TokenInfo) error

IntendSettlePaymentChannel starts payment channel settling process

func (*CelerClient) IntendWithdraw

func (c *CelerClient) IntendWithdraw(token *entity.TokenInfo, amount *big.Int) error

func (*CelerClient) IsConnectedToCeler

func (c *CelerClient) IsConnectedToCeler(tokenaddr string, addr string) (rpc.JoinCelerStatus, string, error)

IsConnectedToCeler checks if the given peer has connected to Celer and returns its join status(LOCAL or REMOTE) and its free balance as a decimal string value. If the peer has not joined Celer, it returns join status(NOT JOIN) and an empty string

func (*CelerClient) MonitorCooperativeWithdrawJob

func (c *CelerClient) MonitorCooperativeWithdrawJob(
	withdrawHash string, callback cooperativewithdraw.Callback)

func (*CelerClient) MonitorDepositJob

func (c *CelerClient) MonitorDepositJob(jobID string, cb deposit.DepositCallback)

func (*CelerClient) MyAddress

func (c *CelerClient) MyAddress() ctype.Addr

MyAddress returns ctype.Addr from c.cNode.EthAddress

func (*CelerClient) NewAppChannelOnDeployedContract

func (c *CelerClient) NewAppChannelOnDeployedContract(
	contractAddr ctype.Addr,
	nonce uint64,
	players []ctype.Addr,
	onchainTimeout uint64,
	sc common.StateCallback) (string, error)

NewAppChannelOnDeployedContract initializes a generalized state channel with a deployed contract It returns the session ID of the channel

func (*CelerClient) NewAppChannelOnVirtualContract

func (c *CelerClient) NewAppChannelOnVirtualContract(
	byteCode []byte,
	constructor []byte,
	nonce uint64,
	onchainTimeout uint64,
	sc common.StateCallback) (string, error)

NewAppChannelOnVirtualContract initializes a generalized state channel with a virtual contract It returns the virtual address of the channel

func (*CelerClient) OnChainApplyAppChannelAction

func (c *CelerClient) OnChainApplyAppChannelAction(cid string, action []byte) error

OnChainApplyAppChannelAction applies onchain action to a app channel

func (*CelerClient) OnChainFinalizeAppChannelOnActionTimeout

func (c *CelerClient) OnChainFinalizeAppChannelOnActionTimeout(cid string) error

OnChainFinalizeAppChannelOnActionTimeout finalizes a app channel on action timeout

func (*CelerClient) OnChainGetAppChannelActionDeadline

func (c *CelerClient) OnChainGetAppChannelActionDeadline(cid string) (uint64, error)

OnChainGetAppChannelActionDeadline gets the onchain action deadline

func (*CelerClient) OnChainGetAppChannelBooleanOutcome

func (c *CelerClient) OnChainGetAppChannelBooleanOutcome(cid string, query []byte) (bool, bool, error)

OnChainGetAppChannelBooleanOutcome returns 1: isFinalized(cid), 2: getOutcome(query), 3: error

func (*CelerClient) OnChainGetAppChannelSeqNum

func (c *CelerClient) OnChainGetAppChannelSeqNum(cid string) (uint64, error)

OnChainGetAppChannelSeqNum gets the onchain sequence number

func (*CelerClient) OnChainGetAppChannelSettleFinalizedTime

func (c *CelerClient) OnChainGetAppChannelSettleFinalizedTime(cid string) (uint64, error)

OnChainGetAppChannelSettleFinalizedTime gets the onchain settle finalized time

func (*CelerClient) OnChainGetAppChannelState

func (c *CelerClient) OnChainGetAppChannelState(cid string, key *big.Int) ([]byte, error)

OnChainGetAppChannelState gets the onchain app state associated with the given key

func (*CelerClient) OnChainGetAppChannelStatus

func (c *CelerClient) OnChainGetAppChannelStatus(cid string) (uint8, error)

OnChainGetAppChannelStatus gets the onchain status (0:IDLE, 1:SETTLE, 2:ACTION, 3:FINALIZED)

func (*CelerClient) OnReceivingToken

func (c *CelerClient) OnReceivingToken(callback event.OnReceivingTokenCallback)

func (*CelerClient) OnSendingToken

func (c *CelerClient) OnSendingToken(callback event.OnSendingTokenCallback)

func (*CelerClient) OpenChannel

func (c *CelerClient) OpenChannel(
	token *entity.TokenInfo, myAmt, peerAmt *big.Int, appcb clientCallbackAdapter) error

TODO: if we ever want to enforce only one openchannel request is pending, we can trylock and unlock in cb

func (*CelerClient) RegisterStream

func (c *CelerClient) RegisterStream() error

RegisterStream establishes gRPC streaming connections with OSP

func (*CelerClient) RejectBooleanPay

func (c *CelerClient) RejectBooleanPay(payID ctype.PayIDType) error

func (*CelerClient) RemoveCooperativeWithdrawJob

func (c *CelerClient) RemoveCooperativeWithdrawJob(withdrawHash string)

func (*CelerClient) RemoveDepositJob

func (c *CelerClient) RemoveDepositJob(jobID string)

func (*CelerClient) RequestSgnGuardState

func (c *CelerClient) RequestSgnGuardState(token *entity.TokenInfo) error

func (*CelerClient) ResolveCondPayOnChain

func (c *CelerClient) ResolveCondPayOnChain(payID ctype.PayIDType) error

ResolveCondPayOnChain tries to resolve a payment onchain in the PayRegistry

func (*CelerClient) SetDelegation

func (c *CelerClient) SetDelegation(tokens []*entity.TokenInfo, timeout int64) error

func (*CelerClient) SetMsgDropper

func (c *CelerClient) SetMsgDropper(dropRecv, dropSend bool)

func (*CelerClient) SettleAppChannel

func (c *CelerClient) SettleAppChannel(cid string, stateproof []byte) error

SettleAppChannel tries to settle a app channel onchain

func (*CelerClient) SettleAppChannelByInvalidState

func (c *CelerClient) SettleAppChannelByInvalidState(cid string, oracleProof []byte, cosignedStateProof []byte) error

SettleAppChannelByInvalidState settle an app channel due to invalid state

func (*CelerClient) SettleAppChannelByInvalidTurn

func (c *CelerClient) SettleAppChannelByInvalidTurn(cid string, oracleProof []byte, cosignedStateProof []byte) error

SettleAppChannelByInvalidTurn settle an app channel due to invalid turn

func (*CelerClient) SettleAppChannelByMoveTimeout

func (c *CelerClient) SettleAppChannelByMoveTimeout(cid string, oracleProof []byte) error

SettleAppChannelByMoveTimeout settle an app channel due to movement timeout

func (*CelerClient) SettleAppChannelBySigTimeout

func (c *CelerClient) SettleAppChannelBySigTimeout(cid string, oracleProof []byte) error

SettleAppChannelBySigTimeout settle an app channel due to signature timeout

func (*CelerClient) SettleExpiredPays

func (c *CelerClient) SettleExpiredPays(token *entity.TokenInfo) error

func (*CelerClient) SettleOnChainResolvedPay

func (c *CelerClient) SettleOnChainResolvedPay(payID ctype.PayIDType) error

func (*CelerClient) SignAppState

func (c *CelerClient) SignAppState(cid string, seqNum uint64, state []byte) ([]byte, []byte, error)

SignAppState returns 1: proto serialized app state, 2: signature, 3: error

func (*CelerClient) SignState

func (c *CelerClient) SignState(in []byte) []byte

func (*CelerClient) SyncOnChainChannelStates

func (c *CelerClient) SyncOnChainChannelStates(token *entity.TokenInfo) error

func (*CelerClient) TcbOpenChannel

func (c *CelerClient) TcbOpenChannel(
	token *entity.TokenInfo, peerAmt *big.Int, appcb clientCallbackAdapter) error

func (*CelerClient) VetoWithdraw

func (c *CelerClient) VetoWithdraw(token *entity.TokenInfo) error

Jump to

Keyboard shortcuts

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