msggen: add checkrune method

This commit is contained in:
daywalker90 2024-04-24 21:59:28 +02:00 committed by Christian Decker
parent b4c061798c
commit 5430b65b4c
10 changed files with 246 additions and 43 deletions

View file

@ -748,6 +748,15 @@
"CheckMessage.pubkey": 2,
"CheckMessage.verified": 1
},
"CheckruneRequest": {
"CheckRune.method": 3,
"CheckRune.nodeid": 2,
"CheckRune.params": 4,
"CheckRune.rune": 1
},
"CheckruneResponse": {
"CheckRune.valid": 1
},
"CloseRequest": {
"Close.destination": 3,
"Close.fee_negotiation_step": 4,
@ -3950,6 +3959,30 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"CheckRune": {
"added": "pre-v0.10.1",
"deprecated": null
},
"CheckRune.method": {
"added": "pre-v0.10.1",
"deprecated": false
},
"CheckRune.nodeid": {
"added": "pre-v0.10.1",
"deprecated": false
},
"CheckRune.params": {
"added": "pre-v0.10.1",
"deprecated": false
},
"CheckRune.rune": {
"added": "pre-v0.10.1",
"deprecated": false
},
"CheckRune.valid": {
"added": "pre-v0.10.1",
"deprecated": false
},
"Close": {
"added": "pre-v0.10.1",
"deprecated": null

View file

@ -117,6 +117,7 @@ service Node {
rpc BkprListBalances(BkprlistbalancesRequest) returns (BkprlistbalancesResponse) {}
rpc BkprListIncome(BkprlistincomeRequest) returns (BkprlistincomeResponse) {}
rpc BlacklistRune(BlacklistruneRequest) returns (BlacklistruneResponse) {}
rpc CheckRune(CheckruneRequest) returns (CheckruneResponse) {}
rpc CreateRune(CreateruneRequest) returns (CreateruneResponse) {}
rpc ShowRunes(ShowrunesRequest) returns (ShowrunesResponse) {}
@ -3519,6 +3520,17 @@ message BlacklistruneBlacklist {
uint64 end = 2;
}
message CheckruneRequest {
string rune = 1;
optional string nodeid = 2;
optional string method = 3;
repeated string params = 4;
}
message CheckruneResponse {
bool valid = 1;
}
message CreateruneRequest {
optional string rune = 1;
repeated string restrictions = 2;

View file

@ -3814,6 +3814,15 @@ impl From<responses::BlacklistruneResponse> for pb::BlacklistruneResponse {
}
}
#[allow(unused_variables)]
impl From<responses::CheckruneResponse> for pb::CheckruneResponse {
fn from(c: responses::CheckruneResponse) -> Self {
Self {
valid: c.valid, // Rule #2 for type boolean
}
}
}
#[allow(unused_variables)]
impl From<responses::CreateruneResponse> for pb::CreateruneResponse {
fn from(c: responses::CreateruneResponse) -> Self {
@ -5278,6 +5287,19 @@ impl From<requests::BlacklistruneRequest> for pb::BlacklistruneRequest {
}
}
#[allow(unused_variables)]
impl From<requests::CheckruneRequest> for pb::CheckruneRequest {
fn from(c: requests::CheckruneRequest) -> Self {
Self {
method: c.method, // Rule #2 for type string?
nodeid: c.nodeid, // Rule #2 for type string?
// Field: CheckRune.params
params: c.params.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3
rune: c.rune, // Rule #2 for type string
}
}
}
#[allow(unused_variables)]
impl From<requests::CreateruneRequest> for pb::CreateruneRequest {
fn from(c: requests::CreateruneRequest) -> Self {
@ -6650,6 +6672,18 @@ impl From<pb::BlacklistruneRequest> for requests::BlacklistruneRequest {
}
}
#[allow(unused_variables)]
impl From<pb::CheckruneRequest> for requests::CheckruneRequest {
fn from(c: pb::CheckruneRequest) -> Self {
Self {
method: c.method, // Rule #1 for type string?
nodeid: c.nodeid, // Rule #1 for type string?
params: Some(c.params.into_iter().map(|s| s.into()).collect()), // Rule #4
rune: c.rune, // Rule #1 for type string
}
}
}
#[allow(unused_variables)]
impl From<pb::CreateruneRequest> for requests::CreateruneRequest {
fn from(c: pb::CreateruneRequest) -> Self {

View file

@ -3570,6 +3570,38 @@ impl Node for Server
}
async fn check_rune(
&self,
request: tonic::Request<pb::CheckruneRequest>,
) -> Result<tonic::Response<pb::CheckruneResponse>, tonic::Status> {
let req = request.into_inner();
let req: requests::CheckruneRequest = req.into();
debug!("Client asked for check_rune");
trace!("check_rune 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::CheckRune(req))
.await
.map_err(|e| Status::new(
Code::Unknown,
format!("Error calling method CheckRune: {:?}", e)))?;
match result {
Response::CheckRune(r) => {
trace!("check_rune response: {:?}", r);
Ok(tonic::Response::new(r.into()))
},
r => Err(Status::new(
Code::Internal,
format!(
"Unexpected result {:?} to method call CheckRune",
r
)
)),
}
}
async fn create_rune(
&self,
request: tonic::Request<pb::CreateruneRequest>,

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

@ -135,6 +135,7 @@ pub enum Request {
#[serde(rename = "bkpr-listincome")]
BkprListIncome(requests::BkprlistincomeRequest),
BlacklistRune(requests::BlacklistruneRequest),
CheckRune(requests::CheckruneRequest),
CreateRune(requests::CreateruneRequest),
ShowRunes(requests::ShowrunesRequest),
}
@ -261,6 +262,7 @@ pub enum Response {
#[serde(rename = "bkpr-listincome")]
BkprListIncome(responses::BkprlistincomeResponse),
BlacklistRune(responses::BlacklistruneResponse),
CheckRune(responses::CheckruneResponse),
CreateRune(responses::CreateruneResponse),
ShowRunes(responses::ShowrunesResponse),
}
@ -3843,6 +3845,34 @@ pub mod requests {
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CheckruneRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub method: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub nodeid: Option<String>,
#[serde(skip_serializing_if = "crate::is_none_or_empty")]
pub params: Option<Vec<String>>,
pub rune: String,
}
impl From<CheckruneRequest> for Request {
fn from(r: CheckruneRequest) -> Self {
Request::CheckRune(r)
}
}
impl IntoRequest for CheckruneRequest {
type Response = super::responses::CheckruneResponse;
}
impl TypedRequest for CheckruneRequest {
type Response = super::responses::CheckruneResponse;
fn method(&self) -> &str {
"checkrune"
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CreateruneRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub rune: Option<String>,
@ -10145,6 +10175,22 @@ pub mod responses {
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CheckruneResponse {
pub valid: bool,
}
impl TryFrom<Response> for CheckruneResponse {
type Error = super::TryFromResponseError;
fn try_from(response: Response) -> Result<Self, Self::Error> {
match response {
Response::CheckRune(response) => Ok(response),
_ => Err(TryFromResponseError)
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CreateruneResponse {
#[serde(skip_serializing_if = "Option::is_none")]

View file

@ -514,6 +514,7 @@ DecodeRoutehintListField = PrimitiveField(
deprecated=None
)
CreateRuneRestrictionsField = ArrayField(itemtype=PrimitiveField("string", None, None, added=None, deprecated=None), dims=1, path=None, description=None, added=None, deprecated=None)
CheckRuneParamsField = ArrayField(itemtype=PrimitiveField("string", None, None, added=None, deprecated=None), dims=1, path=None, description=None, added=None, deprecated=None)
# TlvStreams are special, they don't have preset dict-keys, rather
# they can specify `u64` keys pointing to hex payloads. So the schema
@ -547,6 +548,7 @@ overrides = {
'Offer.amount': OfferStringField,
'SetConfig.val': SetConfigValField,
'CreateRune.restrictions': CreateRuneRestrictionsField,
'CheckRune.params': CheckRuneParamsField,
}

View file

@ -202,6 +202,7 @@ def load_jsonrpc_service():
"Bkpr-ListBalances",
"Bkpr-ListIncome",
"BlacklistRune",
"CheckRune",
"CreateRune",
"ShowRunes",
]

File diff suppressed because one or more lines are too long

View file

@ -559,6 +559,11 @@ class NodeStub(object):
request_serializer=node__pb2.BlacklistruneRequest.SerializeToString,
response_deserializer=node__pb2.BlacklistruneResponse.FromString,
)
self.CheckRune = channel.unary_unary(
'/cln.Node/CheckRune',
request_serializer=node__pb2.CheckruneRequest.SerializeToString,
response_deserializer=node__pb2.CheckruneResponse.FromString,
)
self.CreateRune = channel.unary_unary(
'/cln.Node/CreateRune',
request_serializer=node__pb2.CreateruneRequest.SerializeToString,
@ -1253,6 +1258,12 @@ class NodeServicer(object):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def CheckRune(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 CreateRune(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@ -1843,6 +1854,11 @@ def add_NodeServicer_to_server(servicer, server):
request_deserializer=node__pb2.BlacklistruneRequest.FromString,
response_serializer=node__pb2.BlacklistruneResponse.SerializeToString,
),
'CheckRune': grpc.unary_unary_rpc_method_handler(
servicer.CheckRune,
request_deserializer=node__pb2.CheckruneRequest.FromString,
response_serializer=node__pb2.CheckruneResponse.SerializeToString,
),
'CreateRune': grpc.unary_unary_rpc_method_handler(
servicer.CreateRune,
request_deserializer=node__pb2.CreateruneRequest.FromString,
@ -3741,6 +3757,23 @@ class Node(object):
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def CheckRune(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/CheckRune',
node__pb2.CheckruneRequest.SerializeToString,
node__pb2.CheckruneResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def CreateRune(request,
target,

View file

@ -2803,6 +2803,12 @@ def blacklistrune2py(m):
})
def checkrune2py(m):
return remove_default({
"valid": m.valid, # PrimitiveField in generate_composite
})
def createrune2py(m):
return remove_default({
"rune": m.rune, # PrimitiveField in generate_composite