Compare commits

...

19 Commits
poc1 ... 0.2.2

Author SHA1 Message Date
9e57aac5eb Merge branch 'release/0.2.2' 2014-02-15 12:10:25 +01:00
1ba7ffe9f8 Added text for keys 2014-02-15 12:10:13 +01:00
3fd5715872 Added git flow explanation 2014-02-15 11:49:29 +01:00
3a03d091eb Removed RlpValue in favour of Value 2014-02-15 01:34:35 +01:00
fe59a2b26d Updated to the great merge package 2014-02-15 00:05:04 +01:00
68fbfe70da Default to .ethereum 2014-02-12 16:34:35 +01:00
954f897938 Use seed 2014-02-11 18:46:10 +01:00
980987ae8f Added block retrieval 2014-02-10 20:24:36 +01:00
d831064f65 Skip the first byte in generating addresses 2014-02-10 20:22:52 +01:00
3ecb2ef29c removed pub key log 2014-02-10 11:37:11 +01:00
8320fd998e Added pub key to keyring 2014-02-09 23:35:02 +01:00
37a89e577c Added address 2014-02-08 23:50:08 +01:00
9ac81c5b2b Proper keys 2014-02-08 23:26:43 +01:00
7b7242b9ea Proper keys 2014-02-08 23:25:48 +01:00
c2bb5e39e1 Unused package 2014-02-08 23:21:29 +01:00
67572417c6 Use the generated key 2014-02-08 23:21:09 +01:00
542bc2fce4 Woops 2014-02-08 22:57:40 +01:00
d7205b7aff Updated readme 2014-02-08 22:16:11 +01:00
f1ba1df165 Added key address and key generation 2014-02-08 22:07:17 +01:00
4 changed files with 141 additions and 66 deletions

View File

