added listhtlcs model

This commit is contained in:
ff 2023-02-15 22:16:20 +01:00 committed by Rusty Russell
parent 5f653780f5
commit 6920e36135
12 changed files with 211 additions and 37 deletions

View File

@ -102,6 +102,32 @@
"spent": 2,
"unconfirmed": 0
},
"ListhtlcsHtlcsDirection": {
"in": 1,
"out": 0
},
"ListhtlcsHtlcsState": {
"RCVD_ADD_ACK_COMMIT": 3,
"RCVD_ADD_ACK_REVOCATION": 14,
"RCVD_ADD_COMMIT": 11,
"RCVD_ADD_HTLC": 10,
"RCVD_ADD_REVOCATION": 2,
"RCVD_REMOVE_ACK_COMMIT": 18,
"RCVD_REMOVE_ACK_REVOCATION": 9,
"RCVD_REMOVE_COMMIT": 6,
"RCVD_REMOVE_HTLC": 5,
"RCVD_REMOVE_REVOCATION": 17,
"SENT_ADD_ACK_COMMIT": 13,
"SENT_ADD_ACK_REVOCATION": 4,
"SENT_ADD_COMMIT": 1,
"SENT_ADD_HTLC": 0,
"SENT_ADD_REVOCATION": 12,
"SENT_REMOVE_ACK_COMMIT": 8,
"SENT_REMOVE_ACK_REVOCATION": 19,
"SENT_REMOVE_COMMIT": 16,
"SENT_REMOVE_HTLC": 15,
"SENT_REMOVE_REVOCATION": 7
},
"ListinvoicesIndex": {
"created": 0,
"updated": 1
@ -925,6 +951,21 @@
"ListFunds.channels[]": 2,
"ListFunds.outputs[]": 1
},
"ListhtlcsHtlcs": {
"ListHtlcs.htlcs[].amount_msat": 4,
"ListHtlcs.htlcs[].direction": 5,
"ListHtlcs.htlcs[].expiry": 3,
"ListHtlcs.htlcs[].id": 2,
"ListHtlcs.htlcs[].payment_hash": 6,
"ListHtlcs.htlcs[].short_channel_id": 1,
"ListHtlcs.htlcs[].state": 7
},
"ListhtlcsRequest": {
"ListHtlcs.id": 1
},
"ListhtlcsResponse": {
"ListHtlcs.htlcs[]": 1
},
"ListinvoicesInvoices": {
"ListInvoices.invoices[].amount_msat": 6,
"ListInvoices.invoices[].amount_received_msat": 12,
@ -3577,6 +3618,46 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"ListHtlcs": {
"added": "v23.02",
"deprecated": null
},
"ListHtlcs.htlcs[]": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListHtlcs.htlcs[].amount_msat": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListHtlcs.htlcs[].direction": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListHtlcs.htlcs[].expiry": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListHtlcs.htlcs[].id": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListHtlcs.htlcs[].payment_hash": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListHtlcs.htlcs[].short_channel_id": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListHtlcs.htlcs[].state": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListHtlcs.id": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListInvoices": {
"added": "pre-v0.10.1",
"deprecated": null

Binary file not shown.

BIN
cln-grpc/src/convert.rs generated

Binary file not shown.

View File

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

BIN
cln-rpc/src/model.rs generated

Binary file not shown.

BIN
contrib/msggen/dist/msggen-0.1.0.tar.gz vendored Normal file

Binary file not shown.

View File

View File

@ -177,6 +177,7 @@ class OverridePatch(Patch):
'ListPeers.peers[].channels[].state_changes[].old_state': "ChannelState",
'ListPeers.peers[].channels[].htlcs[].state': "HtlcState",
'ListPeerChannels.channels[].htlcs[].state': "HtlcState",
'ListHtlcs.htlcs[].state': "HtlcState",
}
def visit(self, f: model.Field) -> None:

View File

@ -83,6 +83,7 @@ def load_jsonrpc_service(schema_dir: str):
"ListForwards",
# "listoffers",
"ListPays",
"ListHtlcs",
# "multifundchannel",
# "multiwithdraw",
# "offer",

File diff suppressed because one or more lines are too long

View File

@ -249,6 +249,11 @@ class NodeStub(object):
request_serializer=node__pb2.ListpaysRequest.SerializeToString,
response_deserializer=node__pb2.ListpaysResponse.FromString,
)
self.ListHtlcs = channel.unary_unary(
'/cln.Node/ListHtlcs',
request_serializer=node__pb2.ListhtlcsRequest.SerializeToString,
response_deserializer=node__pb2.ListhtlcsResponse.FromString,
)
self.Ping = channel.unary_unary(
'/cln.Node/Ping',
request_serializer=node__pb2.PingRequest.SerializeToString,
@ -576,6 +581,12 @@ class NodeServicer(object):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def ListHtlcs(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 Ping(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@ -862,6 +873,11 @@ def add_NodeServicer_to_server(servicer, server):
request_deserializer=node__pb2.ListpaysRequest.FromString,
response_serializer=node__pb2.ListpaysResponse.SerializeToString,
),
'ListHtlcs': grpc.unary_unary_rpc_method_handler(
servicer.ListHtlcs,
request_deserializer=node__pb2.ListhtlcsRequest.FromString,
response_serializer=node__pb2.ListhtlcsResponse.SerializeToString,
),
'Ping': grpc.unary_unary_rpc_method_handler(
servicer.Ping,
request_deserializer=node__pb2.PingRequest.FromString,
@ -1711,6 +1727,23 @@ class Node(object):
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def ListHtlcs(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/ListHtlcs',
node__pb2.ListhtlcsRequest.SerializeToString,
node__pb2.ListhtlcsResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def Ping(request,
target,

View File

@ -1289,6 +1289,24 @@ def listpays2py(m):
})
def listhtlcs_htlcs2py(m):
return remove_default({
"short_channel_id": m.short_channel_id, # PrimitiveField in generate_composite
"id": m.id, # PrimitiveField in generate_composite
"expiry": m.expiry, # PrimitiveField in generate_composite
"amount_msat": amount2msat(m.amount_msat), # PrimitiveField in generate_composite
"direction": str(m.direction), # EnumField in generate_composite
"payment_hash": hexlify(m.payment_hash), # PrimitiveField in generate_composite
"state": str(m.state), # EnumField in generate_composite
})
def listhtlcs2py(m):
return remove_default({
"htlcs": [listhtlcs_htlcs2py(i) for i in m.htlcs], # ArrayField[composite] in generate_composite
})
def ping2py(m):
return remove_default({
"totlen": m.totlen, # PrimitiveField in generate_composite