accounts, internal, signer: formatting

This commit is contained in:
Martin Holst Swende 2018-11-29 09:54:21 +01:00
parent e29a666258
commit a6239990a2
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0
7 changed files with 12 additions and 12 deletions

View file

@ -18,6 +18,9 @@ package external
import ( import (
"fmt" "fmt"
"math/big"
"sync"
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -28,8 +31,6 @@ import (
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/signer/core" "github.com/ethereum/go-ethereum/signer/core"
"math/big"
"sync"
) )
type ExternalBackend struct { type ExternalBackend struct {

View file

@ -281,7 +281,7 @@ func startNode(ctx *cli.Context, stack *node.Node) {
utils.StartNode(stack) utils.StartNode(stack)
// Unlock any account specifically requested // Unlock any account specifically requested
if keystores := stack.AccountManager().Backends(keystore.KeyStoreType); len(keystores) > 0{ if keystores := stack.AccountManager().Backends(keystore.KeyStoreType); len(keystores) > 0 {
ks := keystores[0].(*keystore.KeyStore) ks := keystores[0].(*keystore.KeyStore)
passwords := utils.MakePasswordList(ctx) passwords := utils.MakePasswordList(ctx)
unlocks := strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",") unlocks := strings.Split(ctx.GlobalString(utils.UnlockedAccountFlag.Name), ",")

View file

@ -890,7 +890,7 @@ func setEtherbase(ctx *cli.Context, ks *keystore.KeyStore, cfg *eth.Config) {
Fatalf("Invalid miner etherbase: %v", err) Fatalf("Invalid miner etherbase: %v", err)
} }
cfg.Etherbase = account.Address cfg.Etherbase = account.Address
}else{ } else {
Fatalf("No etherbase configured") Fatalf("No etherbase configured")
} }
} }
@ -991,7 +991,7 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
setDataDir(ctx, cfg) setDataDir(ctx, cfg)
if ctx.GlobalIsSet( ExternalSignerFlag.Name){ if ctx.GlobalIsSet(ExternalSignerFlag.Name) {
cfg.ExternalSigner = ctx.GlobalString(ExternalSignerFlag.Name) cfg.ExternalSigner = ctx.GlobalString(ExternalSignerFlag.Name)
} }
@ -1176,7 +1176,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
checkExclusive(ctx, LightServFlag, SyncModeFlag, "light") checkExclusive(ctx, LightServFlag, SyncModeFlag, "light")
var ks *keystore.KeyStore var ks *keystore.KeyStore
if keystores := stack.AccountManager().Backends(keystore.KeyStoreType); len(keystores) > 0{ if keystores := stack.AccountManager().Backends(keystore.KeyStoreType); len(keystores) > 0 {
ks = keystores[0].(*keystore.KeyStore) ks = keystores[0].(*keystore.KeyStore)
} }
setEtherbase(ctx, ks, cfg) setEtherbase(ctx, ks, cfg)

View file

@ -22,6 +22,7 @@ import (
"sort" "sort"
"testing" "testing"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
@ -80,7 +81,7 @@ func (ap *testerAccountPool) sign(header *types.Header, signer string) {
ap.accounts[signer], _ = crypto.GenerateKey() ap.accounts[signer], _ = crypto.GenerateKey()
} }
// Sign the header and embed the signature in extra data // Sign the header and embed the signature in extra data
sig, _ := crypto.Sign(sigHash(header).Bytes(), ap.accounts[signer]) sig, _ := crypto.Sign(accounts.CliqueHash(header).Bytes(), ap.accounts[signer])
copy(header.Extra[len(header.Extra)-extraSeal:], sig) copy(header.Extra[len(header.Extra)-extraSeal:], sig)
} }

View file

@ -409,7 +409,6 @@ func (s *PrivateAccountAPI) SignTransaction(ctx context.Context, args SendTxArgs
return &SignTransactionResult{data, signed}, nil return &SignTransactionResult{data, signed}, nil
} }
// Sign calculates an Ethereum ECDSA signature for: // Sign calculates an Ethereum ECDSA signature for:
// keccack256("\x19Ethereum Signed Message:\n" + len(message) + message)) // keccack256("\x19Ethereum Signed Message:\n" + len(message) + message))
// //

View file

@ -436,11 +436,11 @@ func makeAccountManager(conf *Config) (*accounts.Manager, string, error) {
// Assemble the account manager and supported backends // Assemble the account manager and supported backends
backends := []accounts.Backend{} backends := []accounts.Backend{}
if len(conf.ExternalSigner) > 0 { if len(conf.ExternalSigner) > 0 {
if extapi,err := external.NewExternalBackend(conf.ExternalSigner); err == nil{ if extapi, err := external.NewExternalBackend(conf.ExternalSigner); err == nil {
backends = append(backends, extapi) backends = append(backends, extapi)
} }
} }
if len(backends) == 0{ if len(backends) == 0 {
// For now, we're using EITHER external signer OR local signers. // For now, we're using EITHER external signer OR local signers.
// If/when we implement some form of lockfile for USB and keystore wallets, // If/when we implement some form of lockfile for USB and keystore wallets,
// we can have both, but it's very confusing for the user to see the same // we can have both, but it's very confusing for the user to see the same
@ -462,7 +462,6 @@ func makeAccountManager(conf *Config) (*accounts.Manager, string, error) {
} }
} }
return accounts.NewManager(backends...), ephemeral, nil return accounts.NewManager(backends...), ephemeral, nil
} }

View file

@ -53,7 +53,7 @@ type ExternalAPI interface {
New(ctx context.Context) (accounts.Account, error) New(ctx context.Context) (accounts.Account, error)
// SignTransaction request to sign the specified transaction // SignTransaction request to sign the specified transaction
SignTransaction(ctx context.Context, args SendTxArgs, methodSelector *string) (*ethapi.SignTransactionResult, error) SignTransaction(ctx context.Context, args SendTxArgs, methodSelector *string) (*ethapi.SignTransactionResult, error)
// Sign - resquest to sign the given data (plus prefix) // Sign - request to sign the given data (plus prefix)
Sign(ctx context.Context, addr common.MixedcaseAddress, data hexutil.Bytes) (hexutil.Bytes, error) Sign(ctx context.Context, addr common.MixedcaseAddress, data hexutil.Bytes) (hexutil.Bytes, error)
// Export - request to export an account // Export - request to export an account
Export(ctx context.Context, addr common.Address) (json.RawMessage, error) Export(ctx context.Context, addr common.Address) (json.RawMessage, error)