| 347 | } |
| 348 | |
| 349 | async fn create_invoice( |
| 350 | &self, |
| 351 | request: tonic::Request<pb::CreateinvoiceRequest>, |
| 352 | ) -> Result<tonic::Response<pb::CreateinvoiceResponse>, tonic::Status> { |
| 353 | let req = request.into_inner(); |
| 354 | let req: requests::CreateinvoiceRequest = req.into(); |
| 355 | debug!("Client asked for create_invoice"); |
| 356 | trace!("create_invoice request: {:?}", req); |
| 357 | let mut rpc = ClnRpc::new(&self.rpc_path) |
| 358 | .await |
| 359 | .map_err(|e| Status::new(Code::Internal, e.to_string()))?; |
| 360 | let result = rpc.call(Request::CreateInvoice(req)) |
| 361 | .await |
| 362 | .map_err(|e| Status::new( |
| 363 | Code::Unknown, |
| 364 | format!("Error calling method CreateInvoice: {:?}", e)))?; |
| 365 | match result { |
| 366 | Response::CreateInvoice(r) => { |
| 367 | trace!("create_invoice response: {:?}", r); |
| 368 | Ok(tonic::Response::new(r.into())) |
| 369 | }, |
| 370 | r => Err(Status::new( |
| 371 | Code::Internal, |
| 372 | format!( |
| 373 | "Unexpected result {:?} to method call CreateInvoice", |
| 374 | r |
| 375 | ) |
| 376 | )), |
| 377 | } |
| 378 | |
| 379 | } |
| 380 | |
| 381 | async fn datastore( |
| 382 | &self, |