Skip to content

Commit 0eb65e4

Browse files
daywalker90endothermicdev
authored andcommitted
schemas: use sat and sat_or_all again where appropiate
Changelog-None
1 parent 964c073 commit 0eb65e4

20 files changed

+79
-48
lines changed

cln-grpc/src/convert.rs

Lines changed: 24 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/msggen/msggen/gen/grpc/convert.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def generate_composite(self, prefix, field: CompositeField, override=None):
100100
"u16?": f"c.{name}.map(|v| v.into())",
101101
"msat": f"Some(c.{name}.into())",
102102
"msat?": f"c.{name}.map(|f| f.into())",
103+
"sat": f"Some(c.{name}.into())",
104+
"sat?": f"c.{name}.map(|f| f.into())",
103105
"pubkey": f"c.{name}.serialize().to_vec()",
104106
"pubkey?": f"c.{name}.map(|v| v.serialize().to_vec())",
105107
"hex": f"hex::decode(&c.{name}).unwrap()",
@@ -115,6 +117,8 @@ def generate_composite(self, prefix, field: CompositeField, override=None):
115117
"msat_or_any": f"Some(c.{name}.into())",
116118
"msat_or_all": f"Some(c.{name}.into())",
117119
"msat_or_all?": f"c.{name}.map(|o|o.into())",
120+
"sat_or_all": f"Some(c.{name}.into())",
121+
"sat_or_all?": f"c.{name}.map(|o|o.into())",
118122
"feerate?": f"c.{name}.map(|o|o.into())",
119123
"feerate": f"Some(c.{name}.into())",
120124
"outpoint?": f"c.{name}.map(|o|o.into())",

contrib/msggen/msggen/gen/grpc/unconvert.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ def generate_composite(self, prefix, field: CompositeField, override=None) -> No
110110
"msat_or_all?": f"c.{name}.map(|a| a.into())",
111111
"msat_or_any": f"c.{name}.unwrap().into()",
112112
"msat_or_any?": f"c.{name}.map(|a| a.into())",
113+
"sat": f"c.{name}.unwrap().into()",
114+
"sat?": f"c.{name}.map(|a| a.into())",
115+
"sat_or_all": f"c.{name}.unwrap().into()",
116+
"sat_or_all?": f"c.{name}.map(|a| a.into())",
113117
"feerate": f"c.{name}.unwrap().into()",
114118
"feerate?": f"c.{name}.map(|a| a.into())",
115119
"outpoint?": f"c.{name}.map(|a| a.into())",

contrib/msggen/msggen/gen/grpc/util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"msat": "Amount",
1010
"msat_or_all": "AmountOrAll",
1111
"msat_or_any": "AmountOrAny",
12+
"sat": "Amount",
13+
"sat_or_all": "AmountOrAll",
1214
"currency": "string",
1315
"number": "double",
1416
"pubkey": "bytes",

contrib/msggen/msggen/gen/grpc2py.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(self, dest: TextIO):
5454
"boolean": "m.{name}",
5555
"short_channel_id": "m.{name}",
5656
"msat": "amount2msat(m.{name})",
57+
"sat": "amount2sat(m.{name})",
5758
"currency": "m.{name}",
5859
"number": "m.{name}",
5960
}
@@ -87,6 +88,10 @@ def amount2msat(a):
8788
return a.msat
8889
8990
91+
def amount2sat(a):
92+
return a.msat / 1000
93+
94+
9095
def remove_default(d):
9196
# grpc is really not good at empty values, they get replaced with the type's default value...
9297
return {k: v for k, v in d.items() if v is not None and v != ""}

contrib/msggen/msggen/gen/rpc/rust.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
"msat": "Amount",
2828
"msat_or_all": "AmountOrAll",
2929
"msat_or_any": "AmountOrAny",
30+
"sat": "Amount",
31+
"sat_or_all": "AmountOrAll",
3032
"currency": "String",
3133
"number": "f64",
3234
"pubkey": "PublicKey",

contrib/msggen/msggen/model.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ class PrimitiveField(Field):
415415
"msat",
416416
"msat_or_any",
417417
"msat_or_all",
418+
"sat",
419+
"sat_or_all",
418420
"currency",
419421
"hex",
420422
"short_channel_id",

0 commit comments

Comments
 (0)