Skip to content

msggen: add missing methods for 24.11 #7549

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

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1,739 changes: 1,569 additions & 170 deletions .msggen.json

Large diffs are not rendered by default.

441 changes: 441 additions & 0 deletions cln-grpc/proto/node.proto

Large diffs are not rendered by default.

1,402 changes: 1,208 additions & 194 deletions cln-grpc/src/convert.rs

Large diffs are not rendered by default.

704 changes: 704 additions & 0 deletions cln-grpc/src/server.rs

Large diffs are not rendered by default.

9,183 changes: 5,261 additions & 3,922 deletions cln-rpc/src/model.rs

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions cln-rpc/src/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,60 @@ impl ShortChannelId {
}
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ShortChannelIdDir {
pub short_channel_id: ShortChannelId,
pub direction: u32,
}
impl Serialize for ShortChannelIdDir {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
serializer.serialize_str(&self.to_string())
}
}

impl<'de> Deserialize<'de> for ShortChannelIdDir {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
use serde::de::Error;
let s: String = Deserialize::deserialize(deserializer)?;
Ok(Self::from_str(&s).map_err(|e| Error::custom(e.to_string()))?)
}
}
impl FromStr for ShortChannelIdDir {
type Err = crate::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let parts: Result<Vec<String>, _> = s.split('/').map(|p| p.parse()).collect();
let parts = parts.with_context(|| format!("Malformed short_channel_id_dir: {}", s))?;
if parts.len() != 2 {
return Err(anyhow!(
"Malformed short_channel_id_dir: element count mismatch"
));
}

Ok(ShortChannelIdDir {
short_channel_id: ShortChannelId::from_str(&parts[0])?,
direction: parts[1].parse::<u32>()?,
})
}
}
impl Display for ShortChannelIdDir {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}x{}x{}/{}",
self.short_channel_id.block(),
self.short_channel_id.txindex(),
self.short_channel_id.outnum(),
self.direction
)
}
}

#[derive(Clone, Copy, Debug)]
pub struct Secret([u8; 32]);

Expand Down
4 changes: 4 additions & 0 deletions contrib/msggen/msggen/gen/grpc/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def generate_composite(self, prefix, field: CompositeField, override=None):
"secret": f"i.to_vec()",
"hash": f"<Sha256 as AsRef<[u8]>>::as_ref(&i).to_vec()",
"short_channel_id": f"i.to_string()",
"short_channel_id_dir": f"i.to_string()",
"pubkey": f"i.serialize().to_vec()",
}.get(typ, f"i.into()")

self.write(f"// Field: {f.path}\n", numindent=3)
Expand Down Expand Up @@ -110,6 +112,8 @@ def generate_composite(self, prefix, field: CompositeField, override=None):
"txid?": f"c.{name}.map(|v| hex::decode(v).unwrap())",
"short_channel_id": f"c.{name}.to_string()",
"short_channel_id?": f"c.{name}.map(|v| v.to_string())",
"short_channel_id_dir": f"c.{name}.to_string()",
"short_channel_id_dir?": f"c.{name}.map(|v| v.to_string())",
"hash": f"<Sha256 as AsRef<[u8]>>::as_ref(&c.{name}).to_vec()",
"hash?": f"c.{name}.map(|v| <Sha256 as AsRef<[u8]>>::as_ref(&v).to_vec())",
"secret": f"c.{name}.to_vec()",
Expand Down
4 changes: 4 additions & 0 deletions contrib/msggen/msggen/gen/grpc/unconvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def generate_composite(self, prefix, field: CompositeField, override=None) -> No
"secret": f"s.try_into().unwrap()",
"hash": f"Sha256::from_slice(&s).unwrap()",
"short_channel_id": f"cln_rpc::primitives::ShortChannelId::from_str(&s).unwrap()",
"short_channel_id_dir": f"cln_rpc::primitives::ShortChannelIdDir::from_str(&s).unwrap()",
"pubkey": f"PublicKey::from_slice(&s).unwrap()",
}.get(typ, f"s.into()")