@ -3,11 +3,10 @@ Ethereum
[![Build Status](https://travis-ci.org/ethereum/go-ethereum.png?branch=master)](https://travis-ci.org/ethereum/go-ethereum)
Ethereum Go developer client (c) [0255c7881](https://github.com/ethereum/go-ethereum#copy)
A fair warning; Ethereum is not yet to be used in production. There's no
test-net and you aren't mining real blocks (just one which is the genesis block).
Ethereum Go developer client (c) Jeffrey Wilcke
Ethereum is currently in its testing phase. The current state is "Proof
of Concept 2". For build instructions see the [Wiki](https://github.com/ethereum/go-ethereum/wiki/Building-Edge).
Ethereum Go is split up in several sub packages Please refer to each
individual package for more information.
@ -33,37 +32,46 @@ contains the LevelDB interface and memory DB interface.
This executable is the front-end (currently nothing but a dev console) for
the Ethereum Go implementation.
Deps
====
Ethereum Go makes use of a modified `secp256k1-go` and therefor GMP.
Ubuntu 12+
* `apt-get install gmp-dev`
OS X 10.9+:
* `brew install gmp`
Build
=======
`go get -u -t github.com/ethereum/go-ethereum`
For build instruction please see the [Wiki](https://github.com/ethereum/go-ethereum/wiki/Building-Edge)
Command line options
====================
```
-c launch the developer console
-m start mining fake blocks and broadcast fake messages to the net
-c Launch the developer console
-m Start mining blocks
-genaddr Generates a new address and private key (destructive action)
-p Port on which the server will accept incomming connections (= 30303)
-upnp Enable UPnP (= false)
-x Desired amount of peers (= 5)
-h This help
```
Developer console commands
==========================
```
addp <host>:<port> Connect to the given host
tx <addr> <amount> Send <amount> Wei to the specified <addr>
```
See the "help" command for *developer* options.
Contribution
============
If you'd like to contribute to Ethereum Go please fork, fix, commit and
send a pull request. Commits who do not comply with the coding standards
are ignored.
are ignored. If you send pull requests make absolute sure that you
commit on the `develop` branch and that you do not merge to master.
Commits that are directly based on master are simply ignored.
To make life easier try [git flow](http://nvie.com/posts/a-successful-git-branching-model/) it sets
this all up and streamlines your work flow.
Coding standards
================
@ -95,6 +103,3 @@ expect you to write tests for me so I don't have to test your code
manually. (If you want to contribute by just writing tests that's fine
too!)
### Copy
69bce990a619e747b4f57483724b0e8a1732bb3b44ccf70b0dd6abd272af94550fc9d8b21232d33ebf30d38a148612f68e936094b4daeb9ea7174088a439070401 0255c78815d4f056f84c96de438ed9e38c69c0f8af24f5032248be5a79fe9071c3

28
config.go Normal file
View File

@ -0,0 +1,28 @@
package main
import (
"flag"
)
var StartConsole bool
var StartMining bool
var UseUPnP bool
var OutboundPort string
var ShowGenesis bool
var AddPeer string
var MaxPeer int
var GenAddr bool
var UseSeed bool
func Init() {
flag.BoolVar(&StartConsole, "c", false, "debug and testing console")
flag.BoolVar(&StartMining, "m", false, "start dagger mining")
flag.BoolVar(&ShowGenesis, "g", false, "prints genesis header and exits")
flag.BoolVar(&UseUPnP, "upnp", false, "enable UPnP support")
flag.BoolVar(&UseSeed, "seed", true, "seed peers")
flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")
flag.StringVar(&OutboundPort, "p", "30303", "listening port")
flag.IntVar(&MaxPeer, "x", 5, "maximum desired peers")
flag.Parse()
}

View File

@ -6,10 +6,10 @@ import (
"errors"
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/ethchain-go"
"github.com/ethereum/ethdb-go"
"github.com/ethereum/ethutil-go"
"github.com/ethereum/ethwire-go"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
_ "math/big"
"os"
"strings"
@ -66,6 +66,9 @@ func (i *Console) ValidateInput(action string, argumentLength int) error {
case action == "addp" && argumentLength != 1:
err = true
expArgCount = 1
case action == "block" && argumentLength != 1:
err = true
expArgCount = 1
}
if err {
@ -76,9 +79,9 @@ func (i *Console) ValidateInput(action string, argumentLength int) error {
}
func (i *Console) PrintRoot() {
root := ethutil.Conv(i.trie.Root)
if len(root.AsBytes()) != 0 {
fmt.Println(hex.EncodeToString(root.AsBytes()))
root := ethutil.NewValue(i.trie.Root)
if len(root.Bytes()) != 0 {
fmt.Println(hex.EncodeToString(root.Bytes()))
} else {
fmt.Println(i.trie.Root)
}
@ -124,17 +127,16 @@ func (i *Console) ParseInput(input string) bool {
ethutil.BigPow(2, 36), // diff
ethutil.Big(tokens[2]))) // nonce
case "decode":
value := ethutil.NewRlpValueFromBytes([]byte(tokens[1]))
value := ethutil.NewValueFromBytes([]byte(tokens[1]))
fmt.Println(value)
case "getaddr":
encoded, _ := hex.DecodeString(tokens[1])
d := i.ethereum.BlockManager.BlockChain().CurrentBlock.State().Get(string(encoded))
if d != "" {
decoder := ethutil.NewRlpValueFromBytes([]byte(d))
fmt.Println(decoder)
} else {
fmt.Println("getaddr: address unknown")
}
addr := i.ethereum.BlockManager.BlockChain().CurrentBlock.GetAddr(encoded)
fmt.Println("addr:", addr)
case "block":
encoded, _ := hex.DecodeString(tokens[1])
block := i.ethereum.BlockManager.BlockChain().GetBlock(encoded)
fmt.Println(block)
case "say":
i.ethereum.Broadcast(ethwire.MsgTalkTy, []interface{}{tokens[1]})
case "addp":
@ -149,7 +151,9 @@ func (i *Console) ParseInput(input string) bool {
fmt.Println("recipient err:", err)
} else {
tx := ethchain.NewTransaction(recipient, ethutil.Big(tokens[2]), []string{""})
tx.Sign([]byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
keyRing := ethutil.NewValueFromBytes(data)
tx.Sign(keyRing.Get(0).Bytes())
fmt.Printf("%x\n", tx.Hash())
i.ethereum.TxPool.QueueTransaction(tx)
}
@ -158,7 +162,7 @@ func (i *Console) ParseInput(input string) bool {
addr, _ := hex.DecodeString(tokens[1])
data, _ := ethutil.Config.Db.Get(addr)
if len(data) != 0 {
decoder := ethutil.NewRlpValueFromBytes(data)
decoder := ethutil.NewValueFromBytes(data)
fmt.Println(decoder)
} else {
fmt.Println("gettx: tx not found")
@ -177,6 +181,8 @@ func (i *Console) ParseInput(input string) bool {
"get KEY - Retrieves the given key\n" +
"root - Prints the hex encoded merkle root\n" +
"rawroot - Prints the raw merkle root\n" +
"block HASH - Prints the block\n" +
"getaddr ADDR - Prints the account associated with the address\n" +
"\033[1m= Dagger =\033[0m\n" +
"dag HASH NONCE - Verifies a nonce with the given hash with dagger\n" +
"\033[1m= Encoding =\033[0m\n" +

View File

@ -1,13 +1,11 @@
package main
import (
"encoding/hex"
"flag"
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/ethchain-go"
"github.com/ethereum/ethutil-go"
_ "github.com/ethereum/ethwire-go"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/obscuren/secp256k1-go"
"log"
"os"
"os/signal"
@ -16,22 +14,6 @@ import (
const Debug = true
var StartConsole bool
var StartMining bool
var UseUPnP bool
var OutboundPort string
var ShowGenesis bool
func Init() {
flag.BoolVar(&StartConsole, "c", false, "debug and testing console")
flag.BoolVar(&StartMining, "m", false, "start dagger mining")
flag.BoolVar(&ShowGenesis, "g", false, "prints genesis header and exits")
flag.BoolVar(&UseUPnP, "upnp", false, "enable UPnP support")
flag.StringVar(&OutboundPort, "port", "30303", "listening port")
flag.Parse()
}
// Register interrupt handlers so we can stop the ethereum
func RegisterInterupts(s *eth.Ethereum) {
// Buffered chan of one is enough
@ -47,20 +29,67 @@ func RegisterInterupts(s *eth.Ethereum) {
}()
}
func CreateKeyPair(force bool) {
data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
if len(data) == 0 || force {
pub, prv := secp256k1.GenerateKeyPair()
addr := ethutil.Sha3Bin(pub[1:])[12:]
fmt.Printf(`
Generating new address and keypair.
Please keep your keys somewhere save.
Currently Ethereum(G) does not support
exporting keys.
++++++++++++++++ KeyRing +++++++++++++++++++
addr: %x
prvk: %x
pubk: %x
++++++++++++++++++++++++++++++++++++++++++++
`, addr, prv, pub)
keyRing := ethutil.NewValue([]interface{}{prv, addr, pub[1:]})
ethutil.Config.Db.Put([]byte("KeyRing"), keyRing.Encode())
}
}
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
Init()
ethchain.InitFees()
ethutil.ReadConfig()
ethutil.ReadConfig(".ethereum")
ethutil.Config.Seed = UseSeed
// Instantiated a eth stack
ethereum, err := eth.New(eth.CapDefault, UseUPnP)
if err != nil {
log.Println(err)
log.Println("eth start err:", err)
return
}
if GenAddr {
fmt.Println("This action overwrites your old private key. Are you sure? (y/n)")
var r string
fmt.Scanln(&r)
for ; ; fmt.Scanln(&r) {
if r == "n" || r == "y" {
break
} else {
fmt.Printf("Yes or no?", r)
}
}
if r == "y" {
CreateKeyPair(true)
}
os.Exit(0)
} else {
CreateKeyPair(false)
}
if ShowGenesis {
fmt.Println(ethereum.BlockManager.BlockChain().Genesis())
os.Exit(0)
@ -68,6 +97,9 @@ func main() {
log.Printf("Starting Ethereum v%s\n", ethutil.Config.Ver)
// Set the max peers
ethereum.MaxPeers = MaxPeer
if StartConsole {
err := os.Mkdir(ethutil.Config.ExecPath, os.ModePerm)
// Error is OK if the error is ErrExist
@ -84,12 +116,14 @@ func main() {
ethereum.Start()
if StartMining {
log.Printf("Dev Test Mining started...\n")
log.Printf("Miner started\n")
// Fake block mining. It broadcasts a new block every 5 seconds
go func() {
pow := &ethchain.EasyPow{}
addr, _ := hex.DecodeString("82c3b0b72cf62f1a9ce97c64da8072efa28225d8")
data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
keyRing := ethutil.NewValueFromBytes(data)
addr := keyRing.Get(1).Bytes()
for {
txs := ethereum.TxPool.Flush()
@ -97,14 +131,16 @@ func main() {
block := ethereum.BlockManager.BlockChain().NewBlock(addr, txs)
// Apply all transactions to the block
ethereum.BlockManager.ApplyTransactions(block, block.Transactions())
ethereum.BlockManager.AccumelateRewards(block, block)
// Search the nonce
block.Nonce = pow.Search(block)
err := ethereum.BlockManager.ProcessBlock(block)
if err != nil {
log.Println(err)
} else {
//ethereum.Broadcast(ethwire.MsgBlockTy, []interface{}{block.RlpValue().Value})
log.Println("\n+++++++ MINED BLK +++++++\n", block.String())
log.Println("\n+++++++ MINED BLK +++++++\n", ethereum.BlockManager.BlockChain().CurrentBlock)
}
}
}()