|
|
@ -15,7 +15,7 @@ type EthLib struct { |
|
|
|
txPool *ethchain.TxPool |
|
|
|
txPool *ethchain.TxPool |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (lib *EthLib) CreateTx(recipient, valueStr, gasStr, gasPriceStr, data string) string { |
|
|
|
func (lib *EthLib) CreateTx(recipient, valueStr, gasStr, gasPriceStr, data string) (string, error) { |
|
|
|
var hash []byte |
|
|
|
var hash []byte |
|
|
|
var contractCreation bool |
|
|
|
var contractCreation bool |
|
|
|
if len(recipient) == 0 { |
|
|
|
if len(recipient) == 0 { |
|
|
@ -24,7 +24,7 @@ func (lib *EthLib) CreateTx(recipient, valueStr, gasStr, gasPriceStr, data strin |
|
|
|
var err error |
|
|
|
var err error |
|
|
|
hash, err = hex.DecodeString(recipient) |
|
|
|
hash, err = hex.DecodeString(recipient) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err.Error() |
|
|
|
return "", err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -37,7 +37,7 @@ func (lib *EthLib) CreateTx(recipient, valueStr, gasStr, gasPriceStr, data strin |
|
|
|
if contractCreation { |
|
|
|
if contractCreation { |
|
|
|
asm, err := mutan.Compile(strings.NewReader(data), false) |
|
|
|
asm, err := mutan.Compile(strings.NewReader(data), false) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err.Error() |
|
|
|
return "", err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
code := ethutil.Assemble(asm...) |
|
|
|
code := ethutil.Assemble(asm...) |
|
|
@ -45,7 +45,9 @@ func (lib *EthLib) CreateTx(recipient, valueStr, gasStr, gasPriceStr, data strin |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
tx = ethchain.NewTransactionMessage(hash, value, gasPrice, gas, []string{}) |
|
|
|
tx = ethchain.NewTransactionMessage(hash, value, gasPrice, gas, []string{}) |
|
|
|
} |
|
|
|
} |
|
|
|
tx.Nonce = lib.stateManager.GetAddrState(keyPair.Address()).Nonce |
|
|
|
acc := lib.stateManager.GetAddrState(keyPair.Address()) |
|
|
|
|
|
|
|
tx.Nonce = acc.Nonce |
|
|
|
|
|
|
|
//acc.Nonce++
|
|
|
|
tx.Sign(keyPair.PrivateKey) |
|
|
|
tx.Sign(keyPair.PrivateKey) |
|
|
|
lib.txPool.QueueTransaction(tx) |
|
|
|
lib.txPool.QueueTransaction(tx) |
|
|
|
|
|
|
|
|
|
|
@ -55,7 +57,7 @@ func (lib *EthLib) CreateTx(recipient, valueStr, gasStr, gasPriceStr, data strin |
|
|
|
ethutil.Config.Log.Infof("Tx hash %x", tx.Hash()) |
|
|
|
ethutil.Config.Log.Infof("Tx hash %x", tx.Hash()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return ethutil.Hex(tx.Hash()) |
|
|
|
return ethutil.Hex(tx.Hash()), nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|