Documentation
¶
Index ¶
- Constants
- type Asset
- type AssetDenomination
- type AssetRepository
- type BaseConviction
- type BatchFees
- type BatchFeesUpdate
- type BatchSwept
- type Conviction
- type ConvictionRepository
- type ConvictionType
- type Crime
- type CrimeType
- type Event
- type EventRepository
- type EventType
- type ExpiredRound
- 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) CheckpointTxsList() []string
- 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, collectedFees uint64) ([]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, 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 ScheduledSessionUpdate
- type ScriptConviction
- type Settings
- func (s Settings) AllowCSVBlockType() bool
- func (s *Settings) ClearBatchFees() []string
- func (s *Settings) ClearScheduledSession() []string
- func (s Settings) MaxAssetsPerVtxo() int
- func (s *Settings) Update(u SettingsUpdate) ([]string, error)
- func (s *Settings) UpdateBatchFees(updates BatchFeesUpdate) ([]string, error)
- func (s *Settings) UpdateScheduledSession(updates ScheduledSessionUpdate) ([]string, error)
- func (s Settings) Validate() error
- type SettingsRepository
- type SettingsUpdate
- type Stage
- type Tx
- type Vtxo
- type VtxoRepository
Constants ¶
const OffchainTxTopic = "offchain_tx"
const RoundTopic = "round"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetDenomination ¶ added in v0.9.0
type AssetRepository ¶ added in v0.9.0
type AssetRepository interface {
AddAssets(ctx context.Context, assetsByTx map[string][]Asset) (int, error)
GetAssets(ctx context.Context, assetIds []string) ([]Asset, error)
GetControlAsset(ctx context.Context, assetID string) (string, error)
AssetExists(ctx context.Context, assetID string) (bool, error)
Close()
}
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 BatchFees ¶ added in v0.9.9
type BatchFees struct {
OnchainInputFee string
OffchainInputFee string
OnchainOutputFee string
OffchainOutputFee string
}
func NewBatchFees ¶ added in v0.9.9
func (*BatchFees) Update ¶ added in v0.9.9
func (f *BatchFees) Update(u BatchFeesUpdate) error
type BatchFeesUpdate ¶ added in v0.9.9
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 ExpiredRound ¶ added in v0.9.8
type Intent ¶
type Intent struct {
Id string
Inputs []Vtxo
Receivers []Receiver
Proof string
Message string
Txid string
// hex-encoded extension OP_RETURN script to be added as output of the vtxo tree leaf transaction
LeafTxExtension string
}
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) CheckpointTxsList ¶ added in v0.8.9
func (s *OffchainTx) CheckpointTxsList() []string
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
CollectedFees uint64
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
Fees uint64
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)
GetSweepTxs(ctx context.Context, commitmentTxid string) (map[string]string, 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)
// GetExpiredRounds returns the list of info about batches that expired but haven't been
// swept because of uneconomical conditions (amount too low to cover network fees)
GetExpiredRounds(ctx context.Context, expiredBefore int64) ([]ExpiredRound, error)
GetRoundIds(
ctx context.Context,
startedAfter, startedBefore int64,
withFailed, withCompleted bool,
) ([]string, error)
// TODO return only connector addresses with unspent utxos
GetSweptRoundsConnectorAddress(ctx context.Context) ([]string, error)
GetTxsWithTxids(ctx context.Context, txids []string) ([]string, error)
GetRoundsWithCommitmentTxids(ctx context.Context, txids []string) (map[string]any, error)
GetIntentByTxid(ctx context.Context, txid string) (*Intent, error)
// PatchCollectedFees sets the collected fees of the given rounds (by id),
// used to lazily persist fees recomputed for rounds finalized before fee
// persistence was introduced (https://github.com/arkade-os/arkd/pull/933).
PatchCollectedFees(ctx context.Context, feesByRoundId map[string]uint64) 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
}
func NewScheduledSession ¶ added in v0.8.0
func (ScheduledSession) IsEmpty ¶ added in v0.9.9
func (s ScheduledSession) IsEmpty() bool
func (*ScheduledSession) Update ¶ added in v0.9.9
func (s *ScheduledSession) Update(u ScheduledSessionUpdate) error
func (ScheduledSession) Validate ¶ added in v0.9.9
func (s ScheduledSession) Validate() error
type ScheduledSessionUpdate ¶ added in v0.9.9
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 Settings ¶ added in v0.9.9
type Settings struct {
SessionDuration time.Duration
UnrolledVtxoMinExpiryMargin time.Duration
BanThreshold uint64
BanDuration time.Duration
UnilateralExitDelay arklib.RelativeLocktime
PublicUnilateralExitDelay arklib.RelativeLocktime
CheckpointExitDelay arklib.RelativeLocktime
BoardingExitDelay arklib.RelativeLocktime
VtxoTreeExpiry arklib.RelativeLocktime
RoundMinParticipantsCount int64
RoundMaxParticipantsCount int64
VtxoMinAmount int64
VtxoMaxAmount int64
UtxoMinAmount int64
UtxoMaxAmount int64
SettlementMinExpiryGap time.Duration
VtxoNoCsvValidationCutoffDate time.Time
MaxTxWeight uint64
MaxOpReturnOutputs uint64
AssetTxMaxWeightRatio float32
NoteUriPrefix string
ScheduledSession *ScheduledSession
BatchFees BatchFees
BuildVersionHeader string
BuildVersionHeaderRequired bool
DigestHeaderRequired bool
UpdatedAt time.Time
}
func NewSettings ¶ added in v0.9.9
func NewSettings( sessionDuration, unrolledVtxoMinExpiryMargin, banThreshold, banDuration, settlementMinExpiryGap, vtxoNoCsvValidationCutoffDate, roundMinParticipantsCount, roundMaxParticipantsCount, vtxoMinAmount, vtxoMaxAmount, utxoMinAmount, utxoMaxAmount int64, unilateralExitDelay, publicUnilateralExitDelay, checkpointExitDelay, boardingExitDelay, vtxoTreeExpiry arklib.RelativeLocktime, maxTxWeight, maxOpReturnOutputs uint64, assetTxMaxWeightRatio float32, noteUriPrefix, minVersionAccepted string, minVersionRequired, digestHeaderRequired bool, ) (*Settings, error)
func (Settings) AllowCSVBlockType ¶ added in v0.9.9
func (*Settings) ClearBatchFees ¶ added in v0.9.9
ClearBatchFees deletes the batch fees from settings and returns the changelog like Update does.
func (*Settings) ClearScheduledSession ¶ added in v0.9.9
ClearScheduledSession deletes the scheduled session from settings and returns the changelog like Update does.
func (Settings) MaxAssetsPerVtxo ¶ added in v0.9.9
func (*Settings) Update ¶ added in v0.9.9
func (s *Settings) Update(u SettingsUpdate) ([]string, error)
Update updates any field of Settings but ScheduledSession and BatchFees and returns a changelog with the list of all modified fields in dash-separated format.
func (*Settings) UpdateBatchFees ¶ added in v0.9.9
func (s *Settings) UpdateBatchFees(updates BatchFeesUpdate) ([]string, error)
UpdateBatchFees updates the batch fees settings and returns the changelog like Update does.
func (*Settings) UpdateScheduledSession ¶ added in v0.9.9
func (s *Settings) UpdateScheduledSession(updates ScheduledSessionUpdate) ([]string, error)
UpdateScheduledSession updates the scheduled session settings and returns the changelog like Update does.
type SettingsRepository ¶ added in v0.9.9
type SettingsUpdate ¶ added in v0.9.9
type SettingsUpdate struct {
SessionDuration *time.Duration
UnrolledVtxoMinExpiryMargin *time.Duration
BanThreshold *uint64
BanDuration *time.Duration
UnilateralExitDelay *arklib.RelativeLocktime
PublicUnilateralExitDelay *arklib.RelativeLocktime
CheckpointExitDelay *arklib.RelativeLocktime
BoardingExitDelay *arklib.RelativeLocktime
VtxoTreeExpiry *arklib.RelativeLocktime
RoundMinParticipantsCount *int64
RoundMaxParticipantsCount *int64
VtxoMinAmount *int64
VtxoMaxAmount *int64
UtxoMinAmount *int64
UtxoMaxAmount *int64
SettlementMinExpiryGap *time.Duration
VtxoNoCsvValidationCutoffDate *time.Time
MaxTxWeight *uint64
MaxOpReturnOutputs *uint64
AssetTxMaxWeightRatio *float32
NoteUriPrefix *string
BuildVersionHeader *string
BuildVersionHeaderRequired *bool
DigestHeaderRequired *bool
}
SettingsUpdate is a copy of the Settings repo struct, but with optional fields to easily handle changes.
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
Assets []AssetDenomination
}
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)
GetAllNonUnrolledVtxos(ctx context.Context, pubkey string) ([]Vtxo, []Vtxo, error)
GetAllSweepableUnrolledVtxos(ctx context.Context) ([]Vtxo, error)
GetAllVtxos(ctx context.Context) ([]Vtxo, error)
GetAllVtxosWithPubKeys(
ctx context.Context,
pubkeys []string,
after, before int64,
) ([]Vtxo, error)
GetExpiringLiquidity(ctx context.Context, after, before int64) (uint64, error)
GetRecoverableLiquidity(ctx context.Context) (uint64, error)
UpdateVtxosExpiration(ctx context.Context, outpoints []Outpoint, expiresAt int64) error
GetLeafVtxosForBatch(ctx context.Context, txid string) ([]Vtxo, error)
GetSweepableVtxosByCommitmentTxid(
ctx context.Context, commitmentTxid string,
) ([]Outpoint, error)
GetAllChildrenVtxos(ctx context.Context, txid string) ([]Outpoint, error)
GetVtxoPubKeysByCommitmentTxid(
ctx context.Context, commitmentTxid string, withMinimumAmount uint64,
) (
[]string, error,
)
GetVtxoPubKeysByCommitmentTxids(
ctx context.Context, commitmentTxids []string, withMinimumAmount uint64,
) (
[]string, error,
)
GetPendingSpentVtxosWithPubKeys(
ctx context.Context,
pubkeys []string,
after, before int64,
) ([]Vtxo, error)
GetPendingSpentVtxosWithOutpoints(ctx context.Context, outpoints []Outpoint) ([]Vtxo, error)
Close()
}