Documentation ¶
Overview ¶
Package channel contains all relevant components to generate, utilize and conclude payment channels on the Stellar blockchain. These main components consist of the Funder and Adjudicator interfaces that govern the interaction between the channel users. Additionally, the AdjEventSub interface processes the emitted events from the Soroban smart contracts, using the interfaces from go-perun.
Index ¶
- Constants
- Variables
- func AssembleCreateContractOp(sourceAccount string, wasmFileName string, contractSalt string, ...) *txnbuild.InvokeHostFunction
- func AssembleInstallContractCodeOp(sourceAccount string, wasmFileName string) *txnbuild.InvokeHostFunction
- func BuildCloseTxArgs(state pchannel.State, sigs []pwallet.Sig) (xdr.ScVec, error)
- func BuildDisputeTxArgs(state pchannel.State, sigs []pwallet.Sig) (xdr.ScVec, error)
- func EncodeState(state *channel.State) ([]byte, error)
- func GetChannelBoolFromEvents(evData xdr.ScVal) (wire.Channel, bool, error)
- func GetChannelFromEvents(evData xdr.ScVal) (wire.Channel, error)
- func IdenticalControls(controlCurr, controlNext wire.Control) bool
- func MakeTime(challDurSec uint64) time.Duration
- type AdjEvent
- type AdjEventSub
- type Adjudicator
- func (a *Adjudicator) BuildWithdrawTxArgs(req pchannel.AdjudicatorReq) (xdr.ScVec, error)
- func (a *Adjudicator) Close(ctx context.Context, id pchannel.ID, state *pchannel.State, sigs []pwallet.Sig) error
- func (a *Adjudicator) Dispute(ctx context.Context, state *pchannel.State, sigs []pwallet.Sig) error
- func (a *Adjudicator) ForceClose(ctx context.Context, id pchannel.ID, state *pchannel.State, sigs []pwallet.Sig, ...) error
- func (a *Adjudicator) GetAssetID() xdr.ScAddress
- func (a *Adjudicator) GetChannelState(ctx context.Context, state *pchannel.State) (wire.Channel, error)
- func (a *Adjudicator) GetPerunID() xdr.ScAddress
- func (a Adjudicator) Progress(ctx context.Context, req pchannel.ProgressReq) error
- func (a *Adjudicator) Register(ctx context.Context, req pchannel.AdjudicatorReq, ...) error
- func (a *Adjudicator) Subscribe(ctx context.Context, cid pchannel.ID) (pchannel.AdjudicatorSubscription, error)
- func (a *Adjudicator) Withdraw(ctx context.Context, req pchannel.AdjudicatorReq, smap pchannel.StateMap) error
- type CloseEvent
- type DisputedEvent
- type Event
- type EventType
- type ExpiredTimeout
- type FundEvent
- type Funder
- func (f *Funder) AbortChannel(ctx context.Context, params *pchannel.Params, state *pchannel.State) error
- func (f *Funder) Fund(ctx context.Context, req pchannel.FundingReq) error
- func (f *Funder) FundChannel(ctx context.Context, params *pchannel.Params, state *pchannel.State, ...) error
- func (f *Funder) GetAssetID() xdr.ScAddress
- func (f *Funder) GetChannelState(ctx context.Context, params *pchannel.Params, state *pchannel.State) (wire.Channel, error)
- func (f *Funder) GetPerunID() xdr.ScAddress
- func (f *Funder) OpenChannel(ctx context.Context, params *pchannel.Params, state *pchannel.State) error
- type OpenEvent
- type PerunEvent
- type StellarEvent
- type TimePoint
- type Timeout
- type Version
- type WithdrawnEvent
- func (e *WithdrawnEvent) EventDataFromChannel(chanState wire.Channel, timestamp uint64) error
- func (e *WithdrawnEvent) GetChannel() wire.Channel
- func (e *WithdrawnEvent) ID() pchannel.ID
- func (e *WithdrawnEvent) Timeout() pchannel.Timeout
- func (e WithdrawnEvent) Tstamp() uint64
- func (e *WithdrawnEvent) Version() Version
Constants ¶
const ( DefaultBufferSize = 1024 DefaultSubscriptionPollingInterval = time.Duration(5) * time.Second )
const AssertPerunSymbol = "perun"
const DefaultPollingInterval = time.Duration(6) * time.Second
const DefaultTimeoutPollInterval = 1 * time.Second
DefaultTimeoutPollInterval default value for the PollInterval of a Timeout.
const MaxIterationsUntilAbort = 20
const PerunContractPath = "../testdata/perun_soroban_contract.wasm"
Variables ¶
var ( STELLAR_PERUN_CHANNEL_CONTRACT_TOPICS = map[xdr.ScSymbol]EventType{ xdr.ScSymbol("open"): EventTypeOpen, xdr.ScSymbol("fund"): EventTypeFundChannel, xdr.ScSymbol("fund_c"): EventTypeFundedChannel, xdr.ScSymbol("closed"): EventTypeClosed, xdr.ScSymbol("withdraw"): EventTypeWithdrawing, xdr.ScSymbol("pay_c"): EventTypeWithdrawn, xdr.ScSymbol("f_closed"): EventTypeForceClosed, xdr.ScSymbol("dispute"): EventTypeDisputed, } ErrNotStellarPerunContract = errors.New("event was not from a Perun payment channel contract") ErrEventUnsupported = errors.New("this type of event is unsupported") ErrEventIntegrity = errors.New("contract ID does not match payment channel + passphrase") )
var Backend = backend{}
var ErrChannelAlreadyClosed = errors.New("channel is already closed")
Functions ¶
func AssembleInstallContractCodeOp ¶
func AssembleInstallContractCodeOp(sourceAccount string, wasmFileName string) *txnbuild.InvokeHostFunction
func BuildCloseTxArgs ¶
func BuildDisputeTxArgs ¶
func IdenticalControls ¶
Types ¶
type AdjEvent ¶
type AdjEventSub ¶
type AdjEventSub struct {
// contains filtered or unexported fields
}
AdjudicatorSub implements the AdjudicatorSubscription interface.
func NewAdjudicatorSub ¶
func (*AdjEventSub) Close ¶
func (s *AdjEventSub) Close() error
func (*AdjEventSub) Err ¶
func (s *AdjEventSub) Err() error
func (*AdjEventSub) GetChannelState ¶
func (*AdjEventSub) Next ¶
func (s *AdjEventSub) Next() pchannel.AdjudicatorEvent
type Adjudicator ¶
type Adjudicator struct {
// contains filtered or unexported fields
}
func NewAdjudicator ¶
func NewAdjudicator(acc *wallet.Account, stellarClient *env.StellarClient, perunID xdr.ScAddress, assetID xdr.ScAddress) *Adjudicator
func (*Adjudicator) BuildWithdrawTxArgs ¶
func (a *Adjudicator) BuildWithdrawTxArgs(req pchannel.AdjudicatorReq) (xdr.ScVec, error)
func (*Adjudicator) ForceClose ¶
func (*Adjudicator) GetAssetID ¶
func (a *Adjudicator) GetAssetID() xdr.ScAddress
func (*Adjudicator) GetChannelState ¶
func (*Adjudicator) GetPerunID ¶
func (a *Adjudicator) GetPerunID() xdr.ScAddress
func (Adjudicator) Progress ¶
func (a Adjudicator) Progress(ctx context.Context, req pchannel.ProgressReq) error
func (*Adjudicator) Register ¶
func (a *Adjudicator) Register(ctx context.Context, req pchannel.AdjudicatorReq, states []pchannel.SignedState) error
Register registers and disputes a channel.
func (*Adjudicator) Subscribe ¶
func (a *Adjudicator) Subscribe(ctx context.Context, cid pchannel.ID) (pchannel.AdjudicatorSubscription, error)
func (*Adjudicator) Withdraw ¶
func (a *Adjudicator) Withdraw(ctx context.Context, req pchannel.AdjudicatorReq, smap pchannel.StateMap) error
type CloseEvent ¶
func (*CloseEvent) EventDataFromChannel ¶
func (e *CloseEvent) EventDataFromChannel(chanState wire.Channel, timestamp uint64) error
func (*CloseEvent) GetChannel ¶
func (e *CloseEvent) GetChannel() wire.Channel
func (*CloseEvent) ID ¶
func (e *CloseEvent) ID() pchannel.ID
func (*CloseEvent) Timeout ¶
func (e *CloseEvent) Timeout() pchannel.Timeout
func (*CloseEvent) Tstamp ¶
func (e *CloseEvent) Tstamp() uint64
func (*CloseEvent) Version ¶
func (e *CloseEvent) Version() Version
type DisputedEvent ¶
type DisputedEvent struct { Channel wire.Channel IDV pchannel.ID VersionV Version Timestamp uint64 }
func (*DisputedEvent) EventDataFromChannel ¶
func (e *DisputedEvent) EventDataFromChannel(chanState wire.Channel, timestamp uint64) error
func (*DisputedEvent) ID ¶
func (e *DisputedEvent) ID() pchannel.ID
func (*DisputedEvent) Timeout ¶
func (e *DisputedEvent) Timeout() pchannel.Timeout
func (*DisputedEvent) Tstamp ¶
func (e *DisputedEvent) Tstamp() uint64
func (*DisputedEvent) Version ¶
func (e *DisputedEvent) Version() Version
type Event ¶
type Event = xdr.ContractEvent
type EventType ¶
type EventType int
const ( EventTypeOpen EventType = iota EventTypeFundChannel // participant/s funding channel EventTypeFundedChannel // participants have funded channel EventTypeClosed // channel closed -> withdrawing enabled EventTypeWithdrawing // participant/s withdrawing EventTypeWithdrawn // participants have withdrawn EventTypeForceClosed // participant has force closed the channel EventTypeDisputed // participant has disputed the channel )
type ExpiredTimeout ¶
type ExpiredTimeout struct{}
ExpiredTimeout is always expired. Implements the Perun Timeout interface.
func NewExpiredTimeout ¶
func NewExpiredTimeout() *ExpiredTimeout
NewExpiredTimeout returns a new ExpiredTimeout.
type FundEvent ¶
func (*FundEvent) EventDataFromChannel ¶
type Funder ¶
type Funder struct {
// contains filtered or unexported fields
}
func (*Funder) AbortChannel ¶
func (*Funder) FundChannel ¶
func (*Funder) GetAssetID ¶
func (*Funder) GetChannelState ¶
func (*Funder) GetPerunID ¶
type OpenEvent ¶
func (*OpenEvent) GetChannel ¶
type PerunEvent ¶
func DecodeEventsPerun ¶
func DecodeEventsPerun(txMeta xdr.TransactionMeta) ([]PerunEvent, error)
type StellarEvent ¶
func (*StellarEvent) GetType ¶
func (e *StellarEvent) GetType() EventType
type Timeout ¶
Timeout can be used to wait until a specific timepoint is reached by the blockchain. Implements the Perun Timeout interface.
func NewTimeout ¶
NewTimeout returns a new Timeout which expires at the given time.
type WithdrawnEvent ¶
type WithdrawnEvent struct { Channel wire.Channel IDV pchannel.ID VersionV Version Timestamp uint64 }
func (*WithdrawnEvent) EventDataFromChannel ¶
func (e *WithdrawnEvent) EventDataFromChannel(chanState wire.Channel, timestamp uint64) error
func (*WithdrawnEvent) GetChannel ¶
func (e *WithdrawnEvent) GetChannel() wire.Channel
func (*WithdrawnEvent) ID ¶
func (e *WithdrawnEvent) ID() pchannel.ID
func (*WithdrawnEvent) Timeout ¶
func (e *WithdrawnEvent) Timeout() pchannel.Timeout
func (WithdrawnEvent) Tstamp ¶
func (e WithdrawnEvent) Tstamp() uint64
func (*WithdrawnEvent) Version ¶
func (e *WithdrawnEvent) Version() Version
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package env provides the functionality to connect to the Stellar blockchain and broadcast transactions to the network and decode its response.
|
Package env provides the functionality to connect to the Stellar blockchain and broadcast transactions to the network and decode its response. |
Package types defines the stellar asset that is used in payment channels.
|
Package types defines the stellar asset that is used in payment channels. |