msggen: Regenerate for addition of SendCustomMsg

Performed using:
  PYTHONPATH=contrib/msggen python3 contrib/msggen/msggen/__main__.py
This commit is contained in:
Carl Dong 2023-02-06 12:14:54 -05:00 committed by Alex Myers
parent ef51ae3c6d
commit b83a19164c
8 changed files with 201 additions and 21 deletions

View file

@ -905,6 +905,13 @@
"PingResponse": {
"Ping.totlen": 1
},
"SendcustommsgRequest": {
"SendCustomMsg.msg": 2,
"SendCustomMsg.node_id": 1
},
"SendcustommsgResponse": {
"SendCustomMsg.status": 1
},
"SendonionFirst_hop": {
"SendOnion.first_hop.amount_msat": 2,
"SendOnion.first_hop.delay": 3,

View file

@ -52,6 +52,7 @@ service Node {
rpc ListForwards(ListforwardsRequest) returns (ListforwardsResponse) {}
rpc ListPays(ListpaysRequest) returns (ListpaysResponse) {}
rpc Ping(PingRequest) returns (PingResponse) {}
rpc SendCustomMsg(SendcustommsgRequest) returns (SendcustommsgResponse) {}
rpc SetChannel(SetchannelRequest) returns (SetchannelResponse) {}
rpc SignInvoice(SigninvoiceRequest) returns (SigninvoiceResponse) {}
rpc SignMessage(SignmessageRequest) returns (SignmessageResponse) {}
@ -1300,6 +1301,15 @@ message PingResponse {
uint32 totlen = 1;
}
message SendcustommsgRequest {
bytes node_id = 1;
bytes msg = 2;
}
message SendcustommsgResponse {
string status = 1;
}
message SetchannelRequest {
string id = 1;
optional Amount feebase = 2;

View file

@ -1081,6 +1081,15 @@ impl From<responses::PingResponse> for pb::PingResponse {
}
}
#[allow(unused_variables)]
impl From<responses::SendcustommsgResponse> for pb::SendcustommsgResponse {
fn from(c: responses::SendcustommsgResponse) -> Self {
Self {
status: c.status, // Rule #2 for type string
}
}
}
#[allow(unused_variables)]
impl From<responses::SetchannelChannels> for pb::SetchannelChannels {
fn from(c: responses::SetchannelChannels) -> Self {
@ -1691,6 +1700,16 @@ impl From<requests::PingRequest> for pb::PingRequest {
}
}
#[allow(unused_variables)]
impl From<requests::SendcustommsgRequest> for pb::SendcustommsgRequest {
fn from(c: requests::SendcustommsgRequest) -> Self {
Self {
node_id: c.node_id.serialize().to_vec(), // Rule #2 for type pubkey
msg: hex::decode(&c.msg).unwrap(), // Rule #2 for type hex
}
}
}
#[allow(unused_variables)]
impl From<requests::SetchannelRequest> for pb::SetchannelRequest {
fn from(c: requests::SetchannelRequest) -> Self {
@ -2287,6 +2306,16 @@ impl From<pb::PingRequest> for requests::PingRequest {
}
}
#[allow(unused_variables)]
impl From<pb::SendcustommsgRequest> for requests::SendcustommsgRequest {
fn from(c: pb::SendcustommsgRequest) -> Self {
Self {
node_id: PublicKey::from_slice(&c.node_id).unwrap(), // Rule #1 for type pubkey
msg: hex::encode(&c.msg), // Rule #1 for type hex
}
}
}
#[allow(unused_variables)]
impl From<pb::SetchannelRequest> for requests::SetchannelRequest {
fn from(c: pb::SetchannelRequest) -> Self {
@ -3391,6 +3420,15 @@ impl From<pb::PingResponse> for responses::PingResponse {
}
}
#[allow(unused_variables)]
impl From<pb::SendcustommsgResponse> for responses::SendcustommsgResponse {
fn from(c: pb::SendcustommsgResponse) -> Self {
Self {
status: c.status, // Rule #1 for type string
}
}
}
#[allow(unused_variables)]
impl From<pb::SetchannelChannels> for responses::SetchannelChannels {
fn from(c: pb::SetchannelChannels) -> Self {

View file

@ -1434,6 +1434,38 @@ async fn ping(
}
async fn send_custom_msg(
&self,
request: tonic::Request<pb::SendcustommsgRequest>,
) -> Result<tonic::Response<pb::SendcustommsgResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::SendcustommsgRequest = req.into();
debug!("Client asked for send_custom_msg");
trace!("send_custom_msg 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::SendCustomMsg(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method SendCustomMsg: {:?}", e)))?;
match result {
Response::SendCustomMsg(r) => {
trace!("send_custom_msg response: {:?}", r);
Ok(tonic::Response::new(r.into()))
},
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call SendCustomMsg",
r
)
)),
}
}
async fn set_channel(
&self,
request: tonic::Request<pb::SetchannelRequest>,

34
cln-rpc/src/model.rs generated
View file

@ -60,6 +60,7 @@ pub enum Request {
ListForwards(requests::ListforwardsRequest),
ListPays(requests::ListpaysRequest),
Ping(requests::PingRequest),
SendCustomMsg(requests::SendcustommsgRequest),
SetChannel(requests::SetchannelRequest),
SignInvoice(requests::SigninvoiceRequest),
SignMessage(requests::SignmessageRequest),
@ -114,6 +115,7 @@ pub enum Response {
ListForwards(responses::ListforwardsResponse),
ListPays(responses::ListpaysResponse),
Ping(responses::PingResponse),
SendCustomMsg(responses::SendcustommsgResponse),
SetChannel(responses::SetchannelResponse),
SignInvoice(responses::SigninvoiceResponse),
SignMessage(responses::SignmessageResponse),
@ -1218,6 +1220,22 @@ pub mod requests {
type Response = super::responses::PingResponse;
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SendcustommsgRequest {
pub node_id: PublicKey,
pub msg: String,
}
impl From<SendcustommsgRequest> for Request {
fn from(r: SendcustommsgRequest) -> Self {
Request::SendCustomMsg(r)
}
}
impl IntoRequest for SendcustommsgRequest {
type Response = super::responses::SendcustommsgResponse;
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SetchannelRequest {
pub id: String,
@ -3503,6 +3521,22 @@ pub mod responses {
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SendcustommsgResponse {
pub status: String,
}
impl TryFrom<Response> for SendcustommsgResponse {
type Error = super::TryFromResponseError;
fn try_from(response: Response) -> Result<Self, Self::Error> {
match response {
Response::SendCustomMsg(response) => Ok(response),
_ => Err(TryFromResponseError)
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SetchannelChannels {
pub peer_id: PublicKey,

View file

@ -852,6 +852,12 @@ def ping2py(m):
})
def sendcustommsg2py(m):
return remove_default({
"status": m.status, # PrimitiveField in generate_composite
})
def setchannel_channels2py(m):
return remove_default({
"peer_id": hexlify(m.peer_id), # PrimitiveField in generate_composite

File diff suppressed because one or more lines are too long

View file

@ -234,6 +234,11 @@ class NodeStub(object):
request_serializer=node__pb2.PingRequest.SerializeToString,
response_deserializer=node__pb2.PingResponse.FromString,
)
self.SendCustomMsg = channel.unary_unary(
'/cln.Node/SendCustomMsg',
request_serializer=node__pb2.SendcustommsgRequest.SerializeToString,
response_deserializer=node__pb2.SendcustommsgResponse.FromString,
)
self.SetChannel = channel.unary_unary(
'/cln.Node/SetChannel',
request_serializer=node__pb2.SetchannelRequest.SerializeToString,
@ -523,6 +528,12 @@ class NodeServicer(object):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def SendCustomMsg(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 SetChannel(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@ -770,6 +781,11 @@ def add_NodeServicer_to_server(servicer, server):
request_deserializer=node__pb2.PingRequest.FromString,
response_serializer=node__pb2.PingResponse.SerializeToString,
),
'SendCustomMsg': grpc.unary_unary_rpc_method_handler(
servicer.SendCustomMsg,
request_deserializer=node__pb2.SendcustommsgRequest.FromString,
response_serializer=node__pb2.SendcustommsgResponse.SerializeToString,
),
'SetChannel': grpc.unary_unary_rpc_method_handler(
servicer.SetChannel,
request_deserializer=node__pb2.SetchannelRequest.FromString,
@ -1548,6 +1564,23 @@ class Node(object):
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def SendCustomMsg(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/SendCustomMsg',
node__pb2.SendcustommsgRequest.SerializeToString,
node__pb2.SendcustommsgResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def SetChannel(request,
target,