Skip to content

Conversation

@alvasw
Copy link
Contributor

@alvasw alvasw commented Oct 4, 2025

PR #7483 added the --only-funded flag to the getfundingaddresses method.
This flag was added to bisq-cli and the filtering happened client-side.
This change moves the filtering to the server-side, so that all API
users can use the 'only-funded' option.

Summary by CodeRabbit

  • New Features
    • Added --only-funded option to getfundingaddresses, allowing display of only addresses with a positive balance.
  • API
    • gRPC now accepts an only_funded flag in the funding addresses request to filter results to funded addresses.
  • Documentation
    • Updated help text for getfundingaddresses to describe the new filtering option.
  • Tests
    • Updated tests to cover the new only-funded behavior.

helixx87 and others added 2 commits July 8, 2025 17:10
PR bisq-network#7483 added the --only-funded flag to the getfundingaddresses method.
This flag was added to bisq-cli and the filtering happened client-side.
This change moves the filtering to the server-side, so that all API
users can use the 'only-funded' option.
@alvasw
Copy link
Contributor Author

alvasw commented Oct 4, 2025

Tests:

  • Setup
    • Generate few new addresses
    • Fund some of the generated addresses
  • Test API call without specifying --only-funded flag
  • Test API call with --only-funded flag set to true
  • Test API call with --only-funded flag set to false

@coderabbitai
Copy link

coderabbitai bot commented Oct 4, 2025

Walkthrough

Adds an --only-funded flag to the getfundingaddresses command across CLI, gRPC, Core, and Daemon. Updates proto to carry the flag, introduces a dedicated option parser, adjusts method signatures to accept a boolean, and updates help and tests accordingly.

Changes

Cohort / File(s) Summary
CLI entrypoint & help
cli/src/main/java/bisq/cli/CliMain.java, core/src/main/resources/help/getfundingaddresses-help.txt
Wire --only-funded into CLI command flow; print help reflecting the new option.
CLI option parsing
cli/src/main/java/bisq/cli/opts/GetFundingAddressesOptionParser.java, cli/src/main/java/bisq/cli/opts/OptLabel.java
Add dedicated parser and label for only-funded option; default false; provides getter.
CLI gRPC client & request
cli/src/main/java/bisq/cli/GrpcClient.java, cli/src/main/java/bisq/cli/request/WalletsServiceRequest.java
Change getFundingAddresses signature to accept boolean; propagate to request and include setOnlyFunded.
Core API & service
core/src/main/java/bisq/core/api/CoreApi.java, core/src/main/java/bisq/core/api/CoreWalletsService.java
Update API to accept onlyFunded; conditionally filter addresses to those with positive balance; adjust stream usage.
Daemon gRPC service
daemon/src/main/java/bisq/daemon/grpc/GrpcWalletsService.java
Read only_funded from request; pass through to CoreApi.
Protocol
proto/src/main/proto/grpc.proto
Add optional bool only_funded to GetFundingAddressesRequest.
Tests
cli/src/test/java/bisq/cli/table/AddressCliOutputDiffTest.java
Update calls to new getFundingAddresses(false) signature.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant C as CliMain
  participant P as GetFundingAddressesOptionParser
  participant GC as GrpcClient
  participant D as Daemon GrpcWalletsService
  participant A as CoreApi
  participant W as CoreWalletsService

  U->>C: bisq-cli getfundingaddresses --only-funded[=true|false]
  C->>P: parse(args)
  P-->>C: onlyFunded flag
  C->>GC: getFundingAddresses(onlyFunded)
  GC->>D: GetFundingAddressesRequest{ only_funded=onlyFunded }
  D->>A: getFundingAddresses(onlyFunded)
  A->>W: getFundingAddresses(onlyFunded)
  alt onlyFunded == true
    W->>W: filter addresses with balance > 0
  else onlyFunded == false
    W->>W: include all funding addresses
  end
  W-->>A: List<AddressBalanceInfo>
  A-->>D: List<AddressBalanceInfo>
  D-->>GC: GetFundingAddressesResponse
  GC-->>C: List<AddressBalanceInfo>
  C-->>U: Print addresses
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit taps the CLI with glee,
“Only funded, please!”—so tidy to see.
Through proto and daemons the boolean hops,
Core counts coins, the empty it drops.
Carrot in paw, I ship with delight—
Filtered addresses, crisp and light. 🥕🚀

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The description provides a brief summary of the change but does not follow the repository’s template because it omits the required “Fixes #…” line referencing relevant issues. Please add the “Fixes #issueNumber” section at the top of the description and ensure the PR description adheres to the template’s structure.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title succinctly describes the main change, indicating that BTC positive balance filtering has been moved to the API level, which matches the modifications implemented across client and server.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
core/src/main/java/bisq/core/api/CoreWalletsService.java (1)

240-245: Performance concern: O(N²) complexity from repeated lookups.

Line 244 calls getAddressEntry(address) for each address in the stream. The getAddressEntry method (lines 640-650) performs a linear search through the address entry list. For N addresses, this results in O(N²) complexity.

Consider memoizing getAddressEntry similar to how getAddressBalance is memoized (line 225):

 // getAddressBalance is memoized, because we'll map it over addresses twice.
 // To get the balances, we'll be using .getUnchecked, because we know that
 // this::getAddressBalance cannot return null.
 var balances = memoize(this::getAddressBalance);
