@@ -1513,6 +1513,86 @@ describe('ETH:', function () {
15131513 const calledParams = isWalletAddressSpy . firstCall . args [ 0 ] ;
15141514 calledParams . should . have . property ( 'walletVersion' , 2 ) ;
15151515 } ) ;
1516+
1517+ it ( 'should fail v6 address creation if walletVersion was not passed (simulates old bug)' , async function ( ) {
1518+ const bgUrl = common . Environments [ bitgo . getEnv ( ) ] . uri ;
1519+ const ethCoin = bitgo . coin ( 'hteth' ) as Hteth ;
1520+ const walletDataV6 = {
1521+ id : '598f606cd8fc24710d2ebadb1d9459bb' ,
1522+ coinSpecific : {
1523+ baseAddress : '0xdf07117705a9f8dc4c2a78de66b7f1797dba9d4e' ,
1524+ walletVersion : 6 ,
1525+ } ,
1526+ coin : 'hteth' ,
1527+ keys : [
1528+ '598f606cd8fc24710d2ebad89dce86c2' ,
1529+ '598f606cc8e43aef09fcb785221d9dd2' ,
1530+ '5935d59cf660764331bafcade1855fd7' ,
1531+ ] ,
1532+ receiveAddress : {
1533+ address : '0xdf07117705a9f8dc4c2a78de66b7f1797dba9d4e' ,
1534+ } ,
1535+ } ;
1536+ const ethWalletV6 = new Wallet ( bitgo , ethCoin , walletDataV6 ) ;
1537+
1538+ // Stub isWalletAddress to simulate the OLD bug where walletVersion was not passed
1539+ const originalIsWalletAddress = ethCoin . isWalletAddress . bind ( ethCoin ) ;
1540+ const isWalletAddressStub = sinon . stub ( ethCoin , 'isWalletAddress' ) . callsFake ( async ( params ) => {
1541+ // Remove walletVersion to simulate the old bug
1542+ const paramsWithoutWalletVersion = { ...params } ;
1543+ delete ( paramsWithoutWalletVersion as any ) . walletVersion ;
1544+ return originalIsWalletAddress ( paramsWithoutWalletVersion ) ;
1545+ } ) ;
1546+
1547+ // Mock keychain requests
1548+ nock ( bgUrl ) . get ( `/api/v2/hteth/key/598f606cd8fc24710d2ebad89dce86c2` ) . reply ( 200 , {
1549+ id : '598f606cd8fc24710d2ebad89dce86c2' ,
1550+ pub : 'xpub661MyMwAqRbcFXDcWD2vxuebcT1ZpTF4Vke6qmMW8yzddwNYpAPjvYEEL5jLfyYXW2fuxtAxY8TgjPUJLcf1C8qz9N6VgZxArKX4EwB8rH5' ,
1551+ commonKeychain :
1552+ '033b02aac4f038fef5118350b77d302ec6202931ca2e7122aad88994ffefcbc70a6069e662436236abb1619195232c41580204cb202c22357ed8f53e69eac5c69e' ,
1553+ source : 'user' ,
1554+ type : 'tss' ,
1555+ } ) ;
1556+ nock ( bgUrl ) . get ( `/api/v2/hteth/key/598f606cc8e43aef09fcb785221d9dd2` ) . reply ( 200 , {
1557+ id : '598f606cc8e43aef09fcb785221d9dd2' ,
1558+ pub : 'xpub661MyMwAqRbcGhSaXikpuTC9KU88Xx9LrjKSw1JKsvXNgabpTdgjy7LSovh9ZHhcqhAHQu7uthu7FguNGdcC4aXTKK5gqTcPe4WvLYRbCSG' ,
1559+ commonKeychain :
1560+ '033b02aac4f038fef5118350b77d302ec6202931ca2e7122aad88994ffefcbc70a6069e662436236abb1619195232c41580204cb202c22357ed8f53e69eac5c69e' ,
1561+ source : 'backup' ,
1562+ type : 'tss' ,
1563+ } ) ;
1564+ nock ( bgUrl ) . get ( `/api/v2/hteth/key/5935d59cf660764331bafcade1855fd7` ) . reply ( 200 , {
1565+ id : '5935d59cf660764331bafcade1855fd7' ,
1566+ pub : 'xpub661MyMwAqRbcFsXShW8R3hJsHNTYTUwzcejnLkY7KCtaJbDqcGkcBF99BrEJSjNZHeHveiYUrsAdwnjUMGwpgmEbiKcZWRuVA9HxnRaA3r3' ,
1567+ commonKeychain :
1568+ '033b02aac4f038fef5118350b77d302ec6202931ca2e7122aad88994ffefcbc70a6069e662436236abb1619195232c41580204cb202c22357ed8f53e69eac5c69e' ,
1569+ source : 'bitgo' ,
1570+ type : 'tss' ,
1571+ } ) ;
1572+
1573+ // Mock address creation API
1574+ nock ( bgUrl )
1575+ . post ( `/api/v2/hteth/wallet/${ ethWalletV6 . id ( ) } /address` )
1576+ . reply ( 200 , {
1577+ id : '638a48c6c3dba40007a3497fa49a080c' ,
1578+ address : '0xc012041dac143a59fa491db3a2b67b69bd78b685' ,
1579+ chain : 0 ,
1580+ index : 0 ,
1581+ coin : 'hteth' ,
1582+ wallet : ethWalletV6 . id ( ) ,
1583+ coinSpecific : {
1584+ forwarderVersion : 4 ,
1585+ salt : '0x0' ,
1586+ feeAddress : '0xb1e725186990b86ca8efed08a3ccda9c9f400f09' ,
1587+ } ,
1588+ } ) ;
1589+
1590+ // Without walletVersion, address creation should fail because
1591+ // the code doesn't know to use TSS verification for v6 wallets
1592+ await assert . rejects ( async ( ) => ethWalletV6 . createAddress ( { chain : 0 } ) , UnexpectedAddressError ) ;
1593+
1594+ isWalletAddressStub . restore ( ) ;
1595+ } ) ;
15161596 } ) ;
15171597
15181598 describe ( 'EVM Cross Chain Recovery' , function ( ) {
0 commit comments