Skip to content

Commit

Permalink
assert private key available in online mode
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Steven Allen <[email protected]>
  • Loading branch information
Stebalien committed Dec 13, 2018
1 parent 2eafa3f commit 58292f7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
return errors.New("node already online")
}

if n.PrivateKey == nil {
return fmt.Errorf("private key not available")
}

// get undialable addrs from config
cfg, err := n.Repo.Config()
if err != nil {
Expand Down Expand Up @@ -767,6 +771,9 @@ func (n *IpfsNode) loadID() error {
// GetKey will return a key from the Keystore with name `name`.
func (n *IpfsNode) GetKey(name string) (ic.PrivKey, error) {
if name == "self" {
if n.PrivateKey == nil {
return nil, fmt.Errorf("private key not available")
}
return n.PrivateKey, nil
} else {
return n.Repo.Keystore().Get(name)
Expand Down

0 comments on commit 58292f7

Please sign in to comment.