aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-02-24 20:51:16 +0800
committerobscuren <geffobscura@gmail.com>2014-02-24 20:51:16 +0800
commitfe9eb472887baec464cc50657affd85b13bcbeba (patch)
tree07ac439393d244a45470ba86792ae9c159d9e11a /ui
parent0656f465b0c0690f237e42ac1e8f306dcda6c40b (diff)
downloadgo-tangerine-fe9eb472887baec464cc50657affd85b13bcbeba.tar.gz
go-tangerine-fe9eb472887baec464cc50657affd85b13bcbeba.tar.zst
go-tangerine-fe9eb472887baec464cc50657affd85b13bcbeba.zip
Minor fixes that to reflect changes in library
Diffstat (limited to 'ui')
-rw-r--r--ui/library.go28
1 files changed, 21 insertions, 7 deletions
diff --git a/ui/library.go b/ui/library.go
index 0dfb10ac7..c9273e8c5 100644
--- a/ui/library.go
+++ b/ui/library.go
@@ -5,6 +5,7 @@ import (
"fmt"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
+ "strings"
)
type EthLib struct {
@@ -13,22 +14,34 @@ type EthLib struct {
txPool *ethchain.TxPool
}
-func (lib *EthLib) CreateTx(receiver, a string) string {
- hash, err := hex.DecodeString(receiver)
- if err != nil {
- return err.Error()
+func (lib *EthLib) CreateTx(receiver, a, data string) string {
+ var hash []byte
+ if len(receiver) == 0 {
+ hash = ethchain.ContractAddr
+ } else {
+ var err error
+ hash, err = hex.DecodeString(receiver)
+ if err != nil {
+ return err.Error()
+ }
}
- data, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
- keyRing := ethutil.NewValueFromBytes(data)
+
+ k, _ := ethutil.Config.Db.Get([]byte("KeyRing"))
+ keyRing := ethutil.NewValueFromBytes(k)
amount := ethutil.Big(a)
- tx := ethchain.NewTransaction(hash, amount, []string{""})
+ code := ethchain.Compile(strings.Split(data, "\n"))
+ tx := ethchain.NewTransaction(hash, amount, code)
tx.Nonce = lib.blockManager.GetAddrState(keyRing.Get(1).Bytes()).Nonce
tx.Sign(keyRing.Get(0).Bytes())
lib.txPool.QueueTransaction(tx)
+ if len(receiver) == 0 {
+ ethutil.Config.Log.Infof("Contract addr %x", tx.Hash()[12:])
+ }
+
return ethutil.Hex(tx.Hash())
}
@@ -40,5 +53,6 @@ func (lib *EthLib) GetBlock(hexHash string) *Block {
block := lib.blockChain.GetBlock(hash)
fmt.Println(block)
+
return &Block{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())}
}