schema: Add enforcedelay to setchannel

This was missing in the last version
This commit is contained in:
Christian Decker 2022-09-21 15:53:42 +02:00
parent 51e2433087
commit 93b315756f
6 changed files with 67 additions and 48 deletions

View file

@ -985,6 +985,7 @@
"SetChannel.channels[].warning_htlcmin_too_low": 7
},
"SetchannelRequest": {
"SetChannel.enforcedelay": 6,
"SetChannel.feebase": 2,
"SetChannel.feeppm": 3,
"SetChannel.htlcmax": 5,

View file

@ -1294,6 +1294,7 @@ message SetchannelRequest {
optional uint32 feeppm = 3;
optional Amount htlcmin = 4;
optional Amount htlcmax = 5;
optional uint32 enforcedelay = 6;
}
message SetchannelResponse {

View file

@ -961,39 +961,34 @@ impl From<responses::PingResponse> for pb::PingResponse {
}
#[allow(unused_variables)]
<<<<<<< HEAD
impl From<responses::SetchannelChannels> 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<responses::SetchannelResponse> 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<responses::SignmessageResponse> 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<pb::PingRequest> for requests::PingRequest {
}
#[allow(unused_variables)]
<<<<<<< HEAD
impl From<pb::SignmessageRequest> for requests::SignmessageRequest {
fn from(c: pb::SignmessageRequest) -> Self {
=======
impl From<&pb::SetchannelRequest> for requests::SetchannelRequest {
fn from(c: &pb::SetchannelRequest) -> Self {
impl From<pb::SetchannelRequest> 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<pb::SignmessageRequest> for requests::SignmessageRequest {
fn from(c: pb::SignmessageRequest) -> Self {
Self {
message: c.message, // Rule #1 for type string
}

View file

@ -1439,7 +1439,7 @@ async fn set_channel(
request: tonic::Request<pb::SetchannelRequest>,
) -> Result<tonic::Response<pb::SetchannelResponse>, 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,

25
cln-rpc/src/model.rs generated
View file

@ -1288,6 +1288,18 @@ pub mod requests {
pub htlcmin: Option<Amount>,
#[serde(alias = "htlcmax", skip_serializing_if = "Option::is_none")]
pub htlcmax: Option<Amount>,
#[serde(alias = "enforcedelay", skip_serializing_if = "Option::is_none")]
pub enforcedelay: Option<u32>,
}
impl From<SetchannelRequest> 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<SetchannelChannels>,
}
impl TryFrom<Response> for SetchannelResponse {
type Error = super::TryFromResponseError;
fn try_from(response: Response) -> Result<Self, Self::Error> {
match response {
Response::SetChannel(response) => Ok(response),
_ => Err(TryFromResponseError)
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SignmessageResponse {
#[serde(alias = "signature")]

View file

@ -20,6 +20,9 @@
},
"htlcmax": {
"type": "msat"
},
"enforcedelay": {
"type": "u32"
}
}
}