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

grpc: addpsbtoutput command #7108

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
43 changes: 43 additions & 0 deletions .msggen.json
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,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
},
"Autoclean-onceAutoclean": {
"AutoClean-Once.autoclean.expiredinvoices": 6,
"AutoClean-Once.autoclean.failedforwards": 2,
Expand Down Expand Up @@ -3323,6 +3334,38 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"AddPsbtOutput": {
"added": "pre-v0.10.1",
"deprecated": false
},
"AddPsbtOutput.destination": {
"added": "pre-v0.10.1",
"deprecated": false
},
"AddPsbtOutput.estimated_added_weight": {
"added": "pre-v0.10.1",
"deprecated": false
},
"AddPsbtOutput.initialpsbt": {
"added": "pre-v0.10.1",
"deprecated": false
},
"AddPsbtOutput.locktime": {
"added": "pre-v0.10.1",
"deprecated": false
},
"AddPsbtOutput.outnum": {
"added": "pre-v0.10.1",
"deprecated": false
},
"AddPsbtOutput.psbt": {
"added": "pre-v0.10.1",
"deprecated": false
},
"AddPsbtOutput.satoshi": {
"added": "pre-v0.10.1",
"deprecated": false
},
"AutoClean-Once": {
"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 @@ -274,6 +274,38 @@ impl Node for Server

}

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

2 changes: 1 addition & 1 deletion contrib/msggen/msggen/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
],
"properties": {
"satoshi": {
"type": "sat",
"type": "msat",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right. The psbt code handles satoshi amounts and the description matches this. Maybe there needs to be a new rust primitive type?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cdecker and me discussed this before, for now this is correct. But could be improved in the future. I think this was changed when the schemas got merged and some were forgotten. I've had to do this on a couple commits aswell.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see here: #7230 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for the back story!

"description": [
"The satoshi value of the output. It can be a whole number, a whole number ending in *sat*, or a number with 1 to 8 decimal places ending in *btc*."
]
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 @@ -89,13 +89,16 @@ def load_notification(name, typename: TypeName):


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",
"AutoClean-Once",
"AutoClean-Status",
Expand Down
1,830 changes: 917 additions & 913 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 @@ -640,6 +645,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 @@ -1339,6 +1350,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 @@ -2006,6 +2022,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 @@ -186,6 +186,14 @@ def addgossip2py(m):
})


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


def autocleaninvoice2py(m):
return remove_default({
"cycle_seconds": m.cycle_seconds, # PrimitiveField in generate_composite
Expand Down
2 changes: 1 addition & 1 deletion doc/schemas/lightning-addpsbtoutput.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"properties": {
"satoshi": {
"type": "sat",
"type": "msat",
"description": [
"The satoshi value of the output. It can be a whole number, a whole number ending in *sat*, or a number with 1 to 8 decimal places ending in *btc*."
]
Expand Down