Wip VM. Created contracts

This commit is contained in:
obscuren
2014-01-03 00:43:49 +01:00
parent 9df4c74511
commit 7cd41ac45a
6 changed files with 80 additions and 18 deletions

View File

@@ -3,8 +3,8 @@ package main
import (
"math/big"
"fmt"
"encoding/hex"
"crypto/sha256"
_"encoding/hex"
_"crypto/sha256"
_ "bytes"
)
@@ -63,13 +63,14 @@ func NewTransaction(to string, value uint32, data []string) *Transaction {
tx.data[i] = instr
}
b:= []byte(tx.MarshalRlp())
hash := sha256.Sum256(b)
tx.addr = hex.EncodeToString(hash[0:19])
return &tx
}
func (tx *Transaction) Hash() []byte {
return Sha256Bin(tx.MarshalRlp())
}
func (tx *Transaction) MarshalRlp() []byte {
// Prepare the transaction for serialization
preEnc := []interface{}{