Skip to content

Commit dbe06cd

Browse files
committed
feat(sdk-core): skip amount validation for hbar claim rewards self-transfer
HBAR claim rewards uses a 1-tinybar self-transfer where the wire format merges [{acct,-1},{acct,+1}] into [{acct,0}]. This causes a legitimate amount mismatch (buildParams="1" vs explained="0") in validateBuiltStakingTransaction. Add isHbarClaimRewards() guard to skip the amount check when sender == recipient for HBAR claim rewards. Ticket: SI-605
1 parent b6be824 commit dbe06cd

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

modules/sdk-core/src/bitgo/staking/stakingWallet.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ export class StakingWallet implements IStakingWallet {
198198
return this.wallet.baseCoin.getFamily() === 'trx';
199199
}
200200

201+
private isHbarClaimRewards(transaction: StakingTransaction) {
202+
return this.wallet.baseCoin.getFamily() === 'hbar' && transaction.transactionType.toLowerCase() === 'claim_rewards';
203+
}
204+
201205
/**
202206
* Sign the staking transaction
203207
* @param signOptions
@@ -433,9 +437,18 @@ export class StakingWallet implements IStakingWallet {
433437
const matchResult = transactionRecipientsMatch(userRecipient, platformRecipient);
434438

435439
if (!matchResult.amountMatch) {
436-
mismatchErrors.push(
437-
`Recipient ${address} amount mismatch. Expected: ${userRecipient.amount}, Got: ${platformRecipient.amount}`
438-
);
440+
// HBAR claim rewards uses a self-transfer (sender == recipient) of 1 tinybar.
441+
// The wire format merges [{acct, -1}, {acct, +1}] into [{acct, 0}], so the
442+
// explained amount is "0" while buildParams amount is "1". This mismatch is
443+
// expected and safe -- skip the amount error for this specific case.
444+
const isHbarSelfTransferClaim =
445+
this.isHbarClaimRewards(transaction) &&
446+
userRecipient.address.toLowerCase() === platformRecipient.address.toLowerCase();
447+
if (!isHbarSelfTransferClaim) {
448+
mismatchErrors.push(
449+
`Recipient ${address} amount mismatch. Expected: ${userRecipient.amount}, Got: ${platformRecipient.amount}`
450+
);
451+
}
439452
}
440453
if (!matchResult.tokenMatch) {
441454
mismatchErrors.push(

0 commit comments

Comments
 (0)