aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-05-13 01:00:35 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-05-13 01:00:35 +0800
commitd6357aa616715df1e98cfb90c3aa5372e15cc24b (patch)
tree3f1792e7d71a82de0ceb6047eaf87f2f72aa82ff /cmd
parent58d6ec689ff44232cd5d6a7cbbaad2d7a2cb44bd (diff)
parente389585f1f2e77fd7cd507499015bf3754581e4e (diff)
downloadgo-tangerine-d6357aa616715df1e98cfb90c3aa5372e15cc24b.tar
go-tangerine-d6357aa616715df1e98cfb90c3aa5372e15cc24b.tar.gz
go-tangerine-d6357aa616715df1e98cfb90c3aa5372e15cc24b.tar.bz2
go-tangerine-d6357aa616715df1e98cfb90c3aa5372e15cc24b.tar.lz
go-tangerine-d6357aa616715df1e98cfb90c3aa5372e15cc24b.tar.xz
go-tangerine-d6357aa616715df1e98cfb90c3aa5372e15cc24b.tar.zst
go-tangerine-d6357aa616715df1e98cfb90c3aa5372e15cc24b.zip
Merge pull request #631 from Gustav-Simonsson/improve_key_store_crypto
Improve key store crypto
Diffstat (limited to 'cmd')
-rw-r--r--cmd/geth/admin.go6
-rw-r--r--cmd/geth/js.go3
-rw-r--r--cmd/geth/js_test.go4
-rw-r--r--cmd/geth/main.go9
-rw-r--r--cmd/mist/gui.go2
-rw-r--r--cmd/utils/flags.go2
6 files changed, 13 insertions, 13 deletions
diff --git a/cmd/geth/admin.go b/cmd/geth/admin.go
index b0cb7507a..15923c366 100644
--- a/cmd/geth/admin.go
+++ b/cmd/geth/admin.go
@@ -126,7 +126,7 @@ func (js *jsre) pendingTransactions(call otto.FunctionCall) otto.Value {
// Add the accouns to a new set
accountSet := set.New()
for _, account := range accounts {
- accountSet.Add(common.BytesToAddress(account.Address))
+ accountSet.Add(account.Address)
}
//ltxs := make([]*tx, len(txs))
@@ -391,7 +391,7 @@ func (js *jsre) unlock(call otto.FunctionCall) otto.Value {
}
}
am := js.ethereum.AccountManager()
- err = am.TimedUnlock(common.FromHex(addr), passphrase, time.Duration(seconds)*time.Second)
+ err = am.TimedUnlock(common.HexToAddress(addr), passphrase, time.Duration(seconds)*time.Second)
if err != nil {
fmt.Printf("Unlock account failed '%v'\n", err)
return otto.FalseValue()
@@ -433,7 +433,7 @@ func (js *jsre) newAccount(call otto.FunctionCall) otto.Value {
fmt.Printf("Could not create the account: %v", err)
return otto.UndefinedValue()
}
- return js.re.ToVal(common.ToHex(acct.Address))
+ return js.re.ToVal(acct.Address.Hex())
}
func (js *jsre) nodeInfo(call otto.FunctionCall) otto.Value {
diff --git a/cmd/geth/js.go b/cmd/geth/js.go
index 61e97433a..4ddb3bd9c 100644
--- a/cmd/geth/js.go
+++ b/cmd/geth/js.go
@@ -26,6 +26,7 @@ import (
"strings"
"github.com/ethereum/go-ethereum/cmd/utils"
+ "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/docserver"
"github.com/ethereum/go-ethereum/common/natspec"
"github.com/ethereum/go-ethereum/eth"
@@ -164,7 +165,7 @@ func (self *jsre) UnlockAccount(addr []byte) bool {
return false
}
// TODO: allow retry
- if err := self.ethereum.AccountManager().Unlock(addr, pass); err != nil {
+ if err := self.ethereum.AccountManager().Unlock(common.BytesToAddress(addr), pass); err != nil {
return false
} else {
fmt.Println("Account is now unlocked for this session.")
diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go
index 9b6d503ab..c2a0e2fe2 100644
--- a/cmd/geth/js_test.go
+++ b/cmd/geth/js_test.go
@@ -45,7 +45,7 @@ type testjethre struct {
}
func (self *testjethre) UnlockAccount(acc []byte) bool {
- err := self.ethereum.AccountManager().Unlock(acc, "")
+ err := self.ethereum.AccountManager().Unlock(common.BytesToAddress(acc), "")
if err != nil {
panic("unable to unlock")
}
@@ -68,7 +68,7 @@ func testJEthRE(t *testing.T) (string, *testjethre, *eth.Ethereum) {
// set up mock genesis with balance on the testAddress
core.GenesisData = []byte(testGenesis)
- ks := crypto.NewKeyStorePassphrase(filepath.Join(tmp, "keys"))
+ ks := crypto.NewKeyStorePassphrase(filepath.Join(tmp, "keystore"))
am := accounts.NewManager(ks)
ethereum, err := eth.New(&eth.Config{
DataDir: tmp,
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 5fe83a2a0..dbcfe8175 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -365,11 +365,10 @@ func unlockAccount(ctx *cli.Context, am *accounts.Manager, account string) (pass
// Load startup keys. XXX we are going to need a different format
// Attempt to unlock the account
passphrase = getPassPhrase(ctx, "", false)
- accbytes := common.FromHex(account)
- if len(accbytes) == 0 {
+ if len(account) == 0 {
utils.Fatalf("Invalid account address '%s'", account)
}
- err = am.Unlock(accbytes, passphrase)
+ err = am.Unlock(common.StringToAddress(account), passphrase)
if err != nil {
utils.Fatalf("Unlock account failed '%v'", err)
}
@@ -385,11 +384,11 @@ func startEth(ctx *cli.Context, eth *eth.Ethereum) {
account := ctx.GlobalString(utils.UnlockedAccountFlag.Name)
if len(account) > 0 {
if account == "primary" {
- accbytes, err := am.Primary()
+ primaryAcc, err := am.Primary()
if err != nil {
utils.Fatalf("no primary account: %v", err)
}
- account = common.ToHex(accbytes)
+ account = primaryAcc.Hex()
}
unlockAccount(ctx, am, account)
}
diff --git a/cmd/mist/gui.go b/cmd/mist/gui.go
index 53194ae50..f443bacbc 100644
--- a/cmd/mist/gui.go
+++ b/cmd/mist/gui.go
@@ -232,7 +232,7 @@ func (self *Gui) loadMergedMiningOptions() {
func (gui *Gui) insertTransaction(window string, tx *types.Transaction) {
var inout string
from, _ := tx.From()
- if gui.eth.AccountManager().HasAccount(common.Hex2Bytes(from.Hex())) {
+ if gui.eth.AccountManager().HasAccount(from) {
inout = "send"
} else {
inout = "recv"
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 339dd3f47..ddbd36b5c 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -346,7 +346,7 @@ func GetChain(ctx *cli.Context) (*core.ChainManager, common.Database, common.Dat
func GetAccountManager(ctx *cli.Context) *accounts.Manager {
dataDir := ctx.GlobalString(DataDirFlag.Name)
- ks := crypto.NewKeyStorePassphrase(filepath.Join(dataDir, "keys"))
+ ks := crypto.NewKeyStorePassphrase(filepath.Join(dataDir, "keystore"))
return accounts.NewManager(ks)
}