Skip to content

refactor: add explicit initialisation of the ecc library #5

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

Merged
merged 2 commits into from
Mar 28, 2022

Conversation

motorina0
Copy link
Collaborator

Followup PR of the discussion here: #4 (comment)

Yes. I would prefer something explicit as in the code snippet below for several reasons:

  • if the eccLib is invalid, then it will fail at the initEccLib(...) invocation place (which can make it easy to investigate/debug), instead of failing inside p2tr or Psbt
  • if p2tr is used without an eccLib then the error message can clearly state that: "No ECC Library provided. You must call initEccLib(...) with a valid TinySecp256k1Interface instance"
    • side note: rename TinySecp256k1Interface to Secp256k1Interface?
  • it makes the code-base a little easier to work with (no need to pass eccLib around)
  • it makes the public API a little simpler (no eccLib option for p2tr and Psbt)
  • calling initEccLib(...) is optional (only required if p2tr is used)
  • calling initEccLib(...) multiple times with the same TinySecp256k1Interface instance is a noop
// client code
import { payments, address, initEccLib } from 'bitcoinjs-lib'

initEccLib(clientEccLib)

- remove optional `eccLib` parameter for `p2tr` and `psbt`
@motorina0 motorina0 self-assigned this Mar 25, 2022
@motorina0 motorina0 merged commit bbf5cda into p2tr-v1 Mar 28, 2022
motorina0 added a commit that referenced this pull request Nov 29, 2022
* refactor: explicit initialization on the ecc library

- remove optional `eccLib` parameter for `p2tr` and `psbt`
motorina0 added a commit that referenced this pull request Nov 29, 2022
* refactor: explicit initialization on the ecc library

- remove optional `eccLib` parameter for `p2tr` and `psbt`
motorina0 added a commit that referenced this pull request Nov 29, 2022
* refactor: explicit initialization on the ecc library

- remove optional `eccLib` parameter for `p2tr` and `psbt`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant