func TestRun2(t *testing.T) { ethutil.ReadConfig("") db, _ := ethdb.NewMemDatabase() state := NewState(ethutil.NewTrie(db, "")) script := Compile([]string{ "PUSH", "0", "PUSH", "0", "TXSENDER", "PUSH", "10000000", "MKTX", }) fmt.Println(ethutil.NewValue(script)) tx := NewTransaction(ContractAddr, ethutil.Big("100000000000000000000000000000000000000000000000000"), script) fmt.Printf("contract addr %x\n", tx.Hash()[12:]) contract := MakeContract(tx, state) vm := &Vm{} vm.Process(contract, state, RuntimeVars{ address: tx.Hash()[12:], blockNumber: 1, sender: ethutil.FromHex("cd1722f3947def4cf144679da39c4c32bdc35681"), prevHash: ethutil.FromHex("5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"), coinbase: ethutil.FromHex("2adc25665018aa1fe0e6bc666dac8fc2697ff9ba"), time: 1, diff: big.NewInt(256), txValue: tx.Value, txData: tx.Data, }) }
func AddTestNetFunds(block *Block) { for _, addr := range []string{ "8a40bfaa73256b60764c1bf40675a99083efb075", // Gavin "e6716f9544a56c530d868e4bfbacb172315bdead", // Jeffrey "1e12515ce3e0f817a4ddef9ca55788a1d66bd2df", // Vit "1a26338f0d905e295fccb71fa9ea849ffa12aaf4", // Alex } { //log.Println("2^200 Wei to", addr) codedAddr := ethutil.FromHex(addr) addr := block.state.GetAccount(codedAddr) addr.Amount = ethutil.BigPow(2, 200) block.state.UpdateAccount(codedAddr, addr) } }
func ImportPrivateKey(prvKey string) { key := ethutil.FromHex(prvKey) msg := []byte("tmp") // Couldn't think of a better way to get the pub key sig, _ := secp256k1.Sign(msg, key) pub, _ := secp256k1.RecoverPubkey(msg, sig) pair := ðutil.Key{PrivateKey: key, PublicKey: pub} ethutil.Config.Db.Put([]byte("KeyRing"), pair.RlpEncode()) fmt.Printf(` Importing private key ++++++++++++++++ KeyRing +++++++++++++++++++ addr: %x prvk: %x pubk: %x ++++++++++++++++++++++++++++++++++++++++++++ `, pair.Address(), key, pub) }
"github.com/ethereum/go-ethereum/utils" "github.com/miekg/dns" "strings" ) /* * Try it with: * dig @localhost -p 8053 bytesized-hosting.eth * Problem: No recursion */ var Datadir string var Port string var DnsPort string var MaxPeer int var dnsreg = ethutil.FromHex("1b6a704f1c12e98b4b355d385e8eeaa7e7b237e2") func NewRR(s string) dns.RR { r, _ := dns.NewRR(s); return r } func initEthereum() *eth.Ethereum { // Create flag for datadir folder flag.StringVar(&Datadir, "datadir", ".ethdns", "specifies the datadir to use. Takes precedence over config file.") flag.StringVar(&Port, "port", "20202", "specifies the Ethereum port to use.") flag.StringVar(&DnsPort, "dnsport", "8053", "specifies the DNS port to use.") flag.IntVar(&MaxPeer, "maxpeer", 10, "maximum desired peers") flag.Parse() // Set logging flags var lt ethutil.LoggerType lt = ethutil.LogFile | ethutil.LogStd