# TODO fix properly
Expand Down Expand Up @@ -121,6 +123,8 @@ def generate_composite(self, prefix, field: CompositeField, override=None) -> No
"DecodeRoutehintList?": f"c.{name}.map(|drl| drl.into())",
"short_channel_id": f"cln_rpc::primitives::ShortChannelId::from_str(&c.{name}).unwrap()",
"short_channel_id?": f"c.{name}.map(|v| cln_rpc::primitives::ShortChannelId::from_str(&v).unwrap())",
"short_channel_id_dir": f"cln_rpc::primitives::ShortChannelIdDir::from_str(&c.{name}).unwrap()",
"short_channel_id_dir?": f"c.{name}.map(|v| cln_rpc::primitives::ShortChannelIdDir::from_str(&v).unwrap())",
"secret": f"c.{name}.try_into().unwrap()",
"secret?": f"c.{name}.map(|v| v.try_into().unwrap())",
"hash": f"Sha256::from_slice(&c.{name}).unwrap()",
Expand Down
1 change: 1 addition & 0 deletions contrib/msggen/msggen/gen/grpc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"number": "double",
"pubkey": "bytes",
"short_channel_id": "string",
"short_channel_id_dir": "string",
"signature": "string",
"string": "string",
"txid": "bytes",
Expand Down
1 change: 1 addition & 0 deletions contrib/msggen/msggen/gen/grpc2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(self, dest: TextIO):
"integer": "m.{name}",
"boolean": "m.{name}",
"short_channel_id": "m.{name}",
"short_channel_id_dir": "m.{name}",
"msat": "amount2msat(m.{name})",
"sat": "amount2sat(m.{name})",
"currency": "m.{name}",
Expand Down
1 change: 1 addition & 0 deletions contrib/msggen/msggen/gen/rpc/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"number": "f64",
"pubkey": "PublicKey",
"short_channel_id": "ShortChannelId",
"short_channel_id_dir": "ShortChannelIdDir",
"signature": "String",
"string": "String",
"txid": "String",
Expand Down
22 changes: 22 additions & 0 deletions contrib/msggen/msggen/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"DelInvoice",
"Dev-Forget-Channel",
"EmergencyRecover",
"GetEmergencyRecoverData",
"ExposeSecret",
"Recover",
"RecoverChannel",
"Invoice",
Expand Down Expand Up @@ -60,6 +62,7 @@
"DelPay",
"DelForward",
"DisableOffer",
"EnableOffer",
"Disconnect",
"Feerates",
"FetchInvoice",
Expand All @@ -70,6 +73,7 @@
"GetLog",
"FunderUpdate",
"GetRoute",
"ListAddresses",
"ListForwards",
"ListOffers",
"ListPays",
Expand Down Expand Up @@ -98,6 +102,7 @@
"Splice_Init",
"Splice_Signed",
"Splice_Update",
"Dev-Splice",
"UnreserveInputs",
"UpgradeWallet",
"WaitBlockHeight",
Expand All @@ -116,10 +121,27 @@
"Bkpr-ListAccountEvents",
"Bkpr-ListBalances",
"Bkpr-ListIncome",
"Bkpr-EditDescriptionByPaymentId",
"Bkpr-EditDescriptionByOutpoint",
"BlacklistRune",
"CheckRune",
"CreateRune",
"ShowRunes",
"AskRene-Unreserve",
"AskRene-ListLayers",
"AskRene-Create-Layer",
"AskRene-Remove-Layer",
"AskRene-Reserve",
"AskRene-Age",
"GetRoutes",
"AskRene-Disable-Node",
"AskRene-Inform-Channel",
"AskRene-Create-Channel",
"AskRene-Update-Channel",
"AskRene-Bias-Channel",
"AskRene-ListReservations",
"InjectPaymentOnion",
"Xpay",
]

grpc_notification_names = [
Expand Down
1,752 changes: 943 additions & 809 deletions contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py

Large diffs are not rendered by default.

Loading
Loading