diff --git a/src/functions/bitcoin/bitcoin-functions.ts b/src/functions/bitcoin/bitcoin-functions.ts index 1dfbbea..beeb01a 100644 --- a/src/functions/bitcoin/bitcoin-functions.ts +++ b/src/functions/bitcoin/bitcoin-functions.ts @@ -12,7 +12,7 @@ import { import { P2Ret, P2TROut } from '@scure/btc-signer/payment'; import { TransactionInput } from '@scure/btc-signer/psbt'; import { BIP32Factory, BIP32Interface } from 'bip32'; -import { Network, address } from 'bitcoinjs-lib'; +import { Network, address, initEccLib } from 'bitcoinjs-lib'; import { bitcoin, regtest, testnet } from 'bitcoinjs-lib/src/networks.js'; import { Decimal } from 'decimal.js'; import * as ellipticCurveCryptography from 'tiny-secp256k1'; @@ -37,6 +37,7 @@ const TAPROOT_UNSPENDABLE_KEY_HEX = const ECDSA_PUBLIC_KEY_LENGTH = 33; const bip32 = BIP32Factory(ellipticCurveCryptography); +initEccLib(ellipticCurveCryptography); export function getFeeAmount(bitcoinAmount: number, feeBasisPoints: number): number { const feePercentage = new Decimal(feeBasisPoints).dividedBy(10000); diff --git a/tests/unit/bitcoin-functions.test.ts b/tests/unit/bitcoin-functions.test.ts index 290fa9b..606ec28 100644 --- a/tests/unit/bitcoin-functions.test.ts +++ b/tests/unit/bitcoin-functions.test.ts @@ -78,7 +78,7 @@ describe('Bitcoin Functions', () => { }); it('accepts taproot (p2tr) address', () => { - const address = 'bc1qw02rsw9afgp4dsd5n87z5s6rqnf455yhhsnz9f'; + const address = 'bc1pgj9ef0lhysgd2v042jta4mv8qmc70yappkv7vpl76dhfvrdfvusqqe4qj3'; expect(getFeeRecipientAddress(address, network)).toBe(address); }); @@ -103,7 +103,7 @@ describe('Bitcoin Functions', () => { }); it('accepts taproot (p2tr) address', () => { - const address = 'tb1qqhy33peyp82mf82fktdtphfmnhtxyhtp6x9hrc'; + const address = 'tb1pa8hxt6r2gkc8d5thzfrw7gyrqlv354rdy4k05ylkvf6nadnhg8xsygyusf'; expect(getFeeRecipientAddress(address, network)).toBe(address); }); @@ -128,7 +128,7 @@ describe('Bitcoin Functions', () => { }); it('accepts taproot (p2tr) address', () => { - const address = 'bcrt1qqhy33peyp82mf82fktdtphfmnhtxyhtpc0u653'; + const address = 'bcrt1pa8hxt6r2gkc8d5thzfrw7gyrqlv354rdy4k05ylkvf6nadnhg8xsf3w69n'; expect(getFeeRecipientAddress(address, network)).toBe(address); });