Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use only one env var
  • Loading branch information
AL-CT committed Jul 22, 2025
commit b2e7cfe30949f039d665716a306990e25a04b9b2
12 changes: 3 additions & 9 deletions cmd/popmd/popmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,10 @@ var (
Help: "the bitcoin url to connect to; it's either a tbc or blockstream url",
Print: config.PrintAll,
},
"POPM_FEE_OVERRIDE": config.Config{
"POPM_STATIC_FEE": config.Config{
Value: &cfg.StaticFee,
DefaultValue: false,
Help: "if popm should override fee estimation and use a static fee",
Print: config.PrintAll,
},
"POPM_FEE_AMOUNT": config.Config{
Value: &cfg.StaticFeeAmount,
DefaultValue: uint(1),
Help: "static fee amount in sats/byte (requires POPM_FEE_OVERRIDE=true)",
DefaultValue: uint(0),
Help: "static fee amount in sats/byte; overrides fee estimation if greater than 0",
Print: config.PrintAll,
},
}
Expand Down
11 changes: 5 additions & 6 deletions service/popm/popm.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ type Config struct {
PrometheusListenAddress string
PrometheusNamespace string
RetryMineThreshold uint
StaticFee bool
StaticFeeAmount uint
StaticFee uint

// cooked settings, do not export
opgethReconnectTimeout time.Duration
Expand Down Expand Up @@ -171,9 +170,9 @@ func NewServer(cfg *Config) (*Server, error) {
workC: make(chan struct{}, 2),
}

if cfg.StaticFee && cfg.StaticFeeAmount < minRelayFee {
if cfg.StaticFee != 0 && cfg.StaticFee < minRelayFee {
return nil, fmt.Errorf("static fee set to %v, minimum is %v",
cfg.StaticFeeAmount, minRelayFee)
cfg.StaticFee, minRelayFee)
}

switch strings.ToLower(cfg.Network) {
Expand Down Expand Up @@ -346,10 +345,10 @@ func (s *Server) getFee(ctx context.Context) (*tbcapi.FeeEstimate, error) {
defer log.Tracef("getFee exit")

var feeAmount *tbcapi.FeeEstimate
if s.cfg.StaticFee {
if s.cfg.StaticFee != 0 {
feeAmount = &tbcapi.FeeEstimate{
Blocks: s.cfg.BitcoinConfirmations,
SatsPerByte: float64(s.cfg.StaticFeeAmount),
SatsPerByte: float64(s.cfg.StaticFee),
}
} else {
// Estimate BTC fees.
Expand Down
11 changes: 1 addition & 10 deletions service/popm/popm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,21 +343,12 @@ func TestStaticFee(t *testing.T) {
cfg.BitcoinSource = "tbc"
cfg.BitcoinSecret = "5e2deaa9f1bb2bcef294cc36513c591c5594d6b671fe83a104aa2708bc634c"
cfg.LogLevel = "popm=TRACE; mock=TRACE;"
cfg.StaticFee = true
cfg.StaticFeeAmount = 0
cfg.StaticFee = 3

if err := loggo.ConfigureLoggers(cfg.LogLevel); err != nil {
t.Fatal(err)
}

// shouldn't allow static fee of 0
_, err := NewServer(cfg)
if err == nil {
t.Fatal("expected error")
}

cfg.StaticFeeAmount = 3
// should allow static fee of 3
s, err := NewServer(cfg)
if err != nil {
t.Fatal(err)
Expand Down