diff --git a/channel_opener_server.go b/channel_opener_server.go index 8de2184..3f78286 100644 --- a/channel_opener_server.go +++ b/channel_opener_server.go @@ -8,10 +8,10 @@ import ( "log" "time" - "github.com/breez/lspd/basetypes" "github.com/breez/lspd/btceclegacy" "github.com/breez/lspd/interceptor" "github.com/breez/lspd/lightning" + "github.com/breez/lspd/lsps0" lspdrpc "github.com/breez/lspd/rpc" "github.com/breez/lspd/shared" ecies "github.com/ecies/go/v2" @@ -146,7 +146,7 @@ func (s *channelOpenerServer) RegisterPayment( pi.OpeningFeeParams = &lspdrpc.OpeningFeeParams{ MinMsat: uint64(node.NodeConfig.ChannelMinimumFeeMsat), Proportional: uint32(node.NodeConfig.ChannelFeePermyriad * 100), - ValidUntil: time.Now().UTC().Add(time.Duration(time.Hour * 24)).Format(basetypes.TIME_FORMAT), + ValidUntil: time.Now().UTC().Add(time.Duration(time.Hour * 24)).Format(lsps0.TIME_FORMAT), MaxIdleTime: uint32(node.NodeConfig.MaxInactiveDuration / 600), MaxClientToSelfDelay: uint32(10000), } diff --git a/interceptor/intercept.go b/interceptor/intercept.go index 91bf3b3..c54cb28 100644 --- a/interceptor/intercept.go +++ b/interceptor/intercept.go @@ -13,6 +13,7 @@ import ( "github.com/breez/lspd/chain" "github.com/breez/lspd/config" "github.com/breez/lspd/lightning" + "github.com/breez/lspd/lsps0" "github.com/breez/lspd/notifications" "github.com/breez/lspd/shared" "github.com/btcsuite/btcd/wire" @@ -191,7 +192,7 @@ func (i *Interceptor) Intercept(scid *basetypes.ShortChannelID, reqPaymentHash [ params = &shared.OpeningFeeParams{ MinFeeMsat: uint64(i.config.ChannelMinimumFeeMsat), Proportional: uint32(i.config.ChannelFeePermyriad * 100), - ValidUntil: time.Now().UTC().Add(time.Duration(time.Hour * 24)).Format(basetypes.TIME_FORMAT), + ValidUntil: time.Now().UTC().Add(time.Duration(time.Hour * 24)).Format(lsps0.TIME_FORMAT), MinLifetime: uint32(i.config.MaxInactiveDuration / 600), MaxClientToSelfDelay: uint32(10000), } @@ -206,9 +207,9 @@ func (i *Interceptor) Intercept(scid *basetypes.ShortChannelID, reqPaymentHash [ }, nil } - validUntil, err := time.Parse(basetypes.TIME_FORMAT, params.ValidUntil) + validUntil, err := time.Parse(lsps0.TIME_FORMAT, params.ValidUntil) if err != nil { - log.Printf("time.Parse(%s, %s) failed. Failing channel open: %v", basetypes.TIME_FORMAT, params.ValidUntil, err) + log.Printf("time.Parse(%s, %s) failed. Failing channel open: %v", lsps0.TIME_FORMAT, params.ValidUntil, err) return InterceptResult{ Action: INTERCEPT_FAIL_HTLC_WITH_CODE, FailureCode: FAILURE_TEMPORARY_CHANNEL_FAILURE, diff --git a/basetypes/time.go b/lsps0/time.go similarity index 74% rename from basetypes/time.go rename to lsps0/time.go index 6c28c37..7760737 100644 --- a/basetypes/time.go +++ b/lsps0/time.go @@ -1,3 +1,3 @@ -package basetypes +package lsps0 var TIME_FORMAT string = "2006-01-02T15:04:05.999Z" diff --git a/lsps2/store.go b/lsps2/store.go index 607f8bc..8bdb7ec 100644 --- a/lsps2/store.go +++ b/lsps2/store.go @@ -7,6 +7,7 @@ import ( "time" "github.com/breez/lspd/basetypes" + "github.com/breez/lspd/lsps0" "github.com/breez/lspd/shared" "github.com/btcsuite/btcd/wire" ) @@ -33,9 +34,9 @@ type BuyRegistration struct { } func (b *BuyRegistration) IsExpired() bool { - t, err := time.Parse(basetypes.TIME_FORMAT, b.OpeningFeeParams.ValidUntil) + t, err := time.Parse(lsps0.TIME_FORMAT, b.OpeningFeeParams.ValidUntil) if err != nil { - log.Printf("BuyRegistration.IsExpired(): time.Parse(%v, %v) error: %v", basetypes.TIME_FORMAT, b.OpeningFeeParams.ValidUntil, err) + log.Printf("BuyRegistration.IsExpired(): time.Parse(%v, %v) error: %v", lsps0.TIME_FORMAT, b.OpeningFeeParams.ValidUntil, err) return true } diff --git a/shared/opening_service.go b/shared/opening_service.go index 4c34b31..0cc942b 100644 --- a/shared/opening_service.go +++ b/shared/opening_service.go @@ -9,7 +9,7 @@ import ( "sort" "time" - "github.com/breez/lspd/basetypes" + "github.com/breez/lspd/lsps0" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/btcec/v2/ecdsa" ) @@ -51,7 +51,7 @@ func (s *openingService) GetFeeParamsMenu(token string, privateKey *btcec.Privat params := &OpeningFeeParams{ MinFeeMsat: setting.Params.MinFeeMsat, Proportional: setting.Params.Proportional, - ValidUntil: validUntil.Format(basetypes.TIME_FORMAT), + ValidUntil: validUntil.Format(lsps0.TIME_FORMAT), MinLifetime: setting.Params.MinLifetime, MaxClientToSelfDelay: setting.Params.MaxClientToSelfDelay, } @@ -86,9 +86,9 @@ func (s *openingService) ValidateOpeningFeeParams(params *OpeningFeeParams, publ return false } - t, err := time.Parse(basetypes.TIME_FORMAT, params.ValidUntil) + t, err := time.Parse(lsps0.TIME_FORMAT, params.ValidUntil) if err != nil { - log.Printf("validateOpeningFeeParams: time.Parse(%v, %v) error: %v", basetypes.TIME_FORMAT, params.ValidUntil, err) + log.Printf("validateOpeningFeeParams: time.Parse(%v, %v) error: %v", lsps0.TIME_FORMAT, params.ValidUntil, err) return false }