File tree Expand file tree Collapse file tree
sdk-core/src/bitgo/wallet Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1549,6 +1549,26 @@ describe('V2 Wallet:', function () {
15491549 unusedNocks . pendingMocks ( ) . length . should . eql ( 2 ) ;
15501550 nock . cleanAll ( ) ;
15511551 } ) ;
1552+
1553+ it ( 'should route custodial fanoutUnspents through tx/initiate' , async function ( ) {
1554+ const custodialBasecoin = bitgo . coin ( 'tbtc' ) ;
1555+ const custodialWalletData = {
1556+ id : '5b34252f1bf349930e34020a' ,
1557+ coin : 'tbtc' ,
1558+ type : 'custodial' ,
1559+ keys : [ '5b3424f91bf349930e340175' ] ,
1560+ } ;
1561+ const custodialWallet = new Wallet ( bitgo , custodialBasecoin , custodialWalletData ) ;
1562+
1563+ const initiatePath = `/api/v2/${ custodialWallet . coin ( ) } /wallet/${ custodialWallet . id ( ) } /tx/initiate` ;
1564+ const response = nock ( bgUrl )
1565+ . post ( initiatePath , _ . matches ( { type : 'fanout' } ) )
1566+ . reply ( 200 , { status : 'accepted' , txRequestId : 'mock-tx-request-id' } ) ;
1567+
1568+ const result = await custodialWallet . fanoutUnspents ( { numUnspentsToMake : 10 } ) ;
1569+ response . isDone ( ) . should . be . true ( ) ;
1570+ ( result as any ) . status . should . equal ( 'accepted' ) ;
1571+ } ) ;
15521572 } ) ;
15531573
15541574 describe ( 'Transaction prebuilds' , function ( ) {
Original file line number Diff line number Diff line change @@ -710,7 +710,7 @@ export class Wallet implements IWallet {
710710 if ( this . _wallet . type === 'custodial' && routeName === 'consolidate' ) {
711711 return this . initiateTransaction ( { ...params , type : 'consolidate' } ) ;
712712 } else if ( this . _wallet . type === 'custodial' && routeName === 'fanout' ) {
713- throw new Error ( 'Fanout is not supported for custodial wallets' ) ;
713+ return this . initiateTransaction ( { ... params , type : 'fanout' } ) ;
714714 }
715715
716716 common . validateParams ( params , [ ] , [ 'walletPassphrase' , 'xprv' ] ) ;
You can’t perform that action at this time.
0 commit comments