File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
sdk-core/src/bitgo/wallet Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -1513,6 +1513,21 @@ describe('V2 Wallet:', function () {
15131513
15141514 response . isDone ( ) . should . be . true ( ) ;
15151515 } ) ;
1516+
1517+ it ( 'should only build tx (not sign/send) while fanning out unspents' , async function ( ) {
1518+ const path = `/api/v2/${ wallet . coin ( ) } /wallet/${ wallet . id ( ) } /fanoutUnspents` ;
1519+ const response = nock ( bgUrl ) . persist ( ) . post ( path , _ . matches ( { unspents } ) ) . reply ( 200 ) ;
1520+
1521+ const unusedNocks = nock ( bgUrl ) ;
1522+ unusedNocks . get ( `/api/v2/${ wallet . coin ( ) } /key/${ wallet . keyIds ( ) [ 0 ] } ` ) . reply ( 200 ) ;
1523+ unusedNocks . post ( `/api/v2/${ wallet . coin ( ) } /wallet/${ wallet . id ( ) } /tx/send` ) . reply ( 200 ) ;
1524+
1525+ await wallet . fanoutUnspents ( { address, unspents } , ManageUnspentsOptions . BUILD_ONLY ) ;
1526+
1527+ response . isDone ( ) . should . be . true ( ) ;
1528+ unusedNocks . pendingMocks ( ) . length . should . eql ( 2 ) ;
1529+ nock . cleanAll ( ) ;
1530+ } ) ;
15161531 } ) ;
15171532
15181533 describe ( 'manage unspents' , function ( ) {
Original file line number Diff line number Diff line change @@ -815,9 +815,14 @@ export class Wallet implements IWallet {
815815 * @param {Number } params.maxFeeRate - The max limit for a fee rate in satoshis/kB
816816 * @param {Number } params.maxNumInputsToUse - the number of unspents you want to use in the transaction
817817 * @param {Number } params.numUnspentsToMake - the number of new unspents to make
818+ *
819+ * @param {ManageUnspentsOptions } option - flag to toggle build and send or build only
818820 */
819- async fanoutUnspents ( params : FanoutUnspentsOptions = { } ) : Promise < unknown > {
820- return this . manageUnspents ( 'fanout' , params ) ;
821+ async fanoutUnspents (
822+ params : FanoutUnspentsOptions = { } ,
823+ option = ManageUnspentsOptions . BUILD_SIGN_SEND
824+ ) : Promise < unknown > {
825+ return this . manageUnspents ( 'fanout' , params , option ) ;
821826 }
822827
823828 /**
You can’t perform that action at this time.
0 commit comments