domain

package
v0.3.21 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetVhtlcId added in v0.3.0

func GetVhtlcId(preimageHash, sender, receiver []byte) string

func IsTerminalChainSwapStatus added in v0.3.16

func IsTerminalChainSwapStatus(status ChainSwapStatus) bool

func ShouldRefundChainSwapStatus added in v0.3.16

func ShouldRefundChainSwapStatus(status ChainSwapStatus) bool

func ShouldResumeChainSwapStatus added in v0.3.16

func ShouldResumeChainSwapStatus(status ChainSwapStatus) bool

Types

type ChainSwap added in v0.3.16

type ChainSwap struct {
	Id string

	From          boltz.Currency
	To            boltz.Currency
	ClaimPreimage string

	Amount uint64

	UserBtcLockupAddress string

	UserLockupTxId   string
	ServerLockupTxId string
	ClaimTxId        string
	RefundTxId       string

	CreatedAt    int64
	Status       ChainSwapStatus
	ErrorMessage string

	BoltzCreateResponseJSON string
}

func (*ChainSwap) Claimed added in v0.3.16

func (cs *ChainSwap) Claimed(txid string)

Claimed updates the swap when funds are successfully claimed

func (*ChainSwap) Failed added in v0.3.16

func (cs *ChainSwap) Failed(errorMsg string)

Failed marks the swap as failed with an error message

func (*ChainSwap) RefundFailed added in v0.3.16

func (cs *ChainSwap) RefundFailed(errorMsg string)

RefundFailed marks the swap as refund failed

func (*ChainSwap) Refunded added in v0.3.16

func (cs *ChainSwap) Refunded(txid string)

Refunded updates the swap when funds are refunded

func (*ChainSwap) RefundedUnilaterally added in v0.3.16

func (cs *ChainSwap) RefundedUnilaterally(txid string)

RefundedUnilaterally updates the swap when funds are refunded

func (*ChainSwap) ServerLocked added in v0.3.16

func (cs *ChainSwap) ServerLocked(txid string)

ServerLocked updates the swap when server locks funds

func (*ChainSwap) UserLockFailed added in v0.3.16

func (cs *ChainSwap) UserLockFailed(errorMsg string)

UserLockFailed marks the swap as user lock failed

func (*ChainSwap) UserLocked added in v0.3.16

func (cs *ChainSwap) UserLocked(txid string)

UserLocked updates the swap when user locks funds

type ChainSwapRepository added in v0.3.16

type ChainSwapRepository interface {
	// Add creates a new chain swap record
	Add(ctx context.Context, swap ChainSwap) error

	// Get retrieves a chain swap by ID
	Get(ctx context.Context, id string) (*ChainSwap, error)

	// GetAll retrieves all chain swaps
	GetAll(ctx context.Context) ([]ChainSwap, error)

	// GetByIDs retrieves chain swaps filtered by IDs
	GetByIDs(ctx context.Context, ids []string) ([]ChainSwap, error)

	// GetByStatus retrieves chain swaps filtered by status
	GetByStatus(ctx context.Context, status ChainSwapStatus) ([]ChainSwap, error)

	// Update updates an existing chain swap
	Update(ctx context.Context, swap ChainSwap) error

	// Delete removes a chain swap (rarely used, kept for completeness)
	Delete(ctx context.Context, id string) error

	// Close closes the repository
	Close()
}

ChainSwapRepository stores chain swaps initiated by the wallet

type ChainSwapStatus added in v0.3.16

type ChainSwapStatus int
const (
	// Pending states
	ChainSwapPending ChainSwapStatus = iota
	ChainSwapUserLocked
	ChainSwapServerLocked

	// Success states
	ChainSwapClaimed

	// Failed states
	ChainSwapUserLockedFailed
	ChainSwapFailed
	ChainSwapRefundFailed
	ChainSwapRefunded
	ChainSwapRefundedUnilaterally
)

type ConnectionType added in v0.3.0

type ConnectionType int
const (
	CLN_CONNECTION ConnectionType = iota
	LND_CONNECTION
)

type DelegateRepository added in v0.3.14

type DelegateRepository interface {
	Add(ctx context.Context, task DelegateTask) error
	GetByID(ctx context.Context, id string) (*DelegateTask, error)
	// return status == pending tasks
	GetAllPending(ctx context.Context) ([]PendingDelegateTask, error)
	GetAll(ctx context.Context, status DelegateTaskStatus, limit int, offset int) ([]DelegateTask, error)
	GetPendingTaskByIntentTxID(ctx context.Context, txid string) (*PendingDelegateTask, error)
	// return pending tasks that have any of the given inputs
	GetPendingTaskIDsByInputs(ctx context.Context, inputs []wire.OutPoint) ([]string, error)
	CancelTasks(ctx context.Context, ids ...string) error
	CompleteTasks(ctx context.Context, commitmentTxid string, ids ...string) error
	FailTasks(ctx context.Context, reason string, ids ...string) error
	Close()
}

