From d57e8163fefd5308e4cd8c9c81c758ac46f7b2d2 Mon Sep 17 00:00:00 2001 From: JoeGruff Date: Wed, 31 Jul 2019 04:00:36 +0000 Subject: [PATCH] server.go: get public key from stakepoold - set votingWalletVoteKey - check that coldwalletextpub does not belong to the pool --- server.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server.go b/server.go index 7022c253..815711d1 100644 --- a/server.go +++ b/server.go @@ -5,6 +5,7 @@ package main import ( + "errors" "fmt" "net" "net/http" @@ -14,6 +15,7 @@ import ( "github.com/gorilla/context" "github.com/gorilla/csrf" + "github.com/decred/dcrd/hdkeychain" "github.com/decred/dcrd/rpcclient/v3" "github.com/decred/dcrstakepool/controllers" "github.com/decred/dcrstakepool/email" @@ -95,6 +97,22 @@ func runMain() error { return fmt.Errorf("Failed to initialize the smtp server: %v", err) } + // Retrieve the extended public key for the voting wallet's "default" account. + voteKey, err := stakepooldConnMan.DefaultAccountPubKey() + if err != nil { + return fmt.Errorf("failed to get master extended public key for the \"default\" account: %v", err) + } + if votingWalletVoteKey, err = hdkeychain.NewKeyFromString(voteKey); err != nil { + return fmt.Errorf("unable to decode the voting wallet master extended public key: %v", err) + } + // Check that coldwalletextpub does not belong to the voting wallets. + if hasKey, err := stakepooldConnMan.WalletsHavePubKey(cfg.ColdWalletExtPub); err != nil || hasKey { + if err != nil { + return fmt.Errorf("failed to get master extended public keys: %v", err) + } + return errors.New("the Cold Wallet Extended Public Key must not belong to the voting wallet") + } + controller, err := controllers.NewMainController(activeNetParams.Params, cfg.AdminIPs, cfg.AdminUserIDs, cfg.APISecret, APIVersionsSupported, cfg.BaseURL, cfg.ClosePool, cfg.ClosePoolMsg, coldWalletFeeKey,