diff --git a/modules/bitgo/test/v2/unit/wallet.ts b/modules/bitgo/test/v2/unit/wallet.ts index 885f1cedb4..0f0317f6cf 100644 --- a/modules/bitgo/test/v2/unit/wallet.ts +++ b/modules/bitgo/test/v2/unit/wallet.ts @@ -1461,9 +1461,13 @@ describe('V2 Wallet:', function () { }); }); - describe('maxNumInputsToUse verification', function () { + describe('fanout input maxNumInputsToUse and unspents verification', function () { const address = '5b34252f1bf349930e34020a'; const maxNumInputsToUse = 2; + const unspents = [ + 'cc30565750e2aeb818625aaedaf89db5c614e5977b9645cee1d7289f616fb1d8:0', + '8c45164787a954ab07864af9b05b34fbde3a8e430a8c65b0e60e4e543d8e1b6c:2', + ]; let basecoin; let wallet; @@ -1492,6 +1496,23 @@ describe('V2 Wallet:', function () { response.isDone().should.be.true(); }); + + it('should pass unspents parameter when calling fanout unspents', async function () { + const path = `/api/v2/${wallet.coin()}/wallet/${wallet.id()}/fanoutUnspents`; + const response = nock(bgUrl) + .persist() + .post(path, _.matches({ unspents })) // use _.matches to do a partial match on request body object instead of strict matching + .reply(200); + + try { + await wallet.fanoutUnspents({ address, unspents }); + } catch (e) { + // the fanoutUnspents method will probably throw an exception for not having all of the correct nocks + // we only care about /fanoutUnspents and whether unspents is an allowed parameter + } + + response.isDone().should.be.true(); + }); }); describe('manage unspents', function () { diff --git a/modules/sdk-core/src/bitgo/wallet/iWallet.ts b/modules/sdk-core/src/bitgo/wallet/iWallet.ts index 608a8fa652..98d05f5d35 100644 --- a/modules/sdk-core/src/bitgo/wallet/iWallet.ts +++ b/modules/sdk-core/src/bitgo/wallet/iWallet.ts @@ -341,6 +341,7 @@ export interface FanoutUnspentsOptions extends WalletSignTransactionOptions { maxValue?: number | string; minHeight?: number; maxNumInputsToUse?: number; + unspents?: string[]; numUnspentsToMake?: number; minConfirms?: number; enforceMinConfirmsForChange?: boolean; diff --git a/modules/sdk-core/src/bitgo/wallet/wallet.ts b/modules/sdk-core/src/bitgo/wallet/wallet.ts index 9d7a88e28e..643543372b 100644 --- a/modules/sdk-core/src/bitgo/wallet/wallet.ts +++ b/modules/sdk-core/src/bitgo/wallet/wallet.ts @@ -680,6 +680,7 @@ export class Wallet implements IWallet { common.validateParams(params, [], ['walletPassphrase', 'xprv']); const reqId = new RequestTracer(); + const fanoutInputFormat = params.maxNumInputsToUse ? 'maxNumInputsToUse' : 'unspents'; const filteredParams = _.pick(params, [ 'feeRate', 'maxFeeRate', @@ -695,7 +696,7 @@ export class Wallet implements IWallet { 'txFormat', 'bulk', - routeName === 'consolidate' ? 'limit' : 'maxNumInputsToUse', + routeName === 'consolidate' ? 'limit' : fanoutInputFormat, 'numUnspentsToMake', ]); this.bitgo.setRequestTracer(reqId);