web3 / web3.js

Collection of comprehensive TypeScript libraries for Interaction with the Ethereum JSON RPC API and utility functions.
https://web3js.org/
Other
19.31k stars 4.95k forks source link

getBalance in ethereum-light.js from sandbox branch accepts only decimal addresses #144

Closed nagydani closed 9 years ago

nagydani commented 9 years ago

To reproduce, try this:

> web3.eth.getBalance('dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6').toNumber()
0
> web3.eth.getBalance('0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6').toNumber()
0
> web3.eth.getBalance('1255171934823351805979544608257289442498956485798').toNumber()
1.6069380442589903e+60
frozeman commented 9 years ago

thats odd. Etheruem.js is just passing it through to the RPC. It can be that the hex is in go converted to this weird byte array we saw before and then passed to the RPC. Can you guys check?

zsfelfoldi commented 9 years ago

I'll check. But it works fine with the ethereum.js from the main branch.

frozeman commented 9 years ago

hm..

debris commented 9 years ago

any update on this?

zsfelfoldi commented 9 years ago

Well, in last thursday's develop version it worked fine. In the latest version it seems to be wrong again. Drives me crazy, now i'm comparing these two.

debris commented 9 years ago

in e213551699cd10e6ef2f5fd7a43dbc6e01ad0ad8 I added few tests for 0xdbdbdb2cbd23b783741e8d7fcf51e459b497e4a6 && 1255171934823351805979544608257289442498956485798. They are passing and web3.eth.balance should be working fine. If it is not, it's otto JSRE or go-ethereum internal issue. If it's required I investigate the possibilities of running tests directly in the go-etheruem jsre.

zsfelfoldi commented 9 years ago

My bad, it works fine now, something else was wrong when I tried it last time.