Skip to content

HopType.toJson() sets issuer instead of account#799

Open
cybele-ripple wants to merge 6 commits into
mainfrom
hoptype-account-issuer-bug
Open

HopType.toJson() sets issuer instead of account#799
cybele-ripple wants to merge 6 commits into
mainfrom
hoptype-account-issuer-bug

Conversation

@cybele-ripple

Copy link
Copy Markdown
Collaborator

In HopType.toJson() in HopType.java, there is a check for TYPE_ISSUER. If present, the account field was filled with the issuer data, instead of the issuer field. This PR fixes this issue.

Unit tests were added for HopType.java (in HopTypeTest.java) to test this change.

…#756)

In toJson(), when the TYPE_ISSUER flag was set the code called
builder.account() instead of builder.issuer(). This overwrote the
account field with the issuer address and left the issuer field unset,
silently corrupting round-tripped payment path data. The fix changes the
one incorrect call to builder.issuer(). A new HopTypeTest covers both
the issuer-preserved and the account-not-overwritten cases.
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.63%. Comparing base (4871032) to head (7b9d414).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #799      +/-   ##
============================================
+ Coverage     93.51%   93.63%   +0.12%     
- Complexity     2606     2608       +2     
============================================
  Files           486      486              
  Lines          6580     6580              
  Branches        566      566              
============================================
+ Hits           6153     6161       +8     
+ Misses          270      259      -11     
- Partials        157      160       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cybele-ripple

Copy link
Copy Markdown
Collaborator Author

/ai-review

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues.

Review by Claude Sonnet 4.6 · Prompt: V15

sappenin
sappenin previously approved these changes Jun 12, 2026
sappenin and others added 3 commits June 12, 2026 13:49
* XrpCurrencyAmount.equals() and hashCode() now include isNegative (Issue #757)

equals() was only comparing the unsigned magnitude via value(), so
+1_000_000 drops and -1_000_000 drops were considered equal. hashCode()
had the same defect, breaking HashMap/HashSet keying and deduplication.
Fixed equals() to also compare the isNegative() flag, and fixed
hashCode() to hash both value() and isNegative() via Objects.hash().
Also corrected a pre-existing test assertion in plusXrp that only passed
due to the buggy equals() behavior (negative + negative was compared
against a positive expected value).

* Restore Immutables null-safety comment in XrpCurrencyAmount.equals()

The comment noting that the cast result can't be null due to Immutables
was lost when the intermediate variable was renamed in the equals() fix.
Restore it on the new variable for clarity.

* Fix Math.abs(Long.MIN_VALUE) overflow in XrpCurrencyAmount.ofDrops(long) (#798)

* Fix Math.abs(Long.MIN_VALUE) overflow in XrpCurrencyAmount.ofDrops(long)

Guard against Long.MIN_VALUE before calling Math.abs(), which overflows
back to Long.MIN_VALUE in two's complement arithmetic and produces a
corrupted UnsignedLong value. Now throws IllegalArgumentException
immediately with a clear message. Adds a regression test.

Fixes #755

* Move Long.MIN_VALUE guard inside negative-drops branch

Only relevant when drops < 0 (Math.abs overflow), so no need to check
on the happy-path.

---------

Co-authored-by: David Fuelling <sappenin@gmail.com>

---------

Co-authored-by: David Fuelling <sappenin@gmail.com>
Add LockedAmount to BASE_10_UINT64_FIELD_NAMES in UInt64Type (Issue #792)

LockedAmount is a UInt64 field used in MPT escrow ledger objects. Because
it was missing from BASE_10_UINT64_FIELD_NAMES, the binary codec treated
it as base-16 on both encode and decode. This meant a JSON value of "1000"
was silently encoded as 0x0000000000001000 (decimal 4096) instead of the
correct 0x00000000000003E8 (decimal 1000), corrupting MPT escrow amounts.

The fix adds "LockedAmount" to the set alongside MaximumAmount,
OutstandingAmount, and MPTAmount, which are the other MPT-related UInt64
fields that share this base-10 convention.

Co-authored-by: David Fuelling <sappenin@gmail.com>
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.

2 participants