Versions in this module Expand all Collapse all v1 v1.2.0 Mar 8, 2026 Changes in this version + const ChannelHubVersion + const INTENT_CLOSE + const INTENT_DEPOSIT + const INTENT_FINALIZE_ESCROW_DEPOSIT + const INTENT_FINALIZE_ESCROW_WITHDRAWAL + const INTENT_FINALIZE_MIGRATION + const INTENT_INITIATE_ESCROW_DEPOSIT + const INTENT_INITIATE_ESCROW_WITHDRAWAL + const INTENT_INITIATE_MIGRATION + const INTENT_OPERATE + const INTENT_WITHDRAW + var ChannelSignerTypes = []ChannelSignerType + func BuildSigValidatorsBitmap(signerTypes []ChannelSignerType) string + func DecimalToBigInt(amount decimal.Decimal, decimals uint8) (*big.Int, error) + func GenerateChannelMetadata(asset string) [32]byte + func GenerateSessionKeyStateIDV1(userAddress, sessionKey string, version uint64) (string, error) + func GetChannelSessionKeyAuthMetadataHashV1(version uint64, assets []string, expiresAt int64) (common.Hash, error) + func GetEscrowChannelID(homeChannelID string, stateVersion uint64) (string, error) + func GetHomeChannelID(node, user, asset string, nonce uint64, challengeDuration uint32, ...) (string, error) + func GetReceiverTransactionID(fromAccount, receiverNewStateID string) (string, error) + func GetSenderTransactionID(toAccount string, senderNewStateID string) (string, error) + func GetStateID(userWallet, asset string, epoch, version uint64) string + func GetStateTransitionHash(transition Transition) ([32]byte, error) + func IsChannelSignerSupported(approvedSigValidators string, signerType ChannelSignerType) bool + func PackChallengeState(state State, assetStore AssetStore) ([]byte, error) + func PackChannelKeyStateV1(sessionKey string, metadataHash common.Hash) ([]byte, error) + func PackState(state State, assetStore AssetStore) ([]byte, error) + func SignerValidatorsSupported(channelValidators string) bool + func TransitionToIntent(transition Transition) uint8 + func ValidateChannelSessionKeyAuthSigV1(state ChannelSessionKeyStateV1) error + func ValidateDecimalPrecision(amount decimal.Decimal, maxDecimals uint8) error + type ActionAllowance struct + Allowance uint64 + GatedAction GatedAction + TimeWindow string + Used uint64 + type AppRegistryClient interface + ApproveToken func(amount decimal.Decimal) (string, error) + GetBalance func(user string) (decimal.Decimal, error) + GetTokenDecimals func() (uint8, error) + Lock func(targetWallet string, amount decimal.Decimal) (string, error) + Relock func() (string, error) + Unlock func() (string, error) + Withdraw func(destinationWallet string) (string, error) + type Asset struct + Decimals uint8 + Name string + SuggestedBlockchainID uint64 + Symbol string + Tokens []Token + type AssetStore interface + GetAssetDecimals func(asset string) (uint8, error) + GetTokenDecimals func(blockchainID uint64, tokenAddress string) (uint8, error) + type BalanceEntry struct + Asset string + Balance decimal.Decimal + type Blockchain struct + BlockStep uint64 + ChannelHubAddress string + ID uint64 + LockingContractAddress string + Name string + type BlockchainClient interface + Approve func(asset string, amount decimal.Decimal) (string, error) + Challenge func(candidate State, challengerSig []byte, challengerIdx ChannelParticipant) (string, error) + ChallengeEscrowDeposit func(candidate State, challengerSig []byte, challengerIdx ChannelParticipant) (string, error) + ChallengeEscrowWithdrawal func(candidate State, challengerSig []byte, challengerIdx ChannelParticipant) (string, error) + Checkpoint func(candidate State) (string, error) + Close func(candidate State) (string, error) + Create func(def ChannelDefinition, initCCS State) (string, error) + Deposit func(node, token string, amount decimal.Decimal) (string, error) + EnsureSigValidatorRegistered func(validatorID uint8, validatorAddress string, checkOnly bool) error + FinalizeEscrowDeposit func(candidate State) (string, error) + FinalizeEscrowWithdrawal func(candidate State) (string, error) + GetAccountsBalances func(accounts []string, tokens []string) ([][]decimal.Decimal, error) + GetEscrowDepositData func(escrowChannelID string) (EscrowDepositDataResponse, error) + GetEscrowWithdrawalData func(escrowChannelID string) (EscrowWithdrawalDataResponse, error) + GetHomeChannelData func(homeChannelID string) (HomeChannelDataResponse, error) + GetNodeBalance func(token string) (decimal.Decimal, error) + GetOpenChannels func(user string) ([]string, error) + GetTokenBalance func(asset string, walletAddress string) (decimal.Decimal, error) + InitiateEscrowDeposit func(def ChannelDefinition, initCCS State) (string, error) + InitiateEscrowWithdrawal func(def ChannelDefinition, initCCS State) (string, error) + MigrateChannelHere func(def ChannelDefinition, candidate State) (string, error) + Withdraw func(node, token string, amount decimal.Decimal) (string, error) + type BlockchainEvent struct + BlockNumber uint64 + BlockchainID uint64 + ContractAddress string + LogIndex uint32 + Name string + TransactionHash string + type Channel struct + ApprovedSigValidators string + Asset string + BlockchainID uint64 + ChallengeDuration uint32 + ChallengeExpiresAt *time.Time + ChannelID string + Nonce uint64 + StateVersion uint64 + Status ChannelStatus + TokenAddress string + Type ChannelType + UserWallet string + func NewChannel(channelID, userWallet, asset string, ChType ChannelType, blockchainID uint64, ...) *Channel + type ChannelDefaultSigner struct + func NewChannelDefaultSigner(signer sign.Signer) (*ChannelDefaultSigner, error) + func (s *ChannelDefaultSigner) Sign(data []byte) (sign.Signature, error) + func (s *ChannelDefaultSigner) Type() ChannelSignerType + type ChannelDefinition struct + ApprovedSigValidators string + Challenge uint32 + Nonce uint64 + type ChannelHubEventHandler interface + HandleEscrowDepositChallenged func(context.Context, *EscrowDepositChallengedEvent) error + HandleEscrowDepositFinalized func(context.Context, *EscrowDepositFinalizedEvent) error + HandleEscrowDepositInitiated func(context.Context, *EscrowDepositInitiatedEvent) error + HandleEscrowWithdrawalChallenged func(context.Context, *EscrowWithdrawalChallengedEvent) error + HandleEscrowWithdrawalFinalized func(context.Context, *EscrowWithdrawalFinalizedEvent) error + HandleEscrowWithdrawalInitiated func(context.Context, *EscrowWithdrawalInitiatedEvent) error + HandleHomeChannelChallenged func(context.Context, *HomeChannelChallengedEvent) error + HandleHomeChannelCheckpointed func(context.Context, *HomeChannelCheckpointedEvent) error + HandleHomeChannelClosed func(context.Context, *HomeChannelClosedEvent) error + HandleHomeChannelCreated func(context.Context, *HomeChannelCreatedEvent) error + HandleHomeChannelMigrated func(context.Context, *HomeChannelMigratedEvent) error + type ChannelParticipant uint8 + var ChannelParticipantNode ChannelParticipant = 1 + var ChannelParticipantUser ChannelParticipant = 0 + type ChannelSessionKeySignerV1 struct + func NewChannelSessionKeySignerV1(signer sign.Signer, metadataHash, authSig string) (*ChannelSessionKeySignerV1, error) + func (s *ChannelSessionKeySignerV1) Sign(data []byte) (sign.Signature, error) + func (s *ChannelSessionKeySignerV1) Type() ChannelSignerType + type ChannelSessionKeyStateV1 struct + Assets []string + ExpiresAt time.Time + SessionKey string + UserAddress string + UserSig string + Version uint64 + type ChannelSigValidator struct + func NewChannelSigValidator(permissionsVerifier VerifyChannelSessionKePermissionsV1) *ChannelSigValidator + func (s *ChannelSigValidator) Recover(data, sig []byte) (string, error) + func (s *ChannelSigValidator) Verify(wallet string, data, sig []byte) error + type ChannelSigner interface + Type func() ChannelSignerType + type ChannelSignerType uint8 + const ChannelSignerType_Default + const ChannelSignerType_SessionKey + func GetSignerType(sig []byte) (ChannelSignerType, error) + func (t ChannelSignerType) String() string + type ChannelStatus uint8 + var ChannelStatusChallenged ChannelStatus = 2 + var ChannelStatusClosed ChannelStatus = 3 + var ChannelStatusOpen ChannelStatus = 1 + var ChannelStatusVoid ChannelStatus = 0 + func (s *ChannelStatus) Scan(src any) error + func (s ChannelStatus) String() string + type ChannelType uint8 + var ChannelTypeEscrow ChannelType = 2 + var ChannelTypeHome ChannelType = 1 + type EscrowDepositChallengedEvent channelChallengedEvent + type EscrowDepositDataResponse struct + ChallengeExpiry uint64 + EscrowChannelID string + LastState State + Node string + UnlockExpiry uint64 + type EscrowDepositFinalizedEvent channelEvent + type EscrowDepositInitiatedEvent channelEvent + type EscrowWithdrawalChallengedEvent channelChallengedEvent + type EscrowWithdrawalDataResponse struct + EscrowChannelID string + LastState State + Node string + type EscrowWithdrawalFinalizedEvent channelEvent + type EscrowWithdrawalInitiatedEvent channelEvent + type GatedAction string + var GatedActionAppSessionCreation GatedAction = "app_session_creation" + var GatedActionAppSessionDeposit GatedAction = "app_session_deposit" + var GatedActionAppSessionOperation GatedAction = "app_session_operation" + var GatedActionAppSessionWithdrawal GatedAction = "app_session_withdrawal" + var GatedActionTransfer GatedAction = "transfer" + func GatedActionFromID(id uint8) (GatedAction, bool) + func (g GatedAction) ID() uint8 + type HomeChannelChallengedEvent channelChallengedEvent + type HomeChannelCheckpointedEvent channelEvent + type HomeChannelClosedEvent channelEvent + type HomeChannelCreatedEvent channelEvent + type HomeChannelDataResponse struct + ChallengeExpiry uint64 + Definition ChannelDefinition + LastState State + Node string + type HomeChannelMigratedEvent channelEvent + type Ledger struct + BlockchainID uint64 + NodeBalance decimal.Decimal + NodeNetFlow decimal.Decimal + TokenAddress string + UserBalance decimal.Decimal + UserNetFlow decimal.Decimal + func (l Ledger) Validate() error + func (l1 Ledger) Equal(l2 Ledger) error + type LockingContractEventHandler interface + HandleUserLockedBalanceUpdated func(context.Context, *UserLockedBalanceUpdatedEvent) error + type NodeConfig struct + Blockchains []Blockchain + NodeAddress string + NodeVersion string + SupportedSigValidators []ChannelSignerType + type PaginationMetadata struct + Page uint32 + PageCount uint32 + PerPage uint32 + TotalCount uint32 + type PaginationParams struct + Limit *uint32 + Offset *uint32 + Sort *string + func (p *PaginationParams) GetOffsetAndLimit(defaultLimit, maxLimit uint32) (offset, limit uint32) + type State struct + Asset string + Epoch uint64 + EscrowChannelID *string + EscrowLedger *Ledger + HomeChannelID *string + HomeLedger Ledger + ID string + NodeSig *string + Transition Transition + UserSig *string + UserWallet string + Version uint64 + func NewVoidState(asset, userWallet string) *State + func (state *State) ApplyAcknowledgementTransition() (Transition, error) + func (state *State) ApplyChannelCreation(channelDef ChannelDefinition, blockchainID uint64, ...) (string, error) + func (state *State) ApplyCommitTransition(accountID string, amount decimal.Decimal) (Transition, error) + func (state *State) ApplyEscrowDepositTransition(amount decimal.Decimal) (Transition, error) + func (state *State) ApplyEscrowLockTransition(blockchainID uint64, tokenAddress string, amount decimal.Decimal) (Transition, error) + func (state *State) ApplyEscrowWithdrawTransition(amount decimal.Decimal) (Transition, error) + func (state *State) ApplyFinalizeTransition() (Transition, error) + func (state *State) ApplyHomeDepositTransition(amount decimal.Decimal) (Transition, error) + func (state *State) ApplyHomeWithdrawalTransition(amount decimal.Decimal) (Transition, error) + func (state *State) ApplyMigrateTransition(amount decimal.Decimal) (Transition, error) + func (state *State) ApplyMutualLockTransition(blockchainID uint64, tokenAddress string, amount decimal.Decimal) (Transition, error) + func (state *State) ApplyReleaseTransition(accountID string, amount decimal.Decimal) (Transition, error) + func (state *State) ApplyTransferReceiveTransition(sender string, amount decimal.Decimal, txID string) (Transition, error) + func (state *State) ApplyTransferSendTransition(recipient string, amount decimal.Decimal) (Transition, error) + func (state *State) IsFinal() bool + func (state State) NextState() *State + type StateAdvancer interface + ValidateAdvancement func(currentState, proposedState State) error + type StateAdvancerV1 struct + func NewStateAdvancerV1(assetStore AssetStore) *StateAdvancerV1 + func (v *StateAdvancerV1) ValidateAdvancement(currentState, proposedState State) error + type StatePacker interface + PackState func(state State) ([]byte, error) + type StatePackerV1 struct + func NewStatePackerV1(assetStore AssetStore) *StatePackerV1 + func (p *StatePackerV1) PackChallengeState(state State) ([]byte, error) + func (p *StatePackerV1) PackState(state State) ([]byte, error) + type Token struct + Address string + BlockchainID uint64 + Decimals uint8 + Name string + Symbol string + type Transaction struct + Amount decimal.Decimal + Asset string + CreatedAt time.Time + FromAccount string + ID string + ReceiverNewStateID *string + SenderNewStateID *string + ToAccount string + TxType TransactionType + func NewTransaction(id, asset string, txType TransactionType, fromAccount, toAccount string, ...) *Transaction + func NewTransactionFromTransition(senderState *State, receiverState *State, transition Transition) (*Transaction, error) + type TransactionType uint8 + const TransactionTypeCommit + const TransactionTypeEscrowDeposit + const TransactionTypeEscrowLock + const TransactionTypeEscrowWithdraw + const TransactionTypeFinalize + const TransactionTypeHomeDeposit + const TransactionTypeHomeWithdrawal + const TransactionTypeMigrate + const TransactionTypeMutualLock + const TransactionTypeRebalance + const TransactionTypeRelease + const TransactionTypeTransfer + func (t TransactionType) String() string + type Transition struct + AccountID string + Amount decimal.Decimal + TxID string + Type TransitionType + func NewTransition(transitionType TransitionType, txID, accountID string, amount decimal.Decimal) *Transition + func (t1 Transition) Equal(t2 Transition) error + type TransitionType uint8 + const TransitionTypeAcknowledgement + const TransitionTypeCommit + const TransitionTypeEscrowDeposit + const TransitionTypeEscrowLock + const TransitionTypeEscrowWithdraw + const TransitionTypeFinalize + const TransitionTypeHomeDeposit + const TransitionTypeHomeWithdrawal + const TransitionTypeMigrate + const TransitionTypeMutualLock + const TransitionTypeRelease + const TransitionTypeTransferReceive + const TransitionTypeTransferSend + const TransitionTypeVoid + func (t TransitionType) GatedAction() GatedAction + func (t TransitionType) String() string + type UserLockedBalanceUpdatedEvent struct + Balance decimal.Decimal + BlockchainID uint64 + UserAddress string + type VerifyChannelSessionKePermissionsV1 func(walletAddr, sessionKeyAddr, metadataHash string) (bool, error)