type DelegateTask added in v0.3.14

type DelegateTask struct {
	ID                 string
	Intent             Intent
	ForfeitTxs         map[wire.OutPoint]string // forfeit transaction per input
	Fee                uint64
	DelegatorPublicKey string
	ScheduledAt        time.Time
	Status             DelegateTaskStatus
	FailReason         string // set only when task is failed
	CommitmentTxid     string // set only when task is completed
}

type DelegateTaskStatus added in v0.3.14

type DelegateTaskStatus int
const (
	DelegateTaskStatusPending DelegateTaskStatus = iota
	DelegateTaskStatusCompleted
	DelegateTaskStatusFailed
	DelegateTaskStatusCancelled
)

func DelegateTaskStatusFromString added in v0.3.14

func DelegateTaskStatusFromString(s string) (DelegateTaskStatus, error)

DelegateTaskStatusFromString parses string to DelegateTaskStatus

func (DelegateTaskStatus) String added in v0.3.14

func (s DelegateTaskStatus) String() string

String returns the string representation of the status

type Intent added in v0.3.14

type Intent struct {
	Message string
	Proof   string
	Txid    string
	Inputs  []wire.OutPoint
}

type LnConnectionOpts added in v0.3.0

type LnConnectionOpts struct {
	LnDatadir      string
	LnUrl          string
	ConnectionType ConnectionType
}

type PendingDelegateTask added in v0.3.14

type PendingDelegateTask struct {
	ID          string
	ScheduledAt time.Time
}

type Settings

type Settings struct {
	ApiRoot          string
	ServerUrl        string
	EsploraUrl       string
	Currency         string
	EventServer      string
	FullNode         string
	Unit             string
	LnConnectionOpts *LnConnectionOpts
}

type SettingsRepository

type SettingsRepository interface {
	AddDefaultSettings(ctx context.Context) error
	AddSettings(ctx context.Context, settings Settings) error
	GetSettings(ctx context.Context) (*Settings, error)
	CleanSettings(ctx context.Context) error
	UpdateSettings(ctx context.Context, settings Settings) error
	Close()
}

type SubscribedScriptRepository added in v0.1.13

type SubscribedScriptRepository interface {
	Get(ctx context.Context) ([]string, error)
	Add(ctx context.Context, subscribedScripts []string) (count int, err error)
	Delete(ctx context.Context, subscribedScripts []string) (count int, err error)
	Close()
}

type Swap added in v0.1.12

type Swap struct {
	Id          string
	Amount      uint64
	Timestamp   int64
	To          boltz.Currency
	From        boltz.Currency
	Status      SwapStatus
	Type        SwapType
	Invoice     string
	Vhtlc       Vhtlc
	FundingTxId string // the txid of the virtual tx that funded the vhtlc
	RedeemTxId  string // the txid of the virtual tx that redeemed the funds, by either "claiming" or "refunding"
}

type SwapRepository added in v0.1.12

type SwapRepository interface {
	GetAll(ctx context.Context) ([]Swap, error)
	Get(ctx context.Context, swapId string) (*Swap, error)
	Add(ctx context.Context, swaps []Swap) (int, error)
	Update(ctx context.Context, swap Swap) error
	Close()
}

SwapRepository stores the Swap initiated by the wallet

type SwapStatus added in v0.1.12

type SwapStatus int
const (
	SwapPending SwapStatus = iota
	SwapFailed
	SwapSuccess
)

type SwapType added in v0.3.0

type SwapType int
const (
	SwapRegular SwapType = iota
	SwapPayment
)

type VHTLCRepository

type VHTLCRepository interface {
	GetAll(ctx context.Context) ([]Vhtlc, error)
	Get(ctx context.Context, id string) (*Vhtlc, error)
	GetByIds(ctx context.Context, ids []string) ([]Vhtlc, error)
	Add(ctx context.Context, vhtlc Vhtlc) error
	Close()
}

VHTLCRepository stores the VHTLC options owned by the wallet

type Vhtlc added in v0.3.0

type Vhtlc struct {
	vhtlc.Opts
	Id string
}

func NewVhtlc added in v0.3.0

func NewVhtlc(opts vhtlc.Opts) Vhtlc

Jump to

Keyboard shortcuts

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