Skip to content

Commit

Permalink
fix build errors after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
itswisdomagain committed Aug 21, 2019
1 parent 98ae593 commit 5f42c09
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 59 deletions.
86 changes: 43 additions & 43 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,50 +67,50 @@ var runServiceCommand func(string) error
//
// See loadConfig for details on the configuration load process.
type config struct {
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`
ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"`
DataDir string `short:"b" long:"datadir" description:"Directory to store data"`
LogDir string `long:"logdir" description:"Directory to log output."`
Listen string `long:"listen" description:"Listen for connections on the specified interface/port (default all interfaces port: 9113, testnet: 19113)"`
TestNet bool `long:"testnet" description:"Use the test network"`
SimNet bool `long:"simnet" description:"Use the simulation test network"`
Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"`
CPUProfile string `long:"cpuprofile" description:"Write CPU profile to the specified file"`
MemProfile string `long:"memprofile" description:"Write mem profile to the specified file"`
DebugLevel string `short:"d" long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems"`
APISecret string `long:"apisecret" description:"Secret string used to encrypt API tokens."`
BaseURL string `long:"baseurl" description:"BaseURL to use when sending links via email"`
ShowVersion bool `short:"V" long:"version" description:"Display version information and exit"`
ConfigFile string `short:"C" long:"configfile" description:"Path to configuration file"`
DataDir string `short:"b" long:"datadir" description:"Directory to store data"`
LogDir string `long:"logdir" description:"Directory to log output."`
Listen string `long:"listen" description:"Listen for connections on the specified interface/port (default all interfaces port: 9113, testnet: 19113)"`
TestNet bool `long:"testnet" description:"Use the test network"`
SimNet bool `long:"simnet" description:"Use the simulation test network"`
Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"`
CPUProfile string `long:"cpuprofile" description:"Write CPU profile to the specified file"`
MemProfile string `long:"memprofile" description:"Write mem profile to the specified file"`
DebugLevel string `short:"d" long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems"`
APISecret string `long:"apisecret" description:"Secret string used to encrypt API tokens."`
BaseURL string `long:"baseurl" description:"BaseURL to use when sending links via email"`
// todo: can `ColdWalletExtPub` and `PoolFees` be read from stakepoold via rpc?
ColdWalletExtPub string `long:"coldwalletextpub" description:"The extended public key for addresses to which voting service user fees are sent."`
ClosePool bool `long:"closepool" description:"Disable user registration actions (sign-ups and submitting addresses)"`
ClosePoolMsg string `long:"closepoolmsg" description:"Message to display when closepool is set."`
CookieSecret string `long:"cookiesecret" description:"Secret string used to encrypt session data."`
CookieSecure bool `long:"cookiesecure" description:"Set whether cookies can be sent in clear text or not."`
DBHost string `long:"dbhost" description:"Hostname for database connection"`
DBUser string `long:"dbuser" description:"Username for database connection"`
DBPassword string `long:"dbpassword" description:"Password for database connection"`
DBPort string `long:"dbport" description:"Port for database connection"`
DBName string `long:"dbname" description:"Name of database"`
PublicPath string `long:"publicpath" description:"Path to the public folder which contains css/fonts/images/javascript."`
TemplatePath string `long:"templatepath" description:"Path to the views folder which contains html files."`
PoolEmail string `long:"poolemail" description:"Email address to for support inquiries"`
PoolFees float64 `long:"poolfees" description:"The per-ticket fees the user must send to the pool with their tickets"`
PoolLink string `long:"poollink" description:"URL for support inquiries such as forum, IRC, etc"`
RealIPHeader string `long:"realipheader" description:"The name of an HTTP request header containing the actual remote client IP address, typically set by a reverse proxy. An empty string (default) indicates to use net/Request.RemodeAddr."`
SMTPFrom string `long:"smtpfrom" description:"From address to use on outbound mail"`
SMTPHost string `long:"smtphost" description:"SMTP hostname/ip and port, e.g. mail.example.com:25"`
SMTPUsername string `long:"smtpusername" description:"SMTP username for authentication if required"`
SMTPPassword string `long:"smtppassword" description:"SMTP password for authentication if required"`
UseSMTPS bool `long:"usesmtps" description:"Connect to the SMTP server using smtps."`
SMTPSkipVerify bool `long:"smtpskipverify" description:"Skip SMTP TLS cert verification. Will only skip if SMTPCert is empty"`
SMTPCert string `long:"smtpcert" description:"Path for the smtp certificate file"`
SystemCerts *x509.CertPool
StakepooldHosts []string `long:"stakepooldhosts" description:"Hostnames for stakepoold servers"`
StakepooldCerts []string `long:"stakepooldcerts" description:"Certificate paths for stakepoold servers"`
WalletHosts []string `long:"wallethosts" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"`
WalletUsers []string `long:"walletusers" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"`
WalletPasswords []string `long:"walletpasswords" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"`
WalletCerts []string `long:"walletcerts" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"`
ColdWalletExtPub string `long:"coldwalletextpub" description:"The extended public key for addresses to which voting service user fees are sent."`
ClosePool bool `long:"closepool" description:"Disable user registration actions (sign-ups and submitting addresses)"`
ClosePoolMsg string `long:"closepoolmsg" description:"Message to display when closepool is set."`
CookieSecret string `long:"cookiesecret" description:"Secret string used to encrypt session data."`
CookieSecure bool `long:"cookiesecure" description:"Set whether cookies can be sent in clear text or not."`
DBHost string `long:"dbhost" description:"Hostname for database connection"`
DBUser string `long:"dbuser" description:"Username for database connection"`
DBPassword string `long:"dbpassword" description:"Password for database connection"`
DBPort string `long:"dbport" description:"Port for database connection"`
DBName string `long:"dbname" description:"Name of database"`
PublicPath string `long:"publicpath" description:"Path to the public folder which contains css/fonts/images/javascript."`
TemplatePath string `long:"templatepath" description:"Path to the views folder which contains html files."`
PoolEmail string `long:"poolemail" description:"Email address to for support inquiries"`
PoolFees float64 `long:"poolfees" description:"The per-ticket fees the user must send to the pool with their tickets"`
PoolLink string `long:"poollink" description:"URL for support inquiries such as forum, IRC, etc"`
RealIPHeader string `long:"realipheader" description:"The name of an HTTP request header containing the actual remote client IP address, typically set by a reverse proxy. An empty string (default) indicates to use net/Request.RemodeAddr."`
SMTPFrom string `long:"smtpfrom" description:"From address to use on outbound mail"`
SMTPHost string `long:"smtphost" description:"SMTP hostname/ip and port, e.g. mail.example.com:25"`
SMTPUsername string `long:"smtpusername" description:"SMTP username for authentication if required"`
SMTPPassword string `long:"smtppassword" description:"SMTP password for authentication if required"`
UseSMTPS bool `long:"usesmtps" description:"Connect to the SMTP server using smtps."`
SMTPSkipVerify bool `long:"smtpskipverify" description:"Skip SMTP TLS cert verification. Will only skip if SMTPCert is empty"`
SMTPCert string `long:"smtpcert" description:"Path for the smtp certificate file"`
SystemCerts *x509.CertPool
StakepooldHosts []string `long:"stakepooldhosts" description:"Hostnames for stakepoold servers"`
StakepooldCerts []string `long:"stakepooldcerts" description:"Certificate paths for stakepoold servers"`
WalletHosts []string `long:"wallethosts" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"`
WalletUsers []string `long:"walletusers" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"`
WalletPasswords []string `long:"walletpasswords" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"`
WalletCerts []string `long:"walletcerts" description:"Deprecated: dcrstakepool no longer connects to dcrwallet"`
// todo: `VotingWalletExtPub` can be read from the vsp backend dcrwallet via stakepoold rpc instead!
VotingWalletExtPub string `long:"votingwalletextpub" description:"The extended public key of the default account of the voting wallet"`
AdminIPs []string `long:"adminips" description:"Expected admin host"`
Expand Down
24 changes: 8 additions & 16 deletions controllers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func (controller *MainController) APIAddress(c web.C, r *http.Request) ([]string
return nil, codes.Unavailable, "system error", errors.New("unable to process wallet commands")
}

userFeeAddr, err := controller.FeeAddressForUserID(userId)
userFeeAddr, err := controller.FeeAddressForUserID(int(user.Id))
if err != nil {
log.Warnf("unexpected error deriving pool addr: %s", err.Error())
return nil, codes.Unavailable, "system error", errors.New("unable to process wallet commands")
Expand All @@ -386,8 +386,7 @@ func (controller *MainController) APIAddress(c web.C, r *http.Request) ([]string
func (controller *MainController) APIPurchaseTicket(c web.C, r *http.Request) (*poolapi.PurchaseInfo, codes.Code, string, error) {
userPubKeyAddr := r.FormValue("UserPubKeyAddr")

u, err := validateUserPubKeyAddr(userPubKeyAddr)
if err != nil {
if _, err := validateUserPubKeyAddr(userPubKeyAddr); err != nil {
return nil, codes.InvalidArgument, "address error", err
}

Expand Down Expand Up @@ -417,7 +416,7 @@ func (controller *MainController) APIPurchaseTicket(c web.C, r *http.Request) (*
remoteIP := getClientIP(r, controller.realIPHeader)
log.Infof("APIPurchaseTicket POST from %v, created new user account %v. Inserting.", remoteIP, user.Email)

err = models.InsertUser(dbMap, user)
err := models.InsertUser(dbMap, user)
if err != nil {
log.Errorf("Error while creating new user account for ticket purchase: %v", err)
return nil, codes.Unavailable, "system error", errors.New("unable to setup db entry for purchase")
Expand All @@ -428,7 +427,7 @@ func (controller *MainController) APIPurchaseTicket(c web.C, r *http.Request) (*
userId := int(user.Id)

// Get the ticket address for this user
pooladdress, err := controller.TicketAddressForUserID(userId)
pooladdress, err := controller.TicketAddressForUserID(int(user.Id))
if err != nil {
log.Errorf("unable to derive ticket address: %v", err)
return nil, codes.Unavailable, "system error", errors.New("unable to process wallet commands")
Expand All @@ -447,29 +446,22 @@ func (controller *MainController) APIPurchaseTicket(c web.C, r *http.Request) (*

poolPubKeyAddr := poolValidateAddress.PubKeyAddr

p, err := dcrutil.DecodeAddress(poolPubKeyAddr)
if err != nil {
controller.handlePotentialFatalError("DecodeAddress poolPubKeyAddr", err)
if _, err = dcrutil.DecodeAddress(poolPubKeyAddr); err != nil {
return nil, codes.Unavailable, "system error", errors.New("unable to process wallet commands")
}

if controller.RPCIsStopped() {
return nil, codes.Unavailable, "system error", errors.New("unable to process wallet commands")
}
createMultiSig, err := controller.rpcServers.CreateMultisig(1, []dcrutil.Address{p, u})
createMultiSig, err := controller.StakepooldServers.CreateMultisig([]string{poolPubKeyAddr, userPubKeyAddr})
if err != nil {
controller.handlePotentialFatalError("CreateMultisig", err)
return nil, codes.Unavailable, "system error", errors.New("unable to process wallet commands")
}

// Serialize the RedeemScript (hex string -> []byte)
// Serialize the redeem script (hex string -> []byte)
serializedScript, err := hex.DecodeString(createMultiSig.RedeemScript)
if err != nil {
controller.handlePotentialFatalError("CreateMultisig DecodeString", err)
return nil, codes.Unavailable, "system error", errors.New("unable to process wallet commands")
}

// Import the RedeemScript
// Import the redeem script
var importedHeight int64
importedHeight, err = controller.StakepooldServers.ImportScript(serializedScript)
if err != nil {
Expand Down

0 comments on commit 5f42c09

Please sign in to comment.