aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-03-27 22:22:20 +0800
committerobscuren <geffobscura@gmail.com>2014-03-27 22:22:20 +0800
commite65c4ee93e9dad629997c7839df7a8a0e7cff353 (patch)
tree6f1c37e96f648afa43ca5f397d32e3d9a9930abd
parent642630db15a793cf0a0f7fbd827daee364df5423 (diff)
downloadgo-tangerine-e65c4ee93e9dad629997c7839df7a8a0e7cff353.tar
go-tangerine-e65c4ee93e9dad629997c7839df7a8a0e7cff353.tar.gz
go-tangerine-e65c4ee93e9dad629997c7839df7a8a0e7cff353.tar.bz2
go-tangerine-e65c4ee93e9dad629997c7839df7a8a0e7cff353.tar.lz
go-tangerine-e65c4ee93e9dad629997c7839df7a8a0e7cff353.tar.xz
go-tangerine-e65c4ee93e9dad629997c7839df7a8a0e7cff353.tar.zst
go-tangerine-e65c4ee93e9dad629997c7839df7a8a0e7cff353.zip
Updated transaction constructor
-rw-r--r--.gitignore1
-rw-r--r--ethereum/dev_console.go25
2 files changed, 11 insertions, 15 deletions
diff --git a/.gitignore b/.gitignore
index f725d58d1..f816a06a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,4 +9,5 @@
*un~
.DS_Store
*/**/.DS_Store
+./ethereum/ethereum
diff --git a/ethereum/dev_console.go b/ethereum/dev_console.go
index ead4b55e5..5452b9a61 100644
--- a/ethereum/dev_console.go
+++ b/ethereum/dev_console.go
@@ -11,6 +11,7 @@ import (
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
+ "github.com/obscuren/mutan"
_ "math/big"
"os"
"strings"
@@ -58,9 +59,9 @@ func (i *Console) ValidateInput(action string, argumentLength int) error {
case action == "getaddr" && argumentLength != 1:
err = true
expArgCount = 1
- case action == "contract" && argumentLength != 1:
+ case action == "contract" && argumentLength != 2:
err = true
- expArgCount = 1
+ expArgCount = 2
case action == "say" && argumentLength != 1:
err = true
expArgCount = 1
@@ -79,7 +80,7 @@ func (i *Console) ValidateInput(action string, argumentLength int) error {
}
}
-func (i *Console) Editor() []string {
+func (i *Console) Editor() string {
var buff bytes.Buffer
for {
reader := bufio.NewReader(os.Stdin)
@@ -94,15 +95,7 @@ func (i *Console) Editor() []string {
}
}
- scanner := bufio.NewScanner(strings.NewReader(buff.String()))
- scanner.Split(bufio.ScanLines)
-
- var lines []string
- for scanner.Scan() {
- lines = append(lines, scanner.Text())
- }
-
- return lines
+ return buff.String()
}
func (i *Console) PrintRoot() {
@@ -178,7 +171,7 @@ func (i *Console) ParseInput(input string) bool {
if err != nil {
fmt.Println("recipient err:", err)
} else {
- tx := ethchain.NewTransaction(recipient, ethutil.Big(tokens[2]), []string{""})
+ tx := ethchain.NewTx(recipient, ethutil.Big(tokens[2]), []string{""})
key := ethutil.Config.Db.GetKeys()[0]
tx.Sign(key.PrivateKey)
@@ -197,9 +190,11 @@ func (i *Console) ParseInput(input string) bool {
}
case "contract":
fmt.Println("Contract editor (Ctrl-D = done)")
- code := ethchain.Compile(i.Editor())
+ asm := mutan.NewCompiler().Compile(strings.NewReader(i.Editor()))
+
+ code := ethutil.Assemble(asm)
- contract := ethchain.NewTransaction(ethchain.ContractAddr, ethutil.Big(tokens[1]), code)
+ contract := ethchain.NewContractCreationTx(ethutil.Big(tokens[0]), ethutil.Big(tokens[1]), code)
key := ethutil.Config.Db.GetKeys()[0]
contract.Sign(key.PrivateKey)