-
Notifications
You must be signed in to change notification settings - Fork 21
Implement proper pagination for list-payments cli #84
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
Merged
benthecarman
merged 1 commit into
lightningdevkit:main
from
benthecarman:pagination-payments
Jan 7, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // This file is Copyright its original authors, visible in version control | ||
| // history. | ||
| // | ||
| // This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE | ||
| // or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
| // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. | ||
| // You may not use this file except in accordance with one or both of these | ||
| // licenses. | ||
|
|
||
| //! CLI-specific type wrappers for API responses. | ||
| //! | ||
| //! This file contains wrapper types that customize the serialization format | ||
| //! of API responses for CLI output. These wrappers ensure that the CLI's output | ||
| //! format matches what users expect and what the CLI can parse back as input. | ||
| use ldk_server_client::ldk_server_protos::api::ListPaymentsResponse; | ||
| use ldk_server_client::ldk_server_protos::types::{PageToken, Payment}; | ||
| use serde::Serialize; | ||
|
|
||
| /// CLI-specific wrapper for ListPaymentsResponse that formats the page token | ||
| /// as "token:idx" instead of a JSON object. | ||
| #[derive(Debug, Clone, Serialize)] | ||
| pub struct CliListPaymentsResponse { | ||
| /// List of payments. | ||
| pub payments: Vec<Payment>, | ||
| /// Next page token formatted as "token:idx", or None if no more pages. | ||
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| pub next_page_token: Option<String>, | ||
| } | ||
|
|
||
| impl From<ListPaymentsResponse> for CliListPaymentsResponse { | ||
| fn from(response: ListPaymentsResponse) -> Self { | ||
| let next_page_token = response.next_page_token.map(format_page_token); | ||
|
|
||
| CliListPaymentsResponse { payments: response.payments, next_page_token } | ||
| } | ||
| } | ||
|
|
||
| fn format_page_token(token: PageToken) -> String { | ||
| format!("{}:{}", token.token, token.index) | ||
| } | ||
tankyleo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.