@@ -4,7 +4,6 @@ import { randomBytes } from 'crypto';
44import _ from 'lodash' ;
55import * as utxolib from '@bitgo/utxo-lib' ;
66import { address as wasmAddress , BIP32 , fixedScriptWallet , hasPsbtMagic } from '@bitgo/wasm-utxo' ;
7- import { bitgo } from '@bitgo/utxo-lib' ;
87import {
98 AddressCoinSpecific ,
109 BaseCoin ,
@@ -62,7 +61,6 @@ import { getReplayProtectionPubkeys, isReplayProtectionUnspent } from './transac
6261import { supportedCrossChainRecoveries } from './config' ;
6362import {
6463 assertValidTransactionRecipient ,
65- DecodedTransaction ,
6664 explainTx ,
6765 fromExtendedAddressFormat ,
6866 isScriptRecipient ,
@@ -142,28 +140,21 @@ type UtxoCustomSigningFunction<TNumber extends number | bigint> = {
142140 } ) : Promise < SignedTransaction > ;
143141} ;
144142
145- const { isChainCode , scriptTypeForChain , outputScripts } = bitgo ;
143+ const { ChainCode } = fixedScriptWallet ;
146144
147145/**
148146 * Check if a decoded transaction has at least one taproot key path spend (MuSig2) input.
149- * Works for both utxolib UtxoPsbt and wasm-utxo BitGoPsbt.
150147 */
151- function hasKeyPathSpendInput < TNumber extends number | bigint > (
152- tx : DecodedTransaction < TNumber > ,
148+ function hasKeyPathSpendInput (
149+ tx : fixedScriptWallet . BitGoPsbt ,
153150 pubs : string [ ] | undefined ,
154151 coinName : UtxoCoinName
155152) : boolean {
156- if ( tx instanceof bitgo . UtxoPsbt ) {
157- return bitgo . isTransactionWithKeyPathSpendInput ( tx ) ;
158- }
159- if ( tx instanceof fixedScriptWallet . BitGoPsbt ) {
160- assert ( pubs && isTriple ( pubs ) , 'pub triple is required to check for key path spend inputs in wasm-utxo PSBT' ) ;
161- const rootWalletKeys = fixedScriptWallet . RootWalletKeys . fromXpubs ( pubs ) ;
162- const replayProtection = { publicKeys : getReplayProtectionPubkeys ( coinName ) } ;
163- const parsed = tx . parseTransactionWithWalletKeys ( rootWalletKeys , { replayProtection } ) ;
164- return parsed . inputs . some ( ( input ) => input . scriptType === 'p2trMusig2KeyPath' ) ;
165- }
166- return false ;
153+ assert ( pubs && isTriple ( pubs ) , 'pub triple is required to check for key path spend inputs in wasm-utxo PSBT' ) ;
154+ const rootWalletKeys = fixedScriptWallet . RootWalletKeys . fromXpubs ( pubs ) ;
155+ const replayProtection = { publicKeys : getReplayProtectionPubkeys ( coinName ) } ;
156+ const parsed = tx . parseTransactionWithWalletKeys ( rootWalletKeys , { replayProtection } ) ;
157+ return parsed . inputs . some ( ( input ) => input . scriptType === 'p2trMusig2KeyPath' ) ;
167158}
168159
169160/**
@@ -216,8 +207,6 @@ function convertValidationErrorToTxIntentMismatch(
216207
217208export type { DecodedTransaction } from './transaction/types' ;
218209
219- export type RootWalletKeys = bitgo . RootWalletKeys ;
220-
221210export type UtxoCoinSpecific = AddressCoinSpecific | DescriptorAddressCoinSpecific ;
222211
223212export interface VerifyAddressOptions < TCoinSpecific extends UtxoCoinSpecific > extends BaseVerifyAddressOptions {
@@ -252,8 +241,6 @@ export interface DecoratedExplainTransactionOptions<TNumber extends number | big
252241 changeInfo ?: { address : string ; chain : number ; index : number } [ ] ;
253242}
254243
255- export type UtxoNetwork = utxolib . Network ;
256-
257244export interface TransactionPrebuild < TNumber extends number | bigint = number > extends BaseTransactionPrebuild {
258245 txInfo ?: TransactionInfo < TNumber > ;
259246 blockHeight ?: number ;
@@ -459,7 +446,7 @@ export abstract class AbstractUtxoCoin extends BaseCoin implements Musig2Partici
459446
460447 /** @deprecated */
461448 static get validAddressTypes ( ) : ScriptType2Of3 [ ] {
462- return [ ... outputScripts . scriptTypes2Of3 ] ;
449+ return [ 'p2sh' , 'p2shP2wsh' , 'p2wsh' , 'p2tr' , 'p2trMusig2' ] ;
463450 }
464451
465452 /**
@@ -590,7 +577,9 @@ export abstract class AbstractUtxoCoin extends BaseCoin implements Musig2Partici
590577 * @param addressDetails
591578 */
592579 static inferAddressType ( addressDetails : { chain : number } ) : ScriptType2Of3 | null {
593- return isChainCode ( addressDetails . chain ) ? scriptTypeForChain ( addressDetails . chain ) : null ;
580+ return fixedScriptWallet . ChainCode . is ( addressDetails . chain )
581+ ? ( fixedScriptWallet . ChainCode . scriptType ( addressDetails . chain ) as ScriptType2Of3 )
582+ : null ;
594583 }
595584
596585 decodeTransaction ( input : Buffer | string ) : fixedScriptWallet . BitGoPsbt {
@@ -755,7 +744,10 @@ export abstract class AbstractUtxoCoin extends BaseCoin implements Musig2Partici
755744 * @return true iff coin supports spending from chain
756745 */
757746 supportsAddressChain ( chain : number ) : boolean {
758- return isChainCode ( chain ) && this . supportsAddressType ( utxolib . bitgo . scriptTypeForChain ( chain ) ) ;
747+ return (
748+ fixedScriptWallet . ChainCode . is ( chain ) &&
749+ this . supportsAddressType ( fixedScriptWallet . ChainCode . scriptType ( chain ) as ScriptType2Of3 )
750+ ) ;
759751 }
760752
761753 keyIdsForSigning ( ) : number [ ] {
0 commit comments