Skip to content
This repository has been archived by the owner on Jun 27, 2022. It is now read-only.

Error on getWalletPublicKey with BTC app v2 #733

Open
fabenedetti opened this issue Dec 7, 2021 · 4 comments
Open

Error on getWalletPublicKey with BTC app v2 #733

fabenedetti opened this issue Dec 7, 2021 · 4 comments

Comments

@fabenedetti
Copy link
Contributor

Hi,

I'm experimenting an error since I updated my BTC app on the Ledger device to v2.0.0 (Firmware is 2.0.0 but it can be reproduced with 2.1.0 too).

When I try to read an address using getWalletPublicKey, I receive tthe following error
TypeError: "list" argument must be an Array of Buffers

It breaks here

I'm using an standard path so I don't know what could be the issue.

I have created an small repo to reproduce this issue if you want to take a look

https://github.com/fabenedetti/ledger-read-btc-address

I think this happens only on the browser, because I have some tests that runs on node with the same params and I can't reproduce it there.

This breaks from @ledgerjs/hw-app-btc v6.10.0 (and later versions). It works if you downgrade to v6.7.0.

I noticed that you have a new implementation from BTC that it's only activated from BTC app v2, so I suspect that perhaps there could be something wrong related to this change. It works well with BCH and LTC v2 apps and those are still using the old implementation.

Thanks.

@fabenedetti
Copy link
Contributor Author

Hi,

This is a critical issue for us because it prevents any operation with Ledger and Bitcoin on production.

I would appreciate any feedback on this. I'm still not sure if we are doing something wrong on our side, if we are missing a breaking change or if there is any workaround that we could apply to solve this.

Thanks.

@fedecaccia
Copy link

@greweb hi! I tagged you but Im not sure if you are the proper one, could you check if this is a pending bug and if its on queue? Thanks!

@gre
Copy link
Contributor

gre commented Dec 14, 2021

Ok thanks for the report, we'll look at the issue shortly.

@fabenedetti
Copy link
Contributor Author

@gre I spent some time debugging this and I think there may be an issue on the clientCommand.ts where you apply the subarray function because it returns an Uint8Array running on a browser instead of a Buffer (like on Node.js).

I think that a potential fix could be to convert the result of the subarray to a Buffer using Buffer.from. I suspect that you are already doing it on this line

this.results.push(Buffer.from(request.subarray(1)));

So in order to make it work in a browser, you may need to change the following lines too:

const req = request.subarray(1);

to
const req = Buffer.from(request.subarray(1));

known_preimage.subarray(0, payload_size),

to
Buffer.from(known_preimage.subarray(0, payload_size)),

const req = request.subarray(1);

to
const req = Buffer.from(request.subarray(1));

const req = request.subarray(1);

to
const req = Buffer.from(request.subarray(1));

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants