diff --git a/.msggen.json b/.msggen.json index 91f5fd809..3fde731f9 100644 --- a/.msggen.json +++ b/.msggen.json @@ -985,6 +985,7 @@ "SetChannel.channels[].warning_htlcmin_too_low": 7 }, "SetchannelRequest": { + "SetChannel.enforcedelay": 6, "SetChannel.feebase": 2, "SetChannel.feeppm": 3, "SetChannel.htlcmax": 5, diff --git a/cln-grpc/proto/node.proto b/cln-grpc/proto/node.proto index 1e7ded280..84d513e43 100644 --- a/cln-grpc/proto/node.proto +++ b/cln-grpc/proto/node.proto @@ -1294,6 +1294,7 @@ message SetchannelRequest { optional uint32 feeppm = 3; optional Amount htlcmin = 4; optional Amount htlcmax = 5; + optional uint32 enforcedelay = 6; } message SetchannelResponse { diff --git a/cln-grpc/src/convert.rs b/cln-grpc/src/convert.rs index f7b9c48bb..3fe2ac0c5 100644 --- a/cln-grpc/src/convert.rs +++ b/cln-grpc/src/convert.rs @@ -961,39 +961,34 @@ impl From for pb::PingResponse { } #[allow(unused_variables)] -<<<<<<< HEAD +impl From for pb::SetchannelChannels { + fn from(c: responses::SetchannelChannels) -> Self { + Self { + peer_id: c.peer_id.serialize().to_vec(), // Rule #2 for type pubkey + channel_id: hex::decode(&c.channel_id).unwrap(), // Rule #2 for type hex + short_channel_id: c.short_channel_id.map(|v| v.to_string()), // Rule #2 for type short_channel_id? + fee_base_msat: Some(c.fee_base_msat.into()), // Rule #2 for type msat + fee_proportional_millionths: c.fee_proportional_millionths, // Rule #2 for type u32 + minimum_htlc_out_msat: Some(c.minimum_htlc_out_msat.into()), // Rule #2 for type msat + warning_htlcmin_too_low: c.warning_htlcmin_too_low, // Rule #2 for type string? + maximum_htlc_out_msat: Some(c.maximum_htlc_out_msat.into()), // Rule #2 for type msat + warning_htlcmax_too_high: c.warning_htlcmax_too_high, // Rule #2 for type string? + } + } +} + +#[allow(unused_variables)] +impl From for pb::SetchannelResponse { + fn from(c: responses::SetchannelResponse) -> Self { + Self { + channels: c.channels.into_iter().map(|i| i.into()).collect(), // Rule #3 for type SetchannelChannels + } + } +} + +#[allow(unused_variables)] impl From for pb::SignmessageResponse { fn from(c: responses::SignmessageResponse) -> Self { -======= -impl From<&responses::SetchannelChannels> for pb::SetchannelChannels { - fn from(c: &responses::SetchannelChannels) -> Self { - Self { - peer_id: c.peer_id.to_vec(), // Rule #2 for type pubkey - channel_id: hex::decode(&c.channel_id).unwrap(), // Rule #2 for type hex - short_channel_id: c.short_channel_id.as_ref().map(|v| v.to_string()), // Rule #2 for type short_channel_id? - fee_base_msat: Some(c.fee_base_msat.into()), // Rule #2 for type msat - fee_proportional_millionths: c.fee_proportional_millionths.clone(), // Rule #2 for type u32 - minimum_htlc_out_msat: Some(c.minimum_htlc_out_msat.into()), // Rule #2 for type msat - warning_htlcmin_too_low: c.warning_htlcmin_too_low.clone(), // Rule #2 for type string? - maximum_htlc_out_msat: Some(c.maximum_htlc_out_msat.into()), // Rule #2 for type msat - warning_htlcmax_too_high: c.warning_htlcmax_too_high.clone(), // Rule #2 for type string? - } - } -} - -#[allow(unused_variables)] -impl From<&responses::SetchannelResponse> for pb::SetchannelResponse { - fn from(c: &responses::SetchannelResponse) -> Self { - Self { - channels: c.channels.iter().map(|i| i.into()).collect(), // Rule #3 for type SetchannelChannels - } - } -} - -#[allow(unused_variables)] -impl From<&responses::SignmessageResponse> for pb::SignmessageResponse { - fn from(c: &responses::SignmessageResponse) -> Self { ->>>>>>> bd301acdc... Setchannel request is provided Self { signature: hex::decode(&c.signature).unwrap(), // Rule #2 for type hex recid: hex::decode(&c.recid).unwrap(), // Rule #2 for type hex @@ -1554,26 +1549,22 @@ impl From for requests::PingRequest { } #[allow(unused_variables)] -<<<<<<< HEAD -impl From for requests::SignmessageRequest { - fn from(c: pb::SignmessageRequest) -> Self { -======= -impl From<&pb::SetchannelRequest> for requests::SetchannelRequest { - fn from(c: &pb::SetchannelRequest) -> Self { +impl From for requests::SetchannelRequest { + fn from(c: pb::SetchannelRequest) -> Self { Self { - id: c.id.clone(), // Rule #1 for type string - feebase: c.feebase.as_ref().map(|a| a.into()), // Rule #1 for type msat? - feeppm: c.feeppm.clone(), // Rule #1 for type u32? - htlcmin: c.htlcmin.as_ref().map(|a| a.into()), // Rule #1 for type msat? - htlcmax: c.htlcmax.as_ref().map(|a| a.into()), // Rule #1 for type msat? + id: c.id, // Rule #1 for type string + feebase: c.feebase.map(|a| a.into()), // Rule #1 for type msat? + feeppm: c.feeppm, // Rule #1 for type u32? + htlcmin: c.htlcmin.map(|a| a.into()), // Rule #1 for type msat? + htlcmax: c.htlcmax.map(|a| a.into()), // Rule #1 for type msat? + enforcedelay: c.enforcedelay, // Rule #1 for type u32? } } } #[allow(unused_variables)] -impl From<&pb::SignmessageRequest> for requests::SignmessageRequest { - fn from(c: &pb::SignmessageRequest) -> Self { ->>>>>>> bd301acdc... Setchannel request is provided +impl From for requests::SignmessageRequest { + fn from(c: pb::SignmessageRequest) -> Self { Self { message: c.message, // Rule #1 for type string } diff --git a/cln-grpc/src/server.rs b/cln-grpc/src/server.rs index 3196023e3..7759ca0a6 100644 --- a/cln-grpc/src/server.rs +++ b/cln-grpc/src/server.rs @@ -1439,7 +1439,7 @@ async fn set_channel( request: tonic::Request, ) -> Result, tonic::Status> { let req = request.into_inner(); - let req: requests::SetchannelRequest = (&req).into(); + let req: requests::SetchannelRequest = req.into(); debug!("Client asked for set_channel"); trace!("set_channel request: {:?}", req); let mut rpc = ClnRpc::new(&self.rpc_path) @@ -1453,7 +1453,7 @@ async fn set_channel( match result { Response::SetChannel(r) => { trace!("set_channel response: {:?}", r); - Ok(tonic::Response::new((&r).into())) + Ok(tonic::Response::new(r.into())) }, r => Err(Status::new( Code::Internal, diff --git a/cln-rpc/src/model.rs b/cln-rpc/src/model.rs index 3875d8157..25e23fdbe 100644 --- a/cln-rpc/src/model.rs +++ b/cln-rpc/src/model.rs @@ -1288,6 +1288,18 @@ pub mod requests { pub htlcmin: Option, #[serde(alias = "htlcmax", skip_serializing_if = "Option::is_none")] pub htlcmax: Option, + #[serde(alias = "enforcedelay", skip_serializing_if = "Option::is_none")] + pub enforcedelay: Option, + } + + impl From for Request { + fn from(r: SetchannelRequest) -> Self { + Request::SetChannel(r) + } + } + + impl IntoRequest for SetchannelRequest { + type Response = super::responses::SetchannelResponse; } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -3736,7 +3748,7 @@ pub mod responses { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SetchannelChannels { #[serde(alias = "peer_id")] - pub peer_id: Pubkey, + pub peer_id: PublicKey, #[serde(alias = "channel_id")] pub channel_id: String, #[serde(alias = "short_channel_id", skip_serializing_if = "Option::is_none")] @@ -3761,6 +3773,17 @@ pub mod responses { pub channels: Vec, } + impl TryFrom for SetchannelResponse { + type Error = super::TryFromResponseError; + + fn try_from(response: Response) -> Result { + match response { + Response::SetChannel(response) => Ok(response), + _ => Err(TryFromResponseError) + } + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SignmessageResponse { #[serde(alias = "signature")] diff --git a/doc/schemas/setchannel.request.json b/doc/schemas/setchannel.request.json index 871e2e416..fd47ffbc9 100644 --- a/doc/schemas/setchannel.request.json +++ b/doc/schemas/setchannel.request.json @@ -20,6 +20,9 @@ }, "htlcmax": { "type": "msat" + }, + "enforcedelay": { + "type": "u32" } } }