Skip to content

Commit

Permalink
msggen: Include AddPsbtOutput to RPC list and meta field map; regener…
Browse files Browse the repository at this point in the history
…ate libraries
  • Loading branch information
s373nZ committed Feb 27, 2024
1 parent 87f6ceb commit 7b4a4d3
Show file tree
Hide file tree
Showing 10 changed files with 649 additions and 422 deletions.
43 changes: 43 additions & 0 deletions .msggen.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,17 @@
"AddgossipRequest": {
"AddGossip.message": 1
},
"AddpsbtoutputRequest": {
"AddPsbtOutput.destination": 4,
"AddPsbtOutput.initialpsbt": 3,
"AddPsbtOutput.locktime": 2,
"AddPsbtOutput.satoshi": 1
},
"AddpsbtoutputResponse": {
"AddPsbtOutput.estimated_added_weight": 2,
"AddPsbtOutput.outnum": 3,
"AddPsbtOutput.psbt": 1
},
"AutocleaninvoiceRequest": {
"AutoCleanInvoice.cycle_seconds": 2,
"AutoCleanInvoice.expired_by": 1
Expand Down Expand Up @@ -1854,6 +1865,38 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"AddPsbtOutput": {
"added": "v23.11",
"deprecated": false
},
"AddPsbtOutput.destination": {
"added": "v23.11",
"deprecated": false
},
"AddPsbtOutput.estimated_added_weight": {
"added": "v23.11",
"deprecated": false
},
"AddPsbtOutput.initialpsbt": {
"added": "v23.11",
"deprecated": false
},
"AddPsbtOutput.locktime": {
"added": "v23.11",
"deprecated": false
},
"AddPsbtOutput.outnum": {
"added": "v23.11",
"deprecated": false
},
"AddPsbtOutput.psbt": {
"added": "v23.11",
"deprecated": false
},
"AddPsbtOutput.satoshi": {
"added": "v23.11",
"deprecated": false
},
"AutoCleanInvoice": {
"added": "pre-v0.10.1",
"deprecated": null
Expand Down
14 changes: 14 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.

35 changes: 35 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 @@ -218,6 +218,38 @@ async fn add_gossip(

}

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

}

async fn auto_clean_invoice(
&self,
request: tonic::Request<pb::AutocleaninvoiceRequest>,
Expand Down
52 changes: 52 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.

17 changes: 10 additions & 7 deletions contrib/msggen/msggen/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@
"added": "v23.11",
"properties": {
"satoshi": {
"type": "msat"
"type": "msat",
"description": "The satoshi value of the output. It can be a whole number, a whole number ending in sat, a whole number ending in 000msat, or a number with 1 to 8 decimal places ending in btc."
},
"locktime": {
"type": "u32"
"type": "u32",
"description": "An optional locktime: if not set, it is set to a recent block height (if no initial psbt is specified)."
},
"initialpsbt": {
"type": "string",
"description": "the (optional) base 64 encoded PSBT to begin with. If not specified, one will be generated automatically"
"description": "The (optional) base 64 encoded PSBT to begin with. If not specified, one will be generated automatically."
},
"destination": {
"type": "string"
"type": "string",
"description": "If not set, an internal address is generated."
}
}
},
Expand All @@ -56,15 +59,15 @@
"properties": {
"psbt": {
"type": "string",
"description": "Unsigned PSBT which fulfills the parameters given"
"description": "The unsigned PSBT which fulfills the parameters given."
},
"estimated_added_weight": {
"type": "u32",
"description": "The estimated weight of the added output"
"description": "The estimated weight of the added output."
},
"outnum": {
"type": "u32",
"description": "The 0-based number where the output was placed"
"description": "The 0-based number where the output was placed."
}
}
},
Expand Down
3 changes: 3 additions & 0 deletions contrib/msggen/msggen/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ def load_jsonrpc_method(name):


def load_jsonrpc_service():
# FIXME: Maybe this list should be located somewhere other than utils so
# it's more intuitive to remember to update when new RPC calls are added?
method_names = [
"Getinfo",
"ListPeers",
"ListFunds",
"SendPay",
"ListChannels",
"AddGossip",
"AddPsbtOutput",
"AutoCleanInvoice",
"CheckMessage",
"Close",
Expand Down
834 changes: 419 additions & 415 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 @@ -44,6 +44,11 @@ def __init__(self, channel):
request_serializer=node__pb2.AddgossipRequest.SerializeToString,
response_deserializer=node__pb2.AddgossipResponse.FromString,
)
self.AddPsbtOutput = channel.unary_unary(
'/cln.Node/AddPsbtOutput',
request_serializer=node__pb2.AddpsbtoutputRequest.SerializeToString,
response_deserializer=node__pb2.AddpsbtoutputResponse.FromString,
)
self.AutoCleanInvoice = channel.unary_unary(
'/cln.Node/AutoCleanInvoice',
request_serializer=node__pb2.AutocleaninvoiceRequest.SerializeToString,
Expand Down Expand Up @@ -375,6 +380,12 @@ def AddGossip(self, request, context):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')

def AddPsbtOutput(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 AutoCleanInvoice(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
Expand Down Expand Up @@ -756,6 +767,11 @@ def add_NodeServicer_to_server(servicer, server):
request_deserializer=node__pb2.AddgossipRequest.FromString,
response_serializer=node__pb2.AddgossipResponse.SerializeToString,
),
'AddPsbtOutput': grpc.unary_unary_rpc_method_handler(
servicer.AddPsbtOutput,
request_deserializer=node__pb2.AddpsbtoutputRequest.FromString,
response_serializer=node__pb2.AddpsbtoutputResponse.SerializeToString,
),
'AutoCleanInvoice': grpc.unary_unary_rpc_method_handler(
servicer.AutoCleanInvoice,
request_deserializer=node__pb2.AutocleaninvoiceRequest.FromString,
Expand Down Expand Up @@ -1158,6 +1174,23 @@ def AddGossip(request,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def AddPsbtOutput(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/AddPsbtOutput',
node__pb2.AddpsbtoutputRequest.SerializeToString,
node__pb2.AddpsbtoutputResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

@staticmethod
def AutoCleanInvoice(request,
target,
Expand Down
8 changes: 8 additions & 0 deletions contrib/pyln-testing/pyln/testing/grpc2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ def addgossip2py(m):
})


def addpsbtoutput2py(m):
return remove_default({
"psbt": m.psbt, # PrimitiveField in generate_composite
"estimated_added_weight": m.estimated_added_weight, # PrimitiveField in generate_composite
"outnum": m.outnum, # PrimitiveField in generate_composite
})


def autocleaninvoice2py(m):
return remove_default({
"enabled": m.enabled, # PrimitiveField in generate_composite
Expand Down

0 comments on commit 7b4a4d3

Please sign in to comment.