Skip to content

Commit

Permalink
msggen: Add FetchInvoice method to Rust and grpc bindings
Browse files Browse the repository at this point in the history
Closes #6844

Changelog-Added: Cln-RPC: Add `fetchinvoice` method to cln-rpc and cln-grpc.
  • Loading branch information
cdecker authored and nepet committed Nov 14, 2023
1 parent cce4f68 commit 836d71a
Show file tree
Hide file tree
Showing 8 changed files with 394 additions and 1 deletion.
117 changes: 117 additions & 0 deletions .msggen.json
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,35 @@
"Feerates.perkw": 3,
"Feerates.warning_missing_feerates": 1
},
"FetchinvoiceChanges": {
"FetchInvoice.changes.amount_msat": 5,
"FetchInvoice.changes.description": 2,
"FetchInvoice.changes.description_appended": 1,
"FetchInvoice.changes.vendor": 4,
"FetchInvoice.changes.vendor_removed": 3
},
"FetchinvoiceNext_period": {
"FetchInvoice.next_period.counter": 1,
"FetchInvoice.next_period.endtime": 3,
"FetchInvoice.next_period.paywindow_end": 5,
"FetchInvoice.next_period.paywindow_start": 4,
"FetchInvoice.next_period.starttime": 2
},
"FetchinvoiceRequest": {
"FetchInvoice.amount_msat": 2,
"FetchInvoice.offer": 1,
"FetchInvoice.payer_note": 8,
"FetchInvoice.quantity": 3,
"FetchInvoice.recurrence_counter": 4,
"FetchInvoice.recurrence_label": 6,
"FetchInvoice.recurrence_start": 5,
"FetchInvoice.timeout": 7
},
"FetchinvoiceResponse": {
"FetchInvoice.changes": 2,
"FetchInvoice.invoice": 1,
"FetchInvoice.next_period": 3
},
"FundchannelRequest": {
"FundChannel.amount": 1,
"FundChannel.announce": 3,
Expand Down Expand Up @@ -2853,6 +2882,94 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice": {
"added": "pre-v0.10.1",
"deprecated": null
},
"FetchInvoice.amount_msat": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.changes": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.changes.amount_msat": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.changes.description": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.changes.description_appended": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.changes.vendor": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.changes.vendor_removed": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.invoice": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.next_period": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.next_period.counter": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.next_period.endtime": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.next_period.paywindow_end": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.next_period.paywindow_start": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.next_period.starttime": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.offer": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.payer_note": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.quantity": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.recurrence_counter": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.recurrence_label": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.recurrence_start": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FetchInvoice.timeout": {
"added": "pre-v0.10.1",
"deprecated": false
},
"FundChannel": {
"added": "pre-v0.10.1",
"deprecated": null
Expand Down
34 changes: 34 additions & 0 deletions cln-grpc/proto/node.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions cln-grpc/src/convert.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions cln-grpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,38 @@ async fn feerates(

}

async fn fetch_invoice(
&self,
request: tonic::Request<pb::FetchinvoiceRequest>,
) -> Result<tonic::Response<pb::FetchinvoiceResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::FetchinvoiceRequest = req.into();
debug!("Client asked for fetch_invoice");
trace!("fetch_invoice request: {:?}", req);
let mut rpc = ClnRpc::new(&self.rpc_path)
.await
.map_err(|e| Status::new(Code::Internal, e.to_string()))?;
let result = rpc.call(Request::FetchInvoice(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method FetchInvoice: {:?}", e)))?;
match result {
Response::FetchInvoice(r) => {
trace!("fetch_invoice response: {:?}", r);
Ok(tonic::Response::new(r.into()))
},
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call FetchInvoice",
r
)
)),
}

}

async fn fund_channel(
&self,
request: tonic::Request<pb::FundchannelRequest>,
Expand Down
Loading

0 comments on commit 836d71a

Please sign in to comment.