github.com/ethereum-optimism/optimism@v1.7.2/op-node/p2p/cli/load_signer.go (about)

     1  package cli
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  
     7  	"github.com/ethereum/go-ethereum/crypto"
     8  	"github.com/urfave/cli/v2"
     9  
    10  	"github.com/ethereum-optimism/optimism/op-node/flags"
    11  	"github.com/ethereum-optimism/optimism/op-node/p2p"
    12  )
    13  
    14  // TODO: implement remote signer setup (config to authenticated endpoint)
    15  // and remote signer itself (e.g. a open http client to make signing requests)
    16  
    17  // LoadSignerSetup loads a configuration for a Signer to be set up later
    18  func LoadSignerSetup(ctx *cli.Context) (p2p.SignerSetup, error) {
    19  	key := ctx.String(flags.SequencerP2PKeyName)
    20  	if key != "" {
    21  		// Mnemonics are bad because they leak *all* keys when they leak.
    22  		// Unencrypted keys from file are bad because they are easy to leak (and we are not checking file permissions).
    23  		priv, err := crypto.HexToECDSA(strings.TrimPrefix(key, "0x"))
    24  		if err != nil {
    25  			return nil, fmt.Errorf("failed to read batch submitter key: %w", err)
    26  		}
    27  
    28  		return &p2p.PreparedSigner{Signer: p2p.NewLocalSigner(priv)}, nil
    29  	}
    30  
    31  	// TODO: create remote signer
    32  
    33  	return nil, nil
    34  }