Skip to content

Commit

Permalink
server.go: get public key from stakepoold
Browse files Browse the repository at this point in the history
- set votingWalletVoteKey
- check that coldwalletextpub does not belong to the pool
  • Loading branch information
JoeGruffins committed Jul 31, 2019
1 parent fb2a7ac commit d57e816
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package main

import (
"errors"
"fmt"
"net"
"net/http"
Expand All @@ -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"
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d57e816

Please sign in to comment.