Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msggen: Add staticbackup mapping #6507

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .msggen.json
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,9 @@
"SignpsbtResponse": {
"SignPsbt.signed_psbt": 1
},
"StaticbackupResponse": {
"StaticBackup.scb[]": 1
},
"TxdiscardRequest": {
"TxDiscard.txid": 1
},
Expand Down Expand Up @@ -5285,6 +5288,14 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"StaticBackup": {
"added": "pre-v0.10.1",
"deprecated": null
},
"StaticBackup.scb[]": {
"added": "pre-v0.10.1",
"deprecated": false
},
"Stop": {
"added": "pre-v0.10.1",
"deprecated": null
Expand Down
8 changes: 8 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.

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

32 changes: 32 additions & 0 deletions cln-grpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1818,4 +1818,36 @@ async fn pre_approve_invoice(

}

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

}

}
32 changes: 32 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.

1 change: 1 addition & 0 deletions contrib/msggen/msggen/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def load_jsonrpc_service(schema_dir: str):
# "help",
"PreApproveKeysend",
"PreApproveInvoice",
"StaticBackup",
]
methods = [load_jsonrpc_method(name, schema_dir=schema_dir) for name in method_names]
service = Service(name="Node", methods=methods)
Expand Down
841 changes: 423 additions & 418 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 @@ -294,6 +294,11 @@ def __init__(self, channel):
request_serializer=node__pb2.PreapproveinvoiceRequest.SerializeToString,
response_deserializer=node__pb2.PreapproveinvoiceResponse.FromString,
)
self.StaticBackup = channel.unary_unary(
'/cln.Node/StaticBackup',
request_serializer=node__pb2.StaticbackupRequest.SerializeToString,
response_deserializer=node__pb2.StaticbackupResponse.FromString,
)


class NodeServicer(object):
Expand Down Expand Up @@ -635,6 +640,12 @@ def PreApproveInvoice(self, request, context):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def StaticBackup(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 add_NodeServicer_to_server(servicer, server):
rpc_method_handlers = {
Expand Down Expand Up @@ -918,6 +929,11 @@ def add_NodeServicer_to_server(servicer, server):
request_deserializer=node__pb2.PreapproveinvoiceRequest.FromString,
response_serializer=node__pb2.PreapproveinvoiceResponse.SerializeToString,
),
'StaticBackup': grpc.unary_unary_rpc_method_handler(
servicer.StaticBackup,
request_deserializer=node__pb2.StaticbackupRequest.FromString,
response_serializer=node__pb2.StaticbackupResponse.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'cln.Node', rpc_method_handlers)
Expand Down Expand Up @@ -1879,3 +1895,20 @@ def PreApproveInvoice(request,
node__pb2.PreapproveinvoiceResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def StaticBackup(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/StaticBackup',
node__pb2.StaticbackupRequest.SerializeToString,
node__pb2.StaticbackupResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
6 changes: 6 additions & 0 deletions contrib/pyln-testing/pyln/testing/grpc2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -1371,3 +1371,9 @@ def preapprovekeysend2py(m):
def preapproveinvoice2py(m):
return remove_default({
})


def staticbackup2py(m):
return remove_default({
"scb": [hexlify(m.scb) for i in hexlify(m.scb)], # ArrayField[primitive] in generate_composite
})
8 changes: 6 additions & 2 deletions doc/lightning-staticbackup.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ The **staticbackup** RPC command returns an object with SCB of all the channels
RETURN VALUE
------------

[comment]: # (GENERATE-FROM-SCHEMA-START)
On success, an object is returned, containing:

- **scb** (array of hexs):
- Each item is SCB of a channel in TLV format
- SCB of a channel in TLV format

[comment]: # (GENERATE-FROM-SCHEMA-END)


AUTHOR
Expand All @@ -35,4 +39,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:9cfaa9eb4609b36accc3e3b12a352c00ddd402307e4461f4df274146d12f6eb0)
[comment]: # ( SHA256STAMP:d76fa5580c067419d83f7103758907b8771f9c393a38ec053c3a36de03a76e9a)
2 changes: 1 addition & 1 deletion doc/schemas/staticbackup.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"scb": {
"type": "array",
"items": {
"type": "string",
"type": "hex",
"description": "SCB of a channel in TLV format"
}
}
Expand Down
Loading