diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-26 06:42:07 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-26 06:42:07 +0800 |
commit | b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db (patch) | |
tree | 96e360fc19b7c0a37172d6d27d1221bf175228e6 /ethpub/pub.go | |
parent | 4e1c6a8a22924d06a2a972c024891cebcf8ea054 (diff) | |
parent | 1f3f76cb092e84bd2e90950f0d43d7657eae878e (diff) | |
download | dexon-b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db.tar dexon-b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db.tar.gz dexon-b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db.tar.bz2 dexon-b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db.tar.lz dexon-b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db.tar.xz dexon-b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db.tar.zst dexon-b1463b2dc23ebd072f5e1e2c9a74842fc7ff51db.zip |
Merge branch 'release/poc5-rc9'
Diffstat (limited to 'ethpub/pub.go')
-rw-r--r-- | ethpub/pub.go | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/ethpub/pub.go b/ethpub/pub.go index cd002b500..b75d3abc8 100644 --- a/ethpub/pub.go +++ b/ethpub/pub.go @@ -87,14 +87,14 @@ func (lib *PEthereum) SecretToAddress(key string) string { } func (lib *PEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) (*PReceipt, error) { - return lib.createTx(key, recipient, valueStr, gasStr, gasPriceStr, dataStr, "") + return lib.createTx(key, recipient, valueStr, gasStr, gasPriceStr, dataStr) } -func (lib *PEthereum) Create(key, valueStr, gasStr, gasPriceStr, initStr, bodyStr string) (*PReceipt, error) { - return lib.createTx(key, "", valueStr, gasStr, gasPriceStr, initStr, bodyStr) +func (lib *PEthereum) Create(key, valueStr, gasStr, gasPriceStr, script string) (*PReceipt, error) { + return lib.createTx(key, "", valueStr, gasStr, gasPriceStr, script) } -func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, initStr, scriptStr string) (*PReceipt, error) { +func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, scriptStr string) (*PReceipt, error) { var hash []byte var contractCreation bool if len(recipient) == 0 { @@ -121,33 +121,47 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, in var tx *ethchain.Transaction // Compile and assemble the given data if contractCreation { - var initScript, mainScript []byte - var err error - if ethutil.IsHex(initStr) { - initScript = ethutil.FromHex(initStr[2:]) - } else { - initScript, err = ethutil.Compile(initStr) - if err != nil { - return nil, err + /* + var initScript, mainScript []byte + var err error + if ethutil.IsHex(initStr) { + initScript = ethutil.FromHex(initStr[2:]) + } else { + initScript, err = ethutil.Compile(initStr) + if err != nil { + return nil, err + } + } + + if ethutil.IsHex(scriptStr) { + mainScript = ethutil.FromHex(scriptStr[2:]) + } else { + mainScript, err = ethutil.Compile(scriptStr) + if err != nil { + return nil, err + } } - } + script := ethchain.AppendScript(initScript, mainScript) + */ + var script []byte + var err error if ethutil.IsHex(scriptStr) { - mainScript = ethutil.FromHex(scriptStr[2:]) + script = ethutil.FromHex(scriptStr) } else { - mainScript, err = ethutil.Compile(scriptStr) + script, err = ethutil.Compile(scriptStr) if err != nil { return nil, err } } - tx = ethchain.NewContractCreationTx(value, gas, gasPrice, mainScript, initScript) + tx = ethchain.NewContractCreationTx(value, gas, gasPrice, script) } else { // Just in case it was submitted as a 0x prefixed string - if len(initStr) > 0 && initStr[0:2] == "0x" { - initStr = initStr[2:len(initStr)] + if len(scriptStr) > 0 && scriptStr[0:2] == "0x" { + scriptStr = scriptStr[2:len(scriptStr)] } - tx = ethchain.NewTransactionMessage(hash, value, gas, gasPrice, ethutil.FromHex(initStr)) + tx = ethchain.NewTransactionMessage(hash, value, gas, gasPrice, ethutil.FromHex(scriptStr)) } acc := lib.stateManager.TransState().GetStateObject(keyPair.Address()) |