diff --git a/config.go b/config.go index 3a0e3423..c857ed54 100644 --- a/config.go +++ b/config.go @@ -62,6 +62,7 @@ type config struct { SupportEmail string `long:"supportemail" ini-name:"supportemail" description:"Email address for users in need of support."` BackupInterval time.Duration `long:"backupinterval" ini-name:"backupinterval" description:"Time period between automatic database backups. Valid time units are {s,m,h}. Minimum 30 seconds."` VspClosed bool `long:"vspclosed" ini-name:"vspclosed" description:"Closed prevents the VSP from accepting new tickets."` + VspClosedMsg string `long:"vspclosedmsg" ini-name:"vspclosedmsg" description:"A short message displayed on the webpage and returned by the status API endpoint if vspdclosed is true."` AdminPass string `long:"adminpass" ini-name:"adminpass" description:"Password for accessing admin page."` Designation string `long:"designation" ini-name:"designation" description:"Short name for the VSP. Customizes the logo in the top toolbar."` @@ -292,6 +293,11 @@ func loadConfig() (*config, error) { return nil, errors.New("invalid vspfee - should be greater than 0.01 and less than 100.0") } + // If VSP is not closed, ignore any provided closure message. + if !cfg.VspClosed { + cfg.VspClosedMsg = "" + } + // Ensure the support email address is set. if cfg.SupportEmail == "" { return nil, errors.New("the supportemail option is not set") @@ -409,7 +415,7 @@ func loadConfig() (*config, error) { // If database already exists, return error. if fileExists(cfg.dbPath) { return nil, fmt.Errorf("database already initialized at %s, "+ - "--feexpub option is not needed.", cfg.dbPath) + "--feexpub option is not needed", cfg.dbPath) } // Ensure provided value is a valid key for the selected network. @@ -431,7 +437,7 @@ func loadConfig() (*config, error) { // If database does not exist, return error. if !fileExists(cfg.dbPath) { return nil, fmt.Errorf("no database exists in %s. Run vspd with the"+ - " --feexpub option to initialize one.", dataDir) + " --feexpub option to initialize one", dataDir) } } diff --git a/docs/api.md b/docs/api.md index a80174f4..362cf3cc 100644 --- a/docs/api.md +++ b/docs/api.md @@ -49,6 +49,7 @@ when a VSP is closed will result in an error. "pubkey":"SjAmrAqH7LScCUwM1qo5O6Cu7aKhrM1ORszgZwD7HmU=", "feepercentage":3.0, "vspclosed":false, + "vspclosedmsg": "", "network":"testnet3", "vspdversion":"1.0.0-pre", "voting":10, diff --git a/harness.sh b/harness.sh index 911fb50d..c8a78dd1 100755 --- a/harness.sh +++ b/harness.sh @@ -151,6 +151,7 @@ webserverdebug = false supportemail = example@test.com backupinterval = 3m0s vspclosed = false +vspclosedmsg = Your tickets are no longer welcome here. Please go away. adminpass=12345 designation = harness EOF diff --git a/vspd.go b/vspd.go index b9ee11bd..4eae58df 100644 --- a/vspd.go +++ b/vspd.go @@ -90,6 +90,7 @@ func run(ctx context.Context) error { BlockExplorerURL: cfg.netParams.BlockExplorerURL, SupportEmail: cfg.SupportEmail, VspClosed: cfg.VspClosed, + VspClosedMsg: cfg.VspClosedMsg, AdminPass: cfg.AdminPass, Debug: cfg.WebServerDebug, Designation: cfg.Designation, diff --git a/webapi/homepage.go b/webapi/homepage.go index 0b0b01c6..f19cbd23 100644 --- a/webapi/homepage.go +++ b/webapi/homepage.go @@ -30,6 +30,7 @@ type vspStats struct { UpdateTime string SupportEmail string VspClosed bool + VspClosedMsg string Debug bool Designation string BlockHeight uint32 @@ -60,6 +61,7 @@ func initVSPStats() { Network: cfg.NetParams.Name, SupportEmail: cfg.SupportEmail, VspClosed: cfg.VspClosed, + VspClosedMsg: cfg.VspClosedMsg, Debug: cfg.Debug, Designation: cfg.Designation, } diff --git a/webapi/templates/homepage.html b/webapi/templates/homepage.html index a0faec90..7be67646 100644 --- a/webapi/templates/homepage.html +++ b/webapi/templates/homepage.html @@ -5,9 +5,16 @@ {{ if .VspStats.VspClosed }}
-

This Voting Service Provider is closed

- A closed VSP will still vote on tickets with already paid fees, but will not accept new any tickets. - Visit decred.org to find a new VSP. +

+ This Voting Service Provider is closed +

+

+ {{ .VspStats.VspClosedMsg }} +

+

+ A closed VSP will still vote on tickets with already paid fees, but will not accept new any tickets. + Visit decred.org to find a new VSP. +

{{ end }} diff --git a/webapi/types.go b/webapi/types.go index b1d18f6c..2506e0bb 100644 --- a/webapi/types.go +++ b/webapi/types.go @@ -10,6 +10,7 @@ type vspInfoResponse struct { PubKey []byte `json:"pubkey"` FeePercentage float64 `json:"feepercentage"` VspClosed bool `json:"vspclosed"` + VspClosedMsg string `json:"vspclosedmsg"` Network string `json:"network"` VspdVersion string `json:"vspdversion"` Voting int64 `json:"voting"` diff --git a/webapi/vspinfo.go b/webapi/vspinfo.go index 7c6a1411..b4514660 100644 --- a/webapi/vspinfo.go +++ b/webapi/vspinfo.go @@ -21,6 +21,7 @@ func vspInfo(c *gin.Context) { FeePercentage: cfg.VSPFee, Network: cfg.NetParams.Name, VspClosed: cfg.VspClosed, + VspClosedMsg: cfg.VspClosedMsg, VspdVersion: version.String(), Voting: cachedStats.Voting, Voted: cachedStats.Voted, diff --git a/webapi/webapi.go b/webapi/webapi.go index e7a6176b..05f412bd 100644 --- a/webapi/webapi.go +++ b/webapi/webapi.go @@ -31,6 +31,7 @@ type Config struct { FeeAccountName string SupportEmail string VspClosed bool + VspClosedMsg string AdminPass string Debug bool Designation string