Skip to content

Commit ee3b5d9

Browse files
committed
fix(sdk-coin-ada): fix consolidation recovery
Ticket: WIN-7796
1 parent eac1076 commit ee3b5d9

4 files changed

Lines changed: 96 additions & 123 deletions

File tree

modules/sdk-coin-ada/CHANGELOG.md

Lines changed: 12 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -5,221 +5,119 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
55

66
# [4.21.0](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.8...@bitgo/sdk-coin-ada@4.21.0) (2026-01-22)
77

8-
98
### Features
109

11-
* **sdk-coin-ada:** support for sponsored txns ([cb75eda](https://github.com/BitGo/BitGoJS/commit/cb75edad4850135a92e0c5ea41156491977edf73))
12-
* **sdk-coin-ada:** token sponsorship support ([12e0c78](https://github.com/BitGo/BitGoJS/commit/12e0c78cef2d763d0e6de4bea94973d7b0e1788a))
13-
14-
15-
16-
10+
- **sdk-coin-ada:** support for sponsored txns ([cb75eda](https://github.com/BitGo/BitGoJS/commit/cb75edad4850135a92e0c5ea41156491977edf73))
11+
- **sdk-coin-ada:** token sponsorship support ([12e0c78](https://github.com/BitGo/BitGoJS/commit/12e0c78cef2d763d0e6de4bea94973d7b0e1788a))
1712

1813
## [4.20.8](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.7...@bitgo/sdk-coin-ada@4.20.8) (2026-01-19)
1914

20-
2115
### Bug Fixes
2216

23-
* **sdk-coin-ada:** use derivedFromParentWithSeed in address verification ([852137d](https://github.com/BitGo/BitGoJS/commit/852137d53e5813aaaccc0590379f81aafd708892))
24-
25-
26-
27-
17+
- **sdk-coin-ada:** use derivedFromParentWithSeed in address verification ([852137d](https://github.com/BitGo/BitGoJS/commit/852137d53e5813aaaccc0590379f81aafd708892))
2818

2919
## [4.20.7](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.6...@bitgo/sdk-coin-ada@4.20.7) (2026-01-19)
3020

3121
**Note:** Version bump only for package @bitgo/sdk-coin-ada
3222

33-
34-
35-
36-
3723
## [4.20.6](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.5...@bitgo/sdk-coin-ada@4.20.6) (2026-01-14)
3824

3925
**Note:** Version bump only for package @bitgo/sdk-coin-ada
4026

41-
42-
43-
44-
4527
## [4.20.5](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.4...@bitgo/sdk-coin-ada@4.20.5) (2026-01-07)
4628

4729
**Note:** Version bump only for package @bitgo/sdk-coin-ada
4830

49-
50-
51-
52-
5331
## [4.20.4](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.3...@bitgo/sdk-coin-ada@4.20.4) (2025-12-23)
5432

5533
**Note:** Version bump only for package @bitgo/sdk-coin-ada
5634

57-
58-
59-
60-
6135
## [4.20.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.2...@bitgo/sdk-coin-ada@4.20.3) (2025-12-17)
6236

6337
**Note:** Version bump only for package @bitgo/sdk-coin-ada
6438

65-
66-
67-
68-
6939
## [4.20.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.1...@bitgo/sdk-coin-ada@4.20.2) (2025-12-11)
7040

7141
**Note:** Version bump only for package @bitgo/sdk-coin-ada
7242

73-
74-
75-
76-
7743
## [4.20.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.20.0...@bitgo/sdk-coin-ada@4.20.1) (2025-12-05)
7844

7945
**Note:** Version bump only for package @bitgo/sdk-coin-ada
8046

81-
82-
83-
84-
8547
# [4.20.0](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.19.0...@bitgo/sdk-coin-ada@4.20.0) (2025-12-04)
8648

87-
8849
### Features
8950

90-
* address verification for ada ([b4ed3c5](https://github.com/BitGo/BitGoJS/commit/b4ed3c56739ad94471b3ccd417217ac91ecb573d))
91-
92-
93-
94-
51+
- address verification for ada ([b4ed3c5](https://github.com/BitGo/BitGoJS/commit/b4ed3c56739ad94471b3ccd417217ac91ecb573d))
9552

9653
# [4.19.0](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.18.3...@bitgo/sdk-coin-ada@4.19.0) (2025-11-26)
9754

98-
9955
### Features
10056

101-
* **sdk-coin-ada:** add build logs and modify token policy id ([8d8482a](https://github.com/BitGo/BitGoJS/commit/8d8482afa50d707bfa69caa6ccbab750a32c76ef))
102-
103-
104-
105-
57+
- **sdk-coin-ada:** add build logs and modify token policy id ([8d8482a](https://github.com/BitGo/BitGoJS/commit/8d8482afa50d707bfa69caa6ccbab750a32c76ef))
10658

10759
## [4.18.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.18.2...@bitgo/sdk-coin-ada@4.18.3) (2025-11-19)
10860

10961
**Note:** Version bump only for package @bitgo/sdk-coin-ada
11062

111-
112-
113-
114-
11563
## [4.18.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.18.1...@bitgo/sdk-coin-ada@4.18.2) (2025-11-13)
11664

11765
**Note:** Version bump only for package @bitgo/sdk-coin-ada
11866

119-
120-
121-
122-
12367
## [4.18.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.18.0...@bitgo/sdk-coin-ada@4.18.1) (2025-11-12)
12468

125-
12669
### Bug Fixes
12770

128-
* **sdk-coin-ada:** shouldn't throw insufficient qty for total token spend ([6820999](https://github.com/BitGo/BitGoJS/commit/6820999b2d8ce47110d894875db15a0569f31cba))
129-
130-
131-
132-
71+
- **sdk-coin-ada:** shouldn't throw insufficient qty for total token spend ([6820999](https://github.com/BitGo/BitGoJS/commit/6820999b2d8ce47110d894875db15a0569f31cba))
13372

13473
# [4.18.0](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.17.4...@bitgo/sdk-coin-ada@4.18.0) (2025-11-06)
13574

136-
13775
### Features
13876

139-
* deserialize signed CIP-8 message hex ([66b973a](https://github.com/BitGo/BitGoJS/commit/66b973a4708e1b96c53c3785c65654a63b0d43bb))
140-
141-
142-
143-
77+
- deserialize signed CIP-8 message hex ([66b973a](https://github.com/BitGo/BitGoJS/commit/66b973a4708e1b96c53c3785c65654a63b0d43bb))
14478

14579
## [4.17.4](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.17.3...@bitgo/sdk-coin-ada@4.17.4) (2025-10-31)
14680

14781
**Note:** Version bump only for package @bitgo/sdk-coin-ada
14882

149-
150-
151-
152-
15383
## [4.17.3](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.17.2...@bitgo/sdk-coin-ada@4.17.3) (2025-10-29)
15484

15585
**Note:** Version bump only for package @bitgo/sdk-coin-ada
15686

157-
158-
159-
160-
16187
## [4.17.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.17.1...@bitgo/sdk-coin-ada@4.17.2) (2025-10-24)
16288

16389
**Note:** Version bump only for package @bitgo/sdk-coin-ada
16490

165-
166-
167-
168-
16991
## [4.17.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.17.0...@bitgo/sdk-coin-ada@4.17.1) (2025-10-21)
17092

17193
**Note:** Version bump only for package @bitgo/sdk-coin-ada
17294

173-
174-
175-
176-
17795
# [4.17.0](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.16.2...@bitgo/sdk-coin-ada@4.17.0) (2025-10-16)
17896

179-
18097
### Features
18198

182-
* **sdk-coin-ada:** fix ada build signature handling ([34dacbc](https://github.com/BitGo/BitGoJS/commit/34dacbcc1a2e4619503f5a93410b611f55bbc847))
183-
* **sdk-coin-ada:** remove fallback logic for token fee calculation ([daef78e](https://github.com/BitGo/BitGoJS/commit/daef78ea58e9c93c4f1b4e0d78a0249ca6c5f524))
184-
185-
186-
187-
99+
- **sdk-coin-ada:** fix ada build signature handling ([34dacbc](https://github.com/BitGo/BitGoJS/commit/34dacbcc1a2e4619503f5a93410b611f55bbc847))
100+
- **sdk-coin-ada:** remove fallback logic for token fee calculation ([daef78e](https://github.com/BitGo/BitGoJS/commit/daef78ea58e9c93c4f1b4e0d78a0249ca6c5f524))
188101

189102
## [4.16.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.16.1...@bitgo/sdk-coin-ada@4.16.2) (2025-10-13)
190103

191104
**Note:** Version bump only for package @bitgo/sdk-coin-ada
192105

193-
194-
195-
196-
197106
## [4.16.1](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.16.0...@bitgo/sdk-coin-ada@4.16.1) (2025-10-09)
198107

199-
200108
### Bug Fixes
201109

202-
* run check-fmt on code files only ([9745196](https://github.com/BitGo/BitGoJS/commit/9745196b02b9678c740d290a4638ceb153a8fd75))
203-
204-
205-
206-
110+
- run check-fmt on code files only ([9745196](https://github.com/BitGo/BitGoJS/commit/9745196b02b9678c740d290a4638ceb153a8fd75))
207111

208112
# [4.16.0](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.15.2...@bitgo/sdk-coin-ada@4.16.0) (2025-10-08)
209113

210-
211114
### Bug Fixes
212115

213-
* add explicit 'files' in package json ([3b00373](https://github.com/BitGo/BitGoJS/commit/3b0037396f6ac16bb9380bd85bf37f2b133068f4))
214-
116+
- add explicit 'files' in package json ([3b00373](https://github.com/BitGo/BitGoJS/commit/3b0037396f6ac16bb9380bd85bf37f2b133068f4))
215117

216118
### Features
217119

218-
* **sdk-coin-ada:** use 1 ada as min fees ([558f621](https://github.com/BitGo/BitGoJS/commit/558f6213131e75aac3d0cefb12ac7633fe7c9419))
219-
220-
221-
222-
120+
- **sdk-coin-ada:** use 1 ada as min fees ([558f621](https://github.com/BitGo/BitGoJS/commit/558f6213131e75aac3d0cefb12ac7633fe7c9419))
223121

224122
## [4.15.2](https://github.com/BitGo/BitGoJS/compare/@bitgo/sdk-coin-ada@4.15.1...@bitgo/sdk-coin-ada@4.15.2) (2025-10-02)
225123

modules/sdk-coin-ada/src/ada.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,10 @@ export class Ada extends BaseCoin {
382382
seed: params.seed,
383383
};
384384
const { address: senderAddr, accountId } = await this.getAdaAddressAndAccountId(addressParams);
385-
const isUnsignedSweep = !params.userKey && !params.backupKey && !params.walletPassphrase;
385+
const isUnsignedSweep = !params.walletPassphrase;
386386
const { balance, utxoSet } = await this.getAddressInfo(senderAddr);
387387
if (balance <= 0) {
388-
throw new Error('Did not find address with funds to recover');
388+
throw new Error('Did not find address with funds to recover.');
389389
}
390390

391391
// first build the unsigned txn
@@ -407,7 +407,8 @@ export class Ada extends BaseCoin {
407407
(acc: BigNumber, output: { amount: string }) => new BigNumber(acc).plus(output.amount),
408408
new BigNumber(0)
409409
);
410-
if (amount.isLessThan(10000000)) {
410+
411+
if (amount.isLessThan(1000000)) {
411412
throw new Error(
412413
'Insufficient funds to recover, minimum required is 1 ADA plus fees, got ' +
413414
amount.toString() +
@@ -556,7 +557,10 @@ export class Ada extends BaseCoin {
556557
try {
557558
recoveryTransaction = await this.recover(recoverParams);
558559
} catch (e) {
559-
if (e.message === 'Did not find address with funds to recover') {
560+
if (
561+
e.message === 'Did not find address with funds to recover.' ||
562+
e.message.startsWith('Insufficient funds to recover')
563+
) {
560564
lastScanIndex = i;
561565
continue;
562566
}
@@ -572,7 +576,7 @@ export class Ada extends BaseCoin {
572576
}
573577

574578
if (consolidationTransactions.length == 0) {
575-
throw new Error('Did not find an address with funds to recover');
579+
throw new Error('Did not find an address with funds to recover.');
576580
}
577581

578582
if (isUnsignedSweep) {

modules/sdk-coin-ada/test/resources/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export const testnetUTXO = {
373373
UTXO_3: {
374374
tx_hash: '87f6e905a5796277ffb256265fd18d16f84ddb54ec8a841f7d467360c1c9fc2f',
375375
tx_index: 0,
376-
value: 10000000,
376+
value: 1000000,
377377
},
378378
};
379379

modules/sdk-coin-ada/test/unit/ada.ts

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ describe('ADA', function () {
734734
startingScanIndex: 1,
735735
endingScanIndex: 2,
736736
})
737-
.should.rejectedWith('Did not find an address with funds to recover');
737+
.should.rejectedWith('Did not find an address with funds to recover.');
738738
});
739739

740740
it('should throw if startingScanIndex is not ge to 1', async () => {
@@ -763,6 +763,77 @@ describe('ADA', function () {
763763
'Invalid starting or ending index to scan for addresses. startingScanIndex: 1, endingScanIndex: 300.'
764764
);
765765
});
766+
767+
it('should build unsigned consolidation recoveries', async function () {
768+
const res = await basecoin.recoverConsolidations({
769+
userKey: consolidationWrwUser.userKey,
770+
backupKey: consolidationWrwUser.backupKey,
771+
bitgoKey: consolidationWrwUser.bitgoKey,
772+
walletPassphrase: consolidationWrwUser.walletPassphrase,
773+
startingScanIndex: 1,
774+
endingScanIndex: 4,
775+
});
776+
res.should.not.be.empty();
777+
res.transactions.length.should.equal(2);
778+
});
779+
780+
it('should throw error if all addresses have balance less than 1 ADA', async function () {
781+
sandBox.restore();
782+
const callBack = sandBox.stub(Ada.prototype, 'getDataFromNode' as keyof Ada);
783+
callBack.withArgs('address_info', sinon.match.has('_addresses')).resolves({
784+
status: 200,
785+
body: [
786+
{
787+
balance: 500000,
788+
utxo_set: [
789+
{
790+
tx_hash: '8df8d41207980f9e21de698bd5d6c395c39e420f7de27f8539052dd34e3a28d6',
791+
tx_index: 0,
792+
value: 500000,
793+
},
794+
],
795+
},
796+
],
797+
});
798+
callBack.withArgs('tip').resolves(endpointResponses.tipInfoResponse);
799+
800+
await basecoin
801+
.recoverConsolidations({
802+
userKey: consolidationWrwUser.userKey,
803+
backupKey: consolidationWrwUser.backupKey,
804+
bitgoKey: consolidationWrwUser.bitgoKey,
805+
walletPassphrase: consolidationWrwUser.walletPassphrase,
806+
startingScanIndex: 1,
807+
endingScanIndex: 4,
808+
})
809+
.should.be.rejectedWith('Did not find an address with funds to recover.');
810+
});
811+
812+
it('should build even if single address has no funds', async function () {
813+
const res = await basecoin.recoverConsolidations({
814+
userKey: consolidationWrwUser.userKey,
815+
backupKey: consolidationWrwUser.backupKey,
816+
bitgoKey: consolidationWrwUser.bitgoKey,
817+
walletPassphrase: consolidationWrwUser.walletPassphrase,
818+
startingScanIndex: 1,
819+
endingScanIndex: 4,
820+
});
821+
res.should.not.be.empty();
822+
res.transactions.length.should.equal(2);
823+
});
824+
825+
it('should build even if single address has insufficient funds', async function () {
826+
const res = await basecoin.recoverConsolidations({
827+
userKey: consolidationWrwUser.userKey,
828+
backupKey: consolidationWrwUser.backupKey,
829+
bitgoKey: consolidationWrwUser.bitgoKey,
830+
walletPassphrase: consolidationWrwUser.walletPassphrase,
831+
startingScanIndex: 1,
832+
endingScanIndex: 4,
833+
});
834+
res.should.not.be.empty();
835+
res.transactions.length.should.equal(2);
836+
});
766837
});
767838

768839
describe('Recover Transactions Failure:', () => {
@@ -787,7 +858,7 @@ describe('ADA', function () {
787858
walletPassphrase: wrwUser.walletPassphrase,
788859
recoveryDestination: destAddr,
789860
})
790-
.should.rejectedWith('Did not find address with funds to recover');
861+
.should.rejectedWith('Did not find address with funds to recover.');
791862
sandBox.assert.calledOnce(basecoin.getDataFromNode);
792863
});
793864

@@ -806,7 +877,7 @@ describe('ADA', function () {
806877
recoveryDestination: destAddr,
807878
})
808879
.should.rejectedWith(
809-
'Insufficient funds to recover, minimum required is 1 ADA plus fees, got 9834455 fees: 165545'
880+
'Insufficient funds to recover, minimum required is 1 ADA plus fees, got 834455 fees: 165545'
810881
);
811882
sandBox.assert.calledTwice(basecoin.getDataFromNode);
812883
});

0 commit comments

Comments
 (0)