remove remnants of accounts

This commit is contained in:
Martin Holst Swende 2018-08-14 13:20:35 +02:00
parent a5470a6ab5
commit 0c8f2376fa
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0
6 changed files with 11 additions and 76 deletions

View file

@ -51,13 +51,10 @@ var (
// flags that configure the node // flags that configure the node
nodeFlags = []cli.Flag{ nodeFlags = []cli.Flag{
utils.IdentityFlag, utils.IdentityFlag,
utils.UnlockedAccountFlag,
utils.PasswordFileFlag,
utils.BootnodesFlag, utils.BootnodesFlag,
utils.BootnodesV4Flag, utils.BootnodesV4Flag,
utils.BootnodesV5Flag, utils.BootnodesV5Flag,
utils.DataDirFlag, utils.DataDirFlag,
utils.KeyStoreDirFlag,
utils.NoUSBFlag, utils.NoUSBFlag,
utils.DashboardEnabledFlag, utils.DashboardEnabledFlag,
utils.DashboardAddrFlag, utils.DashboardAddrFlag,

View file

@ -69,7 +69,6 @@ var AppHelpFlagGroups = []flagGroup{
Flags: []cli.Flag{ Flags: []cli.Flag{
configFileFlag, configFileFlag,
utils.DataDirFlag, utils.DataDirFlag,
utils.KeyStoreDirFlag,
utils.NoUSBFlag, utils.NoUSBFlag,
utils.NetworkIdFlag, utils.NetworkIdFlag,
utils.TestnetFlag, utils.TestnetFlag,
@ -135,13 +134,6 @@ var AppHelpFlagGroups = []flagGroup{
utils.TrieCacheGenFlag, utils.TrieCacheGenFlag,
}, },
}, },
{
Name: "ACCOUNT",
Flags: []cli.Flag{
utils.UnlockedAccountFlag,
utils.PasswordFileFlag,
},
},
{ {
Name: "API AND CONSOLE", Name: "API AND CONSOLE",
Flags: []cli.Flag{ Flags: []cli.Flag{

View file

@ -460,7 +460,6 @@ pv(1) tool to get a progress bar:
utils.NATFlag, utils.NATFlag,
utils.IPCDisabledFlag, utils.IPCDisabledFlag,
utils.IPCPathFlag, utils.IPCPathFlag,
utils.PasswordFileFlag,
// bzzd-specific flags // bzzd-specific flags
CorsStringFlag, CorsStringFlag,
EnsAPIFlag, EnsAPIFlag,
@ -610,11 +609,8 @@ func getAccount(bzzaccount string, ctx *cli.Context, stack *node.Node) *ecdsa.Pr
log.Info("Swarm account key loaded", "address", crypto.PubkeyToAddress(key.PublicKey)) log.Info("Swarm account key loaded", "address", crypto.PubkeyToAddress(key.PublicKey))
return key return key
} }
// Otherwise try getting it from the keystore. utils.Fatalf(SWARM_ERR_NO_BZZACCOUNT)
am := stack.AccountManager() return nil
ks := am.Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
return decryptStoreAccount(ks, bzzaccount, utils.MakePasswordList(ctx))
} }
// getPrivKey returns the private key of the specified bzzaccount // getPrivKey returns the private key of the specified bzzaccount

View file

@ -20,7 +20,6 @@ package utils
import ( import (
"crypto/ecdsa" "crypto/ecdsa"
"fmt" "fmt"
"io/ioutil"
"math/big" "math/big"
"os" "os"
"path/filepath" "path/filepath"
@ -343,16 +342,6 @@ var (
Usage: "Block extra data set by the miner (default = client version)", Usage: "Block extra data set by the miner (default = client version)",
} }
// Account settings // Account settings
UnlockedAccountFlag = cli.StringFlag{
Name: "unlock",
Usage: "Comma separated list of accounts to unlock",
Value: "",
}
PasswordFileFlag = cli.StringFlag{
Name: "password",
Usage: "Password file to use for non-interactive password input",
Value: "",
}
ExternalSignerFlag = cli.StringFlag{ ExternalSignerFlag = cli.StringFlag{
Name: "signer", Name: "signer",
Usage: "External signer (url or path to ipc file)", Usage: "External signer (url or path to ipc file)",
@ -814,23 +803,6 @@ func setEtherbase(ctx *cli.Context, cfg *eth.Config) {
} }
} }
// MakePasswordList reads password lines from the file specified by the global --password flag.
func MakePasswordList(ctx *cli.Context) []string {
path := ctx.GlobalString(PasswordFileFlag.Name)
if path == "" {
return nil
}
text, err := ioutil.ReadFile(path)
if err != nil {
Fatalf("Failed to read password file: %v", err)
}
lines := strings.Split(string(text), "\n")
// Sanitise DOS line endings.
for i := range lines {
lines[i] = strings.TrimRight(lines[i], "\r")
}
return lines
}
func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) { func SetP2PConfig(ctx *cli.Context, cfg *p2p.Config) {
setNodeKey(ctx, cfg) setNodeKey(ctx, cfg)

View file

@ -159,37 +159,6 @@ func (c *Console) init(preload []string) error {
// Initialize the global name register (disabled for now) // Initialize the global name register (disabled for now)
//c.jsre.Run(`var GlobalRegistrar = eth.contract(` + registrar.GlobalRegistrarAbi + `); registrar = GlobalRegistrar.at("` + registrar.GlobalRegistrarAddr + `");`) //c.jsre.Run(`var GlobalRegistrar = eth.contract(` + registrar.GlobalRegistrarAbi + `); registrar = GlobalRegistrar.at("` + registrar.GlobalRegistrarAddr + `");`)
// If the console is in interactive mode, instrument password related methods to query the user
if c.prompter != nil {
// Retrieve the account management object to instrument
personal, err := c.jsre.Get("personal")
if err != nil {
return err
}
// Override the openWallet, unlockAccount, newAccount and sign methods since
// these require user interaction. Assign these method in the Console the
// original web3 callbacks. These will be called by the jeth.* methods after
// they got the password from the user and send the original web3 request to
// the backend.
if obj := personal.Object(); obj != nil { // make sure the personal api is enabled over the interface
if _, err = c.jsre.Run(`jeth.openWallet = personal.openWallet;`); err != nil {
return fmt.Errorf("personal.openWallet: %v", err)
}
if _, err = c.jsre.Run(`jeth.unlockAccount = personal.unlockAccount;`); err != nil {
return fmt.Errorf("personal.unlockAccount: %v", err)
}
if _, err = c.jsre.Run(`jeth.newAccount = personal.newAccount;`); err != nil {
return fmt.Errorf("personal.newAccount: %v", err)
}
if _, err = c.jsre.Run(`jeth.sign = personal.sign;`); err != nil {
return fmt.Errorf("personal.sign: %v", err)
}
obj.Set("openWallet", bridge.OpenWallet)
obj.Set("unlockAccount", bridge.UnlockAccount)
obj.Set("newAccount", bridge.NewAccount)
obj.Set("sign", bridge.Sign)
}
}
// The admin.sleep and admin.sleepBlocks are offered by the console and not by the RPC layer. // The admin.sleep and admin.sleepBlocks are offered by the console and not by the RPC layer.
admin, err := c.jsre.Get("admin") admin, err := c.jsre.Get("admin")
if err != nil { if err != nil {

View file

@ -1336,6 +1336,9 @@ func NewExternalSigner(endpoint string) (*ExternalSignerAPI, error) {
} }
func (api *ExternalSignerAPI) signTransaction(ctx context.Context, args SendTxArgs) (*types.Transaction, error) { func (api *ExternalSignerAPI) signTransaction(ctx context.Context, args SendTxArgs) (*types.Transaction, error) {
if api == nil{
return nil, errors.New("External API not initialized")
}
res := SignTransactionResult{} res := SignTransactionResult{}
if err := api.client.Call(&res, "account_signTransaction", args); err != nil { if err := api.client.Call(&res, "account_signTransaction", args); err != nil {
return nil, err return nil, err
@ -1343,6 +1346,9 @@ func (api *ExternalSignerAPI) signTransaction(ctx context.Context, args SendTxAr
return res.Tx, nil return res.Tx, nil
} }
func (api *ExternalSignerAPI) listAccounts() ([]common.Address, error) { func (api *ExternalSignerAPI) listAccounts() ([]common.Address, error) {
if api == nil{
return []common.Address{}, errors.New("External API not initialized")
}
var res []common.Address var res []common.Address
if err := api.client.Call(&res, "account_listAccounts"); err != nil { if err := api.client.Call(&res, "account_listAccounts"); err != nil {
return nil, err return nil, err
@ -1350,6 +1356,9 @@ func (api *ExternalSignerAPI) listAccounts() ([]common.Address, error) {
return res, nil return res, nil
} }
func (api *ExternalSignerAPI) newAccount() (common.Address, error) { func (api *ExternalSignerAPI) newAccount() (common.Address, error) {
if api == nil{
return common.Address{}, errors.New("External API not initialized")
}
var res accounts.Account var res accounts.Account
if err := api.client.Call(&res, "account_new"); err != nil { if err := api.client.Call(&res, "account_new"); err != nil {