@@ -5,7 +5,6 @@ import * as utxolib from "@bitgo/utxo-lib";
55import assert from "node:assert" ;
66import {
77 utxolibCompat ,
8- FixedScriptWallet ,
98 toOutputScriptWithCoin ,
109 fromOutputScriptWithCoin ,
1110 type CoinName ,
@@ -16,37 +15,6 @@ type Triple<T> = [T, T, T];
1615
1716type Fixture = [ type : string , script : string , address : string ] ;
1817
19- function getAddressUtxoLib (
20- keys : Triple < utxolib . BIP32Interface > ,
21- chain : number ,
22- index : number ,
23- network : utxolib . Network ,
24- ) : string {
25- if ( ! utxolib . bitgo . isChainCode ( chain ) ) {
26- throw new Error ( `Invalid chain code: ${ chain } ` ) ;
27- }
28-
29- const walletKeys = new utxolib . bitgo . RootWalletKeys ( keys ) ;
30- const derived = walletKeys . deriveForChainAndIndex ( chain , index ) ;
31- const script = utxolib . bitgo . outputScripts . createOutputScript2of3 (
32- derived . publicKeys ,
33- utxolib . bitgo . outputScripts . scriptTypeForChain ( chain ) ,
34- ) ;
35- const address = utxolib . address . fromOutputScript ( script . scriptPubKey , network ) ;
36- return address ;
37- }
38-
39- function getAddressWasm (
40- keys : Triple < utxolib . BIP32Interface > ,
41- chain : number ,
42- index : number ,
43- network : utxolib . Network ,
44- ) : string {
45- const xpubs = keys . map ( ( key ) => key . neutered ( ) . toBase58 ( ) ) ;
46- const wasmAddress = FixedScriptWallet . address ( xpubs , chain , index , network ) ;
47- return wasmAddress ;
48- }
49-
5018function getCoinNameForNetwork ( name : string ) : CoinName {
5119 switch ( name ) {
5220 case "bitcoin" :
@@ -146,23 +114,6 @@ function runTest(network: utxolib.Network, addressFormat?: AddressFormat) {
146114 assert . deepStrictEqual ( Buffer . from ( scriptFromAddress ) , scriptBuf ) ;
147115 }
148116 } ) ;
149-
150- const keyTriple = utxolib . testutil . getKeyTriple ( "wasm" ) ;
151-
152- const supportedChainCodes = utxolib . bitgo . chainCodes . filter ( ( chainCode ) => {
153- const scriptType = utxolib . bitgo . outputScripts . scriptTypeForChain ( chainCode ) ;
154- return utxolib . bitgo . outputScripts . isSupportedScriptType ( network , scriptType ) ;
155- } ) ;
156-
157- it ( `can recreate address from wallet keys for chain codes ${ supportedChainCodes . join ( ", " ) } ` , function ( ) {
158- for ( const chainCode of supportedChainCodes ) {
159- for ( let index = 0 ; index < 2 ; index ++ ) {
160- const utxolibAddress = getAddressUtxoLib ( keyTriple , chainCode , index , network ) ;
161- const wasmAddress = getAddressWasm ( keyTriple , chainCode , index , network ) ;
162- assert . strictEqual ( utxolibAddress , wasmAddress ) ;
163- }
164- }
165- } ) ;
166117 } ) ;
167118}
168119
0 commit comments