trezor / connect

:link: A platform for easy integration of Trezor into 3rd party services
Other
348 stars 262 forks source link

Invalid parameters: Coin not found #181

Closed Adman closed 5 years ago

Adman commented 5 years ago

I added new coin to coins.json and want to test getAddress, getAccountInfo and some transactions from connect-v5 (also want to test if blockbook responds correctly) However, when running this piece of code

window.TrezorConnect.getAccountInfo({                                   
    path: "m/44'/100'/0'",                                              
    coin: "cpc",                                                        
}).then(function(res) {                                                 
    console.log(res);                                                   
});

It responds with failure message

payload: Object { error: "Invalid parameters: Coin not found." }
success: false

Do I need to add that coin info to any other file?

szymonlesisz commented 5 years ago

Hi @Adman, I assume you are running a local version of connect with changed coins.json file. In this case you need to make sure you are calling a right endpoint by setting: window.__TREZOR_CONNECT_SRC = 'https://localhost:8088/'; before you use TrezorConnect.method If you are serving it from 'yarn run dev' command default host is 'https://localhost:8088/' and could be changed inside ./webpack/confing.dev.babel.js

make sure that popup window is displayed from localhost, not from https://connect.trezor.io/5

However TrezorConnect.getAccountInfo method will not work for you since we don't have any backend for "cpc" coin

Adman commented 5 years ago

@szymonlesisz Thanks.

cpc already has blockbook servers. When I sniff WS communication I can clearly see transactions to account. But the balance returned in response is still 0. Is it bug in blockbook or something may be failing and it cannot sum the balance?

szymonlesisz commented 5 years ago

Not sure, Try to open issue in blockbook repo https://github.com/trezor/blockbook/

Adman commented 5 years ago

ok. Maybe this could be related to that issue. Once I get account info, it also throws this error

Uncaught RangeError: Trying to access beyond buffer length
    at x (discovery-worker.6e1c2c4600253465537d.js:8)
    at Uint8Array.Buffer.readUInt32LE (discovery-worker.6e1c2c4600253465537d.js:8)
    at u (discovery-worker.6e1c2c4600253465537d.js:22)
    at Function.h.fromBuffer (discovery-worker.6e1c2c4600253465537d.js:22)
    at Function.h.fromHex (discovery-worker.6e1c2c4600253465537d.js:22)
    at discovery-worker.6e1c2c4600253465537d.js:44
    at Array.forEach (<anonymous>)
    at t.value (discovery-worker.6e1c2c4600253465537d.js:44)
    at Object.handler (discovery-worker.6e1c2c4600253465537d.js:44)
    at discovery-worker.6e1c2c4600253465537d.js:22
szymonlesisz commented 5 years ago

Feel free to debug. I know nothing about "cpc" coin and his properties. The error is thrown by "hd-wallet" module imported in trezor-connect or even in lower layer: "bitcoinjs-lib" module and it's probably caused by the values given in coins.json, so you should look there. Just a guess there is a problem with address derivation from xpub in "discovery-worker"

piavgh commented 5 years ago

@szymonlesisz : Today I have this problem with coin: "eth" Anyone figured this out?

szymonlesisz commented 5 years ago

getAccountInfo is designed for "bitcoin-like" coins only specified here, with "bitcoin" key: https://github.com/trezor/connect/blob/develop/src/data/coins.json Ethereum methods are documented here: https://github.com/trezor/connect/blob/develop/docs/methods.md#ethereum

However we are working on backends for Ethereum and soon there will be "ethereumGetAccountInfo" method available