diff --git a/modules/utxo-core/.mocharc.js b/modules/utxo-core/.mocharc.cjs similarity index 66% rename from modules/utxo-core/.mocharc.js rename to modules/utxo-core/.mocharc.cjs index 5fc6096dae..16b4a65116 100644 --- a/modules/utxo-core/.mocharc.js +++ b/modules/utxo-core/.mocharc.cjs @@ -1,6 +1,6 @@ 'use strict'; module.exports = { - require: 'ts-node/register', + "node-option": ["import=tsx"], extension: ['.js', '.ts'], }; diff --git a/modules/utxo-core/package.json b/modules/utxo-core/package.json index 682f42018c..f38d659e2b 100644 --- a/modules/utxo-core/package.json +++ b/modules/utxo-core/package.json @@ -27,7 +27,7 @@ "lint": "eslint --quiet .", "prepare": "npm run build", "test": "npm run unit-test", - "unit-test": "mocha --recursive \"dist/test/**/*.js\"" + "unit-test": "mocha --recursive test" }, "author": "BitGo SDK Team ", "license": "MIT", @@ -45,7 +45,7 @@ "publishConfig": { "access": "public" }, - "type": "commonjs", + "type": "module", "nyc": { "extension": [ ".ts" @@ -58,5 +58,9 @@ "bip174": "npm:@bitgo-forks/bip174@3.1.0-master.4", "bitcoinjs-message": "npm:@bitgo-forks/bitcoinjs-message@1.0.0-master.3" }, - "gitHead": "18e460ddf02de2dbf13c2aa243478188fb539f0c" + "gitHead": "18e460ddf02de2dbf13c2aa243478188fb539f0c", + "devDependencies": { + "@types/node": "^24", + "tsx": "^4.20.3" + } } diff --git a/modules/utxo-core/src/bip65/index.ts b/modules/utxo-core/src/bip65/index.ts index 2ceffe5de4..788e899a27 100644 --- a/modules/utxo-core/src/bip65/index.ts +++ b/modules/utxo-core/src/bip65/index.ts @@ -1 +1 @@ -export * from './locktime'; +export * from './locktime.js'; diff --git a/modules/utxo-core/src/descriptor/Output.ts b/modules/utxo-core/src/descriptor/Output.ts index 9d2f5b875f..1bf3b559a3 100644 --- a/modules/utxo-core/src/descriptor/Output.ts +++ b/modules/utxo-core/src/descriptor/Output.ts @@ -2,10 +2,10 @@ import assert from 'assert'; import { Descriptor } from '@bitgo/wasm-miniscript'; -import { getFixedOutputSum, MaxOutput, Output, PrevOutput } from '../Output'; +import { getFixedOutputSum, MaxOutput, Output, PrevOutput } from '../Output.js'; -import { DescriptorMap } from './DescriptorMap'; -import { getDescriptorAtIndexCheckScript } from './derive'; +import { DescriptorMap } from './DescriptorMap.js'; +import { getDescriptorAtIndexCheckScript } from './derive.js'; export type WithDescriptor = T & { descriptor: Descriptor; diff --git a/modules/utxo-core/src/descriptor/VirtualSize.ts b/modules/utxo-core/src/descriptor/VirtualSize.ts index 01af5369a1..ead37dedce 100644 --- a/modules/utxo-core/src/descriptor/VirtualSize.ts +++ b/modules/utxo-core/src/descriptor/VirtualSize.ts @@ -2,8 +2,8 @@ import * as utxolib from '@bitgo/utxo-lib'; import { Dimensions, VirtualSizes } from '@bitgo/unspents'; import { Descriptor } from '@bitgo/wasm-miniscript'; -import { DescriptorMap } from './DescriptorMap'; -import { findDescriptorForInput } from './psbt'; +import { DescriptorMap } from './DescriptorMap.js'; +import { findDescriptorForInput } from './psbt/findDescriptors.js'; function getScriptPubKeyLength(descType: string): number { // See https://bitcoinops.org/en/tools/calc-size/ diff --git a/modules/utxo-core/src/descriptor/index.ts b/modules/utxo-core/src/descriptor/index.ts index 1d3d71aa61..2a923e744d 100644 --- a/modules/utxo-core/src/descriptor/index.ts +++ b/modules/utxo-core/src/descriptor/index.ts @@ -1,11 +1,11 @@ -export * from './psbt'; -export * from './address'; -export * from './DescriptorMap'; -export * from './derive'; -export * from './Output'; -export * from './VirtualSize'; -export * from './fromFixedScriptWallet'; -export * from './parse/PatternMatcher'; +export * from './psbt/index.js'; +export * from './address.js'; +export * from './DescriptorMap.js'; +export * from './derive.js'; +export * from './Output.js'; +export * from './VirtualSize.js'; +export * from './fromFixedScriptWallet.js'; +export * from './parse/PatternMatcher.js'; /** @deprecated - import from @bitgo/utxo-core directly instead */ -export * from '../Output'; +export * from '../Output.js'; diff --git a/modules/utxo-core/src/descriptor/psbt/createPsbt.ts b/modules/utxo-core/src/descriptor/psbt/createPsbt.ts index 996ef3905e..8e3807c1ce 100644 --- a/modules/utxo-core/src/descriptor/psbt/createPsbt.ts +++ b/modules/utxo-core/src/descriptor/psbt/createPsbt.ts @@ -1,12 +1,12 @@ -import { TapLeafScript } from 'bip174/src/lib/interfaces'; +import { TapLeafScript } from 'bip174/src/lib/interfaces.js'; import * as utxolib from '@bitgo/utxo-lib'; import { Descriptor, Miniscript } from '@bitgo/wasm-miniscript'; -import { DerivedDescriptorWalletOutput, WithOptDescriptor } from '../Output'; -import { Output } from '../../Output'; +import { DerivedDescriptorWalletOutput, WithOptDescriptor } from '../Output.js'; +import { Output } from '../../Output.js'; -import { toUtxoPsbt, toWrappedPsbt } from './wrap'; -import { assertSatisfiable } from './assertSatisfiable'; +import { toUtxoPsbt, toWrappedPsbt } from './wrap.js'; +import { assertSatisfiable } from './assertSatisfiable.js'; /** * Non-Final (Replaceable) diff --git a/modules/utxo-core/src/descriptor/psbt/findDescriptors.ts b/modules/utxo-core/src/descriptor/psbt/findDescriptors.ts index 8326165a50..4dd1e19b48 100644 --- a/modules/utxo-core/src/descriptor/psbt/findDescriptors.ts +++ b/modules/utxo-core/src/descriptor/psbt/findDescriptors.ts @@ -9,10 +9,10 @@ It will probably only work correctly if all xpubs in the descriptor are derivabl We should take a look at a more robust and standard approach like this: https://github.com/bitcoin/bips/pull/1548 */ -import { PsbtInput, PsbtOutput } from 'bip174/src/lib/interfaces'; +import { PsbtInput, PsbtOutput } from 'bip174/src/lib/interfaces.js'; import { Descriptor } from '@bitgo/wasm-miniscript'; -import { DescriptorMap } from '../DescriptorMap'; +import { DescriptorMap } from '../DescriptorMap.js'; type DescriptorWithoutIndex = { descriptor: Descriptor; index: undefined }; diff --git a/modules/utxo-core/src/descriptor/psbt/index.ts b/modules/utxo-core/src/descriptor/psbt/index.ts index f442f5620d..daf1b1a983 100644 --- a/modules/utxo-core/src/descriptor/psbt/index.ts +++ b/modules/utxo-core/src/descriptor/psbt/index.ts @@ -1,6 +1,6 @@ -export * from './assertSatisfiable'; -export * from './createPsbt'; -export * from './parse'; -export * from './findDescriptors'; -export * from './wrap'; -export * from './sign'; +export * from './assertSatisfiable.js'; +export * from './createPsbt.js'; +export * from './parse.js'; +export * from './findDescriptors.js'; +export * from './wrap.js'; +export * from './sign.js'; diff --git a/modules/utxo-core/src/descriptor/psbt/parse.ts b/modules/utxo-core/src/descriptor/psbt/parse.ts index 6e9822efbc..cf387871ca 100644 --- a/modules/utxo-core/src/descriptor/psbt/parse.ts +++ b/modules/utxo-core/src/descriptor/psbt/parse.ts @@ -1,11 +1,11 @@ import { Descriptor } from '@bitgo/wasm-miniscript'; import * as utxolib from '@bitgo/utxo-lib'; -import { DescriptorMap } from '../DescriptorMap'; -import { getVirtualSize } from '../VirtualSize'; +import { DescriptorMap } from '../DescriptorMap.js'; +import { getVirtualSize } from '../VirtualSize.js'; -import { findDescriptorForInput, findDescriptorForOutput } from './findDescriptors'; -import { assertSatisfiable } from './assertSatisfiable'; +import { findDescriptorForInput, findDescriptorForOutput } from './findDescriptors.js'; +import { assertSatisfiable } from './assertSatisfiable.js'; export type ScriptId = { descriptor: Descriptor; index: number | undefined }; diff --git a/modules/utxo-core/src/index.ts b/modules/utxo-core/src/index.ts index 31db24d010..c69ad47b14 100644 --- a/modules/utxo-core/src/index.ts +++ b/modules/utxo-core/src/index.ts @@ -1,8 +1,8 @@ -export * as bip65 from './bip65'; -export * as descriptor from './descriptor'; -export * as testutil from './testutil'; -export * as paygo from './paygo'; -export * as bip32utils from './bip32utils'; -export * from './dustThreshold'; -export * from './Output'; -export * from './xOnlyPubkey'; +export * as bip65 from './bip65/index.js'; +export * as descriptor from './descriptor/index.js'; +export * as testutil from './testutil/index.js'; +export * as paygo from './paygo/index.js'; +export * as bip32utils from './bip32utils.js'; +export * from './dustThreshold.js'; +export * from './Output.js'; +export * from './xOnlyPubkey.js'; diff --git a/modules/utxo-core/src/paygo/index.ts b/modules/utxo-core/src/paygo/index.ts index 8555f440b6..4154b4b96f 100644 --- a/modules/utxo-core/src/paygo/index.ts +++ b/modules/utxo-core/src/paygo/index.ts @@ -1,2 +1,2 @@ -export * from './parsePayGoAttestation'; -export * from './psbt'; +export * from './parsePayGoAttestation.js'; +export * from './psbt/index.js'; diff --git a/modules/utxo-core/src/paygo/psbt/index.ts b/modules/utxo-core/src/paygo/psbt/index.ts index bea5042737..a4bd1c6f5f 100644 --- a/modules/utxo-core/src/paygo/psbt/index.ts +++ b/modules/utxo-core/src/paygo/psbt/index.ts @@ -1 +1 @@ -export * from './payGoAddressProof'; +export * from './payGoAddressProof.js'; diff --git a/modules/utxo-core/src/paygo/psbt/payGoAddressProof.ts b/modules/utxo-core/src/paygo/psbt/payGoAddressProof.ts index 24dc10361c..4a1d6491b6 100644 --- a/modules/utxo-core/src/paygo/psbt/payGoAddressProof.ts +++ b/modules/utxo-core/src/paygo/psbt/payGoAddressProof.ts @@ -1,8 +1,8 @@ import * as utxolib from '@bitgo/utxo-lib'; -import { checkForOutput } from 'bip174/src/lib/utils'; +import { checkForOutput } from 'bip174/src/lib/utils.js'; -import { verifyMessage } from '../../bip32utils'; -import { createPayGoAttestationBuffer } from '../attestation'; +import { verifyMessage } from '../../bip32utils.js'; +import { createPayGoAttestationBuffer } from '../attestation.js'; import { ErrorMultiplePayGoProof, @@ -10,7 +10,7 @@ import { ErrorNoPayGoProof, ErrorOutputIndexOutOfBounds, ErrorPayGoAddressProofFailedVerification, -} from './Errors'; +} from './Errors.js'; /** This function adds the entropy and signature into the PSBT output unknown key vals. * We store the entropy so that we reconstruct the message
diff --git a/modules/utxo-core/src/testutil/descriptor/descriptors.ts b/modules/utxo-core/src/testutil/descriptor/descriptors.ts index 09144f8ecd..a477c9d917 100644 --- a/modules/utxo-core/src/testutil/descriptor/descriptors.ts +++ b/modules/utxo-core/src/testutil/descriptor/descriptors.ts @@ -3,8 +3,8 @@ import assert from 'assert'; import { Miniscript, Descriptor, ast } from '@bitgo/wasm-miniscript'; import { bip32, BIP32Interface } from '@bitgo/utxo-lib'; -import { DescriptorMap, PsbtParams } from '../../descriptor'; -import { getKeyTriple, Triple, KeyTriple } from '../key.utils'; +import { DescriptorMap, PsbtParams } from '../../descriptor/index.js'; +import { getKeyTriple, Triple, KeyTriple } from '../key.utils.js'; export function getDefaultXPubs(seed?: string): Triple { return getKeyTriple(seed).map((k) => k.neutered().toBase58()) as Triple; diff --git a/modules/utxo-core/src/testutil/descriptor/index.ts b/modules/utxo-core/src/testutil/descriptor/index.ts index 1fe3266605..46a4788669 100644 --- a/modules/utxo-core/src/testutil/descriptor/index.ts +++ b/modules/utxo-core/src/testutil/descriptor/index.ts @@ -1,3 +1,3 @@ -export * from './descriptors'; -export * from './mock.utils'; -export * from './psbt.utils'; +export * from './descriptors.js'; +export * from './mock.utils.js'; +export * from './psbt.utils.js'; diff --git a/modules/utxo-core/src/testutil/descriptor/mock.utils.ts b/modules/utxo-core/src/testutil/descriptor/mock.utils.ts index 487da08fc1..3511ab8235 100644 --- a/modules/utxo-core/src/testutil/descriptor/mock.utils.ts +++ b/modules/utxo-core/src/testutil/descriptor/mock.utils.ts @@ -6,9 +6,9 @@ import { createPsbt, createScriptPubKeyFromDescriptor, DerivedDescriptorTransactionInput, -} from '../../descriptor'; +} from '../../descriptor/index.js'; -import { DescriptorTemplate, getDefaultXPubs, getDescriptor } from './descriptors'; +import { DescriptorTemplate, getDefaultXPubs, getDescriptor } from './descriptors.js'; type MockOutputIdParams = { hash?: string; vout?: number }; diff --git a/modules/utxo-core/src/testutil/descriptor/psbt.utils.ts b/modules/utxo-core/src/testutil/descriptor/psbt.utils.ts index 582b908ac6..5e17a6dbe6 100644 --- a/modules/utxo-core/src/testutil/descriptor/psbt.utils.ts +++ b/modules/utxo-core/src/testutil/descriptor/psbt.utils.ts @@ -1,6 +1,6 @@ import * as utxolib from '@bitgo/utxo-lib'; -import { matchPath, PathElement, toPlainObject } from '../../../src/testutil'; +import { matchPath, PathElement, toPlainObject } from '../../../src/testutil/index.js'; export function toPlainObjectFromPsbt(v: utxolib.Psbt): unknown { return toPlainObject( diff --git a/modules/utxo-core/src/testutil/generatePayGoAttestationProof.utils.ts b/modules/utxo-core/src/testutil/generatePayGoAttestationProof.utils.ts index 7a662db701..fe342e6729 100644 --- a/modules/utxo-core/src/testutil/generatePayGoAttestationProof.utils.ts +++ b/modules/utxo-core/src/testutil/generatePayGoAttestationProof.utils.ts @@ -2,7 +2,7 @@ import crypto from 'crypto'; import { bufferutils } from '@bitgo/utxo-lib'; -import { Prefix } from '../paygo'; +import { Prefix } from '../paygo/index.js'; /** We have a mirrored function similar to our hsm that generates our Bitcoin signed * message so that we can use for testing. This creates a random entropy as well using diff --git a/modules/utxo-core/src/testutil/index.ts b/modules/utxo-core/src/testutil/index.ts index f2d04b3c79..b04644ba05 100644 --- a/modules/utxo-core/src/testutil/index.ts +++ b/modules/utxo-core/src/testutil/index.ts @@ -1,5 +1,5 @@ -export * from './fixtures.utils'; -export * from './key.utils'; -export * from './toPlainObject.utils'; -export * from './generatePayGoAttestationProof.utils'; -export * from './trimMessagePrefix'; +export * from './fixtures.utils.js'; +export * from './key.utils.js'; +export * from './toPlainObject.utils.js'; +export * from './generatePayGoAttestationProof.utils.js'; +export * from './trimMessagePrefix.js'; diff --git a/modules/utxo-core/test/Output.ts b/modules/utxo-core/test/Output.ts index 6bbe2fb3cd..5033986401 100644 --- a/modules/utxo-core/test/Output.ts +++ b/modules/utxo-core/test/Output.ts @@ -1,6 +1,6 @@ import * as assert from 'assert'; -import { getFixedOutputSum, getMaxOutput, getOutputSum, isMaxOutput, toFixedOutputs } from '../src'; +import { getFixedOutputSum, getMaxOutput, getOutputSum, isMaxOutput, toFixedOutputs } from '../src/index.js'; describe('Output', function () { const oBigInt = { value: 1n }; diff --git a/modules/utxo-core/test/bip32utils.ts b/modules/utxo-core/test/bip32utils.ts index 0f5b94b088..a7ac84fa27 100644 --- a/modules/utxo-core/test/bip32utils.ts +++ b/modules/utxo-core/test/bip32utils.ts @@ -3,7 +3,7 @@ import * as assert from 'assert'; import * as utxolib from '@bitgo/utxo-lib'; -import { signMessage, verifyMessage } from '../src/bip32utils'; +import { signMessage, verifyMessage } from '../src/bip32utils.js'; describe('bip32utils', function () { function getSeedBuffers(length: number) { @@ -21,7 +21,12 @@ describe('bip32utils', function () { const expectValid = message === otherMessage && key === otherKey; assert.strictEqual(verifyMessage(otherMessage, otherKey, signature, utxolib.networks.bitcoin), expectValid); assert.strictEqual( - verifyMessage(Buffer.from(otherMessage), otherKey, signature, utxolib.networks.bitcoin), + verifyMessage( + typeof otherMessage === 'string' ? Buffer.from(otherMessage) : otherMessage, + otherKey, + signature, + utxolib.networks.bitcoin + ), expectValid ); }); diff --git a/modules/utxo-core/test/bip65/locktime.ts b/modules/utxo-core/test/bip65/locktime.ts index c73cd19d2c..cc0e8f6e97 100644 --- a/modules/utxo-core/test/bip65/locktime.ts +++ b/modules/utxo-core/test/bip65/locktime.ts @@ -1,6 +1,6 @@ import assert from 'assert'; -import { encodeLocktime } from '../../src/bip65/locktime'; +import { encodeLocktime } from '../../src/bip65/locktime.js'; describe('locktime', function () { it('encodes relative and absolute locktimes', function () { diff --git a/modules/utxo-core/test/descriptor/Output.ts b/modules/utxo-core/test/descriptor/Output.ts index a44c92ee48..bf7766f361 100644 --- a/modules/utxo-core/test/descriptor/Output.ts +++ b/modules/utxo-core/test/descriptor/Output.ts @@ -1,8 +1,8 @@ import assert from 'assert'; -import { isExternalOutput, isInternalOutput, toDerivedDescriptorWalletOutput } from '../../src/descriptor/Output'; -import { getDescriptor } from '../../src/testutil/descriptor'; -import { createScriptPubKeyFromDescriptor } from '../../src/descriptor'; +import { isExternalOutput, isInternalOutput, toDerivedDescriptorWalletOutput } from '../../src/descriptor/Output.js'; +import { getDescriptor } from '../../src/testutil/descriptor/index.js'; +import { createScriptPubKeyFromDescriptor } from '../../src/descriptor/index.js'; describe('decscriptor.Output', function () { const descriptor = getDescriptor('Wsh2Of3'); diff --git a/modules/utxo-core/test/descriptor/derive.ts b/modules/utxo-core/test/descriptor/derive.ts index d8606848e0..e9a007c450 100644 --- a/modules/utxo-core/test/descriptor/derive.ts +++ b/modules/utxo-core/test/descriptor/derive.ts @@ -1,7 +1,7 @@ import assert from 'assert'; -import { getDescriptor } from '../../src/testutil/descriptor'; -import { getDescriptorAtIndex, getDescriptorAtIndexCheckScript } from '../../src/descriptor/derive'; +import { getDescriptor } from '../../src/testutil/descriptor/index.js'; +import { getDescriptorAtIndex, getDescriptorAtIndexCheckScript } from '../../src/descriptor/derive.js'; describe('derive', function () { const derivable = getDescriptor('Wsh2Of3'); diff --git a/modules/utxo-core/test/descriptor/fromFixedScriptWallet.ts b/modules/utxo-core/test/descriptor/fromFixedScriptWallet.ts index a1a100162f..9ab7cacf51 100644 --- a/modules/utxo-core/test/descriptor/fromFixedScriptWallet.ts +++ b/modules/utxo-core/test/descriptor/fromFixedScriptWallet.ts @@ -6,7 +6,7 @@ import { Descriptor } from '@bitgo/wasm-miniscript'; import { getDescriptorForScriptType, getNamedDescriptorsForRootWalletKeys, -} from '../../src/descriptor/fromFixedScriptWallet'; +} from '../../src/descriptor/fromFixedScriptWallet.js'; function getRootWalletKeys(derivationPrefixes?: utxolib.bitgo.Triple): utxolib.bitgo.RootWalletKeys { // This is a fixed script wallet, so we use a fixed key triple. diff --git a/modules/utxo-core/test/descriptor/parse/PatternMatcher.ts b/modules/utxo-core/test/descriptor/parse/PatternMatcher.ts index 3e82020c54..8bdf29fc39 100644 --- a/modules/utxo-core/test/descriptor/parse/PatternMatcher.ts +++ b/modules/utxo-core/test/descriptor/parse/PatternMatcher.ts @@ -2,9 +2,9 @@ import assert from 'assert'; import { Descriptor, ast } from '@bitgo/wasm-miniscript'; -import { getKey } from '../../../src/testutil'; -import { toXOnlyPublicKey } from '../../../src'; -import { PatternMatcher, Pattern } from '../../../src/descriptor/parse/PatternMatcher'; +import { getKey } from '../../../src/testutil/index.js'; +import { toXOnlyPublicKey } from '../../../src/index.js'; +import { PatternMatcher, Pattern } from '../../../src/descriptor/parse/PatternMatcher.js'; function key32(seed: string): Buffer { // return x-only public key from seed diff --git a/modules/utxo-core/test/descriptor/psbt/VirtualSize.ts b/modules/utxo-core/test/descriptor/psbt/VirtualSize.ts index 9fed1ae7c4..978fe0a24a 100644 --- a/modules/utxo-core/test/descriptor/psbt/VirtualSize.ts +++ b/modules/utxo-core/test/descriptor/psbt/VirtualSize.ts @@ -5,16 +5,16 @@ import { getInputVSizesForDescriptors, getVirtualSize, getVirtualSizeEstimateForPsbt, -} from '../../../src/descriptor/VirtualSize'; +} from '../../../src/descriptor/VirtualSize.js'; import { DescriptorTemplate, getDefaultXPubs, getDescriptor, getDescriptorMap, mockPsbtDefault, -} from '../../../src/testutil/descriptor'; -import { getKeyTriple } from '../../../src/testutil'; -import { finalizePsbt } from '../../../src/descriptor'; +} from '../../../src/testutil/descriptor/index.js'; +import { getKeyTriple } from '../../../src/testutil/index.js'; +import { finalizePsbt } from '../../../src/descriptor/index.js'; describe('VirtualSize', function () { describe('getInputVSizesForDescriptorWallet', function () { diff --git a/modules/utxo-core/test/descriptor/psbt/assertSatisfiable.ts b/modules/utxo-core/test/descriptor/psbt/assertSatisfiable.ts index 4263ae88dd..1d1ce0d74f 100644 --- a/modules/utxo-core/test/descriptor/psbt/assertSatisfiable.ts +++ b/modules/utxo-core/test/descriptor/psbt/assertSatisfiable.ts @@ -2,8 +2,8 @@ import * as assert from 'assert'; import { Descriptor } from '@bitgo/wasm-miniscript'; -import { getDefaultXPubs } from '../../../src/testutil/descriptor'; -import { getRequiredLocktime } from '../../../src/descriptor'; +import { getDefaultXPubs } from '../../../src/testutil/descriptor/index.js'; +import { getRequiredLocktime } from '../../../src/descriptor/index.js'; function d(s: string): Descriptor { return Descriptor.fromString(s, 'derivable'); diff --git a/modules/utxo-core/test/descriptor/psbt/findDescriptors.ts b/modules/utxo-core/test/descriptor/psbt/findDescriptors.ts index 40c8619123..f537df0b51 100644 --- a/modules/utxo-core/test/descriptor/psbt/findDescriptors.ts +++ b/modules/utxo-core/test/descriptor/psbt/findDescriptors.ts @@ -1,7 +1,12 @@ import * as assert from 'assert'; -import { DescriptorTemplate, getDefaultXPubs, getDescriptor, mockPsbt } from '../../../src/testutil/descriptor'; -import { findDescriptorForInput, findDescriptorForOutput } from '../../../src/descriptor'; +import { + DescriptorTemplate, + getDefaultXPubs, + getDescriptor, + mockPsbt, +} from '../../../src/testutil/descriptor/index.js'; +import { findDescriptorForInput, findDescriptorForOutput } from '../../../src/descriptor/index.js'; function describeWithTemplates(templateSelf: DescriptorTemplate, templateOther: DescriptorTemplate) { describe(`parsePsbt [${templateSelf},${templateOther}]`, function () { diff --git a/modules/utxo-core/test/descriptor/psbt/psbt.ts b/modules/utxo-core/test/descriptor/psbt/psbt.ts index af339a2d22..332656daa4 100644 --- a/modules/utxo-core/test/descriptor/psbt/psbt.ts +++ b/modules/utxo-core/test/descriptor/psbt/psbt.ts @@ -1,11 +1,19 @@ import assert from 'assert'; +import path from 'path'; +import { fileURLToPath } from 'url'; import * as utxolib from '@bitgo/utxo-lib'; import { BIP32Interface, ECPair, ECPairInterface } from '@bitgo/utxo-lib'; import { Descriptor, Miniscript } from '@bitgo/wasm-miniscript'; -import { PsbtParams, parse, toUtxoPsbt, toWrappedPsbt, ParsedDescriptorTransaction } from '../../../src/descriptor'; -import { getFixture, getKeyTriple } from '../../../src/testutil'; +import { + PsbtParams, + parse, + toUtxoPsbt, + toWrappedPsbt, + ParsedDescriptorTransaction, +} from '../../../src/descriptor/index.js'; +import { getFixture, getKeyTriple } from '../../../src/testutil/index.js'; import { containsKey, DescriptorTemplate, @@ -16,8 +24,8 @@ import { mockPsbtDefault, toPlainObjectFromPsbt, toPlainObjectFromTx, -} from '../../../src/testutil/descriptor'; -import { getNewSignatureCount, signWithKey } from '../../../src/descriptor/psbt/sign'; +} from '../../../src/testutil/descriptor/index.js'; +import { getNewSignatureCount, signWithKey } from '../../../src/descriptor/psbt/sign.js'; function normalize(v: unknown): unknown { if (typeof v === 'bigint') { @@ -45,7 +53,9 @@ function normalize(v: unknown): unknown { } async function assertEqualsFixture(t: string, filename: string, value: unknown) { - filename = __dirname + '/../../../../test/descriptor/psbt/fixtures/' + t + '.' + filename; + const __filename = fileURLToPath(import.meta.url); + const __dirname = path.dirname(__filename); + filename = __dirname + '/fixtures/' + t + '.' + filename; const nv = normalize(value); assert.deepStrictEqual(nv, await getFixture(filename, nv)); } diff --git a/modules/utxo-core/test/dustThreshold.ts b/modules/utxo-core/test/dustThreshold.ts index cdc29fbf98..b3f89e3429 100644 --- a/modules/utxo-core/test/dustThreshold.ts +++ b/modules/utxo-core/test/dustThreshold.ts @@ -2,7 +2,7 @@ import assert from 'assert'; import * as utxolib from '@bitgo/utxo-lib'; -import { getDustThresholdSat } from '../src/dustThreshold'; +import { getDustThresholdSat } from '../src/dustThreshold.js'; describe('getDustThresholdSat', function () { it('has expected values', function () { diff --git a/modules/utxo-core/test/paygo/attestation.ts b/modules/utxo-core/test/paygo/attestation.ts index 26baf23b1e..285be1107b 100644 --- a/modules/utxo-core/test/paygo/attestation.ts +++ b/modules/utxo-core/test/paygo/attestation.ts @@ -1,9 +1,9 @@ import assert from 'assert'; -import { createPayGoAttestationBuffer } from '../../src/paygo/attestation'; -import { generatePayGoAttestationProof } from '../../src/testutil'; +import { createPayGoAttestationBuffer } from '../../src/paygo/attestation.js'; +import { generatePayGoAttestationProof } from '../../src/testutil/index.js'; -import { addressProofEntropy, addressProofMsgBuffer, addressToVerify, network } from './psbt/payGoAddressProof'; +import { addressProofEntropy, addressProofMsgBuffer, addressToVerify, network } from './psbt/payGoAddressProof.js'; describe('createPayGoAttestationBuffer', () => { it('should create a PayGo Attestation proof matching with original proof', () => { diff --git a/modules/utxo-core/test/paygo/parsePayGoAttestation.ts b/modules/utxo-core/test/paygo/parsePayGoAttestation.ts index b58bb3bf69..17bc167ff5 100644 --- a/modules/utxo-core/test/paygo/parsePayGoAttestation.ts +++ b/modules/utxo-core/test/paygo/parsePayGoAttestation.ts @@ -1,8 +1,8 @@ import * as assert from 'assert'; -import { parsePayGoAttestation } from '../../src/paygo'; -import { generatePayGoAttestationProof } from '../../src/testutil'; -import { NIL_UUID } from '../../src/paygo/attestation'; +import { parsePayGoAttestation } from '../../src/paygo/index.js'; +import { generatePayGoAttestationProof } from '../../src/testutil/index.js'; +import { NIL_UUID } from '../../src/paygo/attestation.js'; const addressFromPubKeyBase58 = 'bitgoAddressToExtract'; const bufferAddressPubKeyB58 = Buffer.from(addressFromPubKeyBase58); diff --git a/modules/utxo-core/test/paygo/psbt/payGoAddressProof.ts b/modules/utxo-core/test/paygo/psbt/payGoAddressProof.ts index 1bd8518f78..1f28ff105c 100644 --- a/modules/utxo-core/test/paygo/psbt/payGoAddressProof.ts +++ b/modules/utxo-core/test/paygo/psbt/payGoAddressProof.ts @@ -2,20 +2,20 @@ import assert from 'assert'; import crypto from 'crypto'; import * as utxolib from '@bitgo/utxo-lib'; -import { decodeProprietaryKey } from 'bip174/src/lib/proprietaryKeyVal'; -import { KeyValue } from 'bip174/src/lib/interfaces'; -import { checkForOutput } from 'bip174/src/lib/utils'; +import { decodeProprietaryKey } from 'bip174/src/lib/proprietaryKeyVal.js'; +import { KeyValue } from 'bip174/src/lib/interfaces.js'; +import { checkForOutput } from 'bip174/src/lib/utils.js'; import { addPayGoAddressProof, getPayGoAddressProofOutputIndex, psbtOutputIncludesPaygoAddressProof, verifyPayGoAddressProof, -} from '../../../src/paygo/psbt/payGoAddressProof'; -import { generatePayGoAttestationProof } from '../../../src/testutil/generatePayGoAttestationProof.utils'; -import { trimMessagePrefix } from '../../../src/testutil/trimMessagePrefix'; -import { signMessage } from '../../../src/bip32utils'; -import { NIL_UUID } from '../../../src/paygo/attestation'; +} from '../../../src/paygo/psbt/payGoAddressProof.js'; +import { generatePayGoAttestationProof } from '../../../src/testutil/generatePayGoAttestationProof.utils.js'; +import { trimMessagePrefix } from '../../../src/testutil/trimMessagePrefix.js'; +import { signMessage } from '../../../src/bip32utils.js'; +import { NIL_UUID } from '../../../src/paygo/attestation.js'; // To construct our PSBTs export const network = utxolib.networks.bitcoin; diff --git a/modules/utxo-core/test/xOnlyPubkey.ts b/modules/utxo-core/test/xOnlyPubkey.ts index 88a9faf1e6..2513a59547 100644 --- a/modules/utxo-core/test/xOnlyPubkey.ts +++ b/modules/utxo-core/test/xOnlyPubkey.ts @@ -1,6 +1,6 @@ import assert from 'assert'; -import { toXOnlyPublicKey } from '../src'; +import { toXOnlyPublicKey } from '../src/index.js'; describe('xOnlyPubkey', function () { it('converts to X-Only pubkey', function () { diff --git a/modules/utxo-core/tsconfig.json b/modules/utxo-core/tsconfig.json index 6616905289..6212f6f8c5 100644 --- a/modules/utxo-core/tsconfig.json +++ b/modules/utxo-core/tsconfig.json @@ -3,6 +3,8 @@ "compilerOptions": { "outDir": "./dist", "rootDir": "./", + "module": "NodeNext", + "moduleResolution": "NodeNext", "esModuleInterop": true, "allowJs": false, "strict": true