Skip to content

Conversation

@overcat
Copy link
Member

@overcat overcat commented Jul 5, 2025

  • feat: add isValidEd25519SecretSeed, isValidPreAuthTx and isValidSha256Hash to StrKey class, these functions can be used to validate the corresponding strkey.
  • feat: add med25519 public key support to StrKey.
  • refactor!: the following functions in StrKey are marked as deprecated, they will be removed in the next major release; please refer to the documentation for each function to see the corresponding replacement functions:
    • StrKey#encodeEd25519PublicKey(AccountID)
    • StrKey#encodeMuxedAccount(MuxedAccount)
    • StrKey#decodeMuxedAccount(String)
    • StrKey#encodeToXDRAccountId(String)
    • StrKey#encodeToXDRMuxedAccount(String)

- feat: add `isValidEd25519SecretSeed`, `isValidPreAuthTx` and `isValidSha256Hash` to `StrKey` class, these functions can be used to validate the corresponding strkey.
- feat: add med25519 public key support to `StrKey`.
- refactor!: the following functions in `StrKey` are marked as deprecated, they will be removed in the next major release; please refer to the documentation for each function to see the corresponding replacement functions:
  - `StrKey#encodeEd25519PublicKey(AccountID)`
  - `StrKey#encodeMuxedAccount(MuxedAccount)`
  - `StrKey#decodeMuxedAccount(String)`
  - `StrKey#encodeToXDRAccountId(String)`
  - `StrKey#encodeToXDRMuxedAccount(String)`
@codecov
Copy link

codecov bot commented Jul 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (add-protocol23-support@6e57ab1). Learn more about missing BASE report.

Additional details and impacted files
@@                    Coverage Diff                    @@
##             add-protocol23-support     #702   +/-   ##
=========================================================
  Coverage                          ?   80.46%           
  Complexity                        ?     1247           
=========================================================
  Files                             ?      213           
  Lines                             ?     4961           
  Branches                          ?      416           
=========================================================
  Hits                              ?     3992           
  Misses                            ?      713           
  Partials                          ?      256           
Files with missing lines Coverage Δ
src/main/java/org/stellar/sdk/Address.java 76.59% <100.00%> (ø)
src/main/java/org/stellar/sdk/Asset.java 80.76% <100.00%> (ø)
...ava/org/stellar/sdk/AssetTypeCreditAlphaNum12.java 88.46% <100.00%> (ø)
...java/org/stellar/sdk/AssetTypeCreditAlphaNum4.java 89.28% <100.00%> (ø)
.../main/java/org/stellar/sdk/FeeBumpTransaction.java 88.60% <100.00%> (ø)
src/main/java/org/stellar/sdk/MuxedAccount.java 86.66% <100.00%> (ø)
src/main/java/org/stellar/sdk/Server.java 89.90% <100.00%> (ø)
src/main/java/org/stellar/sdk/StrKey.java 88.71% <100.00%> (ø)
src/main/java/org/stellar/sdk/Transaction.java 93.87% <100.00%> (ø)
.../stellar/sdk/operations/AccountMergeOperation.java 100.00% <100.00%> (ø)
... and 16 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@overcat overcat requested a review from Copilot July 5, 2025 07:44

This comment was marked as outdated.

overcat added 2 commits July 5, 2025 15:55
- feat: add `isValidEd25519SecretSeed`, `isValidPreAuthTx` and `isValidSha256Hash` to `StrKey` class, these functions can be used to validate the corresponding strkey.
- feat: add med25519 public key support to `StrKey`.
- refactor!: the following functions in `StrKey` are marked as deprecated, they will be removed in the next major release; please refer to the documentation for each function to see the corresponding replacement functions:
  - `StrKey#encodeEd25519PublicKey(AccountID)`
  - `StrKey#encodeMuxedAccount(MuxedAccount)`
  - `StrKey#decodeMuxedAccount(String)`
  - `StrKey#encodeToXDRAccountId(String)`
  - `StrKey#encodeToXDRMuxedAccount(String)`
@overcat overcat requested a review from Copilot July 5, 2025 09:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the StrKey utility with new validation methods, adds full support for med25519 (“M…”) public keys, and refactors legacy XDR encoding/decoding calls to use MuxedAccount and KeyPair APIs.

  • Added isValid* methods (seed, preauth tx, SHA-256 hash, contract, liquidity pool, claimable balance, Ed25519, med25519) plus encodeMed25519PublicKey/decodeMed25519PublicKey in StrKey.
  • Deprecated old StrKey encode/decode methods (encodeEd25519PublicKey(AccountID), encodeMuxedAccount, decodeMuxedAccount, encodeToXDRAccountId, encodeToXDRMuxedAccount) ahead of the next major release.
  • Updated XDR conversion across operations and transaction classes to replace StrKey-based calls with MuxedAccount and KeyPair.fromAccountId.

Reviewed Changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 2 comments.

Show a summary per file
File or Package Description
src/main/java/org/stellar/sdk/StrKey.java Introduced validation methods and med25519 support; deprecated legacy StrKey encode/decode.
src/test/java/org/stellar/sdk/StrKeyTest.java Added tests for many new isValid* methods and med25519 public key support.
src/main/java/org/stellar/sdk/operations/* Replaced all StrKey.encode*/decode* XDR calls with MuxedAccount and KeyPair.
src/main/java/org/stellar/sdk/MuxedAccount.java Overhauled constructor and getAddress to handle med25519; removed legacy StrKey use.
src/main/java/org/stellar/sdk/Server.java Updated memo-required logic to use StrKey.isValidMed25519PublicKey instead of hashMemoId.
CHANGELOG.md Documented new features and breaking changes.
Comments suppressed due to low confidence (2)

src/main/java/org/stellar/sdk/StrKey.java:58

  • Add unit tests for isValidEd25519PublicKey to ensure correct validation behavior for valid and invalid G... account IDs.
  public static boolean isValidEd25519PublicKey(String accountID) {

src/main/java/org/stellar/sdk/StrKey.java:281

  • Add unit tests for isValidLiquidityPool and isValidClaimableBalance to cover valid and invalid L... and B... identifiers.
  public static boolean isValidLiquidityPool(String liquidityPoolId) {

SetTrustLineFlagsOp op = new SetTrustLineFlagsOp();

op.setTrustor(StrKey.encodeToXDRAccountId(this.trustor));
op.setTrustor(KeyPair.fromAccountId(this.trustor).getXdrAccountId());
Copy link

Copilot AI Jul 5, 2025

Choose a reason for hiding this comment

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

[nitpick] The conversion from a string account ID to XDR AccountID is repeated across operations; consider extracting this into a shared utility method (e.g., toXdrAccountId) to reduce duplication.

Copilot uses AI. Check for mistakes.
this.accountId = StrKey.encodeEd25519PublicKey(ed25519PublicKey);
this.muxedId = new BigInteger(1, muxedIdBytes);
} else {
throw new IllegalArgumentException("Invalid address");
Copy link

Copilot AI Jul 5, 2025

Choose a reason for hiding this comment

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

Include the invalid address in the exception message to make debugging easier, for example: Invalid address: " + address.

Suggested change
throw new IllegalArgumentException("Invalid address");
throw new IllegalArgumentException("Invalid address: " + address);

Copilot uses AI. Check for mistakes.
@overcat overcat merged commit 17ffc77 into add-protocol23-support Jul 6, 2025
7 checks passed
@overcat overcat deleted the refactor-strkey branch July 6, 2025 01:28
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