Documentation
¶
Overview ¶
40swap daemon to the lightning node
Index ¶
- Constants
- func ErrInvalidConfig(message string) error
- func Start(ctx context.Context, server *rpc.Server, db Repository, ...) error
- func StartAutoSwapLoop(ctx context.Context, autoSwapService *AutoSwapService)
- type AutoSwapConfig
- type AutoSwapService
- type PSBTBuilder
- func (p *PSBTBuilder) BuildClaimPSBT(ctx context.Context, swap *models.SwapOut, swapInfo *swaps.SwapOutResponse, ...) (*psbt.Packet, error)
- func (p *PSBTBuilder) BuildRefundPSBT(ctx context.Context, swap *models.SwapIn, feeRate int64, logger *log.Entry) (*psbt.Packet, error)
- func (p *PSBTBuilder) SignAndBroadcastPSBT(ctx context.Context, pkt *psbt.Packet, privateKey string, ...) (string, error)
- type Repository
- type SwapMonitor
- func (m *SwapMonitor) ClaimSwapOut(ctx context.Context, swap *models.SwapOut) (string, error)
- func (m *SwapMonitor) GetFeesSwapOut(ctx context.Context, swap *models.SwapOut) (int64, int64, error)
- func (m *SwapMonitor) InitiateRefund(ctx context.Context, swap *models.SwapIn) (string, error)
- func (m *SwapMonitor) MonitorSwapIn(ctx context.Context, currentSwap *models.SwapIn) error
- func (m *SwapMonitor) MonitorSwapOut(ctx context.Context, currentSwap *models.SwapOut) error
- func (m *SwapMonitor) MonitorSwaps(ctx context.Context)
Constants ¶
const MONITORING_INTERVAL_SECONDS = 10
Variables ¶
This section is empty.
Functions ¶
func ErrInvalidConfig ¶
ErrInvalidConfig is returned when the auto swap configuration is invalid
func Start ¶
func Start(ctx context.Context, server *rpc.Server, db Repository, swaps swaps.ClientInterface, lightning lightning.Client, bitcoin bitcoin.Client, network lightning.Network, autoSwapService *AutoSwapService) error
func StartAutoSwapLoop ¶
func StartAutoSwapLoop(ctx context.Context, autoSwapService *AutoSwapService)
StartAutoSwapLoop runs the auto swap check every config.GetCheckInterval()
Types ¶
type AutoSwapConfig ¶
type AutoSwapConfig struct {
Enabled bool
CheckIntervalMinutes int
TargetBalanceBTC float64
BackoffFactor float64
MaxAttempts int
RoutingFeeLimitPPM int
MinSwapSizeBTC float64
MaxSwapSizeBTC float64
}
AutoSwapConfig holds the configuration for auto swap functionality
func NewAutoSwapConfigFromFlags ¶
func NewAutoSwapConfigFromFlags( enabled bool, interval int, targetBalance float64, backoffFactor float64, maxAttempts int, routingFeeLimitPPM int, minSwapSize float64, maxSwapSize float64, ) *AutoSwapConfig
NewAutoSwapConfigFromFlags creates a new AutoSwapConfig from CLI flags
func (*AutoSwapConfig) GetCheckInterval ¶
func (c *AutoSwapConfig) GetCheckInterval() time.Duration
GetCheckInterval returns the check interval as a time.Duration
func (*AutoSwapConfig) IsEnabled ¶
func (c *AutoSwapConfig) IsEnabled() bool
IsEnabled returns whether auto swap is enabled
func (*AutoSwapConfig) Validate ¶
func (c *AutoSwapConfig) Validate() error
Validate checks if the configuration is valid
type AutoSwapService ¶
type AutoSwapService struct {
// contains filtered or unexported fields
}
AutoSwapService handles the auto swap functionality
func NewAutoSwapService ¶
func NewAutoSwapService( client swaps.ClientInterface, rpcClient rpc.SwapServiceClient, lightningClient lightning.Client, repository Repository, config *AutoSwapConfig, ) *AutoSwapService
NewAutoSwapService creates a new AutoSwapService with dependencies for reusing existing logic
func (*AutoSwapService) GetCheckInterval ¶
func (s *AutoSwapService) GetCheckInterval() time.Duration
GetCheckInterval returns the auto swap check interval
func (*AutoSwapService) RecoverPendingAutoSwaps ¶
func (s *AutoSwapService) RecoverPendingAutoSwaps(ctx context.Context) error
RecoverPendingAutoSwaps recovers auto swaps that were running before daemon restart
func (*AutoSwapService) RunAutoSwapCheck ¶
func (s *AutoSwapService) RunAutoSwapCheck(ctx context.Context) error
RunAutoSwapCheck performs the auto swap check logic using existing components
type PSBTBuilder ¶
type PSBTBuilder struct {
// contains filtered or unexported fields
}
PSBTBuilder contains methods for building PSBTs locally for both refund and claim transactions
func NewPSBTBuilder ¶
func NewPSBTBuilder(bitcoinClient bitcoin.Client, network lightning.Network) *PSBTBuilder
NewPSBTBuilder creates a new PSBT builder instance
func (*PSBTBuilder) BuildClaimPSBT ¶
func (p *PSBTBuilder) BuildClaimPSBT(ctx context.Context, swap *models.SwapOut, swapInfo *swaps.SwapOutResponse, feeRate int64, logger *log.Entry) (*psbt.Packet, error)
BuildClaimPSBT builds a claim PSBT locally for swap out transactions
type Repository ¶
type Repository interface {
database.SwapInRepository
database.SwapOutRepository
}
type SwapMonitor ¶
type SwapMonitor struct {
// contains filtered or unexported fields
}
func (*SwapMonitor) ClaimSwapOut ¶
func (*SwapMonitor) GetFeesSwapOut ¶
func (*SwapMonitor) InitiateRefund ¶
func (*SwapMonitor) MonitorSwapIn ¶
func (*SwapMonitor) MonitorSwapOut ¶
func (*SwapMonitor) MonitorSwaps ¶
func (m *SwapMonitor) MonitorSwaps(ctx context.Context)