Skip to content

Commit a19dcb4

Browse files
jholdstockjrick
authored andcommitted
jsonrpc: Respect configured VSPMaxFee.
Don't override with a hard-coded value of 0.2e8.
1 parent c6933a3 commit a19dcb4

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const (
5757
defaultDisableCoinTypeUpgrades = false
5858
defaultCircuitLimit = 32
5959
defaultMixSplitLimit = 10
60+
defaultVSPMaxFee = dcrutil.Amount(0.2e8)
6061

6162
// ticket buyer options
6263
defaultBalanceToMaintainAbsolute = 0
@@ -378,7 +379,7 @@ func loadConfig(ctx context.Context) (*config, []string, error) {
378379
},
379380

380381
VSPOpts: vspOptions{
381-
MaxFee: cfgutil.NewAmountFlag(0.2e8),
382+
MaxFee: cfgutil.NewAmountFlag(defaultVSPMaxFee),
382383
},
383384
}
384385

internal/rpc/jsonrpc/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ package jsonrpc
77
import (
88
"context"
99
"net"
10+
11+
"github.com/decred/dcrd/dcrutil/v4"
1012
)
1113

1214
// Options contains the required options for running the legacy RPC server.
@@ -26,5 +28,6 @@ type Options struct {
2628

2729
VSPHost string
2830
VSPPubKey string
31+
VSPMaxFee dcrutil.Amount
2932
Dial func(ctx context.Context, network, addr string) (net.Conn, error)
3033
}

internal/rpc/jsonrpc/methods.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3423,12 +3423,11 @@ func (s *Server) purchaseTicket(ctx context.Context, icmd interface{}) (interfac
34233423
}
34243424
}
34253425

3426-
var vspHost string
3427-
var vspPubKey string
34283426
var vspClient *vsp.Client
34293427
if s.cfg.VSPHost != "" || s.cfg.VSPPubKey != "" {
3430-
vspHost = s.cfg.VSPHost
3431-
vspPubKey = s.cfg.VSPPubKey
3428+
vspHost := s.cfg.VSPHost
3429+
vspPubKey := s.cfg.VSPPubKey
3430+
vspMaxFee := s.cfg.VSPMaxFee
34323431
if vspPubKey == "" {
34333432
return nil, rpcErrorf(dcrjson.ErrRPCInvalidParameter,
34343433
"vsp pubkey can not be null")
@@ -3437,13 +3436,17 @@ func (s *Server) purchaseTicket(ctx context.Context, icmd interface{}) (interfac
34373436
return nil, rpcErrorf(dcrjson.ErrRPCInvalidParameter,
34383437
"vsp host can not be null")
34393438
}
3439+
if vspMaxFee == 0 {
3440+
return nil, rpcErrorf(dcrjson.ErrRPCInvalidParameter,
3441+
"vsp max fee must be greater than zero")
3442+
}
34403443
cfg := vsp.Config{
34413444
URL: vspHost,
34423445
PubKey: vspPubKey,
34433446
Dialer: s.cfg.Dial,
34443447
Wallet: w,
34453448
Policy: vsp.Policy{
3446-
MaxFee: 0.2e8,
3449+
MaxFee: vspMaxFee,
34473450
FeeAcct: account,
34483451
ChangeAcct: changeAccount,
34493452
},

rpcserver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ func startRPCServers(walletLoader *loader.Loader) (*grpc.Server, *jsonrpc.Server
373373
MixChangeAccount: cfg.ChangeAccount,
374374
VSPHost: cfg.VSPOpts.URL,
375375
VSPPubKey: cfg.VSPOpts.PubKey,
376+
VSPMaxFee: cfg.VSPOpts.MaxFee.Amount,
376377
TicketSplitAccount: cfg.TicketSplitAccount,
377378
Dial: cfg.dial,
378379
}

0 commit comments

Comments
 (0)