domain

package
v0.0.0-...-2aaabe7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entity

type Entity struct {
	NostrRecipient string
}

type EntityRepository

type EntityRepository interface {
	Add(ctx context.Context, data Entity, vtxoKeys []VtxoKey) error
	Get(ctx context.Context, vtxoKey VtxoKey) ([]Entity, error)
	Delete(ctx context.Context, vtxoKeys []VtxoKey) error
}

type MarketHour

type MarketHour struct {
	StartTime     time.Time
	EndTime       time.Time
	Period        time.Duration
	RoundInterval time.Duration
	UpdatedAt     time.Time
}

func NewMarketHour

func NewMarketHour(startTime, endTime time.Time, period, roundInterval time.Duration) *MarketHour

type MarketHourRepo

type MarketHourRepo interface {
	Get(ctx context.Context) (*MarketHour, error)
	Upsert(ctx context.Context, marketHour MarketHour) error
	Close()
}

type NoteRepository

type NoteRepository interface {
	Contains(ctx context.Context, id uint64) (bool, error)
	Add(ctx context.Context, id uint64) error
	Close()
}

type Receiver

type Receiver struct {
	Amount         uint64
	OnchainAddress string // onchain
	PubKey         string // offchain
}

func (Receiver) IsOnchain

func (r Receiver) IsOnchain() bool

type Round

type Round struct {
	Id                string
	StartingTimestamp int64
	EndingTimestamp   int64
	Stage             Stage
	TxRequests        map[string]TxRequest
	Txid              string
	UnsignedTx        string
	ForfeitTxs        []string
	VtxoTree          tree.VtxoTree
	Connectors        []string
	ConnectorAddress  string
	DustAmount        uint64
	Version           uint
	Swept             bool // true if all the vtxos are vtxo.Swept or vtxo.Redeemed
	// contains filtered or unexported fields
}

func NewRound

func NewRound(dustAmount uint64) *Round

func NewRoundFromEvents

func NewRoundFromEvents(events []RoundEvent) *Round

func (*Round) EndFinalization

func (r *Round) EndFinalization(forfeitTxs []string, txid string) ([]RoundEvent, error)

func (*Round) Events

func (r *Round) Events() []RoundEvent

func (*Round) Fail

func (r *Round) Fail(err error) []RoundEvent

func (*Round) IsEnded

func (r *Round) IsEnded() bool

func (*Round) IsFailed

func (r *Round) IsFailed() bool

func (*Round) IsStarted

func (r *Round) IsStarted() bool

func (*Round) On

func (r *Round) On(event RoundEvent, replayed bool)

func (*Round) RegisterTxRequests

func (r *Round) RegisterTxRequests(txRequests []TxRequest) ([]RoundEvent, error)

func (*Round) StartFinalization

func (r *Round) StartFinalization(connectorAddress string, connectors []string, vtxoTree tree.VtxoTree, roundTx string) ([]RoundEvent, error)

func (*Round) StartRegistration

func (r *Round) StartRegistration() ([]RoundEvent, error)

func (*Round) Sweep

func (r *Round) Sweep()

func (*Round) TotalInputAmount

func (r *Round) TotalInputAmount() uint64

func (*Round) TotalOutputAmount

func (r *Round) TotalOutputAmount() uint64

type RoundEvent

type RoundEvent interface {
	IsEvent()
}

type RoundEventRepository

type RoundEventRepository interface {
	Save(ctx context.Context, id string, events ...RoundEvent) (*Round, error)
	Load(ctx context.Context, id string) (*Round, error)
	RegisterEventsHandler(func(*Round))
	Close()
}

type RoundFailed

type RoundFailed struct {
	Id        string
	Err       string
	Timestamp int64
}

func (RoundFailed) IsEvent

func (r RoundFailed) IsEvent()

type RoundFinalizationStarted

type RoundFinalizationStarted struct {
	Id               string
	VtxoTree         tree.VtxoTree
	Connectors       []string
	ConnectorAddress string
	RoundTx          string
	MinRelayFeeRate  int64
}

func (RoundFinalizationStarted) IsEvent

func (r RoundFinalizationStarted) IsEvent()

type RoundFinalized

type RoundFinalized struct {
	Id         string
	Txid       string
	ForfeitTxs []string
	Timestamp  int64
}

func (RoundFinalized) IsEvent

func (r RoundFinalized) IsEvent()

type RoundRepository

type RoundRepository interface {
	AddOrUpdateRound(ctx context.Context, round Round) error
	GetRoundWithId(ctx context.Context, id string) (*Round, error)
	GetRoundWithTxid(ctx context.Context, txid string) (*Round, error)
	GetExpiredRoundsTxid(ctx context.Context) ([]string, error)
	GetRoundsIds(ctx context.Context, startedAfter int64, startedBefore int64) ([]string, error)
	GetSweptRoundsConnectorAddress(ctx context.Context) ([]string, error)
	Close()
}

type RoundStage

type RoundStage int
const (
	UndefinedStage RoundStage = iota
	RegistrationStage
	FinalizationStage
)

func (RoundStage) String

func (s RoundStage) String() string

type RoundStarted

type RoundStarted struct {
	Id        string
	Timestamp int64
}

func (RoundStarted) IsEvent

func (r RoundStarted) IsEvent()

type Stage

type Stage struct {
	Code   RoundStage
	Ended  bool
	Failed bool
}

type TxRequest

type TxRequest struct {
	Id        string
	Inputs    []Vtxo
	Receivers []Receiver
}

func NewTxRequest

func NewTxRequest(inputs []Vtxo) (*TxRequest, error)

func (*TxRequest) AddReceivers

func (r *TxRequest) AddReceivers(receivers []Receiver) (err error)

func (TxRequest) TotalInputAmount

func (r TxRequest) TotalInputAmount() uint64

func (TxRequest) TotalOutputAmount

func (r TxRequest) TotalOutputAmount() uint64

type TxRequestsRegistered

type TxRequestsRegistered struct {
	Id         string
	TxRequests []TxRequest
}

func (TxRequestsRegistered) IsEvent

func (r TxRequestsRegistered) IsEvent()

type Vtxo

type Vtxo struct {
	VtxoKey
	Amount    uint64
	PubKey    string
	RoundTxid string
	SpentBy   string // round txid or redeem txid
	Spent     bool
	Redeemed  bool
	Swept     bool
	ExpireAt  int64
	RedeemTx  string // empty if in-round vtxo
	CreatedAt int64
}

func (Vtxo) TapKey

func (v Vtxo) TapKey() (*secp256k1.PublicKey, error)

type VtxoKey

type VtxoKey struct {
	Txid string
	VOut uint32
}

func (VtxoKey) Hash

func (k VtxoKey) Hash() string

func (VtxoKey) String

func (k VtxoKey) String() string

type VtxoRepository

type VtxoRepository interface {
	AddVtxos(ctx context.Context, vtxos []Vtxo) error
	SpendVtxos(ctx context.Context, vtxos []VtxoKey, txid string) error
	RedeemVtxos(ctx context.Context, vtxos []VtxoKey) error
	GetVtxos(ctx context.Context, vtxos []VtxoKey) ([]Vtxo, error)
	GetVtxosForRound(ctx context.Context, txid string) ([]Vtxo, error)
	SweepVtxos(ctx context.Context, vtxos []VtxoKey) error
	GetAllVtxos(ctx context.Context, pubkey string) ([]Vtxo, []Vtxo, error)
	GetAllSweepableVtxos(ctx context.Context) ([]Vtxo, error)
	UpdateExpireAt(ctx context.Context, vtxos []VtxoKey, expireAt int64) error
	Close()
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL