fix(sdk-coin-hbar): merge same-account entries in self-transfer to fix ACCOUNT_REPEATED#8774
Draft
Doddanna17 wants to merge 1 commit into
Draft
fix(sdk-coin-hbar): merge same-account entries in self-transfer to fix ACCOUNT_REPEATED#8774Doddanna17 wants to merge 1 commit into
Doddanna17 wants to merge 1 commit into
Conversation
…o fix self-transfer
buildTransferData() produced two separate protobuf entries for the same
accountID on self-transfer (sender == recipient), causing Hedera to
reject with ACCOUNT_REPEATED_IN_ACCOUNT_AMOUNTS (status 74). Now merges
entries by accountID so self-transfer yields a single [{acct, 0}] entry.
Also updates transaction.ts getTransferData() fallback to handle
zero-amount entries from the merged format (!isNegative instead of
isPositive).
Ticket: SI-539
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
buildTransferData()now merges protobufaccountAmountsentries that share the sameaccountID. For self-transfer (claim rewards), this collapses[{acct, -1}, {acct, +1}]into[{acct, 0}]-- a single entry that Hedera accepts.getTransferData()fallback intransaction.tsupdated to match zero-amount entries (!isNegative()instead ofisPositive()) sotoJson()correctly reports the recipient for merged self-transfers.Context
PR #8742 fixed the deserialization path (so
toJson()doesn't crash on self-transfers), but the build/serialization path still produced two separate entries for the same accountID. Hedera rejects this withACCOUNT_REPEATED_IN_ACCOUNT_AMOUNTS(status 74).This PR fixes the build path. After this, the full HBAR claim rewards flow (staking-service -> WP -> BitGoJS -> indexer -> Hedera) will work end-to-end for self-transfer transactions.
Test plan
{accountID, amount: 0}entryTicket: SI-539