msggen: Add ListClosedChannels and overrides

This commit is contained in:
Christian Decker 2023-05-02 13:36:15 +02:00 committed by Rusty Russell
parent 318f35b243
commit bff3b1ca8c
12 changed files with 290 additions and 1 deletions

View File

@ -58,6 +58,14 @@
"KeysendStatus": {
"complete": 0
},
"ListclosedchannelsClosedchannelsClose_cause": {
"local": 1,
"onchain": 5,
"protocol": 4,
"remote": 3,
"unknown": 0,
"user": 2
},
"ListforwardsForwardsStatus": {
"failed": 3,
"local_failed": 2,
@ -649,6 +657,42 @@
"ListchannelsResponse": {
"ListChannels.channels[]": 1
},
"ListclosedchannelsClosedchannels": {
"ListClosedChannels.closedchannels[].alias": 4,
"ListClosedChannels.closedchannels[].channel_id": 2,
"ListClosedChannels.closedchannels[].channel_type": 8,
"ListClosedChannels.closedchannels[].close_cause": 24,
"ListClosedChannels.closedchannels[].closer": 6,
"ListClosedChannels.closedchannels[].final_to_us_msat": 19,
"ListClosedChannels.closedchannels[].funding_fee_paid_msat": 15,
"ListClosedChannels.closedchannels[].funding_fee_rcvd_msat": 16,
"ListClosedChannels.closedchannels[].funding_outnum": 13,
"ListClosedChannels.closedchannels[].funding_pushed_msat": 17,
"ListClosedChannels.closedchannels[].funding_txid": 12,
"ListClosedChannels.closedchannels[].last_commitment_fee_msat": 23,
"ListClosedChannels.closedchannels[].last_commitment_txid": 22,
"ListClosedChannels.closedchannels[].leased": 14,
"ListClosedChannels.closedchannels[].max_to_us_msat": 21,
"ListClosedChannels.closedchannels[].min_to_us_msat": 20,
"ListClosedChannels.closedchannels[].opener": 5,
"ListClosedChannels.closedchannels[].peer_id": 1,
"ListClosedChannels.closedchannels[].private": 7,
"ListClosedChannels.closedchannels[].short_channel_id": 3,
"ListClosedChannels.closedchannels[].total_htlcs_sent": 11,
"ListClosedChannels.closedchannels[].total_local_commitments": 9,
"ListClosedChannels.closedchannels[].total_msat": 18,
"ListClosedChannels.closedchannels[].total_remote_commitments": 10
},
"ListclosedchannelsClosedchannelsAlias": {
"ListClosedChannels.closedchannels[].alias.local": 1,
"ListClosedChannels.closedchannels[].alias.remote": 2
},
"ListclosedchannelsRequest": {
"ListClosedChannels.id": 1
},
"ListclosedchannelsResponse": {
"ListClosedChannels.closedchannels[]": 1
},
"ListdatastoreDatastore": {
"ListDatastore.datastore[].generation": 2,
"ListDatastore.datastore[].hex": 3,
@ -2402,6 +2446,130 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels": {
"added": "v23.05",
"deprecated": null
},
"ListClosedChannels.closedchannels[]": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].alias": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].alias.local": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].alias.remote": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].channel_id": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].channel_type": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].channel_type.bits[]": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].channel_type.names[]": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].close_cause": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].closer": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].final_to_us_msat": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].funding_fee_paid_msat": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].funding_fee_rcvd_msat": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].funding_outnum": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].funding_pushed_msat": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].funding_txid": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].last_commitment_fee_msat": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].last_commitment_txid": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].leased": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].max_to_us_msat": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].min_to_us_msat": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].opener": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].peer_id": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].private": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].short_channel_id": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].total_htlcs_sent": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].total_local_commitments": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].total_msat": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.closedchannels[].total_remote_commitments": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListClosedChannels.id": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListDatastore": {
"added": "pre-v0.10.1",
"deprecated": null

Binary file not shown.

BIN
cln-grpc/src/convert.rs generated

Binary file not shown.

View File

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

BIN
cln-rpc/src/model.rs generated

Binary file not shown.

View File

@ -50,6 +50,10 @@ overrides = {
'ListPeerChannels.channels[].channel_type': None,
'ListFunds.channels[].state': 'ChannelState',
'ListTransactions.transactions[].type[]': None,
'ListClosedChannels.closedchannels[].closer': "ChannelSide",
'ListClosedChannels.closedchannels[].opener': "ChannelSide",
'ListClosedChannels.closedchannels[].channel_type': None,
}

View File

@ -28,6 +28,10 @@ overrides = {
'ListFunds.channels[].state': 'ChannelState',
'ListTransactions.transactions[].type[]': None,
'Invoice.exposeprivatechannels': None,
'ListClosedChannels.closedchannels[].closer': "ChannelSide",
'ListClosedChannels.closedchannels[].opener': "ChannelSide",
'ListClosedChannels.closedchannels[].channel_type': None,
}
# A map of schema type to rust primitive types.

View File

@ -62,7 +62,7 @@ class VersionAnnotationPatch(Patch):
# the default value only on the first run. Code left commented
# to show how it was done
# if f.added is None and 'added' not in m:
# m['added'] = 'pre-v0.10.1'
# m['added'] = 'pre-v0.10.1'
added = m.get('added', None)
deprecated = m.get('deprecated', None)

View File

@ -65,6 +65,7 @@ def load_jsonrpc_service(schema_dir: str):
"TxPrepare",
"TxSend",
"ListPeerChannels",
"ListClosedChannels",
# "decodepay",
# "decode",
# "delpay",

View File

@ -847,6 +847,53 @@ def listpeerchannels2py(m):
})
def listclosedchannels_closedchannels_alias2py(m):
return remove_default({
"local": m.local, # PrimitiveField in generate_composite
"remote": m.remote, # PrimitiveField in generate_composite
})
def listclosedchannels_closedchannels_channel_type2py(m):
return remove_default({
"bits": [m.bits for i in m.bits], # ArrayField[primitive] in generate_composite
"names": [str(i) for i in m.names], # ArrayField[composite] in generate_composite
})
def listclosedchannels_closedchannels2py(m):
return remove_default({
"peer_id": hexlify(m.peer_id), # PrimitiveField in generate_composite
"channel_id": hexlify(m.channel_id), # PrimitiveField in generate_composite
"short_channel_id": m.short_channel_id, # PrimitiveField in generate_composite
"opener": str(m.opener), # EnumField in generate_composite
"closer": str(m.closer), # EnumField in generate_composite
"private": m.private, # PrimitiveField in generate_composite
"total_local_commitments": m.total_local_commitments, # PrimitiveField in generate_composite
"total_remote_commitments": m.total_remote_commitments, # PrimitiveField in generate_composite
"total_htlcs_sent": m.total_htlcs_sent, # PrimitiveField in generate_composite
"funding_txid": hexlify(m.funding_txid), # PrimitiveField in generate_composite
"funding_outnum": m.funding_outnum, # PrimitiveField in generate_composite
"leased": m.leased, # PrimitiveField in generate_composite
"funding_fee_paid_msat": amount2msat(m.funding_fee_paid_msat), # PrimitiveField in generate_composite
"funding_fee_rcvd_msat": amount2msat(m.funding_fee_rcvd_msat), # PrimitiveField in generate_composite
"funding_pushed_msat": amount2msat(m.funding_pushed_msat), # PrimitiveField in generate_composite
"total_msat": amount2msat(m.total_msat), # PrimitiveField in generate_composite
"final_to_us_msat": amount2msat(m.final_to_us_msat), # PrimitiveField in generate_composite
"min_to_us_msat": amount2msat(m.min_to_us_msat), # PrimitiveField in generate_composite
"max_to_us_msat": amount2msat(m.max_to_us_msat), # PrimitiveField in generate_composite
"last_commitment_txid": hexlify(m.last_commitment_txid), # PrimitiveField in generate_composite
"last_commitment_fee_msat": amount2msat(m.last_commitment_fee_msat), # PrimitiveField in generate_composite
"close_cause": str(m.close_cause), # EnumField in generate_composite
})
def listclosedchannels2py(m):
return remove_default({
"closedchannels": [listclosedchannels_closedchannels2py(i) for i in m.closedchannels], # ArrayField[composite] in generate_composite
})
def disconnect2py(m):
return remove_default({
})

