Skip to content

Commit

Permalink
Increase swap deadline offset (#34)
Browse files Browse the repository at this point in the history
Increase swap deadline offset (#34)

feat(flags.go): add swapPublicationOffset flag to set swap publication deadline offset
feat(loop_provider.go): use swapPublicationOffset value from config to calculate SwapPublicationDeadline, allowing for more flexible swap deadlines
  • Loading branch information
Jossec101 authored Jul 24, 2023
1 parent 043dd55 commit 7611336
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ func init() {
rootCmd.Flags().String("nodeguardHost", "", "Hostname:port to connect to nodeguard")
viper.BindPFlag("nodeguardHost", rootCmd.Flags().Lookup("nodeguardHost"))

//Swap Publication Offset in minutes
rootCmd.Flags().String("swapPublicationOffset", "30m", "Swap publication deadline offset (Maximum time for the swap provider to publish the swap)")
viper.BindPFlag("swapPublicationOffset", rootCmd.Flags().Lookup("swapPublicationOffset"))

//Now we set the global vars

pollingInterval = viper.GetDuration("pollingInterval")
Expand Down
4 changes: 3 additions & 1 deletion provider/loop_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/lightninglabs/loop/looprpc"
"github.com/lightningnetwork/lnd/routing/route"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
)

type LoopProvider struct {
Expand Down Expand Up @@ -243,7 +244,8 @@ func (l *LoopProvider) RequestReverseSubmarineSwap(ctx context.Context, request
OutgoingChanSet: request.ChannelSet,
SweepConfTarget: 2, //TODO Make this configurable
HtlcConfirmations: 2,
SwapPublicationDeadline: uint64(time.Now().Unix()),
//The publication deadline is maximum the offset of the swap deadline conf plus the current time
SwapPublicationDeadline: uint64(time.Now().Add(viper.GetDuration("swapPublicationOffset") * time.Minute).Unix()),
Label: fmt.Sprintf("Reverse submarine swap %d sats on date %s", request.SatsAmount, time.Now().Format(time.RFC3339)),
Initiator: "Liquidator",
})
Expand Down

0 comments on commit 7611336

Please sign in to comment.