mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-26 20:30:59 +01:00
msggen: add help method
Changelog-None
This commit is contained in:
parent
5510445bbc
commit
bd1123cf32
9 changed files with 359 additions and 84 deletions
48
.msggen.json
48
.msggen.json
|
@ -126,6 +126,9 @@
|
|||
"GetrouteRouteStyle": {
|
||||
"tlv": 0
|
||||
},
|
||||
"HelpFormat-hint": {
|
||||
"simple": 0
|
||||
},
|
||||
"KeysendStatus": {
|
||||
"complete": 0
|
||||
},
|
||||
|
@ -1381,6 +1384,19 @@
|
|||
"GetRoute.route[].msatoshi": 7,
|
||||
"GetRoute.route[].style": 6
|
||||
},
|
||||
"HelpHelp": {
|
||||
"Help.help[].category": 2,
|
||||
"Help.help[].command": 1,
|
||||
"Help.help[].description": 3,
|
||||
"Help.help[].verbose": 4
|
||||
},
|
||||
"HelpRequest": {
|
||||
"Help.command": 1
|
||||
},
|
||||
"HelpResponse": {
|
||||
"Help.format-hint": 2,
|
||||
"Help.help[]": 1
|
||||
},
|
||||
"InvoiceRequest": {
|
||||
"Invoice.amount_msat": 10,
|
||||
"Invoice.cltv": 6,
|
||||
|
@ -5375,6 +5391,38 @@
|
|||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Help": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": null
|
||||
},
|
||||
"Help.command": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Help.format-hint": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Help.help[]": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Help.help[].category": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Help.help[].command": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Help.help[].description": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Help.help[].verbose": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Invoice": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": null
|
||||
|
|
21
cln-grpc/proto/node.proto
generated
21
cln-grpc/proto/node.proto
generated
|
@ -100,6 +100,7 @@ service Node {
|
|||
rpc WaitBlockHeight(WaitblockheightRequest) returns (WaitblockheightResponse) {}
|
||||
rpc Wait(WaitRequest) returns (WaitResponse) {}
|
||||
rpc Stop(StopRequest) returns (StopResponse) {}
|
||||
rpc Help(HelpRequest) returns (HelpResponse) {}
|
||||
rpc PreApproveKeysend(PreapprovekeysendRequest) returns (PreapprovekeysendResponse) {}
|
||||
rpc PreApproveInvoice(PreapproveinvoiceRequest) returns (PreapproveinvoiceResponse) {}
|
||||
rpc StaticBackup(StaticbackupRequest) returns (StaticbackupResponse) {}
|
||||
|
@ -2688,6 +2689,26 @@ message StopResponse {
|
|||
optional StopResult result = 1;
|
||||
}
|
||||
|
||||
message HelpRequest {
|
||||
optional string command = 1;
|
||||
}
|
||||
|
||||
message HelpResponse {
|
||||
// Help.format-hint
|
||||
enum HelpFormathint {
|
||||
SIMPLE = 0;
|
||||
}
|
||||
repeated HelpHelp help = 1;
|
||||
optional HelpFormathint format_hint = 2;
|
||||
}
|
||||
|
||||
message HelpHelp {
|
||||
string command = 1;
|
||||
string category = 2;
|
||||
string description = 3;
|
||||
string verbose = 4;
|
||||
}
|
||||
|
||||
message PreapprovekeysendRequest {
|
||||
bytes destination = 1;
|
||||
bytes payment_hash = 2;
|
||||
|
|
41
cln-grpc/src/convert.rs
generated
41
cln-grpc/src/convert.rs
generated
|
@ -2503,6 +2503,29 @@ impl From<responses::StopResponse> for pb::StopResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<responses::HelpHelp> for pb::HelpHelp {
|
||||
fn from(c: responses::HelpHelp) -> Self {
|
||||
Self {
|
||||
category: c.category, // Rule #2 for type string
|
||||
command: c.command, // Rule #2 for type string
|
||||
description: c.description, // Rule #2 for type string
|
||||
verbose: c.verbose, // Rule #2 for type string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<responses::HelpResponse> for pb::HelpResponse {
|
||||
fn from(c: responses::HelpResponse) -> Self {
|
||||
Self {
|
||||
format_hint: c.format_hint.map(|v| v as i32),
|
||||
// Field: Help.help[]
|
||||
help: c.help.into_iter().map(|i| i.into()).collect(), // Rule #3 for type HelpHelp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<responses::PreapprovekeysendResponse> for pb::PreapprovekeysendResponse {
|
||||
fn from(c: responses::PreapprovekeysendResponse) -> Self {
|
||||
|
@ -3947,6 +3970,15 @@ impl From<requests::StopRequest> for pb::StopRequest {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<requests::HelpRequest> for pb::HelpRequest {
|
||||
fn from(c: requests::HelpRequest) -> Self {
|
||||
Self {
|
||||
command: c.command, // Rule #2 for type string?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<requests::PreapprovekeysendRequest> for pb::PreapprovekeysendRequest {
|
||||
fn from(c: requests::PreapprovekeysendRequest) -> Self {
|
||||
|
@ -5215,6 +5247,15 @@ impl From<pb::StopRequest> for requests::StopRequest {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<pb::HelpRequest> for requests::HelpRequest {
|
||||
fn from(c: pb::HelpRequest) -> Self {
|
||||
Self {
|
||||
command: c.command, // Rule #1 for type string?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<pb::PreapprovekeysendRequest> for requests::PreapprovekeysendRequest {
|
||||
fn from(c: pb::PreapprovekeysendRequest) -> Self {
|
||||
|
|
|
@ -3026,6 +3026,38 @@ impl Node for Server
|
|||
|
||||
}
|
||||
|
||||
async fn help(
|
||||
&self,
|
||||
request: tonic::Request<pb::HelpRequest>,
|
||||
) -> Result<tonic::Response<pb::HelpResponse>, tonic::Status> {
|
||||
let req = request.into_inner();
|
||||
let req: requests::HelpRequest = req.into();
|
||||
debug!("Client asked for help");
|
||||
trace!("help 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::Help(req))
|
||||
.await
|
||||
.map_err(|e| Status::new(
|
||||
Code::Unknown,
|
||||
format!("Error calling method Help: {:?}", e)))?;
|
||||
match result {
|
||||
Response::Help(r) => {
|
||||
trace!("help response: {:?}", r);
|
||||
Ok(tonic::Response::new(r.into()))
|
||||
},
|
||||
r => Err(Status::new(
|
||||
Code::Internal,
|
||||
format!(
|
||||
"Unexpected result {:?} to method call Help",
|
||||
r
|
||||
)
|
||||
)),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async fn pre_approve_keysend(
|
||||
&self,
|
||||
request: tonic::Request<pb::PreapprovekeysendRequest>,
|
||||
|
|
76
cln-rpc/src/model.rs
generated
76
cln-rpc/src/model.rs
generated
|
@ -112,6 +112,7 @@ pub enum Request {
|
|||
WaitBlockHeight(requests::WaitblockheightRequest),
|
||||
Wait(requests::WaitRequest),
|
||||
Stop(requests::StopRequest),
|
||||
Help(requests::HelpRequest),
|
||||
PreApproveKeysend(requests::PreapprovekeysendRequest),
|
||||
PreApproveInvoice(requests::PreapproveinvoiceRequest),
|
||||
StaticBackup(requests::StaticbackupRequest),
|
||||
|
@ -228,6 +229,7 @@ pub enum Response {
|
|||
WaitBlockHeight(responses::WaitblockheightResponse),
|
||||
Wait(responses::WaitResponse),
|
||||
Stop(responses::StopResponse),
|
||||
Help(responses::HelpResponse),
|
||||
PreApproveKeysend(responses::PreapprovekeysendResponse),
|
||||
PreApproveInvoice(responses::PreapproveinvoiceResponse),
|
||||
StaticBackup(responses::StaticbackupResponse),
|
||||
|
@ -3404,6 +3406,29 @@ pub mod requests {
|
|||
}
|
||||
}
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct HelpRequest {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub command: Option<String>,
|
||||
}
|
||||
|
||||
impl From<HelpRequest> for Request {
|
||||
fn from(r: HelpRequest) -> Self {
|
||||
Request::Help(r)
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoRequest for HelpRequest {
|
||||
type Response = super::responses::HelpResponse;
|
||||
}
|
||||
|
||||
impl TypedRequest for HelpRequest {
|
||||
type Response = super::responses::HelpResponse;
|
||||
|
||||
fn method(&self) -> &str {
|
||||
"help"
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct PreapprovekeysendRequest {
|
||||
pub amount_msat: Amount,
|
||||
pub destination: PublicKey,
|
||||
|
@ -8365,6 +8390,57 @@ pub mod responses {
|
|||
}
|
||||
}
|
||||
|
||||
/// ['Prints the help in human-readable flat form.']
|
||||
#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||
pub enum HelpFormathint {
|
||||
#[serde(rename = "simple")]
|
||||
SIMPLE = 0,
|
||||
}
|
||||
|
||||
impl TryFrom<i32> for HelpFormathint {
|
||||
type Error = anyhow::Error;
|
||||
fn try_from(c: i32) -> Result<HelpFormathint, anyhow::Error> {
|
||||
match c {
|
||||
0 => Ok(HelpFormathint::SIMPLE),
|
||||
o => Err(anyhow::anyhow!("Unknown variant {} for enum HelpFormathint", o)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToString for HelpFormathint {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
HelpFormathint::SIMPLE => "SIMPLE",
|
||||
}.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct HelpHelp {
|
||||
pub category: String,
|
||||
pub command: String,
|
||||
pub description: String,
|
||||
pub verbose: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct HelpResponse {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub format_hint: Option<HelpFormathint>,
|
||||
pub help: Vec<HelpHelp>,
|
||||
}
|
||||
|
||||
impl TryFrom<Response> for HelpResponse {
|
||||
type Error = super::TryFromResponseError;
|
||||
|
||||
fn try_from(response: Response) -> Result<Self, Self::Error> {
|
||||
match response {
|
||||
Response::Help(response) => Ok(response),
|
||||
_ => Err(TryFromResponseError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct PreapprovekeysendResponse {
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ def load_jsonrpc_service():
|
|||
# "check", # No point in mapping this one
|
||||
"Stop",
|
||||
# "notifications", # No point in mapping this
|
||||
# "help",
|
||||
"Help",
|
||||
"PreApproveKeysend",
|
||||
"PreApproveInvoice",
|
||||
"StaticBackup",
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -474,6 +474,11 @@ class NodeStub(object):
|
|||
request_serializer=node__pb2.StopRequest.SerializeToString,
|
||||
response_deserializer=node__pb2.StopResponse.FromString,
|
||||
)
|
||||
self.Help = channel.unary_unary(
|
||||
'/cln.Node/Help',
|
||||
request_serializer=node__pb2.HelpRequest.SerializeToString,
|
||||
response_deserializer=node__pb2.HelpResponse.FromString,
|
||||
)
|
||||
self.PreApproveKeysend = channel.unary_unary(
|
||||
'/cln.Node/PreApproveKeysend',
|
||||
request_serializer=node__pb2.PreapprovekeysendRequest.SerializeToString,
|
||||
|
@ -1101,6 +1106,12 @@ class NodeServicer(object):
|
|||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def Help(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 PreApproveKeysend(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
|
@ -1648,6 +1659,11 @@ def add_NodeServicer_to_server(servicer, server):
|
|||
request_deserializer=node__pb2.StopRequest.FromString,
|
||||
response_serializer=node__pb2.StopResponse.SerializeToString,
|
||||
),
|
||||
'Help': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.Help,
|
||||
request_deserializer=node__pb2.HelpRequest.FromString,
|
||||
response_serializer=node__pb2.HelpResponse.SerializeToString,
|
||||
),
|
||||
'PreApproveKeysend': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.PreApproveKeysend,
|
||||
request_deserializer=node__pb2.PreapprovekeysendRequest.FromString,
|
||||
|
@ -3292,6 +3308,23 @@ class Node(object):
|
|||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def Help(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/Help',
|
||||
node__pb2.HelpRequest.SerializeToString,
|
||||
node__pb2.HelpResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def PreApproveKeysend(request,
|
||||
target,
|
||||
|
|
|
@ -1986,6 +1986,22 @@ def stop2py(m):
|
|||
})
|
||||
|
||||
|
||||
def help_help2py(m):
|
||||
return remove_default({
|
||||
"category": m.category, # PrimitiveField in generate_composite
|
||||
"command": m.command, # PrimitiveField in generate_composite
|
||||
"description": m.description, # PrimitiveField in generate_composite
|
||||
"verbose": m.verbose, # PrimitiveField in generate_composite
|
||||
})
|
||||
|
||||
|
||||
def help2py(m):
|
||||
return remove_default({
|
||||
"format-hint": str(m.format_hint), # EnumField in generate_composite
|
||||
"help": [help_help2py(i) for i in m.help], # ArrayField[composite] in generate_composite
|
||||
})
|
||||
|
||||
|
||||
def preapprovekeysend2py(m):
|
||||
return remove_default({
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue