@@ -14,7 +14,6 @@ import {
1414} from '@bitgo/sdk-core' ;
1515import * as utxolib from '@bitgo/utxo-lib' ;
1616import { bitgo } from '@bitgo/utxo-lib' ;
17- import { bip32 } from '@bitgo/secp256k1' ;
1817import * as wasmUtxo from '@bitgo/wasm-utxo' ;
1918
2019type ScriptType2Of3 = bitgo . outputScripts . ScriptType2Of3 ;
@@ -38,15 +37,6 @@ interface GenerateFixedScriptAddressOptions extends GenerateAddressOptions {
3837 keychains : { pub : string } [ ] ;
3938}
4039
41- function canonicalAddress ( network : utxolib . Network , address : string , format ?: CreateAddressFormat ) : string {
42- if ( format === 'cashaddr' ) {
43- const script = utxolib . addressFormat . toOutputScriptTryFormats ( address , network ) ;
44- return utxolib . addressFormat . fromOutputScriptWithFormat ( script , format , network ) ;
45- }
46- // Default to canonical format (base58 for most coins)
47- return utxolib . addressFormat . toCanonicalFormat ( address , network ) ;
48- }
49-
5040function supportsAddressType ( network : utxolib . Network , addressType : ScriptType2Of3 ) : boolean {
5141 return utxolib . bitgo . outputScripts . isSupportedScriptType ( network , addressType ) ;
5242}
@@ -58,24 +48,10 @@ export function generateAddressWithChainAndIndex(
5848 index : number ,
5949 format : CreateAddressFormat | undefined
6050) : string {
61- if ( utxolib . isTestnet ( network ) ) {
62- // Convert CreateAddressFormat to AddressFormat for wasm-utxo
63- // 'base58' -> 'default', 'cashaddr' -> 'cashaddr'
64- const wasmFormat = format === 'base58' ? 'default' : format ;
65- return wasmUtxo . fixedScriptWallet . address ( keychains , chain , index , network , wasmFormat ) ;
66- }
67-
68- if ( ! ( keychains instanceof bitgo . RootWalletKeys ) ) {
69- const hdNodes = keychains . map ( ( pub ) => bip32 . fromBase58 ( pub ) ) ;
70- keychains = new bitgo . RootWalletKeys ( hdNodes as Triple < utxolib . BIP32Interface > ) ;
71- }
72-
73- const addressType = bitgo . scriptTypeForChain ( chain ) ;
74-
75- const derivedKeys = keychains . deriveForChainAndIndex ( chain , index ) . publicKeys ;
76- const { scriptPubKey : outputScript } = utxolib . bitgo . outputScripts . createOutputScript2of3 ( derivedKeys , addressType ) ;
77- const address = utxolib . address . fromOutputScript ( outputScript , network ) ;
78- return canonicalAddress ( network , address , format ) ;
51+ // Convert CreateAddressFormat to AddressFormat for wasm-utxo
52+ // 'base58' -> 'default', 'cashaddr' -> 'cashaddr'
53+ const wasmFormat = format === 'base58' ? 'default' : format ;
54+ return wasmUtxo . fixedScriptWallet . address ( keychains , chain , index , network , wasmFormat ) ;
7955}
8056
8157/**
0 commit comments