Skip to content

Commit ba1e828

Browse files
committed
fix(abstract-eth): add consolidate type and validation for TSS wallets
- Add 'consolidate' to allowed transaction types in verifyTssTransaction - Implement consolidationToBaseAddress validation to ensure consolidation transactions send funds to the wallet's base address - Fixes TSS wallet consolidation which was failing with "missing txParams" Ticket: COIN-6431
1 parent 3b715f8 commit ba1e828

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

modules/abstract-eth/src/abstractEthLikeNewCoins.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2820,7 +2820,8 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
28202820
!txParams?.recipients &&
28212821
!(
28222822
txParams.prebuildTx?.consolidateId ||
2823-
(txParams.type && ['acceleration', 'fillNonce', 'transferToken', 'tokenApproval'].includes(txParams.type))
2823+
(txParams.type &&
2824+
['acceleration', 'fillNonce', 'transferToken', 'tokenApproval', 'consolidate'].includes(txParams.type))
28242825
)
28252826
) {
28262827
throw new Error('missing txParams');
@@ -2893,6 +2894,31 @@ export abstract class AbstractEthLikeNewCoins extends AbstractEthLikeCoin {
28932894
}
28942895
}
28952896

2897+
// Verify consolidation transactions send to base address
2898+
if (params.verification?.consolidationToBaseAddress) {
2899+
const coinSpecific = wallet.coinSpecific();
2900+
if (!coinSpecific || !coinSpecific.baseAddress) {
2901+
throw new Error('Unable to determine base address for consolidation');
2902+
}
2903+
const baseAddress = coinSpecific.baseAddress;
2904+
2905+
const txBuilder = this.getTransactionBuilder();
2906+
txBuilder.from(txPrebuild.txHex);
2907+
const tx = await txBuilder.build();
2908+
const txJson = tx.toJson();
2909+
2910+
// Verify the transaction recipient matches the base address
2911+
if (!txJson.to) {
2912+
throw new Error('Consolidation transaction is missing recipient address');
2913+
}
2914+
2915+
if (txJson.to.toLowerCase() !== baseAddress.toLowerCase()) {
2916+
throwRecipientMismatch('Consolidation transaction recipient does not match wallet base address', [
2917+
{ address: txJson.to, amount: txJson.value },
2918+
]);
2919+
}
2920+
}
2921+
28962922
return true;
28972923
}
28982924

0 commit comments

Comments
 (0)