Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare generated taproot addresses with the expected ones in the JS client library #171

Open
bigspider opened this issue Jun 14, 2023 · 6 comments

Comments

@bigspider
Copy link
Collaborator

#166 solved this for the Python and Rust clients; still to do for the JS client.

@landabaso
Copy link
Contributor

For Javascript, you can use https://bitcoinerlab.com/modules/descriptors
Let me know if you need some assistance. I'm happy to help.

@bigspider
Copy link
Collaborator Author

For Javascript, you can use https://bitcoinerlab.com/modules/descriptors Let me know if you need some assistance. I'm happy to help.

Thanks!
Last time I checked, there was a circular dependency, as that module directly imported ledger-bitcoin for the hardware integration.
Perhaps, if the hardware wallet integration part is moved to a separate module, that would be feasible.

Would that work for taproot scripts, as well?

@landabaso
Copy link
Contributor

Ah, I see your point regarding the circular dependency. To resolve this, I could attempt to decouple the hardware wallet integration as you say. Alternatively, it might be worth considering importing ledger-bitcoin as a peerDependency in bitcoinerlab. I'll explore both approaches and get back to you with an update.

As for your question about taproot scripts, the current version does not support it. I haven't started incorporating taproot functionality as of yet. Is this a necessary requirement?

@landabaso
Copy link
Contributor

landabaso commented Jul 12, 2023

I'm having trouble reproducing the circular dependency issue you mentioned. I suspect that my assumptions about the workflow might be different from what you're actually trying to do.

From my understanding, you're intending to add tests using a third-party library. This library would compute addresses for a descriptor, which you would then compare with the results from the Ledger client, correct?

Here are the steps I took for a quick test, based on my understanding:

cd bitcoin_client_js/
npm install --save-dev @bitcoinerlab/secp256k1
npm install --save-dev @bitcoinerlab/descriptors

Then I created a test in src/__tests__/bitcoinerlab.ts:

import * as secp256k1 from '@bitcoinerlab/secp256k1';
import * as descriptors from '@bitcoinerlab/descriptors';
const { Descriptor } = descriptors.DescriptorsFactory(secp256k1);

describe('BitcoinerLab Quick Experiment', () => {
  const descriptor = new Descriptor({
    expression:
      'wpkh(02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9)'
  });
  const address = descriptor.getAddress();
  it('same address', () => {
    expect('bc1q0ht9tyks4vh7p5p904t340cr9nvahy7u3re7zg').toEqual(address);
  });
});

Running the test with npm run test src/__tests__/bitcoinerlab.ts worked without issues, and I was also able to build the project successfully.

EDIT: I just had a thought - could the issue be arising due to differences in npm versions? For reference, I conducted my test using npm v17.9.1.

EDIT2: After further inspection of the PR referenced in this issue, I now understand the context better. It appears you're aiming to conduct runtime tests, not offline ones, which means this would not be a devDependency. I'll revisit the idea of either decoupling the packages or using it as a peerDependency.

landabaso added a commit to bitcoinerlab/ledger that referenced this issue Jul 17, 2023
landabaso added a commit to bitcoinerlab/ledger that referenced this issue Jul 26, 2023
landabaso added a commit to bitcoinerlab/ledger that referenced this issue Jul 26, 2023
@bigspider bigspider changed the title Compare generated addresses with the expected ones in the JS client library Compare generated taproot addresses with the expected ones in the JS client library Jul 28, 2023
@bigspider
Copy link
Collaborator Author

Solved for Segwit in #189, still to do for Taproot Scripts.

@bigspider bigspider changed the title Compare generated taproot addresses with the expected ones in the JS client library Compare generated taproot addresses with the expected ones in the Python and JS client library Nov 22, 2023
@bigspider bigspider changed the title Compare generated taproot addresses with the expected ones in the Python and JS client library Compare generated taproot addresses with the expected ones in the JS client library Feb 15, 2024
@bigspider
Copy link
Collaborator Author

Solved for the python client (all address types) in #227.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants