Fix merge conflicts
This commit is contained in:
13
utils/cmd.go
13
utils/cmd.go
@ -1,9 +1,7 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"github.com/ethereum/eth-go"
|
||||
"github.com/ethereum/eth-go/ethchain"
|
||||
"github.com/ethereum/eth-go/ethminer"
|
||||
"github.com/ethereum/eth-go/ethpub"
|
||||
"github.com/ethereum/eth-go/ethrpc"
|
||||
@ -26,15 +24,12 @@ func DoMining(ethereum *eth.Ethereum) {
|
||||
// Set Mining status
|
||||
ethereum.Mining = true
|
||||
|
||||
data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
|
||||
if len(data) == 0 {
|
||||
if ethutil.GetKeyRing().Len() == 0 {
|
||||
log.Println("No address found, can't start mining")
|
||||
return
|
||||
}
|
||||
|
||||
keyRing := ethutil.NewValueFromBytes(data)
|
||||
addr := keyRing.Get(0).Bytes()
|
||||
pair, _ := ethchain.NewKeyPairFromSec(ethutil.FromHex(hex.EncodeToString(addr)))
|
||||
keyPair := ethutil.GetKeyRing().Get(0)
|
||||
addr := keyPair.Address()
|
||||
|
||||
go func() {
|
||||
// Give it some time to connect with peers
|
||||
@ -45,7 +40,7 @@ func DoMining(ethereum *eth.Ethereum) {
|
||||
}
|
||||
log.Println("Miner started")
|
||||
|
||||
miner := ethminer.NewDefaultMiner(pair.Address(), ethereum)
|
||||
miner := ethminer.NewDefaultMiner(addr, ethereum)
|
||||
miner.Start()
|
||||
}()
|
||||
}
|
||||
|
@ -6,6 +6,60 @@ import (
|
||||
"github.com/obscuren/secp256k1-go"
|
||||
)
|
||||
|
||||
func CreateKeyPair(force bool) {
|
||||
if force {
|
||||
ethutil.GetKeyRing().Reset()
|
||||
fmt.Println("resetting")
|
||||
}
|
||||
|
||||
if ethutil.GetKeyRing().Get(0) == nil {
|
||||
_, prv := secp256k1.GenerateKeyPair()
|
||||
|
||||
keyPair, err := ethutil.GetKeyRing().NewKeyPair(prv)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
mne := ethutil.MnemonicEncode(ethutil.Hex(keyPair.PrivateKey))
|
||||
|
||||
fmt.Printf(`
|
||||
Generating new address and keypair.
|
||||
Please keep your keys somewhere save.
|
||||
|
||||
++++++++++++++++ KeyRing +++++++++++++++++++
|
||||
addr: %x
|
||||
prvk: %x
|
||||
pubk: %x
|
||||
++++++++++++++++++++++++++++++++++++++++++++
|
||||
save these words so you can restore your account later: %s
|
||||
`, keyPair.Address(), keyPair.PrivateKey, keyPair.PublicKey, mne)
|
||||
}
|
||||
}
|
||||
|
||||
func ImportPrivateKey(sec string) {
|
||||
ethutil.GetKeyRing().Reset()
|
||||
|
||||
keyPair, err := ethutil.GetKeyRing().NewKeyPair(ethutil.FromHex(sec))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
mne := ethutil.MnemonicEncode(ethutil.Hex(keyPair.PrivateKey))
|
||||
|
||||
fmt.Printf(`
|
||||
Generating new address and keypair.
|
||||
Please keep your keys somewhere save.
|
||||
|
||||
++++++++++++++++ KeyRing +++++++++++++++++++
|
||||
addr: %x
|
||||
prvk: %x
|
||||
pubk: %x
|
||||
++++++++++++++++++++++++++++++++++++++++++++
|
||||
save these words so you can restore your account later: %s
|
||||
`, keyPair.Address(), keyPair.PrivateKey, keyPair.PublicKey, mne)
|
||||
}
|
||||
|
||||
/*
|
||||
func CreateKeyPair(force bool) {
|
||||
data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
|
||||
if len(data) == 0 || force {
|
||||
@ -28,7 +82,9 @@ save these words so you can restore your account later: %s
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
func ImportPrivateKey(prvKey string) {
|
||||
key := ethutil.FromHex(prvKey)
|
||||
msg := []byte("tmp")
|
||||
@ -49,3 +105,4 @@ pubk: %x
|
||||
|
||||
`, pair.Address(), key, pub)
|
||||
}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user