Skip to content

Commit 5ba89e3

Browse files
committed
0.0001
1 parent 8d9407f commit 5ba89e3

3 files changed

Lines changed: 28 additions & 14 deletions

File tree

main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ func main() {
8484
flag.BoolVar(&cfg.UseAugurFees, "use-augur-fees", useAugurFeesDefault, "Use Augur's 3-block 95% fee estimate for all transactions")
8585
flag.StringVar(&cfg.AugurFeesURL, "augur-fees-url", augurFeesURLDefault, "URL for Augur fees JSON")
8686
flag.IntVar(&cfg.MaxBatchSize, "max-batch-size", btc.MaxPaymentsPerTransaction, "Maximum number of payouts in one on-chain transaction (1-50)")
87-
flag.StringVar(&enabledAmountRangesStr, "enabled-amount-ranges", "1,2,3", "Comma-separated amount ranges to enable (1=0.001-0.009, 2=0.01-0.09, 3=0.1-0.9, 4=1.0-2.0)")
88-
flag.IntVar(&cfg.DefaultAmountRange, "default-amount-range", 2, "Default selected amount range (1-4)")
87+
flag.StringVar(&enabledAmountRangesStr, "enabled-amount-ranges", "1,2,3,4", "Comma-separated amount ranges to enable (1=0.0001-0.0009, 2=0.001-0.009, 3=0.01-0.09, 4=0.1-0.9, 5=1.0-2.0)")
88+
flag.IntVar(&cfg.DefaultAmountRange, "default-amount-range", 3, "Default selected amount range (1-5)")
8989
flag.Float64Var(&cfg.MinBalance, "min-balance", 0.1, "Minimum wallet balance threshold (BTC)")
9090
flag.Float64Var(&cfg.ConsolidationAmountThresholdBTC, "consolidation-amount-threshold", 0.001, "UTXO consolidation threshold (BTC) - UTXOs smaller than this will be consolidated")
9191
flag.IntVar(&cfg.MaxConsolidationUTXOs, "consolidation-max-utxos", 5, "Maximum number of UTXOs to consolidate in a single transaction")
@@ -165,8 +165,8 @@ func main() {
165165
continue
166166
}
167167
rangeID, err := strconv.Atoi(r)
168-
if err != nil || rangeID < 1 || rangeID > 4 {
169-
log.Fatalf("Error: invalid -enabled-amount-ranges value: %s (must be 1-4)", r)
168+
if err != nil || rangeID < 1 || rangeID > 5 {
169+
log.Fatalf("Error: invalid -enabled-amount-ranges value: %s (must be 1-5)", r)
170170
}
171171
cfg.EnabledAmountRanges = append(cfg.EnabledAmountRanges, rangeID)
172172
}

service/service.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ type AmountRange struct {
3030
}
3131

3232
var AllAmountRanges = []AmountRange{
33-
{ID: 1, MinBTC: 0.001, MaxBTC: 0.009, Label: "0.001 - 0.009"},
34-
{ID: 2, MinBTC: 0.01, MaxBTC: 0.09, Label: "0.01 - 0.09"},
35-
{ID: 3, MinBTC: 0.1, MaxBTC: 0.9, Label: "0.1 - 0.9"},
36-
{ID: 4, MinBTC: 1.0, MaxBTC: 2.0, Label: "1.0 - 2.0"},
33+
{ID: 1, MinBTC: 0.0001, MaxBTC: 0.0009, Label: "0.0001 - 0.0009"},
34+
{ID: 2, MinBTC: 0.001, MaxBTC: 0.009, Label: "0.001 - 0.009"},
35+
{ID: 3, MinBTC: 0.01, MaxBTC: 0.09, Label: "0.01 - 0.09"},
36+
{ID: 4, MinBTC: 0.1, MaxBTC: 0.9, Label: "0.1 - 0.9"},
37+
{ID: 5, MinBTC: 1.0, MaxBTC: 2.0, Label: "1.0 - 2.0"},
3738
}
3839

3940
type Config struct {

service/service_test.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ func testConfig() *Config {
244244
MaxWithdrawalsPerIP24h: 2,
245245
MaxDepositsPerAddress: 5,
246246
ClientIPHeader: "X-Real-IP",
247-
EnabledAmountRanges: []int{1, 2, 3},
248-
DefaultAmountRange: 2,
247+
EnabledAmountRanges: []int{1, 2, 3, 4},
248+
DefaultAmountRange: 3,
249249
ConsolidationAmountThresholdBTC: 0.001,
250250
MaxConsolidationUTXOs: 5,
251251
MinConsolidationUTXOs: 2,
@@ -615,6 +615,19 @@ func TestGetEnabledAmountRanges(t *testing.T) {
615615
}
616616
}
617617

618+
func TestAmountRanges(t *testing.T) {
619+
want := []AmountRange{
620+
{ID: 1, MinBTC: 0.0001, MaxBTC: 0.0009, Label: "0.0001 - 0.0009"},
621+
{ID: 2, MinBTC: 0.001, MaxBTC: 0.009, Label: "0.001 - 0.009"},
622+
{ID: 3, MinBTC: 0.01, MaxBTC: 0.09, Label: "0.01 - 0.09"},
623+
{ID: 4, MinBTC: 0.1, MaxBTC: 0.9, Label: "0.1 - 0.9"},
624+
{ID: 5, MinBTC: 1.0, MaxBTC: 2.0, Label: "1.0 - 2.0"},
625+
}
626+
if !reflect.DeepEqual(AllAmountRanges, want) {
627+
t.Fatalf("amount ranges = %#v, want %#v", AllAmountRanges, want)
628+
}
629+
}
630+
618631
func TestGetAmountRangeByID(t *testing.T) {
619632
svc, _ := testServiceFull(t)
620633
svc.cfg.EnabledAmountRanges = []int{2, 3}
@@ -969,7 +982,7 @@ func TestSubmitHandler_Success(t *testing.T) {
969982

970983
body := submitJSONBody(svc, map[string]any{
971984
"address": "tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx",
972-
"amount_range": 2,
985+
"amount_range": 3,
973986
})
974987
r := httptest.NewRequest("POST", "/api/submit", body)
975988
r.RemoteAddr = "127.0.0.1:1234"
@@ -994,7 +1007,7 @@ func TestSubmitHandler_Success(t *testing.T) {
9941007
t.Errorf("expected pending status, got %s", tx.Status)
9951008
}
9961009
if tx.AmountBTC < 0.01 || tx.AmountBTC > 0.09 {
997-
t.Errorf("amount %.8f out of range 2 bounds", tx.AmountBTC)
1010+
t.Errorf("amount %.8f out of range 3 bounds", tx.AmountBTC)
9981011
}
9991012
assertSubmissionMetricIncrement(t, submitQueued, before)
10001013
}
@@ -1118,7 +1131,7 @@ func TestSubmitHandler_DefaultAmountRange(t *testing.T) {
11181131
var tx db.Transaction
11191132
svc.db.Last(&tx)
11201133
if tx.AmountBTC < 0.01 || tx.AmountBTC > 0.09 {
1121-
t.Errorf("amount %.8f should be in default range 2", tx.AmountBTC)
1134+
t.Errorf("amount %.8f should be in default range 3", tx.AmountBTC)
11221135
}
11231136
}
11241137

@@ -3937,7 +3950,7 @@ func TestIntegration_SubmitAndProcess(t *testing.T) {
39373950
if tx.OnchainTxnID == "" {
39383951
t.Error("expected onchain txid after broadcast")
39393952
}
3940-
if tx.AmountBTC < 0.001 || tx.AmountBTC > 0.009 {
3953+
if tx.AmountBTC < 0.0001 || tx.AmountBTC > 0.0009 {
39413954
t.Errorf("amount %.8f should be in range 1", tx.AmountBTC)
39423955
}
39433956
}

0 commit comments

Comments
 (0)