listinvoices: add index and start params.

Now we have defined ordering, we can add a start param.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Added: JSON-RPC: `listinvoices` has `index` and `start` parameters for listing control.
This commit is contained in:
Rusty Russell
2023-07-22 17:21:47 +09:30
parent bbf4f312a4
commit 16c133746b
15 changed files with 426 additions and 275 deletions

32
cln-rpc/src/model.rs generated
View File

@@ -583,6 +583,34 @@ pub mod requests {
type Response = super::responses::ListdatastoreResponse;
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub enum ListinvoicesIndex {
#[serde(rename = "created")]
CREATED,
#[serde(rename = "updated")]
UPDATED,
}
impl TryFrom<i32> for ListinvoicesIndex {
type Error = anyhow::Error;
fn try_from(c: i32) -> Result<ListinvoicesIndex, anyhow::Error> {
match c {
0 => Ok(ListinvoicesIndex::CREATED),
1 => Ok(ListinvoicesIndex::UPDATED),
o => Err(anyhow::anyhow!("Unknown variant {} for enum ListinvoicesIndex", o)),
}
}
}
impl ToString for ListinvoicesIndex {
fn to_string(&self) -> String {
match self {
ListinvoicesIndex::CREATED => "CREATED",
ListinvoicesIndex::UPDATED => "UPDATED",
}.to_string()
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ListinvoicesRequest {
#[serde(skip_serializing_if = "Option::is_none")]
@@ -593,6 +621,10 @@ pub mod requests {
pub payment_hash: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub offer_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub index: Option<ListinvoicesIndex>,
#[serde(skip_serializing_if = "Option::is_none")]
pub start: Option<u64>,
}
impl From<ListinvoicesRequest> for Request {