Documentation
¶
Index ¶
- type CelerClient
- func (c *CelerClient) AddBooleanPay(xfer *entity.TokenTransfer, conds []*entity.Condition, resolveDeadline uint64, ...) (ctype.PayIDType, error)
- func (c *CelerClient) ClearCallbacks()
- func (c *CelerClient) Close()
- func (c *CelerClient) ConfirmBooleanPay(payID ctype.PayIDType) error
- func (c *CelerClient) ConfirmOnChainResolvedPays(token *entity.TokenInfo) error
- func (c *CelerClient) ConfirmSettlePaymentChannel(token *entity.TokenInfo) error
- func (c *CelerClient) ConfirmWithdraw(token *entity.TokenInfo) error
- func (c *CelerClient) CooperativeWithdraw(tokenAddr ctype.Addr, amount *big.Int, callback cooperativewithdraw.Callback) (string, error)
- func (c *CelerClient) DeleteAppChannel(cid string)
- func (c *CelerClient) Deposit(tokenAddr ctype.Addr, amt *big.Int, cb deposit.DepositCallback) (string, error)
- func (c *CelerClient) GetAllPayments() ([]*celersdkintf.Payment, error)
- func (c *CelerClient) GetAppChannelDeployedAddr(cid string) (ctype.Addr, error)
- func (c *CelerClient) GetBalance(cid ctype.CidType) (*common.ChannelBalance, error)
- func (c *CelerClient) GetChannelState(tkAddr ctype.Addr) string
- func (c *CelerClient) GetCondPayInfoFromRegistry(payID ctype.PayIDType) (*big.Int, uint64, error)
- func (c *CelerClient) GetCurrentBlockNumber() *big.Int
- func (c *CelerClient) GetCurrentBlockNumberUint64() uint64
- func (c *CelerClient) GetDAL() *storage.DAL
- func (c *CelerClient) GetFeeMgrEth() string
- func (c *CelerClient) GetIncomingPaymentStatus(payID ctype.PayIDType) int
- func (c *CelerClient) GetMyEthAddr() ctype.Addr
- func (c *CelerClient) GetOutgoingPaymentStatus(payID ctype.PayIDType) int
- func (c *CelerClient) GetPayment(payID ctype.PayIDType) (*celersdkintf.Payment, error)
- func (c *CelerClient) GetRpcClientToOsp() (rpc.RpcClient, error)
- func (c *CelerClient) GetSettleFinalizedTime(token *entity.TokenInfo) (*big.Int, error)
- func (c *CelerClient) GetSgnGuardRequest(token *entity.TokenInfo) (*cnode.SgnRequest, error)
- func (c *CelerClient) GetSgnSubscription() (*cnode.SgnSubscription, error)
- func (c *CelerClient) GetTokenBalance(tokenAddr ctype.Addr) (*big.Int, *big.Int, *big.Int, error)
- func (r *CelerClient) HandleDestinationUnreachable(payID ctype.PayIDType, pay *entity.ConditionalPay, note *anypb.Any)
- func (c *CelerClient) HandleReceivingDone(payID ctype.PayIDType, pay *entity.ConditionalPay, note *anypb.Any, ...)
- func (c *CelerClient) HandleReceivingStart(payID ctype.PayIDType, pay *entity.ConditionalPay, note *anypb.Any)
- func (r *CelerClient) HandleSendComplete(payID ctype.PayIDType, pay *entity.ConditionalPay, note *anypb.Any, ...)
- func (r *CelerClient) HandleSendFail(payID ctype.PayIDType, pay *entity.ConditionalPay, note *anypb.Any, ...)
- func (c *CelerClient) HasPendingOpenChanRequest(tk *entity.TokenInfo) bool
- func (c *CelerClient) InstantiateChannelForToken(token *entity.TokenInfo, appcb clientCallbackAdapter) error
- func (c *CelerClient) IntendSettlePaymentChannel(token *entity.TokenInfo) error
- func (c *CelerClient) IntendWithdraw(token *entity.TokenInfo, amount *big.Int) error
- func (c *CelerClient) IsConnectedToCeler(tokenaddr string, addr string) (rpc.JoinCelerStatus, string, error)
- func (c *CelerClient) MonitorCooperativeWithdrawJob(withdrawHash string, callback cooperativewithdraw.Callback)
- func (c *CelerClient) MonitorDepositJob(jobID string, cb deposit.DepositCallback)
- func (c *CelerClient) MyAddress() ctype.Addr
- func (c *CelerClient) NewAppChannelOnVirtualContract(byteCode []byte, constructor []byte, nonce uint64) (string, error)
- func (c *CelerClient) OnChainGetAppChannelBooleanOutcome(cid string, query []byte) (bool, bool, error)
- func (c *CelerClient) OnReceivingToken(callback event.OnReceivingTokenCallback)
- func (c *CelerClient) OnSendingToken(callback event.OnSendingTokenCallback)
- func (c *CelerClient) OpenChannel(token *entity.TokenInfo, myAmt, peerAmt *big.Int, appcb clientCallbackAdapter) error
- func (c *CelerClient) RegisterStream() error
- func (c *CelerClient) RejectBooleanPay(payID ctype.PayIDType) error
- func (c *CelerClient) RemoveCooperativeWithdrawJob(withdrawHash string)
- func (c *CelerClient) RemoveDepositJob(jobID string)
- func (c *CelerClient) RequestSgnGuardState(token *entity.TokenInfo) error
- func (c *CelerClient) ResolveCondPayOnChain(payID ctype.PayIDType) error
- func (c *CelerClient) SetDelegation(tokens []*entity.TokenInfo, timeout int64) error
- func (c *CelerClient) SetMsgDropper(dropRecv, dropSend bool)
- func (c *CelerClient) SettleExpiredPays(token *entity.TokenInfo) error
- func (c *CelerClient) SettleOnChainResolvedPay(payID ctype.PayIDType) error
- func (c *CelerClient) SignState(in []byte) []byte
- func (c *CelerClient) SyncOnChainChannelStates(token *entity.TokenInfo) error
- func (c *CelerClient) TcbOpenChannel(token *entity.TokenInfo, peerAmt *big.Int, appcb clientCallbackAdapter) error
- func (c *CelerClient) VetoWithdraw(token *entity.TokenInfo) error
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 (*CelerClient) AddBooleanPay ¶
func (c *CelerClient) AddBooleanPay( xfer *entity.TokenTransfer, conds []*entity.Condition, resolveDeadline uint64, note *anypb.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)
DeleteAppChannel removes the registered virtual condition contract from the cnode's in-memory bookkeeping. Does not touch on-chain state.
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) GetAppChannelDeployedAddr ¶
func (c *CelerClient) GetAppChannelDeployedAddr(cid string) (ctype.Addr, error)
GetAppChannelDeployedAddr returns the on-chain deployed address of a registered virtual condition contract, probing the virt-resolver if needed. Returns an error if the contract has not been deployed yet.
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 (*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 (*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 ¶
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 *anypb.Any)
func (*CelerClient) HandleReceivingDone ¶
func (c *CelerClient) HandleReceivingDone( payID ctype.PayIDType, pay *entity.ConditionalPay, note *anypb.Any, reason rpc.PaymentSettleReason)
func (*CelerClient) HandleReceivingStart ¶
func (c *CelerClient) HandleReceivingStart(payID ctype.PayIDType, pay *entity.ConditionalPay, note *anypb.Any)
func (*CelerClient) HandleSendComplete ¶
func (r *CelerClient) HandleSendComplete( payID ctype.PayIDType, pay *entity.ConditionalPay, note *anypb.Any, reason rpc.PaymentSettleReason)
func (*CelerClient) HandleSendFail ¶
func (r *CelerClient) HandleSendFail(payID ctype.PayIDType, pay *entity.ConditionalPay, note *anypb.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 (*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) NewAppChannelOnVirtualContract ¶
func (c *CelerClient) NewAppChannelOnVirtualContract( byteCode []byte, constructor []byte, nonce uint64) (string, error)
NewAppChannelOnVirtualContract registers a VIRTUAL_CONTRACT condition contract on the cnode and returns its deterministic virtual-contract address (used as the session id / Condition.OnChainAddress for VIRTUAL_CONTRACT pays). The bytecode + constructor + nonce are stored so the contract can be deployed on-chain on demand (e.g. on dispute or during outcome query).
func (*CelerClient) OnChainGetAppChannelBooleanOutcome ¶
func (c *CelerClient) OnChainGetAppChannelBooleanOutcome(cid string, query []byte) (bool, bool, error)
OnChainGetAppChannelBooleanOutcome queries IBooleanCond.{isFinalized, getOutcome} on the registered condition contract. For VIRTUAL_CONTRACT this triggers deploy-on-query: if the virtual contract has not been deployed yet, this call submits a deployment transaction first.
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) SettleExpiredPays ¶
func (c *CelerClient) SettleExpiredPays(token *entity.TokenInfo) error
func (*CelerClient) SettleOnChainResolvedPay ¶
func (c *CelerClient) SettleOnChainResolvedPay(payID ctype.PayIDType) 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 (*CelerClient) VetoWithdraw ¶
func (c *CelerClient) VetoWithdraw(token *entity.TokenInfo) error