Documentation
¶
Index ¶
- Constants
- type BaseConviction
- type BatchSwept
- type Conviction
- type ConvictionRepository
- type ConvictionType
- type Crime
- type CrimeType
- type Event
- type EventRepository
- type EventType
- type ForfeitTx
- type Intent
- type Intents
- type IntentsRegistered
- type OffchainTx
- func (s *OffchainTx) Accept(finalArkTx string, signedCheckpointTxs map[string]string, ...) (Event, error)
- func (s *OffchainTx) CommitmentTxidsList() []string
- func (s *OffchainTx) Events() []Event
- func (s *OffchainTx) Fail(err error) Event
- func (s *OffchainTx) Finalize(finalCheckpointTxs map[string]string) (Event, error)
- func (s *OffchainTx) IsAccepted() bool
- func (s *OffchainTx) IsFailed() bool
- func (s *OffchainTx) IsFinalized() bool
- func (s *OffchainTx) IsRequested() bool
- func (s *OffchainTx) Request(arkTxid, arkTx string, unsignedCheckpointTxs map[string]string) (Event, error)
- type OffchainTxAccepted
- type OffchainTxEvent
- type OffchainTxFailed
- type OffchainTxFinalized
- type OffchainTxRepository
- type OffchainTxRequested
- type OffchainTxStage
- type Outpoint
- type Receiver
- type Round
- func (r *Round) EndFinalization(forfeitTxs []ForfeitTx, finalCommitmentTx string) ([]Event, error)
- func (r *Round) Events() []Event
- func (r *Round) ExpiryTimestamp() int64
- func (r *Round) Fail(err error) []Event
- func (r *Round) IsEnded() bool
- func (r *Round) IsFailed() bool
- func (r *Round) IsStarted() bool
- func (r *Round) RegisterIntents(intents []Intent) ([]Event, error)
- func (r *Round) StartFinalization(connectorAddress string, connectors tree.FlatTxTree, vtxoTree tree.FlatTxTree, ...) ([]Event, error)
- func (r *Round) StartRegistration() ([]Event, error)
- func (r *Round) Sweep(leafVtxos []Outpoint, preconfirmedVtxos []Outpoint, txid, tx string) ([]Event, error)
- type RoundEvent
- type RoundFailed
- type RoundFinalizationStarted
- type RoundFinalized
- type RoundRepository
- type RoundStage
- type RoundStarted
- type RoundStats
- type ScheduledSession
- type ScheduledSessionRepo
- type ScriptConviction
- type Stage
- type Tx
- type Vtxo
- type VtxoRepository
Constants ¶
View Source
const OffchainTxTopic = "offchain_tx"
View Source
const RoundTopic = "round"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseConviction ¶ added in v0.8.0
type BaseConviction struct {
ID string
Type ConvictionType
CreatedAt time.Time
ExpiresAt *time.Time
Crime Crime
Pardoned bool
}
func (BaseConviction) GetCreatedAt ¶ added in v0.8.0
func (b BaseConviction) GetCreatedAt() time.Time
func (BaseConviction) GetCrime ¶ added in v0.8.0
func (b BaseConviction) GetCrime() Crime
func (BaseConviction) GetExpiresAt ¶ added in v0.8.0
func (b BaseConviction) GetExpiresAt() *time.Time
func (BaseConviction) GetID ¶ added in v0.8.0
func (b BaseConviction) GetID() string
func (BaseConviction) GetType ¶ added in v0.8.0
func (b BaseConviction) GetType() ConvictionType
func (BaseConviction) IsPardoned ¶ added in v0.8.0
func (b BaseConviction) IsPardoned() bool
type BatchSwept ¶
type Conviction ¶ added in v0.8.0
type Conviction interface {
GetType() ConvictionType
GetID() string
GetCreatedAt() time.Time
GetExpiresAt() *time.Time
GetCrime() Crime
String() string
IsPardoned() bool
}
func NewScriptConviction ¶ added in v0.8.0
func NewScriptConviction(script string, crime Crime, banDuration *time.Duration) Conviction
type ConvictionRepository ¶ added in v0.8.0
type ConvictionRepository interface {
Get(ctx context.Context, id string) (Conviction, error)
GetAll(ctx context.Context, from, to time.Time) ([]Conviction, error)
GetByRoundID(ctx context.Context, roundID string) ([]Conviction, error)
// GetActiveScriptConviction returns all not-expired convictions associated with a given script
GetActiveScriptConvictions(ctx context.Context, script string) ([]ScriptConviction, error)
Add(ctx context.Context, convictions ...Conviction) error
Pardon(ctx context.Context, id string) error
Close()
}
type ConvictionType ¶ added in v0.8.0
type ConvictionType uint8
const (
ConvictionTypeScript ConvictionType = iota
)
type EventRepository ¶
type Intent ¶
func (*Intent) AddReceivers ¶
func (Intent) TotalInputAmount ¶
func (Intent) TotalOutputAmount ¶
type Intents ¶
type Intents []Intent
func (Intents) CountSpentVtxos ¶
func (Intents) HaveOnlyOnchainOutput ¶
type IntentsRegistered ¶
type IntentsRegistered struct {
RoundEvent
Intents []Intent
}
type OffchainTx ¶
type OffchainTx struct {
Stage Stage
StartingTimestamp int64
EndingTimestamp int64
ArkTxid string
ArkTx string
CheckpointTxs map[string]string
CommitmentTxids map[string]string
RootCommitmentTxId string
ExpiryTimestamp int64
FailReason string
Version uint
// contains filtered or unexported fields
}
func NewOffchainTx ¶
func NewOffchainTx() *OffchainTx
func NewOffchainTxFromEvents ¶
func NewOffchainTxFromEvents(events []Event) *OffchainTx
func (*OffchainTx) CommitmentTxidsList ¶
func (s *OffchainTx) CommitmentTxidsList() []string
func (*OffchainTx) Events ¶
func (s *OffchainTx) Events() []Event
func (*OffchainTx) Fail ¶
func (s *OffchainTx) Fail(err error) Event
func (*OffchainTx) Finalize ¶
func (s *OffchainTx) Finalize(finalCheckpointTxs map[string]string) (Event, error)
func (*OffchainTx) IsAccepted ¶
func (s *OffchainTx) IsAccepted() bool
func (*OffchainTx) IsFailed ¶
func (s *OffchainTx) IsFailed() bool
func (*OffchainTx) IsFinalized ¶
func (s *OffchainTx) IsFinalized() bool
func (*OffchainTx) IsRequested ¶
func (s *OffchainTx) IsRequested() bool
type OffchainTxAccepted ¶
type OffchainTxEvent ¶
func (OffchainTxEvent) GetTopic ¶
func (s OffchainTxEvent) GetTopic() string
func (OffchainTxEvent) GetType ¶
func (s OffchainTxEvent) GetType() EventType
type OffchainTxFailed ¶
type OffchainTxFailed struct {
OffchainTxEvent
Reason string
Timestamp int64
}
type OffchainTxFinalized ¶
type OffchainTxFinalized struct {
OffchainTxEvent
FinalCheckpointTxs map[string]string
Timestamp int64
}
type OffchainTxRepository ¶
type OffchainTxRepository interface {
AddOrUpdateOffchainTx(ctx context.Context, offchainTx *OffchainTx) error
GetOffchainTx(ctx context.Context, txid string) (*OffchainTx, error)
Close()
}
type OffchainTxRequested ¶
type OffchainTxRequested struct {
OffchainTxEvent
ArkTx string
UnsignedCheckpointTxs map[string]string
StartingTimestamp int64
}
type OffchainTxStage ¶
type OffchainTxStage int
const ( OffchainTxUndefinedStage OffchainTxStage = iota OffchainTxRequestedStage OffchainTxAcceptedStage OffchainTxFinalizedStage )
func (OffchainTxStage) String ¶
func (s OffchainTxStage) String() string
type Outpoint ¶
func (*Outpoint) FromString ¶ added in v0.8.0
type Round ¶
type Round struct {
Id string
StartingTimestamp int64
EndingTimestamp int64
Stage Stage
Intents map[string]Intent
CommitmentTxid string
CommitmentTx string
ForfeitTxs []ForfeitTx
VtxoTree tree.FlatTxTree
Connectors tree.FlatTxTree
ConnectorAddress string
Version uint
Swept bool
VtxoTreeExpiration int64
SweepTxs map[string]string
FailReason string
Changes []Event
}
func NewRoundFromEvents ¶
func (*Round) EndFinalization ¶
func (*Round) ExpiryTimestamp ¶
func (*Round) StartFinalization ¶
func (r *Round) StartFinalization( connectorAddress string, connectors tree.FlatTxTree, vtxoTree tree.FlatTxTree, commitmentTxid, commitmentTx string, vtxoTreeExpiration int64, ) ([]Event, error)
func (*Round) StartRegistration ¶
type RoundEvent ¶
func (RoundEvent) GetTopic ¶
func (r RoundEvent) GetTopic() string
func (RoundEvent) GetType ¶
func (r RoundEvent) GetType() EventType
type RoundFailed ¶
type RoundFailed struct {
RoundEvent
Reason string
Timestamp int64
}
type RoundFinalizationStarted ¶
type RoundFinalizationStarted struct {
RoundEvent
VtxoTree tree.FlatTxTree
Connectors tree.FlatTxTree
ConnectorAddress string
CommitmentTxid string
CommitmentTx string
VtxoTreeExpiration int64
}
type RoundFinalized ¶
type RoundFinalized struct {
RoundEvent
ForfeitTxs []ForfeitTx
FinalCommitmentTx string
Timestamp int64
}
type RoundRepository ¶
type RoundRepository interface {
AddOrUpdateRound(ctx context.Context, round Round) error
GetRoundWithId(ctx context.Context, id string) (*Round, error)
GetRoundWithCommitmentTxid(ctx context.Context, txid string) (*Round, error)
GetRoundStats(ctx context.Context, commitmentTxid string) (*RoundStats, error)
GetRoundForfeitTxs(ctx context.Context, commitmentTxid string) ([]ForfeitTx, error)
GetRoundConnectorTree(ctx context.Context, commitmentTxid string) (tree.FlatTxTree, error)
GetRoundVtxoTree(ctx context.Context, txid string) (tree.FlatTxTree, error)
GetSweepableRounds(ctx context.Context) ([]string, error)
GetRoundIds(
ctx context.Context,
startedAfter, startedBefore int64,
withFailed, withCompleted bool,
) ([]string, error)
GetSweptRoundsConnectorAddress(ctx context.Context) ([]string, error)
GetTxsWithTxids(ctx context.Context, txids []string) ([]string, error)
GetRoundsWithCommitmentTxids(ctx context.Context, txids []string) (map[string]any, error)
Close()
}
type RoundStage ¶
type RoundStage int
const ( RoundUndefinedStage RoundStage = iota RoundRegistrationStage RoundFinalizationStage )
func (RoundStage) String ¶
func (s RoundStage) String() string
type RoundStarted ¶
type RoundStarted struct {
RoundEvent
Timestamp int64
}
type RoundStats ¶
type ScheduledSession ¶ added in v0.8.0
type ScheduledSession struct {
StartTime time.Time
EndTime time.Time
Period time.Duration
Duration time.Duration
RoundMinParticipantsCount int64
RoundMaxParticipantsCount int64
UpdatedAt time.Time
}
func NewScheduledSession ¶ added in v0.8.0
type ScheduledSessionRepo ¶ added in v0.8.0
type ScriptConviction ¶ added in v0.8.0
type ScriptConviction struct {
BaseConviction
Script string
}
ScriptConviction bans all vtxos with the given script
func (ScriptConviction) String ¶ added in v0.8.0
func (s ScriptConviction) String() string
type Vtxo ¶
type Vtxo struct {
Outpoint
Amount uint64
PubKey string
CommitmentTxids []string
RootCommitmentTxid string
SettledBy string // commitment txid
SpentBy string // forfeit txid or checkpoint txid
ArkTxid string // the link to the ark txid that spent the vtxos
Spent bool
Unrolled bool
Swept bool
Preconfirmed bool
ExpiresAt int64
CreatedAt int64
}
func (Vtxo) OutputScript ¶ added in v0.8.0
func (Vtxo) RequiresForfeit ¶
type VtxoRepository ¶
type VtxoRepository interface {
AddVtxos(ctx context.Context, vtxos []Vtxo) error
SettleVtxos(ctx context.Context, spentVtxos map[Outpoint]string, commitmentTxid string) error
SpendVtxos(ctx context.Context, spentVtxos map[Outpoint]string, arkTxid string) error
UnrollVtxos(ctx context.Context, outpoints []Outpoint) error
SweepVtxos(ctx context.Context, outpoints []Outpoint) (int, error)
GetVtxos(ctx context.Context, outpoints []Outpoint) ([]Vtxo, error)
GetVtxosForRound(ctx context.Context, txid string) ([]Vtxo, error)
GetAllNonUnrolledVtxos(ctx context.Context, pubkey string) ([]Vtxo, []Vtxo, error)
GetAllSweepableVtxos(ctx context.Context) ([]Vtxo, error)
GetAllSweepableUnrolledVtxos(ctx context.Context) ([]Vtxo, error)
GetAllVtxos(ctx context.Context) ([]Vtxo, error)
GetAllVtxosWithPubKeys(ctx context.Context, pubkeys []string) ([]Vtxo, error)
UpdateVtxosExpiration(ctx context.Context, outpoints []Outpoint, expiresAt int64) error
GetLeafVtxosForBatch(ctx context.Context, txid string) ([]Vtxo, error)
GetAllChildrenVtxos(ctx context.Context, txid string) ([]Outpoint, error)
Close()
}
Click to show internal directories.
Click to hide internal directories.