Validate fee config
This commit is contained in:
parent
85a806fb3a
commit
2a476d9589
10
config.go
10
config.go
@ -12,6 +12,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"decred.org/dcrwallet/wallet/txrules"
|
||||
"github.com/decred/dcrd/dcrutil/v3"
|
||||
"github.com/decred/dcrd/hdkeychain/v3"
|
||||
flags "github.com/jessevdk/go-flags"
|
||||
@ -20,7 +21,7 @@ import (
|
||||
var (
|
||||
defaultListen = ":3000"
|
||||
defaultLogLevel = "debug"
|
||||
defaultVSPFee = 0.05
|
||||
defaultVSPFee = 5.0
|
||||
defaultNetwork = "testnet"
|
||||
defaultHomeDir = dcrutil.AppDataDir("vspd", false)
|
||||
defaultConfigFilename = "vspd.conf"
|
||||
@ -38,7 +39,7 @@ type config struct {
|
||||
LogLevel string `long:"loglevel" ini-name:"loglevel" description:"Logging level." choice:"trace" choice:"debug" choice:"info" choice:"warn" choice:"error" choice:"critical"`
|
||||
Network string `long:"network" ini-name:"network" description:"Decred network to use." choice:"testnet" choice:"mainnet" choice:"simnet"`
|
||||
FeeXPub string `long:"feexpub" ini-name:"feexpub" description:"Cold wallet xpub used for collecting fees."`
|
||||
VSPFee float64 `long:"vspfee" ini-name:"vspfee" description:"Fee percentage charged for VSP use. eg. 0.01 (1%), 0.05 (5%)."`
|
||||
VSPFee float64 `long:"vspfee" ini-name:"vspfee" description:"Fee percentage charged for VSP use. eg. 2.0 (2%), 0.5 (0.5%)."`
|
||||
HomeDir string `long:"homedir" ini-name:"homedir" no-ini:"true" description:"Path to application home directory. Used for storing VSP database and logs."`
|
||||
ConfigFile string `long:"configfile" ini-name:"configfile" no-ini:"true" description:"Path to configuration file."`
|
||||
DcrdHost string `long:"dcrdhost" ini-name:"dcrdhost" description:"The ip:port to establish a JSON-RPC connection with dcrd. Should be the same host where vspd is running."`
|
||||
@ -255,6 +256,11 @@ func loadConfig() (*config, error) {
|
||||
return nil, errors.New("minimum backupinterval is 30 seconds")
|
||||
}
|
||||
|
||||
// Ensure the fee percentage is valid per txrules.
|
||||
if !txrules.ValidPoolFeeRate(cfg.VSPFee) {
|
||||
return nil, errors.New("invalid vspfee - should be greater than 0.01 and less than 100.0 ")
|
||||
}
|
||||
|
||||
// Ensure the support email address is set.
|
||||
if cfg.SupportEmail == "" {
|
||||
return nil, errors.New("the supportemail option is not set")
|
||||
|
||||
@ -33,7 +33,7 @@ will result in an error.
|
||||
{
|
||||
"timestamp":1590599436,
|
||||
"pubkey":"SjAmrAqH7LScCUwM1qo5O6Cu7aKhrM1ORszgZwD7HmU=",
|
||||
"feepercentage":0.05,
|
||||
"feepercentage":3.0,
|
||||
"vspclosed":false,
|
||||
"network":"testnet3"
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
<table>
|
||||
<tr><td>Total tickets:</td><td>{{ .TotalTickets }}</td></tr>
|
||||
<tr><td>Fee confirmed tickets:</td><td>{{ .FeeConfirmedTickets }}</td></tr>
|
||||
<tr><td>VSP Fee:</td><td>{{ .VSPFee }}</td></tr>
|
||||
<tr><td>VSP Fee:</td><td>{{ .VSPFee }}% of vote reward</td></tr>
|
||||
<tr><td>Network:</td><td>{{ .Network }}</td></tr>
|
||||
<tr><td>Support:</td><td>{{ .SupportEmail }}</td></tr>
|
||||
<tr><td>Pubkey:</td><td>{{ printf "%x" .PubKey }}</td></tr>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user