|
|
@ -87,14 +87,14 @@ func (lib *PEthereum) SecretToAddress(key string) string { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (lib *PEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) (*PReceipt, error) { |
|
|
|
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) { |
|
|
|
func (lib *PEthereum) Create(key, valueStr, gasStr, gasPriceStr, script string) (*PReceipt, error) { |
|
|
|
return lib.createTx(key, "", valueStr, gasStr, gasPriceStr, initStr, bodyStr) |
|
|
|
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 hash []byte |
|
|
|
var contractCreation bool |
|
|
|
var contractCreation bool |
|
|
|
if len(recipient) == 0 { |
|
|
|
if len(recipient) == 0 { |
|
|
@ -121,6 +121,7 @@ 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 { |
|
|
|
|
|
|
|
/* |
|
|
|
var initScript, mainScript []byte |
|
|
|
var initScript, mainScript []byte |
|
|
|
var err error |
|
|
|
var err error |
|
|
|
if ethutil.IsHex(initStr) { |
|
|
|
if ethutil.IsHex(initStr) { |
|
|
@ -142,14 +143,25 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, in |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
script := ethchain.AppendScript(initScript, mainScript) |
|
|
|
script := ethchain.AppendScript(initScript, mainScript) |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
var script []byte |
|
|
|
|
|
|
|
var err error |
|
|
|
|
|
|
|
if ethutil.IsHex(scriptStr) { |
|
|
|
|
|
|
|
script = ethutil.FromHex(scriptStr) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
script, err = ethutil.Compile(scriptStr) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tx = ethchain.NewContractCreationTx(value, gas, gasPrice, script) |
|
|
|
tx = ethchain.NewContractCreationTx(value, gas, gasPrice, script) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// Just in case it was submitted as a 0x prefixed string
|
|
|
|
// Just in case it was submitted as a 0x prefixed string
|
|
|
|
if len(initStr) > 0 && initStr[0:2] == "0x" { |
|
|
|
if len(scriptStr) > 0 && scriptStr[0:2] == "0x" { |
|
|
|
initStr = initStr[2:len(initStr)] |
|
|
|
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()) |
|
|
|
acc := lib.stateManager.TransState().GetStateObject(keyPair.Address()) |
|
|
|