Example #1
0
// Creates an ethereum address from a create transaction
// If the tx doesn't create a contract, CreateAddress returns nil
func (tx *Transaction) CreateAddress() []byte {
	if tx.Recipient != nil {
		return nil
	}
	data, _ := rlp.EncodeToBytes([]interface{}{tx.from, tx.Nonce})
	hw := sha3.NewKeccak256()
	hw.Write(data)
	b := hw.Sum(nil)
	return b[12:]
}
Example #2
0
// rlp encode and hash (for tx sign bytes)
func rlpHash(x interface{}) (h common.Hash) {
	hw := sha3.NewKeccak256()
	rlp.Encode(hw, x)
	hw.Sum(h[:0])
	return h
}