Binary file not shown.

View File

@ -204,6 +204,11 @@ class NodeStub(object):
request_serializer=node__pb2.ListpeerchannelsRequest.SerializeToString,
response_deserializer=node__pb2.ListpeerchannelsResponse.FromString,
)
self.ListClosedChannels = channel.unary_unary(
'/cln.Node/ListClosedChannels',
request_serializer=node__pb2.ListclosedchannelsRequest.SerializeToString,
response_deserializer=node__pb2.ListclosedchannelsResponse.FromString,
)
self.Disconnect = channel.unary_unary(
'/cln.Node/Disconnect',
request_serializer=node__pb2.DisconnectRequest.SerializeToString,
@ -497,6 +502,12 @@ class NodeServicer(object):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def ListClosedChannels(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 Disconnect(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@ -762,6 +773,11 @@ def add_NodeServicer_to_server(servicer, server):
request_deserializer=node__pb2.ListpeerchannelsRequest.FromString,
response_serializer=node__pb2.ListpeerchannelsResponse.SerializeToString,
),
'ListClosedChannels': grpc.unary_unary_rpc_method_handler(
servicer.ListClosedChannels,
request_deserializer=node__pb2.ListclosedchannelsRequest.FromString,
response_serializer=node__pb2.ListclosedchannelsResponse.SerializeToString,
),
'Disconnect': grpc.unary_unary_rpc_method_handler(
servicer.Disconnect,
request_deserializer=node__pb2.DisconnectRequest.FromString,
@ -1478,6 +1494,23 @@ class Node(object):
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def ListClosedChannels(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/ListClosedChannels',
node__pb2.ListclosedchannelsRequest.SerializeToString,
node__pb2.ListclosedchannelsResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def Disconnect(request,
target,