schemas: use sat and sat_or_all again where appropiate

Changelog-None
This commit is contained in:
daywalker90 2024-05-24 12:50:20 +02:00 committed by Alex Myers
parent 964c0732cf
commit 0eb65e4bb5
20 changed files with 79 additions and 48 deletions

View file

@ -4045,7 +4045,7 @@ impl From<requests::AddpsbtoutputRequest> for pb::AddpsbtoutputRequest {
destination: c.destination, // Rule #2 for type string? destination: c.destination, // Rule #2 for type string?
initialpsbt: c.initialpsbt, // Rule #2 for type string? initialpsbt: c.initialpsbt, // Rule #2 for type string?
locktime: c.locktime, // Rule #2 for type u32? locktime: c.locktime, // Rule #2 for type u32?
satoshi: Some(c.satoshi.into()), // Rule #2 for type msat satoshi: Some(c.satoshi.into()), // Rule #2 for type sat
} }
} }
} }
@ -4455,7 +4455,7 @@ impl From<requests::WithdrawRequest> for pb::WithdrawRequest {
destination: c.destination, // Rule #2 for type string destination: c.destination, // Rule #2 for type string
feerate: c.feerate.map(|o|o.into()), // Rule #2 for type feerate? feerate: c.feerate.map(|o|o.into()), // Rule #2 for type feerate?
minconf: c.minconf.map(|v| v.into()), // Rule #2 for type u16? minconf: c.minconf.map(|v| v.into()), // Rule #2 for type u16?
satoshi: Some(c.satoshi.into()), // Rule #2 for type msat_or_all satoshi: Some(c.satoshi.into()), // Rule #2 for type sat_or_all
// Field: Withdraw.utxos[] // Field: Withdraw.utxos[]
utxos: c.utxos.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 utxos: c.utxos.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3
} }
@ -4491,7 +4491,7 @@ impl From<requests::FundpsbtRequest> for pb::FundpsbtRequest {
nonwrapped: c.nonwrapped, // Rule #2 for type boolean? nonwrapped: c.nonwrapped, // Rule #2 for type boolean?
opening_anchor_channel: c.opening_anchor_channel, // Rule #2 for type boolean? opening_anchor_channel: c.opening_anchor_channel, // Rule #2 for type boolean?
reserve: c.reserve, // Rule #2 for type u32? reserve: c.reserve, // Rule #2 for type u32?
satoshi: Some(c.satoshi.into()), // Rule #2 for type msat_or_all satoshi: Some(c.satoshi.into()), // Rule #2 for type sat_or_all
startweight: c.startweight, // Rule #2 for type u32 startweight: c.startweight, // Rule #2 for type u32
} }
} }
@ -4529,7 +4529,7 @@ impl From<requests::UtxopsbtRequest> for pb::UtxopsbtRequest {
opening_anchor_channel: c.opening_anchor_channel, // Rule #2 for type boolean? opening_anchor_channel: c.opening_anchor_channel, // Rule #2 for type boolean?
reserve: c.reserve, // Rule #2 for type u32? reserve: c.reserve, // Rule #2 for type u32?
reservedok: c.reservedok, // Rule #2 for type boolean? reservedok: c.reservedok, // Rule #2 for type boolean?
satoshi: Some(c.satoshi.into()), // Rule #2 for type msat_or_all satoshi: Some(c.satoshi.into()), // Rule #2 for type sat_or_all
startweight: c.startweight, // Rule #2 for type u32 startweight: c.startweight, // Rule #2 for type u32
// Field: UtxoPsbt.utxos[] // Field: UtxoPsbt.utxos[]
utxos: c.utxos.into_iter().map(|i| i.into()).collect(), // Rule #3 for type outpoint utxos: c.utxos.into_iter().map(|i| i.into()).collect(), // Rule #3 for type outpoint
@ -4696,7 +4696,7 @@ impl From<requests::Fundchannel_completeRequest> for pb::FundchannelCompleteRequ
impl From<requests::FundchannelRequest> for pb::FundchannelRequest { impl From<requests::FundchannelRequest> for pb::FundchannelRequest {
fn from(c: requests::FundchannelRequest) -> Self { fn from(c: requests::FundchannelRequest) -> Self {
Self { Self {
amount: Some(c.amount.into()), // Rule #2 for type msat_or_all amount: Some(c.amount.into()), // Rule #2 for type sat_or_all
announce: c.announce, // Rule #2 for type boolean? announce: c.announce, // Rule #2 for type boolean?
// Field: FundChannel.channel_type[] // Field: FundChannel.channel_type[]
channel_type: c.channel_type.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 channel_type: c.channel_type.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3
@ -4708,7 +4708,7 @@ impl From<requests::FundchannelRequest> for pb::FundchannelRequest {
mindepth: c.mindepth, // Rule #2 for type u32? mindepth: c.mindepth, // Rule #2 for type u32?
push_msat: c.push_msat.map(|f| f.into()), // Rule #2 for type msat? push_msat: c.push_msat.map(|f| f.into()), // Rule #2 for type msat?
request_amt: c.request_amt.map(|f| f.into()), // Rule #2 for type msat? request_amt: c.request_amt.map(|f| f.into()), // Rule #2 for type msat?
reserve: c.reserve.map(|f| f.into()), // Rule #2 for type msat? reserve: c.reserve.map(|f| f.into()), // Rule #2 for type sat?
// Field: FundChannel.utxos[] // Field: FundChannel.utxos[]
utxos: c.utxos.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 utxos: c.utxos.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3
} }
@ -4719,7 +4719,7 @@ impl From<requests::FundchannelRequest> for pb::FundchannelRequest {
impl From<requests::Fundchannel_startRequest> for pb::FundchannelStartRequest { impl From<requests::Fundchannel_startRequest> for pb::FundchannelStartRequest {
fn from(c: requests::Fundchannel_startRequest) -> Self { fn from(c: requests::Fundchannel_startRequest) -> Self {
Self { Self {
amount: Some(c.amount.into()), // Rule #2 for type msat amount: Some(c.amount.into()), // Rule #2 for type sat
announce: c.announce, // Rule #2 for type boolean? announce: c.announce, // Rule #2 for type boolean?
// Field: FundChannel_Start.channel_type[] // Field: FundChannel_Start.channel_type[]
channel_type: c.channel_type.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 channel_type: c.channel_type.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3
@ -4728,7 +4728,7 @@ impl From<requests::Fundchannel_startRequest> for pb::FundchannelStartRequest {
id: c.id.serialize().to_vec(), // Rule #2 for type pubkey id: c.id.serialize().to_vec(), // Rule #2 for type pubkey
mindepth: c.mindepth, // Rule #2 for type u32? mindepth: c.mindepth, // Rule #2 for type u32?
push_msat: c.push_msat.map(|f| f.into()), // Rule #2 for type msat? push_msat: c.push_msat.map(|f| f.into()), // Rule #2 for type msat?
reserve: c.reserve.map(|f| f.into()), // Rule #2 for type msat? reserve: c.reserve.map(|f| f.into()), // Rule #2 for type sat?
} }
} }
} }
@ -4831,7 +4831,7 @@ impl From<requests::ListhtlcsRequest> for pb::ListhtlcsRequest {
impl From<requests::MultifundchannelDestinations> for pb::MultifundchannelDestinations { impl From<requests::MultifundchannelDestinations> for pb::MultifundchannelDestinations {
fn from(c: requests::MultifundchannelDestinations) -> Self { fn from(c: requests::MultifundchannelDestinations) -> Self {
Self { Self {
amount: Some(c.amount.into()), // Rule #2 for type msat_or_all amount: Some(c.amount.into()), // Rule #2 for type sat_or_all
announce: c.announce, // Rule #2 for type boolean? announce: c.announce, // Rule #2 for type boolean?
close_to: c.close_to, // Rule #2 for type string? close_to: c.close_to, // Rule #2 for type string?
compact_lease: c.compact_lease, // Rule #2 for type string? compact_lease: c.compact_lease, // Rule #2 for type string?
@ -4839,7 +4839,7 @@ impl From<requests::MultifundchannelDestinations> for pb::MultifundchannelDestin
mindepth: c.mindepth, // Rule #2 for type u32? mindepth: c.mindepth, // Rule #2 for type u32?
push_msat: c.push_msat.map(|f| f.into()), // Rule #2 for type msat? push_msat: c.push_msat.map(|f| f.into()), // Rule #2 for type msat?
request_amt: c.request_amt.map(|f| f.into()), // Rule #2 for type msat? request_amt: c.request_amt.map(|f| f.into()), // Rule #2 for type msat?
reserve: c.reserve.map(|f| f.into()), // Rule #2 for type msat? reserve: c.reserve.map(|f| f.into()), // Rule #2 for type sat?
} }
} }
} }
@ -4906,7 +4906,7 @@ impl From<requests::Openchannel_abortRequest> for pb::OpenchannelAbortRequest {
impl From<requests::Openchannel_bumpRequest> for pb::OpenchannelBumpRequest { impl From<requests::Openchannel_bumpRequest> for pb::OpenchannelBumpRequest {
fn from(c: requests::Openchannel_bumpRequest) -> Self { fn from(c: requests::Openchannel_bumpRequest) -> Self {
Self { Self {
amount: Some(c.amount.into()), // Rule #2 for type msat amount: Some(c.amount.into()), // Rule #2 for type sat
channel_id: <Sha256 as AsRef<[u8]>>::as_ref(&c.channel_id).to_vec(), // Rule #2 for type hash channel_id: <Sha256 as AsRef<[u8]>>::as_ref(&c.channel_id).to_vec(), // Rule #2 for type hash
funding_feerate: c.funding_feerate.map(|o|o.into()), // Rule #2 for type feerate? funding_feerate: c.funding_feerate.map(|o|o.into()), // Rule #2 for type feerate?
initialpsbt: c.initialpsbt, // Rule #2 for type string initialpsbt: c.initialpsbt, // Rule #2 for type string
@ -4918,7 +4918,7 @@ impl From<requests::Openchannel_bumpRequest> for pb::OpenchannelBumpRequest {
impl From<requests::Openchannel_initRequest> for pb::OpenchannelInitRequest { impl From<requests::Openchannel_initRequest> for pb::OpenchannelInitRequest {
fn from(c: requests::Openchannel_initRequest) -> Self { fn from(c: requests::Openchannel_initRequest) -> Self {
Self { Self {
amount: Some(c.amount.into()), // Rule #2 for type msat amount: Some(c.amount.into()), // Rule #2 for type sat
announce: c.announce, // Rule #2 for type boolean? announce: c.announce, // Rule #2 for type boolean?
// Field: OpenChannel_Init.channel_type[] // Field: OpenChannel_Init.channel_type[]
channel_type: c.channel_type.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 channel_type: c.channel_type.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3
@ -5469,7 +5469,7 @@ impl From<pb::AddpsbtoutputRequest> for requests::AddpsbtoutputRequest {
destination: c.destination, // Rule #1 for type string? destination: c.destination, // Rule #1 for type string?
initialpsbt: c.initialpsbt, // Rule #1 for type string? initialpsbt: c.initialpsbt, // Rule #1 for type string?
locktime: c.locktime, // Rule #1 for type u32? locktime: c.locktime, // Rule #1 for type u32?
satoshi: c.satoshi.unwrap().into(), // Rule #1 for type msat satoshi: c.satoshi.unwrap().into(), // Rule #1 for type sat
} }
} }
} }
@ -5868,7 +5868,7 @@ impl From<pb::WithdrawRequest> for requests::WithdrawRequest {
destination: c.destination, // Rule #1 for type string destination: c.destination, // Rule #1 for type string
feerate: c.feerate.map(|a| a.into()), // Rule #1 for type feerate? feerate: c.feerate.map(|a| a.into()), // Rule #1 for type feerate?
minconf: c.minconf.map(|v| v as u16), // Rule #1 for type u16? minconf: c.minconf.map(|v| v as u16), // Rule #1 for type u16?
satoshi: c.satoshi.unwrap().into(), // Rule #1 for type msat_or_all satoshi: c.satoshi.unwrap().into(), // Rule #1 for type sat_or_all
utxos: Some(c.utxos.into_iter().map(|s| s.into()).collect()), // Rule #4 utxos: Some(c.utxos.into_iter().map(|s| s.into()).collect()), // Rule #4
} }
} }
@ -5903,7 +5903,7 @@ impl From<pb::FundpsbtRequest> for requests::FundpsbtRequest {
nonwrapped: c.nonwrapped, // Rule #1 for type boolean? nonwrapped: c.nonwrapped, // Rule #1 for type boolean?
opening_anchor_channel: c.opening_anchor_channel, // Rule #1 for type boolean? opening_anchor_channel: c.opening_anchor_channel, // Rule #1 for type boolean?
reserve: c.reserve, // Rule #1 for type u32? reserve: c.reserve, // Rule #1 for type u32?
satoshi: c.satoshi.unwrap().into(), // Rule #1 for type msat_or_all satoshi: c.satoshi.unwrap().into(), // Rule #1 for type sat_or_all
startweight: c.startweight, // Rule #1 for type u32 startweight: c.startweight, // Rule #1 for type u32
} }
} }
@ -5940,7 +5940,7 @@ impl From<pb::UtxopsbtRequest> for requests::UtxopsbtRequest {
opening_anchor_channel: c.opening_anchor_channel, // Rule #1 for type boolean? opening_anchor_channel: c.opening_anchor_channel, // Rule #1 for type boolean?
reserve: c.reserve, // Rule #1 for type u32? reserve: c.reserve, // Rule #1 for type u32?
reservedok: c.reservedok, // Rule #1 for type boolean? reservedok: c.reservedok, // Rule #1 for type boolean?
satoshi: c.satoshi.unwrap().into(), // Rule #1 for type msat_or_all satoshi: c.satoshi.unwrap().into(), // Rule #1 for type sat_or_all
startweight: c.startweight, // Rule #1 for type u32 startweight: c.startweight, // Rule #1 for type u32
utxos: c.utxos.into_iter().map(|s| s.into()).collect(), // Rule #4 utxos: c.utxos.into_iter().map(|s| s.into()).collect(), // Rule #4
} }
@ -6104,7 +6104,7 @@ impl From<pb::FundchannelCompleteRequest> for requests::Fundchannel_completeRequ
impl From<pb::FundchannelRequest> for requests::FundchannelRequest { impl From<pb::FundchannelRequest> for requests::FundchannelRequest {
fn from(c: pb::FundchannelRequest) -> Self { fn from(c: pb::FundchannelRequest) -> Self {
Self { Self {
amount: c.amount.unwrap().into(), // Rule #1 for type msat_or_all amount: c.amount.unwrap().into(), // Rule #1 for type sat_or_all
announce: c.announce, // Rule #1 for type boolean? announce: c.announce, // Rule #1 for type boolean?
channel_type: Some(c.channel_type.into_iter().map(|s| s).collect()), // Rule #4 channel_type: Some(c.channel_type.into_iter().map(|s| s).collect()), // Rule #4
close_to: c.close_to, // Rule #1 for type string? close_to: c.close_to, // Rule #1 for type string?
@ -6115,7 +6115,7 @@ impl From<pb::FundchannelRequest> for requests::FundchannelRequest {
mindepth: c.mindepth, // Rule #1 for type u32? mindepth: c.mindepth, // Rule #1 for type u32?
push_msat: c.push_msat.map(|a| a.into()), // Rule #1 for type msat? push_msat: c.push_msat.map(|a| a.into()), // Rule #1 for type msat?
request_amt: c.request_amt.map(|a| a.into()), // Rule #1 for type msat? request_amt: c.request_amt.map(|a| a.into()), // Rule #1 for type msat?
reserve: c.reserve.map(|a| a.into()), // Rule #1 for type msat? reserve: c.reserve.map(|a| a.into()), // Rule #1 for type sat?
utxos: Some(c.utxos.into_iter().map(|s| s.into()).collect()), // Rule #4 utxos: Some(c.utxos.into_iter().map(|s| s.into()).collect()), // Rule #4
} }
} }
@ -6125,7 +6125,7 @@ impl From<pb::FundchannelRequest> for requests::FundchannelRequest {
impl From<pb::FundchannelStartRequest> for requests::Fundchannel_startRequest { impl From<pb::FundchannelStartRequest> for requests::Fundchannel_startRequest {
fn from(c: pb::FundchannelStartRequest) -> Self { fn from(c: pb::FundchannelStartRequest) -> Self {
Self { Self {
amount: c.amount.unwrap().into(), // Rule #1 for type msat amount: c.amount.unwrap().into(), // Rule #1 for type sat
announce: c.announce, // Rule #1 for type boolean? announce: c.announce, // Rule #1 for type boolean?
channel_type: Some(c.channel_type.into_iter().map(|s| s).collect()), // Rule #4 channel_type: Some(c.channel_type.into_iter().map(|s| s).collect()), // Rule #4
close_to: c.close_to, // Rule #1 for type string? close_to: c.close_to, // Rule #1 for type string?
@ -6133,7 +6133,7 @@ impl From<pb::FundchannelStartRequest> for requests::Fundchannel_startRequest {
id: PublicKey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey id: PublicKey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey
mindepth: c.mindepth, // Rule #1 for type u32? mindepth: c.mindepth, // Rule #1 for type u32?
push_msat: c.push_msat.map(|a| a.into()), // Rule #1 for type msat? push_msat: c.push_msat.map(|a| a.into()), // Rule #1 for type msat?
reserve: c.reserve.map(|a| a.into()), // Rule #1 for type msat? reserve: c.reserve.map(|a| a.into()), // Rule #1 for type sat?
} }
} }
} }
@ -6235,7 +6235,7 @@ impl From<pb::ListhtlcsRequest> for requests::ListhtlcsRequest {
impl From<pb::MultifundchannelDestinations> for requests::MultifundchannelDestinations { impl From<pb::MultifundchannelDestinations> for requests::MultifundchannelDestinations {
fn from(c: pb::MultifundchannelDestinations) -> Self { fn from(c: pb::MultifundchannelDestinations) -> Self {
Self { Self {
amount: c.amount.unwrap().into(), // Rule #1 for type msat_or_all amount: c.amount.unwrap().into(), // Rule #1 for type sat_or_all
announce: c.announce, // Rule #1 for type boolean? announce: c.announce, // Rule #1 for type boolean?
close_to: c.close_to, // Rule #1 for type string? close_to: c.close_to, // Rule #1 for type string?
compact_lease: c.compact_lease, // Rule #1 for type string? compact_lease: c.compact_lease, // Rule #1 for type string?
@ -6243,7 +6243,7 @@ impl From<pb::MultifundchannelDestinations> for requests::MultifundchannelDestin
mindepth: c.mindepth, // Rule #1 for type u32? mindepth: c.mindepth, // Rule #1 for type u32?
push_msat: c.push_msat.map(|a| a.into()), // Rule #1 for type msat? push_msat: c.push_msat.map(|a| a.into()), // Rule #1 for type msat?
request_amt: c.request_amt.map(|a| a.into()), // Rule #1 for type msat? request_amt: c.request_amt.map(|a| a.into()), // Rule #1 for type msat?
reserve: c.reserve.map(|a| a.into()), // Rule #1 for type msat? reserve: c.reserve.map(|a| a.into()), // Rule #1 for type sat?
} }
} }
} }
@ -6306,7 +6306,7 @@ impl From<pb::OpenchannelAbortRequest> for requests::Openchannel_abortRequest {
impl From<pb::OpenchannelBumpRequest> for requests::Openchannel_bumpRequest { impl From<pb::OpenchannelBumpRequest> for requests::Openchannel_bumpRequest {
fn from(c: pb::OpenchannelBumpRequest) -> Self { fn from(c: pb::OpenchannelBumpRequest) -> Self {
Self { Self {
amount: c.amount.unwrap().into(), // Rule #1 for type msat amount: c.amount.unwrap().into(), // Rule #1 for type sat
channel_id: Sha256::from_slice(&c.channel_id).unwrap(), // Rule #1 for type hash channel_id: Sha256::from_slice(&c.channel_id).unwrap(), // Rule #1 for type hash
funding_feerate: c.funding_feerate.map(|a| a.into()), // Rule #1 for type feerate? funding_feerate: c.funding_feerate.map(|a| a.into()), // Rule #1 for type feerate?
initialpsbt: c.initialpsbt, // Rule #1 for type string initialpsbt: c.initialpsbt, // Rule #1 for type string
@ -6318,7 +6318,7 @@ impl From<pb::OpenchannelBumpRequest> for requests::Openchannel_bumpRequest {
impl From<pb::OpenchannelInitRequest> for requests::Openchannel_initRequest { impl From<pb::OpenchannelInitRequest> for requests::Openchannel_initRequest {
fn from(c: pb::OpenchannelInitRequest) -> Self { fn from(c: pb::OpenchannelInitRequest) -> Self {
Self { Self {
amount: c.amount.unwrap().into(), // Rule #1 for type msat amount: c.amount.unwrap().into(), // Rule #1 for type sat
announce: c.announce, // Rule #1 for type boolean? announce: c.announce, // Rule #1 for type boolean?
channel_type: Some(c.channel_type.into_iter().map(|s| s).collect()), // Rule #4 channel_type: Some(c.channel_type.into_iter().map(|s| s).collect()), // Rule #4
close_to: c.close_to, // Rule #1 for type string? close_to: c.close_to, // Rule #1 for type string?

View file

@ -100,6 +100,8 @@ class GrpcConverterGenerator(IGenerator):
"u16?": f"c.{name}.map(|v| v.into())", "u16?": f"c.{name}.map(|v| v.into())",
"msat": f"Some(c.{name}.into())", "msat": f"Some(c.{name}.into())",
"msat?": f"c.{name}.map(|f| f.into())", "msat?": f"c.{name}.map(|f| f.into())",
"sat": f"Some(c.{name}.into())",
"sat?": f"c.{name}.map(|f| f.into())",
"pubkey": f"c.{name}.serialize().to_vec()", "pubkey": f"c.{name}.serialize().to_vec()",
"pubkey?": f"c.{name}.map(|v| v.serialize().to_vec())", "pubkey?": f"c.{name}.map(|v| v.serialize().to_vec())",
"hex": f"hex::decode(&c.{name}).unwrap()", "hex": f"hex::decode(&c.{name}).unwrap()",
@ -115,6 +117,8 @@ class GrpcConverterGenerator(IGenerator):
"msat_or_any": f"Some(c.{name}.into())", "msat_or_any": f"Some(c.{name}.into())",
"msat_or_all": f"Some(c.{name}.into())", "msat_or_all": f"Some(c.{name}.into())",
"msat_or_all?": f"c.{name}.map(|o|o.into())", "msat_or_all?": f"c.{name}.map(|o|o.into())",
"sat_or_all": f"Some(c.{name}.into())",
"sat_or_all?": f"c.{name}.map(|o|o.into())",
"feerate?": f"c.{name}.map(|o|o.into())", "feerate?": f"c.{name}.map(|o|o.into())",
"feerate": f"Some(c.{name}.into())", "feerate": f"Some(c.{name}.into())",
"outpoint?": f"c.{name}.map(|o|o.into())", "outpoint?": f"c.{name}.map(|o|o.into())",

View file

@ -110,6 +110,10 @@ class GrpcUnconverterGenerator(GrpcConverterGenerator):
"msat_or_all?": f"c.{name}.map(|a| a.into())", "msat_or_all?": f"c.{name}.map(|a| a.into())",
"msat_or_any": f"c.{name}.unwrap().into()", "msat_or_any": f"c.{name}.unwrap().into()",
"msat_or_any?": f"c.{name}.map(|a| a.into())", "msat_or_any?": f"c.{name}.map(|a| a.into())",
"sat": f"c.{name}.unwrap().into()",
"sat?": f"c.{name}.map(|a| a.into())",
"sat_or_all": f"c.{name}.unwrap().into()",
"sat_or_all?": f"c.{name}.map(|a| a.into())",
"feerate": f"c.{name}.unwrap().into()", "feerate": f"c.{name}.unwrap().into()",
"feerate?": f"c.{name}.map(|a| a.into())", "feerate?": f"c.{name}.map(|a| a.into())",
"outpoint?": f"c.{name}.map(|a| a.into())", "outpoint?": f"c.{name}.map(|a| a.into())",

View file

@ -9,6 +9,8 @@ typemap = {
"msat": "Amount", "msat": "Amount",
"msat_or_all": "AmountOrAll", "msat_or_all": "AmountOrAll",
"msat_or_any": "AmountOrAny", "msat_or_any": "AmountOrAny",
"sat": "Amount",
"sat_or_all": "AmountOrAll",
"currency": "string", "currency": "string",
"number": "double", "number": "double",
"pubkey": "bytes", "pubkey": "bytes",

View file

@ -54,6 +54,7 @@ class Grpc2PyGenerator(IGenerator):
"boolean": "m.{name}", "boolean": "m.{name}",
"short_channel_id": "m.{name}", "short_channel_id": "m.{name}",
"msat": "amount2msat(m.{name})", "msat": "amount2msat(m.{name})",
"sat": "amount2sat(m.{name})",
"currency": "m.{name}", "currency": "m.{name}",
"number": "m.{name}", "number": "m.{name}",
} }
@ -87,6 +88,10 @@ class Grpc2PyGenerator(IGenerator):
return a.msat return a.msat
def amount2sat(a):
return a.msat / 1000
def remove_default(d): def remove_default(d):
# grpc is really not good at empty values, they get replaced with the type's default value... # grpc is really not good at empty values, they get replaced with the type's default value...
return {k: v for k, v in d.items() if v is not None and v != ""} return {k: v for k, v in d.items() if v is not None and v != ""}

View file

@ -27,6 +27,8 @@ typemap = {
"msat": "Amount", "msat": "Amount",
"msat_or_all": "AmountOrAll", "msat_or_all": "AmountOrAll",
"msat_or_any": "AmountOrAny", "msat_or_any": "AmountOrAny",
"sat": "Amount",
"sat_or_all": "AmountOrAll",
"currency": "String", "currency": "String",
"number": "f64", "number": "f64",
"pubkey": "PublicKey", "pubkey": "PublicKey",

View file

@ -415,6 +415,8 @@ class PrimitiveField(Field):
"msat", "msat",
"msat_or_any", "msat_or_any",
"msat_or_all", "msat_or_all",
"sat",
"sat_or_all",
"currency", "currency",
"hex", "hex",
"short_channel_id", "short_channel_id",

View file

@ -79,7 +79,7 @@
], ],
"properties": { "properties": {
"satoshi": { "satoshi": {
"type": "msat", "type": "sat",
"description": [ "description": [
"The satoshi value of the output. It can be a whole number, a whole number ending in *sat*, or a number with 1 to 8 decimal places ending in *btc*." "The satoshi value of the output. It can be a whole number, a whole number ending in *sat*, or a number with 1 to 8 decimal places ending in *btc*."
] ]
@ -10047,7 +10047,7 @@
] ]
}, },
"amount": { "amount": {
"type": "msat_or_all", "type": "sat_or_all",
"description": [ "description": [
"The amount in satoshis taken from the internal wallet to fund the channel (but if we have any anchor channels, this will always leave at least `min-emergency- msat` as change). The string *all* can be used to specify all available funds (or 16777215 satoshi if more is available and large channels were not negotiated with the peer). Otherwise, it is in satoshi precision; it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*. The value cannot be less than the dust limit, currently set to 546, nor more than 16777215 satoshi (unless large channels were negotiated with the peer)." "The amount in satoshis taken from the internal wallet to fund the channel (but if we have any anchor channels, this will always leave at least `min-emergency- msat` as change). The string *all* can be used to specify all available funds (or 16777215 satoshi if more is available and large channels were not negotiated with the peer). Otherwise, it is in satoshi precision; it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*. The value cannot be less than the dust limit, currently set to 546, nor more than 16777215 satoshi (unless large channels were negotiated with the peer)."
] ]
@ -10113,7 +10113,7 @@
"type": "u32" "type": "u32"
}, },
"reserve": { "reserve": {
"type": "msat", "type": "sat",
"description": [ "description": [
"The amount we want the peer to maintain on its side of the channel. It can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*." "The amount we want the peer to maintain on its side of the channel. It can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*."
], ],
@ -10544,7 +10544,7 @@
] ]
}, },
"amount": { "amount": {
"type": "msat", "type": "sat",
"description": [ "description": [
"Satoshi value that the channel will be funded at. This value MUST be accurate, otherwise the negotiated commitment transactions will not encompass the correct channel value." "Satoshi value that the channel will be funded at. This value MUST be accurate, otherwise the negotiated commitment transactions will not encompass the correct channel value."
] ]
@ -10580,7 +10580,7 @@
] ]
}, },
"reserve": { "reserve": {
"type": "msat", "type": "sat",
"description": [ "description": [
"The amount we want the peer to maintain on its side." "The amount we want the peer to maintain on its side."
] ]
@ -11132,7 +11132,7 @@
], ],
"properties": { "properties": {
"satoshi": { "satoshi": {
"type": "msat_or_all", "type": "sat_or_all",
"description": [ "description": [
"The minimum satoshi value of the output(s) needed (or the string `all` meaning use all unreserved inputs). If a value, it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*." "The minimum satoshi value of the output(s) needed (or the string `all` meaning use all unreserved inputs). If a value, it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*."
] ]
@ -22271,7 +22271,7 @@
] ]
}, },
"amount": { "amount": {
"type": "msat_or_all", "type": "sat_or_all",
"description": [ "description": [
"Amount in satoshis taken from the internal wallet to fund the channel (but if we have any anchor channels, this will always leave at least `min-emergency-msat` as change). The string *all* can be used to specify all available funds (or 16,777,215 satoshi if more is available and large channels were not negotiated with the peer). Otherwise it is in satoshi precision; it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*. The value cannot be less than the dust limit, currently 546 satoshi as of this writing, nor more than 16,777,215 satoshi (unless large channels were negotiated with the peer)." "Amount in satoshis taken from the internal wallet to fund the channel (but if we have any anchor channels, this will always leave at least `min-emergency-msat` as change). The string *all* can be used to specify all available funds (or 16,777,215 satoshi if more is available and large channels were not negotiated with the peer). Otherwise it is in satoshi precision; it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*. The value cannot be less than the dust limit, currently 546 satoshi as of this writing, nor more than 16,777,215 satoshi (unless large channels were negotiated with the peer)."
] ]
@ -22314,7 +22314,7 @@
] ]
}, },
"reserve": { "reserve": {
"type": "msat", "type": "sat",
"description": [ "description": [
"Amount we want the peer to maintain on its side of the channel. It can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*." "Amount we want the peer to maintain on its side of the channel. It can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*."
], ],
@ -23376,7 +23376,7 @@
] ]
}, },
"amount": { "amount": {
"type": "msat", "type": "sat",
"description": [ "description": [
"Satoshi value that we will contribute to the channel. This value will be _added_ to the provided PSBT in the output which is encumbered by the 2-of-2 script for this channel." "Satoshi value that we will contribute to the channel. This value will be _added_ to the provided PSBT in the output which is encumbered by the 2-of-2 script for this channel."
] ]
@ -23546,7 +23546,7 @@
] ]
}, },
"amount": { "amount": {
"type": "msat", "type": "sat",
"description": [ "description": [
"Satoshi value that we will contribute to the channel. This value will be _added_ to the provided PSBT in the output which is encumbered by the 2-of-2 script for this channel." "Satoshi value that we will contribute to the channel. This value will be _added_ to the provided PSBT in the output which is encumbered by the 2-of-2 script for this channel."
] ]
@ -29426,7 +29426,7 @@
], ],
"properties": { "properties": {
"satoshi": { "satoshi": {
"type": "msat_or_all", "type": "sat_or_all",
"description": [ "description": [
"The minimum satoshi value of the output(s) needed (or the string `all` meaning use all unreserved inputs). If a value, it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*." "The minimum satoshi value of the output(s) needed (or the string `all` meaning use all unreserved inputs). If a value, it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*."
] ]
@ -30953,7 +30953,7 @@
] ]
}, },
"satoshi": { "satoshi": {
"type": "msat_or_all", "type": "sat_or_all",
"description": [ "description": [
"The amount to be withdrawn from the internal wallet (expressed, as name suggests, in satoshi). The string *all* can be used to specify withdrawal of all available funds (but if we have any anchor channels, this will always leave at least `min-emergency-msat` as change). Otherwise, it is in satoshi precision; it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*." "The amount to be withdrawn from the internal wallet (expressed, as name suggests, in satoshi). The string *all* can be used to specify withdrawal of all available funds (but if we have any anchor channels, this will always leave at least `min-emergency-msat` as change). Otherwise, it is in satoshi precision; it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*."
] ]

View file

@ -392,6 +392,12 @@ def _extra_validator(is_request: bool):
return True return True
return is_msat_request(checker, instance) return is_msat_request(checker, instance)
def is_sat_or_all(checker, instance):
"""sat field, or 'all'"""
if instance == "all":
return True
return is_sat(checker, instance)
def is_currency(checker, instance): def is_currency(checker, instance):
"""currency including currency code""" """currency including currency code"""
pattern = re.compile(r'^\d+(\.\d+)?[A-Z][A-Z][A-Z]$') pattern = re.compile(r'^\d+(\.\d+)?[A-Z][A-Z][A-Z]$')
@ -414,6 +420,7 @@ def _extra_validator(is_request: bool):
"u8": is_u8, "u8": is_u8,
"pubkey": is_pubkey, "pubkey": is_pubkey,
"sat": is_sat, "sat": is_sat,
"sat_or_all": is_sat_or_all,
"msat": is_msat, "msat": is_msat,
"msat_or_all": is_msat_or_all, "msat_or_all": is_msat_or_all,
"msat_or_any": is_msat_or_any, "msat_or_any": is_msat_or_any,

View file

@ -13,6 +13,10 @@ def amount2msat(a):
return a.msat return a.msat
def amount2sat(a):
return a.msat / 1000
def remove_default(d): def remove_default(d):
# grpc is really not good at empty values, they get replaced with the type's default value... # grpc is really not good at empty values, they get replaced with the type's default value...
return {k: v for k, v in d.items() if v is not None and v != ""} return {k: v for k, v in d.items() if v is not None and v != ""}

View file

@ -34,6 +34,7 @@
"u8", "u8",
"pubkey", "pubkey",
"sat", "sat",
"sat_or_all",
"msat", "msat",
"msat_or_all", "msat_or_all",
"msat_or_any", "msat_or_any",

View file

@ -16,7 +16,7 @@
], ],
"properties": { "properties": {
"satoshi": { "satoshi": {
"type": "msat", "type": "sat",
"description": [ "description": [
"The satoshi value of the output. It can be a whole number, a whole number ending in *sat*, or a number with 1 to 8 decimal places ending in *btc*." "The satoshi value of the output. It can be a whole number, a whole number ending in *sat*, or a number with 1 to 8 decimal places ending in *btc*."
] ]

View file

@ -26,7 +26,7 @@
] ]
}, },
"amount": { "amount": {
"type": "msat_or_all", "type": "sat_or_all",
"description": [ "description": [
"The amount in satoshis taken from the internal wallet to fund the channel (but if we have any anchor channels, this will always leave at least `min-emergency- msat` as change). The string *all* can be used to specify all available funds (or 16777215 satoshi if more is available and large channels were not negotiated with the peer). Otherwise, it is in satoshi precision; it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*. The value cannot be less than the dust limit, currently set to 546, nor more than 16777215 satoshi (unless large channels were negotiated with the peer)." "The amount in satoshis taken from the internal wallet to fund the channel (but if we have any anchor channels, this will always leave at least `min-emergency- msat` as change). The string *all* can be used to specify all available funds (or 16777215 satoshi if more is available and large channels were not negotiated with the peer). Otherwise, it is in satoshi precision; it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*. The value cannot be less than the dust limit, currently set to 546, nor more than 16777215 satoshi (unless large channels were negotiated with the peer)."
] ]
@ -92,7 +92,7 @@
"type": "u32" "type": "u32"
}, },
"reserve": { "reserve": {
"type": "msat", "type": "sat",
"description": [ "description": [
"The amount we want the peer to maintain on its side of the channel. It can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*." "The amount we want the peer to maintain on its side of the channel. It can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*."
], ],

View file

@ -22,7 +22,7 @@
] ]
}, },
"amount": { "amount": {
"type": "msat", "type": "sat",
"description": [ "description": [
"Satoshi value that the channel will be funded at. This value MUST be accurate, otherwise the negotiated commitment transactions will not encompass the correct channel value." "Satoshi value that the channel will be funded at. This value MUST be accurate, otherwise the negotiated commitment transactions will not encompass the correct channel value."
] ]
@ -58,7 +58,7 @@
] ]
}, },
"reserve": { "reserve": {
"type": "msat", "type": "sat",
"description": [ "description": [
"The amount we want the peer to maintain on its side." "The amount we want the peer to maintain on its side."
] ]

View file

@ -15,7 +15,7 @@
], ],
"properties": { "properties": {
"satoshi": { "satoshi": {
"type": "msat_or_all", "type": "sat_or_all",
"description": [ "description": [
"The minimum satoshi value of the output(s) needed (or the string `all` meaning use all unreserved inputs). If a value, it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*." "The minimum satoshi value of the output(s) needed (or the string `all` meaning use all unreserved inputs). If a value, it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*."
] ]

View file

@ -36,7 +36,7 @@
] ]
}, },
"amount": { "amount": {
"type": "msat_or_all", "type": "sat_or_all",
"description": [ "description": [
"Amount in satoshis taken from the internal wallet to fund the channel (but if we have any anchor channels, this will always leave at least `min-emergency-msat` as change). The string *all* can be used to specify all available funds (or 16,777,215 satoshi if more is available and large channels were not negotiated with the peer). Otherwise it is in satoshi precision; it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*. The value cannot be less than the dust limit, currently 546 satoshi as of this writing, nor more than 16,777,215 satoshi (unless large channels were negotiated with the peer)." "Amount in satoshis taken from the internal wallet to fund the channel (but if we have any anchor channels, this will always leave at least `min-emergency-msat` as change). The string *all* can be used to specify all available funds (or 16,777,215 satoshi if more is available and large channels were not negotiated with the peer). Otherwise it is in satoshi precision; it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*. The value cannot be less than the dust limit, currently 546 satoshi as of this writing, nor more than 16,777,215 satoshi (unless large channels were negotiated with the peer)."
] ]
@ -79,7 +79,7 @@
] ]
}, },
"reserve": { "reserve": {
"type": "msat", "type": "sat",
"description": [ "description": [
"Amount we want the peer to maintain on its side of the channel. It can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*." "Amount we want the peer to maintain on its side of the channel. It can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*."
], ],

View file

@ -23,7 +23,7 @@
] ]
}, },
"amount": { "amount": {
"type": "msat", "type": "sat",
"description": [ "description": [
"Satoshi value that we will contribute to the channel. This value will be _added_ to the provided PSBT in the output which is encumbered by the 2-of-2 script for this channel." "Satoshi value that we will contribute to the channel. This value will be _added_ to the provided PSBT in the output which is encumbered by the 2-of-2 script for this channel."
] ]

View file

@ -21,7 +21,7 @@
] ]
}, },
"amount": { "amount": {
"type": "msat", "type": "sat",
"description": [ "description": [
"Satoshi value that we will contribute to the channel. This value will be _added_ to the provided PSBT in the output which is encumbered by the 2-of-2 script for this channel." "Satoshi value that we will contribute to the channel. This value will be _added_ to the provided PSBT in the output which is encumbered by the 2-of-2 script for this channel."
] ]

View file

@ -18,7 +18,7 @@
], ],
"properties": { "properties": {
"satoshi": { "satoshi": {
"type": "msat_or_all", "type": "sat_or_all",
"description": [ "description": [
"The minimum satoshi value of the output(s) needed (or the string `all` meaning use all unreserved inputs). If a value, it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*." "The minimum satoshi value of the output(s) needed (or the string `all` meaning use all unreserved inputs). If a value, it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*."
] ]

View file

@ -20,7 +20,7 @@
] ]
}, },
"satoshi": { "satoshi": {
"type": "msat_or_all", "type": "sat_or_all",
"description": [ "description": [
"The amount to be withdrawn from the internal wallet (expressed, as name suggests, in satoshi). The string *all* can be used to specify withdrawal of all available funds (but if we have any anchor channels, this will always leave at least `min-emergency-msat` as change). Otherwise, it is in satoshi precision; it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*." "The amount to be withdrawn from the internal wallet (expressed, as name suggests, in satoshi). The string *all* can be used to specify withdrawal of all available funds (but if we have any anchor channels, this will always leave at least `min-emergency-msat` as change). Otherwise, it is in satoshi precision; it can be a whole number, a whole number ending in *sat*, a whole number ending in *000msat*, or a number with 1 to 8 decimal places ending in *btc*."
] ]