msggen: add createrune method

This commit is contained in:
daywalker90 2024-04-24 21:42:46 +02:00 committed by Christian Decker
parent 19646f93c6
commit 473694c39a
10 changed files with 239 additions and 40 deletions

View file

@ -819,6 +819,15 @@
"CreateOnion.onion": 1,
"CreateOnion.shared_secrets[]": 2
},
"CreateruneRequest": {
"CreateRune.restrictions": 2,
"CreateRune.rune": 1
},
"CreateruneResponse": {
"CreateRune.rune": 1,
"CreateRune.unique_id": 2,
"CreateRune.warning_unrestricted_rune": 3
},
"CustomMsgNotification": {
"custommsg.payload": 2,
"custommsg.peer_id": 1
@ -4114,6 +4123,26 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"CreateRune": {
"added": "pre-v0.10.1",
"deprecated": null
},
"CreateRune.restrictions": {
"added": "pre-v0.10.1",
"deprecated": false
},
"CreateRune.rune": {
"added": "pre-v0.10.1",
"deprecated": false
},
"CreateRune.unique_id": {
"added": "pre-v0.10.1",
"deprecated": false
},
"CreateRune.warning_unrestricted_rune": {
"added": "pre-v0.10.1",
"deprecated": false
},
"Datastore": {
"added": "pre-v0.10.1",
"deprecated": null

View file

@ -116,6 +116,7 @@ service Node {
rpc BkprListAccountEvents(BkprlistaccounteventsRequest) returns (BkprlistaccounteventsResponse) {}
rpc BkprListBalances(BkprlistbalancesRequest) returns (BkprlistbalancesResponse) {}
rpc BkprListIncome(BkprlistincomeRequest) returns (BkprlistincomeResponse) {}
rpc CreateRune(CreateruneRequest) returns (CreateruneResponse) {}
rpc ShowRunes(ShowrunesRequest) returns (ShowrunesResponse) {}
rpc SubscribeBlockAdded(StreamBlockAddedRequest) returns (stream BlockAddedNotification) {}
@ -3503,6 +3504,17 @@ message BkprlistincomeIncome_events {
optional bytes payment_id = 10;
}
message CreateruneRequest {
optional string rune = 1;
repeated string restrictions = 2;
}
message CreateruneResponse {
string rune = 1;
string unique_id = 2;
optional string warning_unrestricted_rune = 3;
}
message ShowrunesRequest {
optional string rune = 1;
}

View file

@ -3794,6 +3794,17 @@ impl From<responses::BkprlistincomeResponse> for pb::BkprlistincomeResponse {
}
}
#[allow(unused_variables)]
impl From<responses::CreateruneResponse> for pb::CreateruneResponse {
fn from(c: responses::CreateruneResponse) -> Self {
Self {
rune: c.rune, // Rule #2 for type string
unique_id: c.unique_id, // Rule #2 for type string
warning_unrestricted_rune: c.warning_unrestricted_rune, // Rule #2 for type string?
}
}
}
#[allow(unused_variables)]
impl From<responses::ShowrunesRunesRestrictionsAlternatives> for pb::ShowrunesRunesRestrictionsAlternatives {
fn from(c: responses::ShowrunesRunesRestrictionsAlternatives) -> Self {
@ -5237,6 +5248,17 @@ impl From<requests::BkprlistincomeRequest> for pb::BkprlistincomeRequest {
}
}
#[allow(unused_variables)]
impl From<requests::CreateruneRequest> for pb::CreateruneRequest {
fn from(c: requests::CreateruneRequest) -> Self {
Self {
// Field: CreateRune.restrictions
restrictions: c.restrictions.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::ShowrunesRequest> for pb::ShowrunesRequest {
fn from(c: requests::ShowrunesRequest) -> Self {
@ -6588,6 +6610,16 @@ impl From<pb::BkprlistincomeRequest> for requests::BkprlistincomeRequest {
}
}
#[allow(unused_variables)]
impl From<pb::CreateruneRequest> for requests::CreateruneRequest {
fn from(c: pb::CreateruneRequest) -> Self {
Self {
restrictions: Some(c.restrictions.into_iter().map(|s| s.into()).collect()), // Rule #4
rune: c.rune, // Rule #1 for type string?
}
}
}
#[allow(unused_variables)]
impl From<pb::ShowrunesRequest> for requests::ShowrunesRequest {
fn from(c: pb::ShowrunesRequest) -> Self {

View file

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

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

@ -134,6 +134,7 @@ pub enum Request {
BkprListBalances(requests::BkprlistbalancesRequest),
#[serde(rename = "bkpr-listincome")]
BkprListIncome(requests::BkprlistincomeRequest),
CreateRune(requests::CreateruneRequest),
ShowRunes(requests::ShowrunesRequest),
}
@ -258,6 +259,7 @@ pub enum Response {
BkprListBalances(responses::BkprlistbalancesResponse),
#[serde(rename = "bkpr-listincome")]
BkprListIncome(responses::BkprlistincomeResponse),
CreateRune(responses::CreateruneResponse),
ShowRunes(responses::ShowrunesResponse),
}
@ -3814,6 +3816,31 @@ pub mod requests {
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CreateruneRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub rune: Option<String>,
#[serde(skip_serializing_if = "crate::is_none_or_empty")]
pub restrictions: Option<Vec<String>>,
}
impl From<CreateruneRequest> for Request {
fn from(r: CreateruneRequest) -> Self {
Request::CreateRune(r)
}
}
impl IntoRequest for CreateruneRequest {
type Response = super::responses::CreateruneResponse;
}
impl TypedRequest for CreateruneRequest {
type Response = super::responses::CreateruneResponse;
fn method(&self) -> &str {
"createrune"
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ShowrunesRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub rune: Option<String>,
@ -10069,6 +10096,25 @@ pub mod responses {
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CreateruneResponse {
#[serde(skip_serializing_if = "Option::is_none")]
pub warning_unrestricted_rune: Option<String>,
pub rune: String,
pub unique_id: String,
}
impl TryFrom<Response> for CreateruneResponse {
type Error = super::TryFromResponseError;
fn try_from(response: Response) -> Result<Self, Self::Error> {
match response {
Response::CreateRune(response) => Ok(response),
_ => Err(TryFromResponseError)
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ShowrunesRunesRestrictionsAlternatives {
pub condition: String,

View file

@ -513,6 +513,7 @@ DecodeRoutehintListField = PrimitiveField(
added=None,
deprecated=None
)
CreateRuneRestrictionsField = 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
@ -544,7 +545,8 @@ overrides = {
'WaitInvoice.label': InvoiceLabelField,
'Offer.recurrence_base': OfferStringField,
'Offer.amount': OfferStringField,
'SetConfig.val': SetConfigValField
'SetConfig.val': SetConfigValField,
'CreateRune.restrictions': CreateRuneRestrictionsField,
}

View file

@ -201,6 +201,7 @@ def load_jsonrpc_service():
"Bkpr-ListAccountEvents",
"Bkpr-ListBalances",
"Bkpr-ListIncome",
"CreateRune",
"ShowRunes",
]

File diff suppressed because one or more lines are too long

View file

@ -554,6 +554,11 @@ class NodeStub(object):
request_serializer=node__pb2.BkprlistincomeRequest.SerializeToString,
response_deserializer=node__pb2.BkprlistincomeResponse.FromString,
)
self.CreateRune = channel.unary_unary(
'/cln.Node/CreateRune',
request_serializer=node__pb2.CreateruneRequest.SerializeToString,
response_deserializer=node__pb2.CreateruneResponse.FromString,
)
self.ShowRunes = channel.unary_unary(
'/cln.Node/ShowRunes',
request_serializer=node__pb2.ShowrunesRequest.SerializeToString,
@ -1237,6 +1242,12 @@ class NodeServicer(object):
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)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def ShowRunes(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@ -1816,6 +1827,11 @@ def add_NodeServicer_to_server(servicer, server):
request_deserializer=node__pb2.BkprlistincomeRequest.FromString,
response_serializer=node__pb2.BkprlistincomeResponse.SerializeToString,
),
'CreateRune': grpc.unary_unary_rpc_method_handler(
servicer.CreateRune,
request_deserializer=node__pb2.CreateruneRequest.FromString,
response_serializer=node__pb2.CreateruneResponse.SerializeToString,
),
'ShowRunes': grpc.unary_unary_rpc_method_handler(
servicer.ShowRunes,
request_deserializer=node__pb2.ShowrunesRequest.FromString,
@ -3692,6 +3708,23 @@ class Node(object):
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def CreateRune(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/CreateRune',
node__pb2.CreateruneRequest.SerializeToString,
node__pb2.CreateruneResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def ShowRunes(request,
target,

View file

@ -2790,6 +2790,14 @@ def bkpr_listincome2py(m):
})
def createrune2py(m):
return remove_default({
"rune": m.rune, # PrimitiveField in generate_composite
"unique_id": m.unique_id, # PrimitiveField in generate_composite
"warning_unrestricted_rune": m.warning_unrestricted_rune, # PrimitiveField in generate_composite
})
def showrunes_runes_restrictions_alternatives2py(m):
return remove_default({
"condition": m.condition, # PrimitiveField in generate_composite