+var addressEntries = memoize(this::getAddressEntry);

 boolean noAddressHasZeroBalance = addressStrings.stream()
         .allMatch(addressString -> balances.getUnchecked(addressString) != 0);

 if (noAddressHasZeroBalance) {
     var newZeroBalanceAddress = btcWalletService.getFreshAddressEntry();
     addressStrings.add(newZeroBalanceAddress.getAddressString());
 }

 Stream<String> resultStream = addressStrings.stream();
 if (onlyFunded) {
     resultStream = resultStream.filter(address -> balances.getUnchecked(address) > 0);
 }

 return resultStream.map(address ->
                 new AddressBalanceInfo(address,
                         balances.getUnchecked(address),
                         getNumConfirmationsForMostRecentTransaction(address),
-                        btcWalletService.isAddressUnused(getAddressEntry(address).getAddress())))
+                        btcWalletService.isAddressUnused(addressEntries.getUnchecked(address).getAddress())))
         .collect(Collectors.toList());
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f5938b and 9ac8067.

📒 Files selected for processing (11)
  • cli/src/main/java/bisq/cli/CliMain.java (3 hunks)
  • cli/src/main/java/bisq/cli/GrpcClient.java (1 hunks)
  • cli/src/main/java/bisq/cli/opts/GetFundingAddressesOptionParser.java (1 hunks)
  • cli/src/main/java/bisq/cli/opts/OptLabel.java (1 hunks)
  • cli/src/main/java/bisq/cli/request/WalletsServiceRequest.java (1 hunks)
  • cli/src/test/java/bisq/cli/table/AddressCliOutputDiffTest.java (2 hunks)
  • core/src/main/java/bisq/core/api/CoreApi.java (1 hunks)
  • core/src/main/java/bisq/core/api/CoreWalletsService.java (3 hunks)
  • core/src/main/resources/help/getfundingaddresses-help.txt (1 hunks)
  • daemon/src/main/java/bisq/daemon/grpc/GrpcWalletsService.java (1 hunks)
  • proto/src/main/proto/grpc.proto (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
cli/src/main/java/bisq/cli/CliMain.java (1)
cli/src/main/java/bisq/cli/opts/GetFundingAddressesOptionParser.java (1)
  • GetFundingAddressesOptionParser (7-26)
cli/src/main/java/bisq/cli/opts/GetFundingAddressesOptionParser.java (1)
cli/src/main/java/bisq/cli/opts/OptLabel.java (1)
  • OptLabel (23-61)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Test Java 11, windows-latest
  • GitHub Check: Test Java 11, ubuntu-latest
  • GitHub Check: Test Java 11, macOS-latest
🔇 Additional comments (14)
proto/src/main/proto/grpc.proto (1)

930-930: LGTM! Proto field definition is correct.

The optional boolean field only_funded is properly defined with tag 1 and follows proto3 conventions. The default value of false ensures backward compatibility with existing clients.

core/src/main/resources/help/getfundingaddresses-help.txt (1)

10-21: LGTM! Clear and helpful documentation.

The documentation for the --only-funded option is concise and clearly explains its purpose. The addition of the OPTIONS section follows standard help text conventions.

cli/src/main/java/bisq/cli/opts/OptLabel.java (1)

41-41: LGTM! Constant follows established conventions.

The OPT_ONLY_FUNDED constant is correctly defined and maintains alphabetical ordering with other option labels.

cli/src/test/java/bisq/cli/table/AddressCliOutputDiffTest.java (2)

30-30: LGTM! Test updated to use new API signature.

The test correctly passes false to maintain the previous behavior of fetching all funding addresses without filtering.


45-45: LGTM! Consistent test update.

Both usages of getFundingAddresses are consistently updated to use the new boolean parameter.

core/src/main/java/bisq/core/api/CoreApi.java (1)

395-397: LGTM! API signature correctly updated.

The method signature properly accepts the onlyFunded boolean parameter and delegates to the wallet service. This centralizes the filtering logic on the server side as intended.

cli/src/main/java/bisq/cli/CliMain.java (3)

70-70: LGTM! Appropriate import added.

The import of GetFundingAddressesOptionParser is necessary for parsing the new option.


253-262: LGTM! Option parsing and integration are correct.

The implementation properly:

  • Parses the --only-funded option using the dedicated parser
  • Checks for help request before processing
  • Passes the boolean flag to the client
  • Maintains consistent error handling and output formatting

904-904: LGTM! Help text correctly documents the option.

The help output clearly shows the --only-funded=<true|false> option format and aligns with the new functionality.

daemon/src/main/java/bisq/daemon/grpc/GrpcWalletsService.java (1)

164-165: LGTM! gRPC service correctly bridges to Core API.

The implementation properly extracts the onlyFunded flag from the gRPC request and passes it to the Core API, completing the server-side filtering integration.

cli/src/main/java/bisq/cli/request/WalletsServiceRequest.java (1)

102-108: LGTM! Request construction is correct.

The method signature properly accepts the onlyFunded boolean parameter and correctly constructs the gRPC request using setOnlyFunded(onlyFunded). This completes the client-side integration of the server-side filtering feature.

cli/src/main/java/bisq/cli/GrpcClient.java (1)

118-120: LGTM!

The method signature correctly adds the boolean onlyFunded parameter and properly delegates to the underlying service request.

core/src/main/java/bisq/core/api/CoreWalletsService.java (2)

81-81: LGTM!

The import for java.util.stream.Stream is correctly added to support the new filtering logic.


235-239: LGTM!

The filtering logic correctly filters addresses to only those with positive balance when onlyFunded is true. The implementation is clear and correct.

Copy link
Contributor

@alejandrogarcia83 alejandrogarcia83 left a comment

Choose a reason for hiding this comment

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

utACK

@alvasw alvasw dismissed alejandrogarcia83’s stale review October 9, 2025 01:22

The merge-base changed after approval.

@alejandrogarcia83 alejandrogarcia83 merged commit 7a4e879 into bisq-network:master Oct 9, 2025
4 checks passed
@alejandrogarcia83 alejandrogarcia83 added this to the v1.9.22 milestone Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants