Skip to content

Commit 7d396b6

Browse files
Merge pull request #8305 from BitGo/BTC-3144
feat(sdk-core): forward custodial fanouts to /tx/initiate
2 parents a73dd0a + b051f0f commit 7d396b6

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

modules/bitgo/test/v2/unit/wallet.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff 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 () {

modules/sdk-core/src/bitgo/wallet/wallet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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']);

0 commit comments

Comments
 (0)