good morning!!!!

Skip to content
Snippets Groups Projects
Commit 14a6e6a9 authored by Jeffrey Wilcke's avatar Jeffrey Wilcke
Browse files

Added the ability to submit byte code for contracts instead of Mutan code.

parent 3e5a7b34
No related branches found
No related tags found
No related merge requests found
...@@ -103,14 +103,25 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, in ...@@ -103,14 +103,25 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, in
var tx *ethchain.Transaction var tx *ethchain.Transaction
// Compile and assemble the given data // Compile and assemble the given data
if contractCreation { if contractCreation {
initScript, err := ethutil.Compile(initStr) var initScript, mainScript []byte
var err error
if ethutil.IsHex(initStr) {
initScript = ethutil.FromHex(initStr)
} else {
initScript, err = ethutil.Compile(initStr[2:])
if err != nil { if err != nil {
return nil, err return nil, err
} }
mainScript, err := ethutil.Compile(scriptStr) }
if ethutil.IsHex(scriptStr) {
mainScript = ethutil.FromHex(scriptStr[2:])
} else {
mainScript, err = ethutil.Compile(scriptStr)
if err != nil { if err != nil {
return nil, err return nil, err
} }
}
tx = ethchain.NewContractCreationTx(value, gas, gasPrice, mainScript, initScript) tx = ethchain.NewContractCreationTx(value, gas, gasPrice, mainScript, initScript)
} else { } else {
......
...@@ -83,3 +83,8 @@ func CopyBytes(b []byte) (copiedBytes []byte) { ...@@ -83,3 +83,8 @@ func CopyBytes(b []byte) (copiedBytes []byte) {
return return
} }
func IsHex(str string) bool {
l := len(str)
return l >= 4 && l%2 == 0 && str[0:2] == "0x"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment