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

Sync up with bitcoinjs-lib 6 #2054

Closed
wants to merge 14 commits into from
Closed

Conversation

brandonblack
Copy link
Contributor

This is a pretty major change:

  • TransactionBuilder, classify, and related are no longer part of bitcoinjs-lib, so they're moved into utxo-lib.
  • tiny-secp256k1 no longer works in browser w/o WASM support, so switched crypto implementation to noble-secp256k1

Copy link
Contributor

@OttoAllmendinger OttoAllmendinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good overall

please use https://www.conventionalcommits.org/en/v1.0.0/ for commits and mention which ref or tag you pulled the TransactionBuilder code from in the upstream repo

bech32?: string;
bech32: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match the Network type from bitocinjs-lib I'd love a better idea if you have one. I considered changing the upstream type in my "BitGo specific" commit, but it looked like it would become a maintenance pain.

Comment on lines -10 to +11
"9f74390b6c7f5988772a909fc689a3e2dd680ceb8d54d4caffdd5907132bc415d7d964f4b25ce02690938cd4b62057f80b929aca4155c64db205a336b2e6ce79",
"69a969c8df93bc7894d045bc5e5d73f50d815fed7f703f11080f6b46561220156a0eed3382ec0eddbfa2737a29a7b07ba572880ae26f05f56ebca40bd7a5a987"
"a2074b68b115e970c8c4bee9cf75c03b82bd3e3086d58801a4adb7b31b9b5f2cea4a5615a4feef74b61db6d765bb814feaf27331fad128dda55cfe106d25d44e",
"6bace9d49a0a7617e8ab40cd5361257829c0f09809d6f70ce130a70d7af3de1bf7409cbe379481e0494b32531b955fff67825cd969a3e95fc853c048692feda1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the PR description:

Schnorr signatures changed because lack of extra nonce data is now empty buffer instead of skipped`

Comment on lines 136 to 139
assert.strictEqual(typeof (network as any).bech32, bech32Coins(network) ? 'string' : 'undefined');
assert.strictEqual(typeof (network as any).bech32, 'string');
if (!bech32Coins(network)) {
assert.strictEqual((network as any).bech32.length, 0);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO undefined is better than zero-length string here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No disagreement, but that's not what the upstream type has.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed it so we do not use the upstream type anymore: 6f553c0

@brandonblack
Copy link
Contributor Author

Improved commit history, formatted code, and tidied up noble_ecc.ts

@OttoAllmendinger OttoAllmendinger force-pushed the bitcoinjs_lib_6_sync branch 2 times, most recently from 0b62e1f to e30785c Compare February 28, 2022 15:37
@OttoAllmendinger OttoAllmendinger self-requested a review February 28, 2022 15:42
@codecov
Copy link

codecov bot commented Feb 28, 2022

Codecov Report

Merging #2054 (3392077) into master (737deab) will increase coverage by 85.92%.
The diff coverage is n/a.

❗ Current head 3392077 differs from pull request most recent head f0a9102. Consider uploading reports for the commit f0a9102 to get more accurate results

@@             Coverage Diff             @@
##           master    #2054       +/-   ##
===========================================
+ Coverage        0   85.92%   +85.92%     
===========================================
  Files           0      169      +169     
  Lines           0     8504     +8504     
  Branches        0     1275     +1275     
===========================================
+ Hits            0     7307     +7307     
- Misses          0      781      +781     
- Partials        0      416      +416     
Flag Coverage Δ
unit 85.92% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
modules/account-lib/src/coin/algo/transaction.ts 82.56% <0.00%> (ø)
modules/account-lib/src/coin/xrp/utils.ts 60.00% <0.00%> (ø)
modules/account-lib/src/coin/hbar/keyPair.ts 100.00% <0.00%> (ø)
modules/account-lib/src/coin/celo/stakingUtils.ts 100.00% <0.00%> (ø)
...odules/account-lib/src/coin/celo/stakingBuilder.ts 93.33% <0.00%> (ø)
...unt-lib/src/coin/hbar/transactionBuilderFactory.ts 82.35% <0.00%> (ø)
modules/account-lib/src/coin/dot/txnSchema.ts 100.00% <0.00%> (ø)
...les/account-lib/src/coin/stx/transactionBuilder.ts 85.13% <0.00%> (ø)
...account-lib/src/coin/sol/stakingActivateBuilder.ts 97.67% <0.00%> (ø)
modules/account-lib/src/coin/cspr/constants.ts 100.00% <0.00%> (ø)
... and 159 more

@brandonblack brandonblack force-pushed the bitcoinjs_lib_6_sync branch 2 times, most recently from 009762f to 3392077 Compare March 1, 2022 19:37
reardencode and others added 14 commits March 30, 2022 14:20
These files were removed from bitcoinjs-lib in version 6, but we're not
ready to give them up quite yet.

Imported from
BitGo/bitcionjs-lib/165f26ae18082158e531b607fcc7245ad641e263

Issue: BG-41154
* Schnorr signatures changed because lack of extra nonce data is now
  empty buffer instead of skipped
* tiny-secp256k1 no longer works in browser w/o WASM support, so
  switched crypto implementation to noble-secp256k1
* Required some moderately extensive changes to noble-secp256k1
  paulmillr/noble-secp256k1#50

Issue: BG-41154
Let's ignore this rule for now since it makes importing bitcoinjs-lib
code more difficult.

Issue: BG-41154
Mostly braces around `if` blocks

Issue: BG-41154
Since TransactionBuilder now lives in `utxo-lib`, we can change the
interface and remove the dependency on `bitcoinjs-lib.Network`

Issue: BG-41154
Not required for updated utxolib/bitcoinjs-lib

Issue: BG-41154
Ideally dependent packages should define those themselves but we will
use this shortcut for now so we do not have to depend on the custom
secp256k1 package everywhere.

Issue: BG-41154
* bump `bip32` package to v3
* use `bip32: BIP32API` type from `@bitgo/utxo-lib`
* use `bip32: BIP32Interface` type from `bip32` package

This has the unfortunate downside that we are depending on
`@bitgo/utxo-lib` for bip32 again, after we removed this dependency in
earlier commits.

We should fix this by instantiating `bip32: BIP32API` per package.
However this is not easy to do here since we are depending on a
slightly exotic secp256k1 library in `@bitgo/utxo-lib` and I don't
want to depend on that directly in `BitGoJS` yet.

Issue: BG-41154
P2TR/Schorr transaction changes due to change in extra nonce data

See f185efebfe330f1ff786694b2703d76ebb87e71a for details

Issue: BG-41154
P2TR/Schorr transaction changes due to change in extra nonce data

See f185efebfe330f1ff786694b2703d76ebb87e71a for details

Issue: BG-41154
@brandonblack brandonblack force-pushed the bitcoinjs_lib_6_sync branch from 3392077 to f0a9102 Compare March 30, 2022 21:28
@github-actions
Copy link

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the stale label May 26, 2022
@github-actions
Copy link

github-actions bot commented Jun 6, 2022

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions bot closed this Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants