github.com/jonasnick/go-ethereum@v0.7.12-0.20150216215225-22176f05d387/eth/wallet.go (about) 1 package eth 2 3 /* 4 import ( 5 "crypto/ecdsa" 6 "errors" 7 "math/big" 8 9 "github.com/jonasnick/go-ethereum/core" 10 "github.com/jonasnick/go-ethereum/core/types" 11 ) 12 13 type Account struct { 14 w *Wallet 15 } 16 17 func (self *Account) Transact(to *Account, value, gas, price *big.Int, data []byte) error { 18 return self.w.transact(self, to, value, gas, price, data) 19 } 20 21 func (self *Account) Address() []byte { 22 return nil 23 } 24 25 func (self *Account) PrivateKey() *ecdsa.PrivateKey { 26 return nil 27 } 28 29 type Wallet struct{} 30 31 func NewWallet() *Wallet { 32 return &Wallet{} 33 } 34 35 func (self *Wallet) GetAccount(i int) *Account { 36 } 37 38 func (self *Wallet) transact(from, to *Account, value, gas, price *big.Int, data []byte) error { 39 if from.PrivateKey() == nil { 40 return errors.New("accounts is not owned (no private key available)") 41 } 42 43 var createsContract bool 44 if to == nil { 45 createsContract = true 46 } 47 48 var msg *types.Transaction 49 if contractCreation { 50 msg = types.NewContractCreationTx(value, gas, price, data) 51 } else { 52 msg = types.NewTransactionMessage(to.Address(), value, gas, price, data) 53 } 54 55 state := self.chainManager.TransState() 56 nonce := state.GetNonce(key.Address()) 57 58 msg.SetNonce(nonce) 59 msg.SignECDSA(from.PriateKey()) 60 61 // Do some pre processing for our "pre" events and hooks 62 block := self.chainManager.NewBlock(from.Address()) 63 coinbase := state.GetOrNewStateObject(from.Address()) 64 coinbase.SetGasPool(block.GasLimit()) 65 self.blockManager.ApplyTransactions(coinbase, state, block, types.Transactions{tx}, true) 66 67 err := self.obj.TxPool().Add(tx) 68 if err != nil { 69 return nil, err 70 } 71 state.SetNonce(key.Address(), nonce+1) 72 73 if contractCreation { 74 addr := core.AddressFromMessage(tx) 75 pipelogger.Infof("Contract addr %x\n", addr) 76 } 77 78 return tx, nil 79 } 80 */