-
Notifications
You must be signed in to change notification settings - Fork 268
Get retiring federator public key optional #3429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: mtmu-integration
Are you sure you want to change the base?
Get retiring federator public key optional #3429
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this 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 refactors the getRetiringFederatorBtcPublicKey method to return an Optional<BtcECKey> instead of a nullable byte[]. This change improves type safety by making the absence of a retiring federator public key explicit through the Optional type, eliminating null checks and promoting better API design.
Key Changes:
- Modified method signature to return
Optional<BtcECKey>instead ofbyte[] - Updated implementations to return
Optional.empty()instead ofnullwhen no retiring federation exists - Refactored empty byte array returns to use
EMPTY_BYTE_ARRAYconstant throughout the Bridge class
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| FederationSupport.java | Updated interface method signature and documentation to return Optional |
| FederationSupportImpl.java | Modified implementation to return Optional and handle empty case with Optional.empty() |
| BridgeSupport.java | Updated method signature to match new return type |
| Bridge.java | Refactored to use Optional API and replaced inline empty byte arrays with EMPTY_BYTE_ARRAY constant |
| FederationSupportImplTest.java | Updated test assertions to check for empty Optional instead of null values |
| BridgeSupportTest.java | Modified mock setup and assertions to work with Optional return type |
| BridgeSupportIT.java | Updated integration tests to assert on Optional presence and extract values properly |
| BridgeIT.java | Refactored test to use parameterized testing and updated mock to return Optional |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| assertTrue(bridgeSupport.getRetiringFederatorBtcPublicKey(0).isPresent()); | ||
| assertEquals(bridgeSupport.getRetiringFederatorBtcPublicKey(0).get(), publicKey); |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method getRetiringFederatorBtcPublicKey(0) is called twice consecutively on lines 521 and 522. Store the result in a variable to avoid redundant method calls.
| assertTrue(bridgeSupport.getRetiringFederatorBtcPublicKey(0).isPresent()); | |
| assertEquals(bridgeSupport.getRetiringFederatorBtcPublicKey(0).get(), publicKey); | |
| Optional<BtcECKey> actualPublicKeyOptional = bridgeSupport.getRetiringFederatorBtcPublicKey(0); | |
| assertTrue(actualPublicKeyOptional.isPresent()); | |
| assertEquals(actualPublicKeyOptional.get(), publicKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Optional<BtcECKey> publicKey = bridgeSupport.getRetiringFederatorBtcPublicKey(index); | ||
| return publicKey.map(BtcECKey::getPubKey).orElse(EMPTY_BYTE_ARRAY); |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name publicKey is ambiguous since it stores an Optional<BtcECKey> (the full key object), not the raw public key bytes. Consider renaming to retiringFederatorKey or retiringFederatorBtcKey to better reflect what it contains.
| Optional<BtcECKey> publicKey = bridgeSupport.getRetiringFederatorBtcPublicKey(index); | |
| return publicKey.map(BtcECKey::getPubKey).orElse(EMPTY_BYTE_ARRAY); | |
| Optional<BtcECKey> retiringFederatorBtcKey = bridgeSupport.getRetiringFederatorBtcPublicKey(index); | |
| return retiringFederatorBtcKey.map(BtcECKey::getPubKey).orElse(EMPTY_BYTE_ARRAY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|



Description
Motivation and Context
How Has This Been Tested?
Types of changes
Checklist: