Skip to content

fix(sdk-coin-hbar): merge same-account entries in self-transfer to fix ACCOUNT_REPEATED#8774

Draft
Doddanna17 wants to merge 1 commit into
masterfrom
SI-539-hbar-self-transfer-merge-entries
Draft

fix(sdk-coin-hbar): merge same-account entries in self-transfer to fix ACCOUNT_REPEATED#8774
Doddanna17 wants to merge 1 commit into
masterfrom
SI-539-hbar-self-transfer-merge-entries

Conversation

@Doddanna17
Copy link
Copy Markdown
Contributor

Summary

  • buildTransferData() now merges protobuf accountAmounts entries that share the same accountID. For self-transfer (claim rewards), this collapses [{acct, -1}, {acct, +1}] into [{acct, 0}] -- a single entry that Hedera accepts.
  • getTransferData() fallback in transaction.ts updated to match zero-amount entries (!isNegative() instead of isPositive()) so toJson() correctly reports the recipient for merged self-transfers.
  • Normal transfers (sender != recipient) are unaffected -- no entries share the same accountID, so the merge loop is a no-op.

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 with ACCOUNT_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

  • Self-transfer produces single merged {accountID, amount: 0} entry
  • Round-trip serialization preserves self-transfer semantics
  • Signing works on self-transfer transactions
  • Normal transfers still produce two distinct entries (regression test)
  • Full sdk-coin-hbar test suite passes (152 passing)

Ticket: SI-539

…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
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 14, 2026

SI-539

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant