Skip to content

Commit 98155e8

Browse files
fix(utxo-lib): avoid circular imports in testutil/mock.ts
Import directly from bitgo module to prevent circular dependency error. Co-authored-by: llm-git <[email protected]> Issue: BTC-2651
1 parent 09a7ce9 commit 98155e8

File tree

1 file changed

+4
-3
lines changed
  • modules/utxo-lib/src/testutil

1 file changed

+4
-3
lines changed

modules/utxo-lib/src/testutil/mock.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { ok as assert } from 'assert';
22
import { BIP32Interface } from '@bitgo/secp256k1';
3-
import * as utxolib from '..';
3+
import { payments } from '..';
44
import { getMainnet, Network, networks } from '../networks';
55

66
import {
77
ChainCode,
8+
withUnsafeNonSegwit,
89
createPsbtForNetwork,
910
fromOutput,
1011
fromOutputWithPrevTx,
@@ -37,7 +38,7 @@ export function mockPrevTx(
3738
const keypair = getKey('mock-prev-tx');
3839
const pubkey = keypair.publicKey;
3940
assert(keypair.privateKey);
40-
const payment = utxolib.payments.p2pkh({ pubkey });
41+
const payment = payments.p2pkh({ pubkey });
4142
const destOutput = payment.output;
4243
if (!destOutput) throw new Error('Impossible, payment we just constructed has no output');
4344

@@ -54,7 +55,7 @@ export function mockPrevTx(
5455
witnessUtxo: { script: destOutput, value: value * (BigInt(vout) + BigInt(1)) + BigInt(1000) },
5556
});
5657
// Don't require the prevTx for signing and finalizing for non-segwit input
57-
utxolib.bitgo.withUnsafeNonSegwit(psbtFromNetwork, () => {
58+
withUnsafeNonSegwit(psbtFromNetwork, () => {
5859
psbtFromNetwork.signInput(0, keypair);
5960
psbtFromNetwork.validateSignaturesOfAllInputs();
6061
psbtFromNetwork.finalizeAllInputs();

0 commit comments

Comments
 (0)