Skip to content

Commit

Permalink
feat: grpc - adding support for Offer command
Browse files Browse the repository at this point in the history
  • Loading branch information
vacwmX authored and cdecker committed Feb 7, 2024
1 parent 3ae3243 commit 68bb1ff
Show file tree
Hide file tree
Showing 6 changed files with 370 additions and 61 deletions.
41 changes: 41 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.

117 changes: 117 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.

31 changes: 31 additions & 0 deletions cln-grpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,37 @@ async fn list_htlcs(

}

async fn offer(
&self,
request: tonic::Request<pb::OfferRequest>,
) -> Result<tonic::Response<pb::OfferResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::OfferRequest = req.into();
debug!("Client asked for offer");
trace!("offer 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::Offer(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method Offer: {:?}", e)))?;
match result {
Response::Offer(r) => {
trace!("offer response: {:?}", r);
Ok(tonic::Response::new(r.into()))
},
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call Offer",
r
)
)),
}
}

async fn ping(
&self,
request: tonic::Request<pb::PingRequest>,
Expand Down
77 changes: 77 additions & 0 deletions cln-rpc/src/model.rs

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

132 changes: 71 additions & 61 deletions contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions contrib/pyln-grpc-proto/pyln/grpc/node_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ def __init__(self, channel):
request_serializer=node__pb2.ListhtlcsRequest.SerializeToString,
response_deserializer=node__pb2.ListhtlcsResponse.FromString,
)
self.Offer = channel.unary_unary(
'/cln.Node/Offer',
request_serializer=node__pb2.OfferRequest.SerializeToString,
response_deserializer=node__pb2.OfferResponse.FromString,
)
self.Ping = channel.unary_unary(
'/cln.Node/Ping',
request_serializer=node__pb2.PingRequest.SerializeToString,
Expand Down Expand Up @@ -629,6 +634,12 @@ def ListHtlcs(self, request, context):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def Offer(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def Ping(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
Expand Down Expand Up @@ -954,6 +965,11 @@ def add_NodeServicer_to_server(servicer, server):
request_deserializer=node__pb2.ListhtlcsRequest.FromString,
response_serializer=node__pb2.ListhtlcsResponse.SerializeToString,
),
'Offer': grpc.unary_unary_rpc_method_handler(
servicer.Offer,
request_deserializer=node__pb2.OfferRequest.FromString,
response_serializer=node__pb2.OfferResponse.SerializeToString,
),
'Ping': grpc.unary_unary_rpc_method_handler(
servicer.Ping,
request_deserializer=node__pb2.PingRequest.FromString,
Expand Down Expand Up @@ -1874,6 +1890,23 @@ def ListHtlcs(request,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def Offer(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/cln.Node/Offer',
node__pb2.OfferRequest.SerializeToString,
node__pb2.OfferResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def Ping(request,
target,
Expand Down

0 comments on commit 68bb1ff

Please sign in to comment.