Consensys / eth-lightwallet

Lightweight JS Wallet for Node and the browser
MIT License
1.47k stars 503 forks source link

valueTx generates contract transaction, not the value one #146

Closed PavelPolyakov closed 7 years ago

PavelPolyakov commented 7 years ago

Hello,

Recently started to play with ethereum development and met the point where I need to transfer some ETH from the account A to B. I use testrpc, but want to create the accounts on demand, so I integrated eth-lightwallet.

As testrpc doesn't know about the new accont and I need to privide the signed request and do raw transaction. Luckily there is an appropriate API provided by the eth-lightwallet.

However, I observed that when I execute this transaction - the value goes out from the account but never lands to the destination one. And, I think this is the reason, in the logs of the testrpc I see that the contract was created.

image

Here is the gist with the reproduction: https://gist.github.com/PavelPolyakov/1a2bc0a2b97e363900c19710390211da

There I used three variants:

  1. Transfer using the web3 capabilities (works only for the accounts which are controlled by the testrpc node). So it's not possible to transfer the value from the newly created address.
  2. Transfer using the raw request, which was created by valueTx. The result - money never come to the destination.
  3. Transfer using the raw request, but the transaction was created using the ethereumjs-tx. Downside of this method - private key needs to be exposed. Result - money are transferred correctly.

Could you, please, have a look on the issue? Maybe I'm missing something.

Regards,

PavelPolyakov commented 7 years ago

hi @christianlundkvist, maybe you'd see what am I doing wrong?

I also browsed the eth-lightwallet source code, especially the valueTx and hadn't found anything which can cause that behaviour, no mentions of the contract or something.

niran commented 7 years ago

function valueTx (txObject) { ... } vs var valueData = txutils.valueTx(FROM, txOptions) doesn't match. Also, I'm pretty sure valueTx and the Transaction object from ethereumjs-tx that it uses both require you to specify every value in the txObject. There are no defaults.

coder5876 commented 7 years ago

Hi @PavelPolyakov yeah as @niran said there is no FROM input in the valueTx function. the valueTx function only takes a txObject So you need to plug in the from address in the txObject instead.

PavelPolyakov commented 7 years ago

@niran , @christianlundkvist oh good, thanks, my bad. My eyes were blurred that I didn't catch that.

Thank you!

PavelPolyakov commented 7 years ago

Hi @niran @christianlundkvist ,

sorry for being back with my issue, but it continued :( here is the gist for the current, only eth-lightwallet example: https://gist.github.com/PavelPolyakov/a89bc59f8fe34abe70ef189da8472def

for some reason, when I try to signing.signTx the callback for the keyFromPassword is executed twice and then program fails.

any hints?

it is important that I want to store my wallets, so I use deserialize. And, when it deserializes (as I understand) it uses the deprecated method. However I'm not sure that that i the reason.

The new KeyStore constructor has been deprecated in favor of KeyStore.createVault(), and will be removed in a future version. Read issue #109 for info. https://github.com/ConsenSys/eth-lightwallet/issues/109

Would appreciate your thoughts.

Regards,

PavelPolyakov commented 7 years ago

my bad again, this time sender didn't have money and this call

web3.eth.sendRawTransaction(signedValueTx);

was causing the exception, but for some reason that exception was causing the call of the callback 2nd time.

Regards 🙌 ,