11import * as assert from 'assert' ;
22
3- import * as utxolib from '@bitgo/utxo-lib' ;
43import { Wallet } from '@bitgo/sdk-core' ;
54
65import { AbstractUtxoCoin , ErrorDeprecatedTxFormat , TxFormat } from '../../src' ;
6+ import { getMainnetCoinName , isMainnetCoin , isTestnetCoin } from '../../src/names' ;
77
88import { utxoCoins , defaultBitGo } from './util' ;
99
@@ -106,39 +106,38 @@ describe('txFormat', function () {
106106 // All testnet wallets default to PSBT-lite
107107 runTest ( {
108108 description : 'should always return psbt-lite for testnet' ,
109- coinFilter : ( coin ) => utxolib . isTestnet ( coin . network ) ,
109+ coinFilter : ( coin ) => isTestnetCoin ( coin . name ) ,
110110 expectedTxFormat : 'psbt-lite' ,
111111 } ) ;
112112
113113 // DistributedCustody wallets default to PSBT (mainnet only, testnet already covered)
114114 runTest ( {
115115 description : 'should return psbt for distributedCustody wallets on mainnet' ,
116- coinFilter : ( coin ) => utxolib . isMainnet ( coin . network ) ,
116+ coinFilter : ( coin ) => isMainnetCoin ( coin . name ) ,
117117 walletFilter : ( w ) => w . options . subType === 'distributedCustody' ,
118118 expectedTxFormat : 'psbt' ,
119119 } ) ;
120120
121121 // MuSig2 wallets default to PSBT (mainnet only, testnet already covered)
122122 runTest ( {
123123 description : 'should return psbt for wallets with musigKp flag on mainnet' ,
124- coinFilter : ( coin ) => utxolib . isMainnet ( coin . network ) ,
124+ coinFilter : ( coin ) => isMainnetCoin ( coin . name ) ,
125125 walletFilter : ( w ) => Boolean ( w . options . walletFlags ?. some ( ( f ) => f . name === 'musigKp' && f . value === 'true' ) ) ,
126126 expectedTxFormat : 'psbt' ,
127127 } ) ;
128128
129129 // Mainnet Bitcoin hot wallets default to PSBT
130130 runTest ( {
131131 description : 'should return psbt for mainnet bitcoin hot wallets' ,
132- coinFilter : ( coin ) =>
133- utxolib . isMainnet ( coin . network ) && utxolib . getMainnet ( coin . network ) === utxolib . networks . bitcoin ,
132+ coinFilter : ( coin ) => isMainnetCoin ( coin . name ) && getMainnetCoinName ( coin . name ) === 'btc' ,
134133 walletFilter : ( w ) => w . options . type === 'hot' ,
135134 expectedTxFormat : 'psbt' ,
136135 } ) ;
137136
138137 // Other mainnet wallets do NOT default to PSBT
139138 runTest ( {
140139 description : 'should return undefined for other mainnet wallets' ,
141- coinFilter : ( coin ) => utxolib . isMainnet ( coin . network ) ,
140+ coinFilter : ( coin ) => isMainnetCoin ( coin . name ) ,
142141 walletFilter : ( w ) => {
143142 const isHotBitcoin = w . options . type === 'hot' ; // This will be bitcoin hot wallets
144143 const isDistributedCustody = w . options . subType === 'distributedCustody' ;
@@ -152,7 +151,7 @@ describe('txFormat', function () {
152151 // Test explicitly requested formats
153152 runTest ( {
154153 description : 'should respect explicitly requested legacy format on mainnet' ,
155- coinFilter : ( coin ) => utxolib . isMainnet ( coin . network ) ,
154+ coinFilter : ( coin ) => isMainnetCoin ( coin . name ) ,
156155 expectedTxFormat : 'legacy' ,
157156 requestedTxFormat : 'legacy' ,
158157 } ) ;
@@ -172,7 +171,7 @@ describe('txFormat', function () {
172171 // Test that legacy format is prohibited on testnet
173172 it ( 'should throw ErrorDeprecatedTxFormat when legacy format is requested on testnet' , function ( ) {
174173 for ( const coin of utxoCoins ) {
175- if ( ! utxolib . isTestnet ( coin . network ) ) {
174+ if ( ! isTestnetCoin ( coin . name ) ) {
176175 continue ;
177176 }
178177
0 commit comments