mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-26 20:30:59 +01:00
msggen: add splice_signed method
This commit is contained in:
parent
9f9b59d45b
commit
04a2ad6f8b
9 changed files with 285 additions and 87 deletions
33
.msggen.json
33
.msggen.json
|
@ -2372,6 +2372,15 @@
|
|||
"Splice_initResponse": {
|
||||
"Splice_Init.psbt": 1
|
||||
},
|
||||
"Splice_signedRequest": {
|
||||
"Splice_Signed.channel_id": 1,
|
||||
"Splice_Signed.psbt": 2,
|
||||
"Splice_Signed.sign_first": 3
|
||||
},
|
||||
"Splice_signedResponse": {
|
||||
"Splice_Signed.tx": 1,
|
||||
"Splice_Signed.txid": 2
|
||||
},
|
||||
"StaticbackupResponse": {
|
||||
"StaticBackup.scb[]": 1
|
||||
},
|
||||
|
@ -8262,6 +8271,30 @@
|
|||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Splice_Signed": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": null
|
||||
},
|
||||
"Splice_Signed.channel_id": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Splice_Signed.psbt": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Splice_Signed.sign_first": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Splice_Signed.tx": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"Splice_Signed.txid": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": false
|
||||
},
|
||||
"StaticBackup": {
|
||||
"added": "pre-v0.10.1",
|
||||
"deprecated": null
|
||||
|
|
12
cln-grpc/proto/node.proto
generated
12
cln-grpc/proto/node.proto
generated
|
@ -85,6 +85,7 @@ service Node {
|
|||
rpc SignInvoice(SigninvoiceRequest) returns (SigninvoiceResponse) {}
|
||||
rpc SignMessage(SignmessageRequest) returns (SignmessageResponse) {}
|
||||
rpc Splice_Init(Splice_initRequest) returns (Splice_initResponse) {}
|
||||
rpc Splice_Signed(Splice_signedRequest) returns (Splice_signedResponse) {}
|
||||
rpc UnreserveInputs(UnreserveinputsRequest) returns (UnreserveinputsResponse) {}
|
||||
rpc WaitBlockHeight(WaitblockheightRequest) returns (WaitblockheightResponse) {}
|
||||
rpc Wait(WaitRequest) returns (WaitResponse) {}
|
||||
|
@ -2407,6 +2408,17 @@ message Splice_initResponse {
|
|||
string psbt = 1;
|
||||
}
|
||||
|
||||
message Splice_signedRequest {
|
||||
bytes channel_id = 1;
|
||||
string psbt = 2;
|
||||
optional bool sign_first = 3;
|
||||
}
|
||||
|
||||
message Splice_signedResponse {
|
||||
bytes tx = 1;
|
||||
bytes txid = 2;
|
||||
}
|
||||
|
||||
message UnreserveinputsRequest {
|
||||
string psbt = 1;
|
||||
optional uint32 reserve = 2;
|
||||
|
|
32
cln-grpc/src/convert.rs
generated
32
cln-grpc/src/convert.rs
generated
|
@ -2288,6 +2288,16 @@ impl From<responses::Splice_initResponse> for pb::SpliceInitResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<responses::Splice_signedResponse> for pb::SpliceSignedResponse {
|
||||
fn from(c: responses::Splice_signedResponse) -> Self {
|
||||
Self {
|
||||
tx: hex::decode(&c.tx).unwrap(), // Rule #2 for type hex
|
||||
txid: hex::decode(&c.txid).unwrap(), // Rule #2 for type txid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<responses::UnreserveinputsReservations> for pb::UnreserveinputsReservations {
|
||||
fn from(c: responses::UnreserveinputsReservations) -> Self {
|
||||
|
@ -3567,6 +3577,17 @@ impl From<requests::Splice_initRequest> for pb::SpliceInitRequest {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<requests::Splice_signedRequest> for pb::SpliceSignedRequest {
|
||||
fn from(c: requests::Splice_signedRequest) -> Self {
|
||||
Self {
|
||||
channel_id: <Sha256 as AsRef<[u8]>>::as_ref(&c.channel_id).to_vec(), // Rule #2 for type hash
|
||||
psbt: c.psbt, // Rule #2 for type string
|
||||
sign_first: c.sign_first, // Rule #2 for type boolean?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<requests::UnreserveinputsRequest> for pb::UnreserveinputsRequest {
|
||||
fn from(c: requests::UnreserveinputsRequest) -> Self {
|
||||
|
@ -4661,6 +4682,17 @@ impl From<pb::SpliceInitRequest> for requests::Splice_initRequest {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<pb::SpliceSignedRequest> for requests::Splice_signedRequest {
|
||||
fn from(c: pb::SpliceSignedRequest) -> Self {
|
||||
Self {
|
||||
channel_id: Sha256::from_slice(&c.channel_id).unwrap(), // Rule #1 for type hash
|
||||
psbt: c.psbt, // Rule #1 for type string
|
||||
sign_first: c.sign_first, // Rule #1 for type boolean?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
impl From<pb::UnreserveinputsRequest> for requests::UnreserveinputsRequest {
|
||||
fn from(c: pb::UnreserveinputsRequest) -> Self {
|
||||
|
|
|
@ -2490,6 +2490,38 @@ async fn splice_init(
|
|||
|
||||
}
|
||||
|
||||
async fn splice_signed(
|
||||
&self,
|
||||
request: tonic::Request<pb::SpliceSignedRequest>,
|
||||
) -> Result<tonic::Response<pb::SpliceSignedResponse>, tonic::Status> {
|
||||
let req = request.into_inner();
|
||||
let req: requests::Splice_signedRequest = req.into();
|
||||
debug!("Client asked for splice_signed");
|
||||
trace!("splice_signed 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::Splice_Signed(req))
|
||||
.await
|
||||
.map_err(|e| Status::new(
|
||||
Code::Unknown,
|
||||
format!("Error calling method Splice_Signed: {:?}", e)))?;
|
||||
match result {
|
||||
Response::Splice_Signed(r) => {
|
||||
trace!("splice_signed response: {:?}", r);
|
||||
Ok(tonic::Response::new(r.into()))
|
||||
},
|
||||
r => Err(Status::new(
|
||||
Code::Internal,
|
||||
format!(
|
||||
"Unexpected result {:?} to method call Splice_Signed",
|
||||
r
|
||||
)
|
||||
)),
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async fn unreserve_inputs(
|
||||
&self,
|
||||
request: tonic::Request<pb::UnreserveinputsRequest>,
|
||||
|
|
44
cln-rpc/src/model.rs
generated
44
cln-rpc/src/model.rs
generated
|
@ -96,6 +96,7 @@ pub enum Request {
|
|||
SignInvoice(requests::SigninvoiceRequest),
|
||||
SignMessage(requests::SignmessageRequest),
|
||||
Splice_Init(requests::Splice_initRequest),
|
||||
Splice_Signed(requests::Splice_signedRequest),
|
||||
UnreserveInputs(requests::UnreserveinputsRequest),
|
||||
WaitBlockHeight(requests::WaitblockheightRequest),
|
||||
Wait(requests::WaitRequest),
|
||||
|
@ -200,6 +201,7 @@ pub enum Response {
|
|||
SignInvoice(responses::SigninvoiceResponse),
|
||||
SignMessage(responses::SignmessageResponse),
|
||||
Splice_Init(responses::Splice_initResponse),
|
||||
Splice_Signed(responses::Splice_signedResponse),
|
||||
UnreserveInputs(responses::UnreserveinputsResponse),
|
||||
WaitBlockHeight(responses::WaitblockheightResponse),
|
||||
Wait(responses::WaitResponse),
|
||||
|
@ -2890,6 +2892,31 @@ pub mod requests {
|
|||
}
|
||||
}
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Splice_signedRequest {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub sign_first: Option<bool>,
|
||||
pub channel_id: Sha256,
|
||||
pub psbt: String,
|
||||
}
|
||||
|
||||
impl From<Splice_signedRequest> for Request {
|
||||
fn from(r: Splice_signedRequest) -> Self {
|
||||
Request::Splice_Signed(r)
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoRequest for Splice_signedRequest {
|
||||
type Response = super::responses::Splice_signedResponse;
|
||||
}
|
||||
|
||||
impl TypedRequest for Splice_signedRequest {
|
||||
type Response = super::responses::Splice_signedResponse;
|
||||
|
||||
fn method(&self) -> &str {
|
||||
"splice_signed"
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct UnreserveinputsRequest {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub reserve: Option<u32>,
|
||||
|
@ -7561,6 +7588,23 @@ pub mod responses {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct Splice_signedResponse {
|
||||
pub tx: String,
|
||||
pub txid: String,
|
||||
}
|
||||
|
||||
impl TryFrom<Response> for Splice_signedResponse {
|
||||
type Error = super::TryFromResponseError;
|
||||
|
||||
fn try_from(response: Response) -> Result<Self, Self::Error> {
|
||||
match response {
|
||||
Response::Splice_Signed(response) => Ok(response),
|
||||
_ => Err(TryFromResponseError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct UnreserveinputsReservations {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
|
|
@ -139,6 +139,7 @@ def load_jsonrpc_service():
|
|||
"SignInvoice",
|
||||
"SignMessage",
|
||||
"Splice_Init",
|
||||
"Splice_Signed",
|
||||
"UnreserveInputs",
|
||||
"WaitBlockHeight",
|
||||
"Wait",
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -399,6 +399,11 @@ class NodeStub(object):
|
|||
request_serializer=node__pb2.Splice_initRequest.SerializeToString,
|
||||
response_deserializer=node__pb2.Splice_initResponse.FromString,
|
||||
)
|
||||
self.Splice_Signed = channel.unary_unary(
|
||||
'/cln.Node/Splice_Signed',
|
||||
request_serializer=node__pb2.Splice_signedRequest.SerializeToString,
|
||||
response_deserializer=node__pb2.Splice_signedResponse.FromString,
|
||||
)
|
||||
self.UnreserveInputs = channel.unary_unary(
|
||||
'/cln.Node/UnreserveInputs',
|
||||
request_serializer=node__pb2.UnreserveinputsRequest.SerializeToString,
|
||||
|
@ -931,6 +936,12 @@ class NodeServicer(object):
|
|||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def Splice_Signed(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 UnreserveInputs(self, request, context):
|
||||
"""Missing associated documentation comment in .proto file."""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
|
@ -1397,6 +1408,11 @@ def add_NodeServicer_to_server(servicer, server):
|
|||
request_deserializer=node__pb2.Splice_initRequest.FromString,
|
||||
response_serializer=node__pb2.Splice_initResponse.SerializeToString,
|
||||
),
|
||||
'Splice_Signed': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.Splice_Signed,
|
||||
request_deserializer=node__pb2.Splice_signedRequest.FromString,
|
||||
response_serializer=node__pb2.Splice_signedResponse.SerializeToString,
|
||||
),
|
||||
'UnreserveInputs': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.UnreserveInputs,
|
||||
request_deserializer=node__pb2.UnreserveinputsRequest.FromString,
|
||||
|
@ -2781,6 +2797,23 @@ class Node(object):
|
|||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def Splice_Signed(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/Splice_Signed',
|
||||
node__pb2.Splice_signedRequest.SerializeToString,
|
||||
node__pb2.Splice_signedResponse.FromString,
|
||||
options, channel_credentials,
|
||||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
|
||||
|
||||
@staticmethod
|
||||
def UnreserveInputs(request,
|
||||
target,
|
||||
|
|
|
@ -1831,6 +1831,13 @@ def splice_init2py(m):
|
|||
})
|
||||
|
||||
|
||||
def splice_signed2py(m):
|
||||
return remove_default({
|
||||
"tx": hexlify(m.tx), # PrimitiveField in generate_composite
|
||||
"txid": hexlify(m.txid), # PrimitiveField in generate_composite
|
||||
})
|
||||
|
||||
|
||||
def unreserveinputs_reservations2py(m):
|
||||
return remove_default({
|
||||
"reserved": m.reserved, # PrimitiveField in generate_composite
|
||||
|
|
Loading…
Add table
Reference in a new issue