aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-04-23 21:54:34 +0800
committerobscuren <geffobscura@gmail.com>2014-04-23 21:54:34 +0800
commit43f1214f97e52863b1f1ef7913991bef3d00c58e (patch)
tree247b4739b26f00f2f912f23592ca3ff4b2ed38ec /ethereal
parentb962779a1318138e08c6e84a537fdbc6c9ebfd97 (diff)
downloadgo-tangerine-43f1214f97e52863b1f1ef7913991bef3d00c58e.tar
go-tangerine-43f1214f97e52863b1f1ef7913991bef3d00c58e.tar.gz
go-tangerine-43f1214f97e52863b1f1ef7913991bef3d00c58e.tar.bz2
go-tangerine-43f1214f97e52863b1f1ef7913991bef3d00c58e.tar.lz
go-tangerine-43f1214f97e52863b1f1ef7913991bef3d00c58e.tar.xz
go-tangerine-43f1214f97e52863b1f1ef7913991bef3d00c58e.tar.zst
go-tangerine-43f1214f97e52863b1f1ef7913991bef3d00c58e.zip
Refactored code
Diffstat (limited to 'ethereal')
-rw-r--r--ethereal/ui/library.go23
1 files changed, 10 insertions, 13 deletions
diff --git a/ethereal/ui/library.go b/ethereal/ui/library.go
index b097ddbb2..537cfa994 100644
--- a/ethereal/ui/library.go
+++ b/ethereal/ui/library.go
@@ -43,8 +43,7 @@ func (lib *EthLib) CreateAndSetPrivKey() (string, string, string, string) {
return mnemonicString, fmt.Sprintf("%x", pair.Address()), fmt.Sprintf("%x", prv), fmt.Sprintf("%x", pub)
}
-func (lib *EthLib) CreateTx(recipient, valueStr, gasStr, gasPriceStr, data string) (string, error) {
- fmt.Println("Create tx")
+func (lib *EthLib) CreateTx(recipient, valueStr, gasStr, gasPriceStr, dataStr string) (string, error) {
var hash []byte
var contractCreation bool
if len(recipient) == 0 {
@@ -64,26 +63,24 @@ func (lib *EthLib) CreateTx(recipient, valueStr, gasStr, gasPriceStr, data strin
var tx *ethchain.Transaction
// Compile and assemble the given data
if contractCreation {
- mainInput, initInput := ethutil.PreProcess(data)
- fmt.Println("Precompile done")
- fmt.Println("main", mainInput)
- mainScript, err := utils.Compile(mainInput)
- if err != nil {
- return "", err
- }
- fmt.Println("init", initInput)
- initScript, err := utils.Compile(initInput)
+ // Compile script
+ mainScript, initScript, err := utils.CompileScript(dataStr)
if err != nil {
return "", err
}
tx = ethchain.NewContractCreationTx(value, gas, gasPrice, mainScript, initScript)
} else {
- tx = ethchain.NewTransactionMessage(hash, value, gas, gasPrice, nil)
+ lines := strings.Split(dataStr, "\n")
+ var data []byte
+ for _, line := range lines {
+ data = append(data, ethutil.BigToBytes(ethutil.Big(line), 256)...)
+ }
+
+ tx = ethchain.NewTransactionMessage(hash, value, gas, gasPrice, data)
}
acc := lib.stateManager.GetAddrState(keyPair.Address())
tx.Nonce = acc.Nonce
- //acc.Nonce++
tx.Sign(keyPair.PrivateKey)
lib.txPool.QueueTransaction(tx)