diff options
Diffstat (limited to 'ethereum')
-rw-r--r-- | ethereum/flags.go | 12 | ||||
-rw-r--r-- | ethereum/javascript_runtime.go | 10 | ||||
-rw-r--r-- | ethereum/main.go | 8 |
3 files changed, 19 insertions, 11 deletions
diff --git a/ethereum/flags.go b/ethereum/flags.go index 8fb87cf34..d5a9c3a8a 100644 --- a/ethereum/flags.go +++ b/ethereum/flags.go @@ -10,6 +10,8 @@ import ( ) var Identifier string +var KeyRing string +var KeyStore string var StartRpc bool var RpcPort int var UseUPnP bool @@ -19,8 +21,8 @@ var AddPeer string var MaxPeer int var GenAddr bool var UseSeed bool -var ImportKey string -var ExportKey bool +var SecretFile string +var ExportDir string var NonInteractive bool var Datadir string var LogFile string @@ -47,6 +49,8 @@ func Init() { } flag.StringVar(&Identifier, "id", "", "Custom client identifier") + flag.StringVar(&KeyRing, "keyring", "", "identifier for keyring to use") + flag.StringVar(&KeyStore, "keystore", "db", "system to store keyrings: db|file (db)") flag.StringVar(&OutboundPort, "port", "30303", "listening port") flag.BoolVar(&UseUPnP, "upnp", false, "enable UPnP support") flag.IntVar(&MaxPeer, "maxpeer", 10, "maximum desired peers") @@ -55,9 +59,9 @@ func Init() { flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)") flag.BoolVar(&UseSeed, "seed", true, "seed peers") flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key") - flag.BoolVar(&ExportKey, "export", false, "export private key") + flag.StringVar(&SecretFile, "import", "", "imports the file given (hex or mnemonic formats)") + flag.StringVar(&ExportDir, "export", "", "exports the session keyring to files in the directory given") flag.StringVar(&LogFile, "logfile", "", "log file (defaults to standard output)") - flag.StringVar(&ImportKey, "import", "", "imports the given private key (hex)") flag.StringVar(&Datadir, "datadir", defaultDataDir(), "specifies the datadir to use") flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file") flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)") diff --git a/ethereum/javascript_runtime.go b/ethereum/javascript_runtime.go index 0dfe07a54..852a50487 100644 --- a/ethereum/javascript_runtime.go +++ b/ethereum/javascript_runtime.go @@ -122,12 +122,12 @@ out: } case object := <-self.changeChan: if stateObject, ok := object.Resource.(*ethchain.StateObject); ok { - for _, cb := range self.objectCb[ethutil.Hex(stateObject.Address())] { + for _, cb := range self.objectCb[ethutil.Bytes2Hex(stateObject.Address())] { val, _ := self.vm.ToValue(ethpub.NewPStateObject(stateObject)) cb.Call(cb, val) } } else if storageObject, ok := object.Resource.(*ethchain.StorageState); ok { - for _, cb := range self.objectCb[ethutil.Hex(storageObject.StateAddress)+ethutil.Hex(storageObject.Address)] { + for _, cb := range self.objectCb[ethutil.Bytes2Hex(storageObject.StateAddress)+ethutil.Bytes2Hex(storageObject.Address)] { val, _ := self.vm.ToValue(ethpub.NewPStorageState(storageObject)) cb.Call(cb, val) } @@ -178,12 +178,12 @@ func (self *JSRE) watch(call otto.FunctionCall) otto.Value { if storageCallback { self.objectCb[addr+storageAddr] = append(self.objectCb[addr+storageAddr], cb) - event := "storage:" + string(ethutil.FromHex(addr)) + ":" + string(ethutil.FromHex(storageAddr)) + event := "storage:" + string(ethutil.Hex2Bytes(addr)) + ":" + string(ethutil.Hex2Bytes(storageAddr)) self.ethereum.Reactor().Subscribe(event, self.changeChan) } else { self.objectCb[addr] = append(self.objectCb[addr], cb) - event := "object:" + string(ethutil.FromHex(addr)) + event := "object:" + string(ethutil.Hex2Bytes(addr)) self.ethereum.Reactor().Subscribe(event, self.changeChan) } @@ -221,7 +221,7 @@ func (self *JSRE) execBlock(call otto.FunctionCall) otto.Value { return otto.UndefinedValue() } - err = utils.BlockDo(self.ethereum, ethutil.FromHex(hash)) + err = utils.BlockDo(self.ethereum, ethutil.Hex2Bytes(hash)) if err != nil { fmt.Println(err) return otto.FalseValue() diff --git a/ethereum/main.go b/ethereum/main.go index 6b1995eec..1531871cb 100644 --- a/ethereum/main.go +++ b/ethereum/main.go @@ -21,10 +21,14 @@ func main() { utils.InitLogging(Datadir, LogFile, LogLevel, DebugFile) - ethereum := utils.NewEthereum(UseUPnP, OutboundPort, MaxPeer) + db := utils.NewDatabase() + + keyManager := utils.NewKeyManager(KeyStore, Datadir, db) // create, import, export keys - utils.KeyTasks(GenAddr, ImportKey, ExportKey, NonInteractive) + utils.KeyTasks(keyManager, KeyRing, GenAddr, SecretFile, ExportDir, NonInteractive) + + ethereum := utils.NewEthereum(db, keyManager, UseUPnP, OutboundPort, MaxPeer) if ShowGenesis { utils.ShowGenesis(ethereum) |