From 7549e1049d4cc3f591e2da08345a5a2fb00c9d0f Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Tue, 23 Jan 2024 21:58:54 -0800 Subject: [PATCH] script: msggen, sql-schema, listconfig and pyln-testing script updates --- .msggen.json | 33 +++ Makefile | 2 +- cln-grpc/proto/node.proto | 67 +++--- cln-grpc/src/convert.rs | 132 +++++------- cln-grpc/src/server.rs | 32 --- cln-rpc/src/model.rs | 191 ++++++++---------- contrib/msggen/msggen/utils/utils.py | 13 +- contrib/pyln-testing/pyln/testing/fixtures.py | 24 +-- contrib/pyln-testing/pyln/testing/grpc2py.py | 33 --- doc/Makefile | 4 +- plugins/Makefile | 19 +- 11 files changed, 219 insertions(+), 331 deletions(-) diff --git a/.msggen.json b/.msggen.json index 15381b47ea17..a70beec694fc 100644 --- a/.msggen.json +++ b/.msggen.json @@ -235,6 +235,12 @@ "ONCHAIN": 8, "OPENINGD": 0 }, + "ListpeersLevel": { + "debug": 1, + "info": 2, + "io": 0, + "unusual": 3 + }, "ListpeersPeersChannelsHtlcsDirection": { "in": 0, "out": 1 @@ -1483,6 +1489,7 @@ "SendonionRequest": { "SendOnion.amount_msat": 12, "SendOnion.bolt11": 7, + "SendOnion.description": 14, "SendOnion.destination": 9, "SendOnion.first_hop": 2, "SendOnion.groupid": 11, @@ -1515,6 +1522,7 @@ "SendpayRequest": { "SendPay.amount_msat": 10, "SendPay.bolt11": 5, + "SendPay.description": 13, "SendPay.groupid": 9, "SendPay.label": 3, "SendPay.localinvreqid": 11, @@ -1522,6 +1530,7 @@ "SendPay.msatoshi": 4, "SendPay.partid": 7, "SendPay.payment_hash": 2, + "SendPay.payment_metadata": 12, "SendPay.payment_secret": 6, "SendPay.route[]": 1 }, @@ -1614,6 +1623,10 @@ "TxDiscard.txid": 2, "TxDiscard.unsigned_tx": 1 }, + "TxprepareOutputs": { + "TxPrepare.outputs[].amount": 2, + "TxPrepare.outputs[].destination": 1 + }, "TxprepareRequest": { "TxPrepare.feerate": 2, "TxPrepare.minconf": 3, @@ -5350,6 +5363,10 @@ "added": "v23.11", "deprecated": false }, + "SendOnion.description": { + "added": "pre-v0.10.1", + "deprecated": false + }, "SendOnion.destination": { "added": "pre-v0.10.1", "deprecated": false @@ -5450,6 +5467,10 @@ "added": "v23.11", "deprecated": false }, + "SendPay.description": { + "added": "pre-v0.10.1", + "deprecated": false + }, "SendPay.destination": { "added": "pre-v0.10.1", "deprecated": false @@ -5482,6 +5503,10 @@ "added": "pre-v0.10.1", "deprecated": false }, + "SendPay.payment_metadata": { + "added": "pre-v0.10.1", + "deprecated": false + }, "SendPay.payment_preimage": { "added": "pre-v0.10.1", "deprecated": false @@ -5702,6 +5727,14 @@ "added": "pre-v0.10.1", "deprecated": false }, + "TxPrepare.outputs[].amount": { + "added": "pre-v0.10.1", + "deprecated": false + }, + "TxPrepare.outputs[].destination": { + "added": "pre-v0.10.1", + "deprecated": false + }, "TxPrepare.psbt": { "added": "pre-v0.10.1", "deprecated": false diff --git a/Makefile b/Makefile index fd2b38e41546..55da5090930f 100644 --- a/Makefile +++ b/Makefile @@ -365,7 +365,7 @@ ifneq ($(RUST),0) include cln-rpc/Makefile include cln-grpc/Makefile -$(MSGGEN_GENALL)&: doc/schemas/*.request.json doc/schemas/*.schema.json +$(MSGGEN_GENALL)&: doc/schemas/lightning-*.json PYTHONPATH=contrib/msggen $(PYTHON) contrib/msggen/msggen/__main__.py # The compiler assumes that the proto files are in the same diff --git a/cln-grpc/proto/node.proto b/cln-grpc/proto/node.proto index d936b793f4e1..bbe4354eda59 100644 --- a/cln-grpc/proto/node.proto +++ b/cln-grpc/proto/node.proto @@ -14,7 +14,6 @@ service Node { rpc SendPay(SendpayRequest) returns (SendpayResponse) {} rpc ListChannels(ListchannelsRequest) returns (ListchannelsResponse) {} rpc AddGossip(AddgossipRequest) returns (AddgossipResponse) {} - rpc AutoCleanInvoice(AutocleaninvoiceRequest) returns (AutocleaninvoiceResponse) {} rpc CheckMessage(CheckmessageRequest) returns (CheckmessageResponse) {} rpc Close(CloseRequest) returns (CloseResponse) {} rpc ConnectPeer(ConnectRequest) returns (ConnectResponse) {} @@ -132,8 +131,15 @@ message GetinfoBinding { } message ListpeersRequest { + // ListPeers.level + enum ListpeersLevel { + IO = 0; + DEBUG = 1; + INFO = 2; + UNUSUAL = 3; + } optional bytes id = 1; - optional string level = 2; + optional ListpeersLevel level = 2; } message ListpeersResponse { @@ -330,9 +336,11 @@ message SendpayRequest { optional Amount amount_msat = 10; optional string bolt11 = 5; optional bytes payment_secret = 6; - optional uint32 partid = 7; + optional uint64 partid = 7; optional bytes localinvreqid = 11; optional uint64 groupid = 9; + optional bytes payment_metadata = 12; + optional string description = 13; } message SendpayResponse { @@ -361,10 +369,10 @@ message SendpayResponse { } message SendpayRoute { - Amount amount_msat = 5; bytes id = 2; - uint32 delay = 3; string channel = 4; + uint32 delay = 3; + Amount amount_msat = 5; } message ListchannelsRequest { @@ -403,17 +411,6 @@ message AddgossipRequest { message AddgossipResponse { } -message AutocleaninvoiceRequest { - optional uint64 expired_by = 1; - optional uint64 cycle_seconds = 2; -} - -message AutocleaninvoiceResponse { - bool enabled = 1; - optional uint64 expired_by = 2; - optional uint64 cycle_seconds = 3; -} - message CheckmessageRequest { string message = 1; string zbase = 2; @@ -622,8 +619,8 @@ message DelinvoiceResponse { message InvoiceRequest { AmountOrAny amount_msat = 10; - string description = 2; string label = 3; + string description = 2; optional uint64 expiry = 7; repeated string fallbacks = 4; optional bytes preimage = 5; @@ -721,6 +718,7 @@ message SendonionRequest { optional bytes destination = 9; optional bytes localinvreqid = 13; optional uint64 groupid = 11; + optional string description = 14; } message SendonionResponse { @@ -1009,7 +1007,7 @@ message NewaddrResponse { message WithdrawRequest { string destination = 1; - optional AmountOrAll satoshi = 2; + AmountOrAll satoshi = 2; optional Feerate feerate = 5; optional uint32 minconf = 3; repeated Outpoint utxos = 4; @@ -1081,7 +1079,7 @@ message FundpsbtReservations { message SendpsbtRequest { string psbt = 1; - optional bool reserve = 2; + optional uint32 reserve = 2; } message SendpsbtResponse { @@ -1099,7 +1097,7 @@ message SignpsbtResponse { } message UtxopsbtRequest { - Amount satoshi = 1; + AmountOrAll satoshi = 1; Feerate feerate = 2; uint32 startweight = 3; repeated Outpoint utxos = 4; @@ -1138,7 +1136,7 @@ message TxdiscardResponse { } message TxprepareRequest { - repeated OutputDesc outputs = 5; + repeated TxprepareOutputs outputs = 5; optional Feerate feerate = 2; optional uint32 minconf = 3; repeated Outpoint utxos = 4; @@ -1150,6 +1148,11 @@ message TxprepareResponse { bytes txid = 3; } +message TxprepareOutputs { + string destination = 1; + Amount amount = 2; +} + message TxsendRequest { bytes txid = 1; } @@ -1190,7 +1193,6 @@ message ListpeerchannelsChannels { optional bool peer_connected = 2; optional ListpeerchannelsChannelsState state = 3; optional bytes scratch_txid = 4; - optional ListpeerchannelsChannelsUpdates updates = 55; optional bool ignore_fee_limits = 54; optional ListpeerchannelsChannelsFeerate feerate = 6; optional string owner = 7; @@ -1240,27 +1242,6 @@ message ListpeerchannelsChannels { optional string close_to_addr = 53; } -message ListpeerchannelsChannelsUpdates { - optional ListpeerchannelsChannelsUpdatesLocal local = 1; - optional ListpeerchannelsChannelsUpdatesRemote remote = 2; -} - -message ListpeerchannelsChannelsUpdatesLocal { - optional Amount htlc_minimum_msat = 1; - optional Amount htlc_maximum_msat = 2; - optional uint32 cltv_expiry_delta = 3; - optional Amount fee_base_msat = 4; - optional uint32 fee_proportional_millionths = 5; -} - -message ListpeerchannelsChannelsUpdatesRemote { - optional Amount htlc_minimum_msat = 1; - optional Amount htlc_maximum_msat = 2; - optional uint32 cltv_expiry_delta = 3; - optional Amount fee_base_msat = 4; - optional uint32 fee_proportional_millionths = 5; -} - message ListpeerchannelsChannelsFeerate { optional uint32 perkw = 1; optional uint32 perkb = 2; diff --git a/cln-grpc/src/convert.rs b/cln-grpc/src/convert.rs index 599550239cea..3fe361508700 100644 --- a/cln-grpc/src/convert.rs +++ b/cln-grpc/src/convert.rs @@ -356,17 +356,6 @@ impl From for pb::AddgossipResponse { } } -#[allow(unused_variables)] -impl From for pb::AutocleaninvoiceResponse { - fn from(c: responses::AutocleaninvoiceResponse) -> Self { - Self { - enabled: c.enabled, // Rule #2 for type boolean - expired_by: c.expired_by, // Rule #2 for type u64? - cycle_seconds: c.cycle_seconds, // Rule #2 for type u64? - } - } -} - #[allow(unused_variables)] impl From for pb::CheckmessageResponse { fn from(c: responses::CheckmessageResponse) -> Self { @@ -1014,42 +1003,6 @@ impl From for pb::TxsendResponse { } } -#[allow(unused_variables)] -impl From for pb::ListpeerchannelsChannelsUpdatesLocal { - fn from(c: responses::ListpeerchannelsChannelsUpdatesLocal) -> Self { - Self { - htlc_minimum_msat: c.htlc_minimum_msat.map(|f| f.into()), // Rule #2 for type msat? - htlc_maximum_msat: c.htlc_maximum_msat.map(|f| f.into()), // Rule #2 for type msat? - cltv_expiry_delta: c.cltv_expiry_delta, // Rule #2 for type u32? - fee_base_msat: c.fee_base_msat.map(|f| f.into()), // Rule #2 for type msat? - fee_proportional_millionths: c.fee_proportional_millionths, // Rule #2 for type u32? - } - } -} - -#[allow(unused_variables)] -impl From for pb::ListpeerchannelsChannelsUpdatesRemote { - fn from(c: responses::ListpeerchannelsChannelsUpdatesRemote) -> Self { - Self { - htlc_minimum_msat: c.htlc_minimum_msat.map(|f| f.into()), // Rule #2 for type msat? - htlc_maximum_msat: c.htlc_maximum_msat.map(|f| f.into()), // Rule #2 for type msat? - cltv_expiry_delta: c.cltv_expiry_delta, // Rule #2 for type u32? - fee_base_msat: c.fee_base_msat.map(|f| f.into()), // Rule #2 for type msat? - fee_proportional_millionths: c.fee_proportional_millionths, // Rule #2 for type u32? - } - } -} - -#[allow(unused_variables)] -impl From for pb::ListpeerchannelsChannelsUpdates { - fn from(c: responses::ListpeerchannelsChannelsUpdates) -> Self { - Self { - local: c.local.map(|v| v.into()), - remote: c.remote.map(|v| v.into()), - } - } -} - #[allow(unused_variables)] impl From for pb::ListpeerchannelsChannelsFeerate { fn from(c: responses::ListpeerchannelsChannelsFeerate) -> Self { @@ -1122,7 +1075,6 @@ impl From for pb::ListpeerchannelsChannels peer_connected: c.peer_connected, // Rule #2 for type boolean? state: c.state.map(|v| v as i32), scratch_txid: c.scratch_txid.map(|v| hex::decode(v).unwrap()), // Rule #2 for type txid? - updates: c.updates.map(|v| v.into()), ignore_fee_limits: c.ignore_fee_limits, // Rule #2 for type boolean? feerate: c.feerate.map(|v| v.into()), owner: c.owner, // Rule #2 for type string? @@ -1815,7 +1767,7 @@ impl From for pb::ListpeersRequest { fn from(c: requests::ListpeersRequest) -> Self { Self { id: c.id.map(|v| v.serialize().to_vec()), // Rule #2 for type pubkey? - level: c.level, // Rule #2 for type string? + level: c.level.map(|v| v as i32), } } } @@ -1833,10 +1785,10 @@ impl From for pb::ListfundsRequest { impl From for pb::SendpayRoute { fn from(c: requests::SendpayRoute) -> Self { Self { - amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat id: c.id.serialize().to_vec(), // Rule #2 for type pubkey - delay: c.delay.into(), // Rule #2 for type u16 channel: c.channel.to_string(), // Rule #2 for type short_channel_id + delay: c.delay, // Rule #2 for type u32 + amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat } } } @@ -1852,9 +1804,11 @@ impl From for pb::SendpayRequest { amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? bolt11: c.bolt11, // Rule #2 for type string? payment_secret: c.payment_secret.map(|v| v.to_vec()), // Rule #2 for type secret? - partid: c.partid.map(|v| v.into()), // Rule #2 for type u16? + partid: c.partid, // Rule #2 for type u64? localinvreqid: c.localinvreqid.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? groupid: c.groupid, // Rule #2 for type u64? + payment_metadata: c.payment_metadata.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? + description: c.description, // Rule #2 for type string? } } } @@ -1879,16 +1833,6 @@ impl From for pb::AddgossipRequest { } } -#[allow(unused_variables)] -impl From for pb::AutocleaninvoiceRequest { - fn from(c: requests::AutocleaninvoiceRequest) -> Self { - Self { - expired_by: c.expired_by, // Rule #2 for type u64? - cycle_seconds: c.cycle_seconds, // Rule #2 for type u64? - } - } -} - #[allow(unused_variables)] impl From for pb::CheckmessageRequest { fn from(c: requests::CheckmessageRequest) -> Self { @@ -2019,8 +1963,8 @@ impl From for pb::InvoiceRequest { fn from(c: requests::InvoiceRequest) -> Self { Self { amount_msat: Some(c.amount_msat.into()), // Rule #2 for type msat_or_any - description: c.description, // Rule #2 for type string label: c.label, // Rule #2 for type string + description: c.description, // Rule #2 for type string expiry: c.expiry, // Rule #2 for type u64? // Field: Invoice.fallbacks[] fallbacks: c.fallbacks.map(|arr| arr.into_iter().map(|i| i.into()).collect()).unwrap_or(vec![]), // Rule #3 @@ -2081,8 +2025,9 @@ impl From for pb::SendonionRequest { bolt11: c.bolt11, // Rule #2 for type string? amount_msat: c.amount_msat.map(|f| f.into()), // Rule #2 for type msat? destination: c.destination.map(|v| v.serialize().to_vec()), // Rule #2 for type pubkey? - localinvreqid: c.localinvreqid.map(|v| >::as_ref(&v).to_vec()), // Rule #2 for type hash? + localinvreqid: c.localinvreqid.map(|v| hex::decode(v).unwrap()), // Rule #2 for type hex? groupid: c.groupid, // Rule #2 for type u64? + description: c.description, // Rule #2 for type string? } } } @@ -2184,7 +2129,7 @@ impl From for pb::WithdrawRequest { fn from(c: requests::WithdrawRequest) -> Self { Self { destination: c.destination, // Rule #2 for type string - satoshi: c.satoshi.map(|o|o.into()), // Rule #2 for type msat_or_all? + satoshi: Some(c.satoshi.into()), // Rule #2 for type msat_or_all feerate: c.feerate.map(|o|o.into()), // Rule #2 for type feerate? minconf: c.minconf.map(|v| v.into()), // Rule #2 for type u16? // Field: Withdraw.utxos[] @@ -2233,7 +2178,7 @@ impl From for pb::SendpsbtRequest { fn from(c: requests::SendpsbtRequest) -> Self { Self { psbt: c.psbt, // Rule #2 for type string - reserve: c.reserve, // Rule #2 for type boolean? + reserve: c.reserve, // Rule #2 for type u32? } } } @@ -2253,7 +2198,7 @@ impl From for pb::SignpsbtRequest { impl From for pb::UtxopsbtRequest { fn from(c: requests::UtxopsbtRequest) -> Self { Self { - satoshi: Some(c.satoshi.into()), // Rule #2 for type msat + satoshi: Some(c.satoshi.into()), // Rule #2 for type msat_or_all feerate: Some(c.feerate.into()), // Rule #2 for type feerate startweight: c.startweight, // Rule #2 for type u32 // Field: UtxoPsbt.utxos[] @@ -2277,12 +2222,22 @@ impl From for pb::TxdiscardRequest { } } +#[allow(unused_variables)] +impl From for pb::TxprepareOutputs { + fn from(c: requests::TxprepareOutputs) -> Self { + Self { + destination: c.destination, // Rule #2 for type string + amount: Some(c.amount.into()), // Rule #2 for type msat + } + } +} + #[allow(unused_variables)] impl From for pb::TxprepareRequest { fn from(c: requests::TxprepareRequest) -> Self { Self { // Field: TxPrepare.outputs[] - outputs: c.outputs.into_iter().map(|i| i.into()).collect(), // Rule #3 for type outputdesc + outputs: c.outputs.into_iter().map(|i| i.into()).collect(), // Rule #3 for type TxprepareOutputs feerate: c.feerate.map(|o|o.into()), // Rule #2 for type feerate? minconf: c.minconf, // Rule #2 for type u32? // Field: TxPrepare.utxos[] @@ -2569,7 +2524,7 @@ impl From for requests::ListpeersRequest { fn from(c: pb::ListpeersRequest) -> Self { Self { id: c.id.map(|v| PublicKey::from_slice(&v).unwrap()), // Rule #1 for type pubkey? - level: c.level, // Rule #1 for type string? + level: c.level.map(|v| v.try_into().unwrap()), } } } @@ -2587,10 +2542,10 @@ impl From for requests::ListfundsRequest { impl From for requests::SendpayRoute { fn from(c: pb::SendpayRoute) -> Self { Self { - amount_msat: c.amount_msat.unwrap().into(), // Rule #1 for type msat id: PublicKey::from_slice(&c.id).unwrap(), // Rule #1 for type pubkey - delay: c.delay as u16, // Rule #1 for type u16 channel: cln_rpc::primitives::ShortChannelId::from_str(&c.channel).unwrap(), // Rule #1 for type short_channel_id + delay: c.delay, // Rule #1 for type u32 + amount_msat: c.amount_msat.unwrap().into(), // Rule #1 for type msat } } } @@ -2605,9 +2560,11 @@ impl From for requests::SendpayRequest { amount_msat: c.amount_msat.map(|a| a.into()), // Rule #1 for type msat? bolt11: c.bolt11, // Rule #1 for type string? payment_secret: c.payment_secret.map(|v| v.try_into().unwrap()), // Rule #1 for type secret? - partid: c.partid.map(|v| v as u16), // Rule #1 for type u16? + partid: c.partid, // Rule #1 for type u64? localinvreqid: c.localinvreqid.map(|v| hex::encode(v)), // Rule #1 for type hex? groupid: c.groupid, // Rule #1 for type u64? + payment_metadata: c.payment_metadata.map(|v| hex::encode(v)), // Rule #1 for type hex? + description: c.description, // Rule #1 for type string? } } } @@ -2632,16 +2589,6 @@ impl From for requests::AddgossipRequest { } } -#[allow(unused_variables)] -impl From for requests::AutocleaninvoiceRequest { - fn from(c: pb::AutocleaninvoiceRequest) -> Self { - Self { - expired_by: c.expired_by, // Rule #1 for type u64? - cycle_seconds: c.cycle_seconds, // Rule #1 for type u64? - } - } -} - #[allow(unused_variables)] impl From for requests::CheckmessageRequest { fn from(c: pb::CheckmessageRequest) -> Self { @@ -2768,8 +2715,8 @@ impl From for requests::InvoiceRequest { fn from(c: pb::InvoiceRequest) -> Self { Self { amount_msat: c.amount_msat.unwrap().into(), // Rule #1 for type msat_or_any - description: c.description, // Rule #1 for type string label: c.label, // Rule #1 for type string + description: c.description, // Rule #1 for type string expiry: c.expiry, // Rule #1 for type u64? fallbacks: Some(c.fallbacks.into_iter().map(|s| s.into()).collect()), // Rule #4 preimage: c.preimage.map(|v| hex::encode(v)), // Rule #1 for type hex? @@ -2827,8 +2774,9 @@ impl From for requests::SendonionRequest { bolt11: c.bolt11, // Rule #1 for type string? amount_msat: c.amount_msat.map(|a| a.into()), // Rule #1 for type msat? destination: c.destination.map(|v| PublicKey::from_slice(&v).unwrap()), // Rule #1 for type pubkey? - localinvreqid: c.localinvreqid.map(|v| Sha256::from_slice(&v).unwrap()), // Rule #1 for type hash? + localinvreqid: c.localinvreqid.map(|v| hex::encode(v)), // Rule #1 for type hex? groupid: c.groupid, // Rule #1 for type u64? + description: c.description, // Rule #1 for type string? } } } @@ -2929,7 +2877,7 @@ impl From for requests::WithdrawRequest { fn from(c: pb::WithdrawRequest) -> Self { Self { destination: c.destination, // Rule #1 for type string - satoshi: c.satoshi.map(|a| a.into()), // Rule #1 for type msat_or_all? + satoshi: c.satoshi.unwrap().into(), // Rule #1 for type msat_or_all 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? utxos: Some(c.utxos.into_iter().map(|s| s.into()).collect()), // Rule #4 @@ -2977,7 +2925,7 @@ impl From for requests::SendpsbtRequest { fn from(c: pb::SendpsbtRequest) -> Self { Self { psbt: c.psbt, // Rule #1 for type string - reserve: c.reserve, // Rule #1 for type boolean? + reserve: c.reserve, // Rule #1 for type u32? } } } @@ -2996,7 +2944,7 @@ impl From for requests::SignpsbtRequest { impl From for requests::UtxopsbtRequest { fn from(c: pb::UtxopsbtRequest) -> Self { Self { - satoshi: c.satoshi.unwrap().into(), // Rule #1 for type msat + satoshi: c.satoshi.unwrap().into(), // Rule #1 for type msat_or_all feerate: c.feerate.unwrap().into(), // Rule #1 for type feerate startweight: c.startweight, // Rule #1 for type u32 utxos: c.utxos.into_iter().map(|s| s.into()).collect(), // Rule #4 @@ -3019,6 +2967,16 @@ impl From for requests::TxdiscardRequest { } } +#[allow(unused_variables)] +impl From for requests::TxprepareOutputs { + fn from(c: pb::TxprepareOutputs) -> Self { + Self { + destination: c.destination, // Rule #1 for type string + amount: c.amount.unwrap().into(), // Rule #1 for type msat + } + } +} + #[allow(unused_variables)] impl From for requests::TxprepareRequest { fn from(c: pb::TxprepareRequest) -> Self { diff --git a/cln-grpc/src/server.rs b/cln-grpc/src/server.rs index 7519a344cc1c..5c55d8b190e4 100644 --- a/cln-grpc/src/server.rs +++ b/cln-grpc/src/server.rs @@ -218,38 +218,6 @@ async fn add_gossip( } -async fn auto_clean_invoice( - &self, - request: tonic::Request, -) -> Result, tonic::Status> { - let req = request.into_inner(); - let req: requests::AutocleaninvoiceRequest = req.into(); - debug!("Client asked for auto_clean_invoice"); - trace!("auto_clean_invoice request: {:?}", req); - let mut rpc = ClnRpc::new(&self.rpc_path) - .await - .map_err(|e| Status::new(Code::Internal, e.to_string()))?; - let result = rpc.call(Request::AutoCleanInvoice(req)) - .await - .map_err(|e| Status::new( - Code::Unknown, - format!("Error calling method AutoCleanInvoice: {:?}", e)))?; - match result { - Response::AutoCleanInvoice(r) => { - trace!("auto_clean_invoice response: {:?}", r); - Ok(tonic::Response::new(r.into())) - }, - r => Err(Status::new( - Code::Internal, - format!( - "Unexpected result {:?} to method call AutoCleanInvoice", - r - ) - )), - } - -} - async fn check_message( &self, request: tonic::Request, diff --git a/cln-rpc/src/model.rs b/cln-rpc/src/model.rs index 48494be9f45c..53accddb57ba 100644 --- a/cln-rpc/src/model.rs +++ b/cln-rpc/src/model.rs @@ -23,7 +23,6 @@ pub enum Request { SendPay(requests::SendpayRequest), ListChannels(requests::ListchannelsRequest), AddGossip(requests::AddgossipRequest), - AutoCleanInvoice(requests::AutocleaninvoiceRequest), CheckMessage(requests::CheckmessageRequest), Close(requests::CloseRequest), Connect(requests::ConnectRequest), @@ -90,7 +89,6 @@ pub enum Response { SendPay(responses::SendpayResponse), ListChannels(responses::ListchannelsResponse), AddGossip(responses::AddgossipResponse), - AutoCleanInvoice(responses::AutocleaninvoiceResponse), CheckMessage(responses::CheckmessageResponse), Close(responses::CloseResponse), Connect(responses::ConnectResponse), @@ -189,12 +187,49 @@ pub mod requests { "getinfo" } } + /// ['supplying level will show log entries related to that peer at the given log', 'level'] + #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] + pub enum ListpeersLevel { + #[serde(rename = "io")] + IO, + #[serde(rename = "debug")] + DEBUG, + #[serde(rename = "info")] + INFO, + #[serde(rename = "unusual")] + UNUSUAL, + } + + impl TryFrom for ListpeersLevel { + type Error = anyhow::Error; + fn try_from(c: i32) -> Result { + match c { + 0 => Ok(ListpeersLevel::IO), + 1 => Ok(ListpeersLevel::DEBUG), + 2 => Ok(ListpeersLevel::INFO), + 3 => Ok(ListpeersLevel::UNUSUAL), + o => Err(anyhow::anyhow!("Unknown variant {} for enum ListpeersLevel", o)), + } + } + } + + impl ToString for ListpeersLevel { + fn to_string(&self) -> String { + match self { + ListpeersLevel::IO => "IO", + ListpeersLevel::DEBUG => "DEBUG", + ListpeersLevel::INFO => "INFO", + ListpeersLevel::UNUSUAL => "UNUSUAL", + }.to_string() + } + } + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ListpeersRequest { #[serde(skip_serializing_if = "Option::is_none")] pub id: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub level: Option, + pub level: Option, } impl From for Request { @@ -239,10 +274,10 @@ pub mod requests { } #[derive(Clone, Debug, Deserialize, Serialize)] pub struct SendpayRoute { - pub amount_msat: Amount, pub id: PublicKey, - pub delay: u16, pub channel: ShortChannelId, + pub delay: u32, + pub amount_msat: Amount, } #[derive(Clone, Debug, Deserialize, Serialize)] @@ -258,11 +293,15 @@ pub mod requests { #[serde(skip_serializing_if = "Option::is_none")] pub payment_secret: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub partid: Option, + pub partid: Option, #[serde(skip_serializing_if = "Option::is_none")] pub localinvreqid: Option, #[serde(skip_serializing_if = "Option::is_none")] pub groupid: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub payment_metadata: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub description: Option, } impl From for Request { @@ -332,31 +371,6 @@ pub mod requests { } } #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct AutocleaninvoiceRequest { - #[serde(skip_serializing_if = "Option::is_none")] - pub expired_by: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub cycle_seconds: Option, - } - - impl From for Request { - fn from(r: AutocleaninvoiceRequest) -> Self { - Request::AutoCleanInvoice(r) - } - } - - impl IntoRequest for AutocleaninvoiceRequest { - type Response = super::responses::AutocleaninvoiceResponse; - } - - impl TypedRequest for AutocleaninvoiceRequest { - type Response = super::responses::AutocleaninvoiceResponse; - - fn method(&self) -> &str { - "autocleaninvoice" - } - } - #[derive(Clone, Debug, Deserialize, Serialize)] pub struct CheckmessageRequest { pub message: String, pub zbase: String, @@ -465,6 +479,7 @@ pub mod requests { "createinvoice" } } + /// ['', ' - `must-create`: fails if it already exists.', " - `must-replace`: fails if it doesn't already exist.", ' - `create-or-replace`: never fails.', " - `must-append`: must already exist, append this to what's already there.", ' - `create-or-append`: append if anything is there, otherwise create.', ' Default is `must-create`'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum DatastoreMode { #[serde(rename = "must-create")] @@ -636,6 +651,7 @@ pub mod requests { "delexpiredinvoice" } } + /// ['label of the invoice to be deleted. The caller should be particularly aware of', 'the error case caused by the *status* changing just before this command is', 'invoked!'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum DelinvoiceStatus { #[serde(rename = "paid")] @@ -697,8 +713,8 @@ pub mod requests { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct InvoiceRequest { pub amount_msat: AmountOrAny, - pub description: String, pub label: String, + pub description: String, #[serde(skip_serializing_if = "Option::is_none")] pub expiry: Option, #[serde(skip_serializing_if = "crate::is_none_or_empty")] @@ -751,6 +767,7 @@ pub mod requests { "listdatastore" } } + /// ['if neither *in_channel* nor *out_channel* is specified, it controls ordering.', 'Defaults to `created`'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum ListinvoicesIndex { #[serde(rename = "created")] @@ -839,9 +856,11 @@ pub mod requests { #[serde(skip_serializing_if = "Option::is_none")] pub destination: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub localinvreqid: Option, + pub localinvreqid: Option, #[serde(skip_serializing_if = "Option::is_none")] pub groupid: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub description: Option, } impl From for Request { @@ -861,6 +880,7 @@ pub mod requests { "sendonion" } } + /// ['Whether the invoice has been paid, pending, or failed'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum ListsendpaysStatus { #[serde(rename = "pending")] @@ -893,6 +913,7 @@ pub mod requests { } } + /// ['if neither bolt11 or payment_hash is specified, `index` controls ordering, by', '`created` (default) or `updated`'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum ListsendpaysIndex { #[serde(rename = "created")] @@ -1117,6 +1138,7 @@ pub mod requests { "waitsendpay" } } + /// ['it specifies the type of address wanted; currently *bech32* (e.g.', '`tb1qu9j4lg5f9rgjyfhvfd905vw46eg39czmktxqgg` on bitcoin testnet or', '`bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej` on bitcoin', 'mainnet), or *p2tr* taproot addresses. The special value *all* generates all', 'known address types for the same underlying key. Defaults to *bech32* address'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum NewaddrAddresstype { #[serde(rename = "bech32")] @@ -1175,8 +1197,7 @@ pub mod requests { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct WithdrawRequest { pub destination: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub satoshi: Option, + pub satoshi: AmountOrAll, #[serde(skip_serializing_if = "Option::is_none")] pub feerate: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -1281,7 +1302,7 @@ pub mod requests { pub struct SendpsbtRequest { pub psbt: String, #[serde(skip_serializing_if = "Option::is_none")] - pub reserve: Option, + pub reserve: Option, } impl From for Request { @@ -1327,7 +1348,7 @@ pub mod requests { } #[derive(Clone, Debug, Deserialize, Serialize)] pub struct UtxopsbtRequest { - pub satoshi: Amount, + pub satoshi: AmountOrAll, pub feerate: Feerate, pub startweight: u32, pub utxos: Vec, @@ -1384,9 +1405,15 @@ pub mod requests { "txdiscard" } } + #[derive(Clone, Debug, Deserialize, Serialize)] + pub struct TxprepareOutputs { + pub destination: String, + pub amount: Amount, + } + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct TxprepareRequest { - pub outputs: Vec, + pub outputs: Vec, #[serde(skip_serializing_if = "Option::is_none")] pub feerate: Option, #[serde(skip_serializing_if = "Option::is_none")] @@ -1550,6 +1577,7 @@ pub mod requests { "disconnect" } } + /// ['', ' *perkw* - provide feerate in units of satoshis per 1000 weight (e.g. the minimum fee is usually `253perkw`)', ' *perkb* - provide feerate in units of satoshis per 1000 virtual bytes (eg. the minimum fee is usually `1000perkb`)'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum FeeratesStyle { #[serde(rename = "perkb")] @@ -1714,6 +1742,7 @@ pub mod requests { "getroute" } } + /// ['if specified, then only the forwards with the given status are returned'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum ListforwardsStatus { #[serde(rename = "offered")] @@ -1750,6 +1779,7 @@ pub mod requests { } } + /// ['if neither *in_channel* nor *out_channel* is specified, it controls ordering.', 'Defaults to `created`'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum ListforwardsIndex { #[serde(rename = "created")] @@ -1811,6 +1841,7 @@ pub mod requests { "listforwards" } } + /// ['to filter the payment by status'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum ListpaysStatus { #[serde(rename = "pending")] @@ -2044,6 +2075,7 @@ pub mod requests { "waitblockheight" } } + /// ['the subsystem to get the next index value from'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum WaitSubsystem { #[serde(rename = "invoices")] @@ -2076,6 +2108,7 @@ pub mod requests { } } + /// ['the name of the index to get the next value for'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum WaitIndexname { #[serde(rename = "created")] @@ -2837,7 +2870,7 @@ pub mod responses { } } - /// status of the payment (could be complete if already sent previously) + /// ['status of the payment (could be complete if already sent previously)'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum SendpayStatus { #[serde(rename = "pending")] @@ -2963,26 +2996,6 @@ pub mod responses { } } - #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct AutocleaninvoiceResponse { - pub enabled: bool, - #[serde(skip_serializing_if = "Option::is_none")] - pub expired_by: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub cycle_seconds: Option, - } - - impl TryFrom for AutocleaninvoiceResponse { - type Error = super::TryFromResponseError; - - fn try_from(response: Response) -> Result { - match response { - Response::AutoCleanInvoice(response) => Ok(response), - _ => Err(TryFromResponseError) - } - } - } - #[derive(Clone, Debug, Deserialize, Serialize)] pub struct CheckmessageResponse { pub verified: bool, @@ -3000,7 +3013,7 @@ pub mod responses { } } - /// Whether we successfully negotiated a mutual close, closed without them, or discarded not-yet-opened channel + /// ['Whether ', 'we successfully negotiated a mutual close, closed without them, or ', 'discarded not-yet-opened channel'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum CloseType { #[serde(rename = "mutual")] @@ -3055,7 +3068,7 @@ pub mod responses { } } - /// Whether they initiated connection or we did + /// ['Whether they initiated connection or we did'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum ConnectDirection { #[serde(rename = "in")] @@ -3158,7 +3171,7 @@ pub mod responses { } } - /// Whether it has been paid, or can no longer be paid + /// ['Whether it has been paid, or can no longer be paid'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum CreateinvoiceStatus { #[serde(rename = "paid")] @@ -3343,7 +3356,7 @@ pub mod responses { } } - /// State of invoice + /// ['State of invoice'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum DelinvoiceStatus { #[serde(rename = "paid")] @@ -3562,7 +3575,7 @@ pub mod responses { } } - /// status of the payment (could be complete if already sent previously) + /// ['status of the payment (could be complete if already sent previously)'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum SendonionStatus { #[serde(rename = "pending")] @@ -3757,7 +3770,7 @@ pub mod responses { } } - /// status of payment + /// ['status of payment'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum PayStatus { #[serde(rename = "complete")] @@ -3899,7 +3912,7 @@ pub mod responses { } } - /// Whether it's paid or expired + /// ["Whether it's paid or expired"] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum WaitanyinvoiceStatus { #[serde(rename = "paid")] @@ -3977,7 +3990,7 @@ pub mod responses { } } - /// Whether it's paid or expired + /// ["Whether it's paid or expired"] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum WaitinvoiceStatus { #[serde(rename = "paid")] @@ -4055,7 +4068,7 @@ pub mod responses { } } - /// status of the payment + /// ['status of the payment'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum WaitsendpayStatus { #[serde(rename = "complete")] @@ -4164,7 +4177,7 @@ pub mod responses { } } - /// status of payment + /// ['status of payment'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum KeysendStatus { #[serde(rename = "complete")] @@ -4443,42 +4456,6 @@ pub mod responses { } } - #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct ListpeerchannelsChannelsUpdatesLocal { - #[serde(skip_serializing_if = "Option::is_none")] - pub htlc_minimum_msat: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub htlc_maximum_msat: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub cltv_expiry_delta: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub fee_base_msat: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub fee_proportional_millionths: Option, - } - - #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct ListpeerchannelsChannelsUpdatesRemote { - #[serde(skip_serializing_if = "Option::is_none")] - pub htlc_minimum_msat: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub htlc_maximum_msat: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub cltv_expiry_delta: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub fee_base_msat: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub fee_proportional_millionths: Option, - } - - #[derive(Clone, Debug, Deserialize, Serialize)] - pub struct ListpeerchannelsChannelsUpdates { - #[serde(skip_serializing_if = "Option::is_none")] - pub local: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub remote: Option, - } - #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ListpeerchannelsChannelsFeerate { #[serde(skip_serializing_if = "Option::is_none")] @@ -4587,8 +4564,6 @@ pub mod responses { #[serde(skip_serializing_if = "Option::is_none")] pub scratch_txid: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub updates: Option, - #[serde(skip_serializing_if = "Option::is_none")] pub ignore_fee_limits: Option, #[serde(skip_serializing_if = "Option::is_none")] pub feerate: Option, @@ -4903,7 +4878,7 @@ pub mod responses { } } - /// what kind of object it decoded to + /// ['what kind of object it decoded to'] #[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] pub enum DecodeType { #[serde(rename = "bolt12 offer")] diff --git a/contrib/msggen/msggen/utils/utils.py b/contrib/msggen/msggen/utils/utils.py index a2679bf5e9e9..8beb1200ba67 100644 --- a/contrib/msggen/msggen/utils/utils.py +++ b/contrib/msggen/msggen/utils/utils.py @@ -5,13 +5,12 @@ def load_jsonrpc_method(name, schema_dir: Path): - """Load a method based on the file naming conventions for the JSON-RPC. - """ + """Load a method based on the file naming conventions for the JSON-RPC.""" base_path = schema_dir - req_file = base_path / f"{name.lower()}.request.json" - resp_file = base_path / f"{name.lower()}.schema.json" - request = CompositeField.from_js(json.load(open(req_file)), path=name) - response = CompositeField.from_js(json.load(open(resp_file)), path=name) + json_file = base_path / f"lightning-{name.lower()}.json" + file_data = json.load(open(json_file)) + request = CompositeField.from_js(file_data.get('request', {}), path=name) + response = CompositeField.from_js(file_data.get('response', {}), path=name) # Normalize the method request and response typename so they no # longer conflict. @@ -33,7 +32,7 @@ def load_jsonrpc_service(schema_dir: str): "SendPay", "ListChannels", "AddGossip", - "AutoCleanInvoice", + # "AutoCleanInvoice", "CheckMessage", "Close", "Connect", diff --git a/contrib/pyln-testing/pyln/testing/fixtures.py b/contrib/pyln-testing/pyln/testing/fixtures.py index c0b0f9cfb134..3974b10d6ad3 100644 --- a/contrib/pyln-testing/pyln/testing/fixtures.py +++ b/contrib/pyln-testing/pyln/testing/fixtures.py @@ -412,15 +412,16 @@ def is_msat_or_any(checker, instance): type_checker=type_checker) -def _load_schema(filename, is_request): +def _load_schema(filename): """Load the schema from @filename and create a validator for it""" with open(filename, 'r') as f: - return _extra_validator(is_request)(json.load(f)) + data = json.load(f) + return [_extra_validator(False)(data.get('response', {})), _extra_validator(True)(data.get('request', {}))] @pytest.fixture(autouse=True) def jsonschemas(): - """Load schema files if they exist: returns request/response schemas by pairs""" + """Load schema file if it exist: returns response/request schemas by pairs""" try: schemafiles = os.listdir('doc/schemas') except FileNotFoundError: @@ -428,20 +429,11 @@ def jsonschemas(): schemas = {} for fname in schemafiles: - if fname.endswith('.schema.json'): - base = fname.rpartition('.schema')[0] - is_request = False - index = 1 - elif fname.endswith('.request.json'): - base = fname.rpartition('.request')[0] - is_request = True - index = 0 - else: - continue - if base not in schemas: + if fname.startswith('lightning-') and fname.endswith('.json'): + base = fname.replace('lightning-', '').replace('.json', '') + # Response is 0 and request is 1 schemas[base] = [None, None] - schemas[base][index] = _load_schema(os.path.join('doc/schemas', fname), - is_request) + schemas[base] = _load_schema(os.path.join('doc/schemas', fname)) return schemas diff --git a/contrib/pyln-testing/pyln/testing/grpc2py.py b/contrib/pyln-testing/pyln/testing/grpc2py.py index 086a859bc040..ed6ed8064f97 100644 --- a/contrib/pyln-testing/pyln/testing/grpc2py.py +++ b/contrib/pyln-testing/pyln/testing/grpc2py.py @@ -285,14 +285,6 @@ def addgossip2py(m): }) -def autocleaninvoice2py(m): - return remove_default({ - "enabled": m.enabled, # PrimitiveField in generate_composite - "expired_by": m.expired_by, # PrimitiveField in generate_composite - "cycle_seconds": m.cycle_seconds, # PrimitiveField in generate_composite - }) - - def checkmessage2py(m): return remove_default({ "verified": m.verified, # PrimitiveField in generate_composite @@ -785,31 +777,6 @@ def listpeerchannels_channels_channel_type2py(m): }) -def listpeerchannels_channels_updates_local2py(m): - return remove_default({ - "htlc_minimum_msat": amount2msat(m.htlc_minimum_msat), # PrimitiveField in generate_composite - "htlc_maximum_msat": amount2msat(m.htlc_maximum_msat), # PrimitiveField in generate_composite - "cltv_expiry_delta": m.cltv_expiry_delta, # PrimitiveField in generate_composite - "fee_base_msat": amount2msat(m.fee_base_msat), # PrimitiveField in generate_composite - "fee_proportional_millionths": m.fee_proportional_millionths, # PrimitiveField in generate_composite - }) - - -def listpeerchannels_channels_updates_remote2py(m): - return remove_default({ - "htlc_minimum_msat": amount2msat(m.htlc_minimum_msat), # PrimitiveField in generate_composite - "htlc_maximum_msat": amount2msat(m.htlc_maximum_msat), # PrimitiveField in generate_composite - "cltv_expiry_delta": m.cltv_expiry_delta, # PrimitiveField in generate_composite - "fee_base_msat": amount2msat(m.fee_base_msat), # PrimitiveField in generate_composite - "fee_proportional_millionths": m.fee_proportional_millionths, # PrimitiveField in generate_composite - }) - - -def listpeerchannels_channels_updates2py(m): - return remove_default({ - }) - - def listpeerchannels_channels_feerate2py(m): return remove_default({ "perkw": m.perkw, # PrimitiveField in generate_composite diff --git a/doc/Makefile b/doc/Makefile index 3d2843aa4f53..9025b8fd5069 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -227,8 +227,8 @@ check-manpages: all-programs check-config-docs default-targets # Makes sure that fields mentioned in schema are in man page, and vice versa. check-config-docs: - @for c in `sed -n 's/^ "\(.*\)": {/\1/p' doc/schemas/listconfigs.schema.json | grep -v '^# version$$' | grep -v '^plugins$$' | grep -v '^important-plugins$$'`; do if ! grep -q "^ \*\*$$c\*\*" doc/lightningd-config.5.md; then echo "$$c undocumented!"; exit 1; fi; done - @for c in `grep -v '\[plugin ' doc/lightningd-config.5.md | sed -n 's/^ \*\*\([^*]*\)\*\*.*/\1/p' | grep -v '^\(help\|version\|mainnet\|testnet\|signet\|plugin\|important-plugin\|plugin-dir\|clear-plugins\)$$'`; do if ! grep -q '"'"$$c"'"' doc/schemas/listconfigs.schema.json; then echo "$$c documented but not in schema!"; exit 1; fi; done + @for c in `sed -n 's/^ "\(.*\)": {/\1/p' doc/schemas/lightning-listconfigs.json | grep -v '^# version$$' | grep -v '^plugins$$' | grep -v '^important-plugins$$'`; do if ! grep -q "^ \*\*$$c\*\*" doc/lightningd-config.5.md; then echo "$$c undocumented!"; exit 1; fi; done + @for c in `grep -v '\[plugin ' doc/lightningd-config.5.md | sed -n 's/^ \*\*\([^*]*\)\*\*.*/\1/p' | grep -v '^\(help\|version\|mainnet\|testnet\|signet\|plugin\|important-plugin\|plugin-dir\|clear-plugins\)$$'`; do if ! grep -q '"'"$$c"'"' doc/schemas/lightning-listconfigs.json; then echo "$$c documented but not in schema!"; exit 1; fi; done doc-maintainer-clean: $(RM) $(MANPAGES) diff --git a/plugins/Makefile b/plugins/Makefile index 0e831f13356d..924f5f570f70 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -217,7 +217,7 @@ plugins/funder: bitcoin/psbt.o common/psbt_open.o $(PLUGIN_FUNDER_OBJS) $(PLUGIN # This covers all the low-level list RPCs which return simple arrays SQL_LISTRPCS := listchannels listforwards listhtlcs listinvoices listnodes listoffers listpeers listpeerchannels listclosedchannels listtransactions listsendpays bkpr-listaccountevents bkpr-listincome -SQL_LISTRPCS_SCHEMAS := $(foreach l,$(SQL_LISTRPCS),doc/schemas/$l.schema.json) +SQL_LISTRPCS_SCHEMAS := $(foreach l,$(SQL_LISTRPCS),doc/schemas/lightning-$l.json) # We squeeze: # descriptions (we don't need) # fields with no members (we don't need) @@ -225,8 +225,23 @@ SQL_LISTRPCS_SCHEMAS := $(foreach l,$(SQL_LISTRPCS),doc/schemas/$l.schema.json) # We can't simply *remove* fields, since the extra comma left over can # make invalid JSON. Grr! # But these simple removals drop us from 100k to 29k. +# plugins/sql-schema_gen.h: plugins/Makefile $(SQL_LISTRPCS_SCHEMAS) +# @$(call VERBOSE,GEN $@, (SEP=""; echo '"{'; for f in $(SQL_LISTRPCS); do echo "$$SEP\\\"$$f\\\":"; sed -e s/\"description\":\ *\".\*\"/\"\":\"\"/ -e s/\".*\":\ *{}/\"\":{}/ -e s/\"/\\\\\"/g < doc/schemas/lightning-$$f.json; SEP=","; done; echo '}"') | tr -d ' \n' > $@) plugins/sql-schema_gen.h: plugins/Makefile $(SQL_LISTRPCS_SCHEMAS) - @$(call VERBOSE,GEN $@, (SEP=""; echo '"{'; for f in $(SQL_LISTRPCS); do echo "$$SEP\\\"$$f\\\":"; sed -e s/\"description\":\ *\".\*\"/\"\":\"\"/ -e s/\".*\":\ *{}/\"\":{}/ -e s/\"/\\\\\"/g < doc/schemas/$$f.schema.json; SEP=","; done; echo '}"') | tr -d ' \n' > $@) + @$(call VERBOSE,GEN $@, \ + ( \ + SEP=""; \ + echo '"{'; \ + for f in $(SQL_LISTRPCS); do \ + RES_JSON=$$(echo "$$(jq '.response' < doc/schemas/lightning-$$f.json)"); \ + RESPONSE_JSON=$$(echo "$$RES_JSON" | jq 'del(.pre_return_value_notes, .post_return_value_notes, .return_value_notes)'); \ + MODIFIED_RESPONSE=$$(echo "$$RESPONSE_JSON" | sed -e 's/"description":\ *".*"/"":""/' -e 's/".*":\ *{}/"":{}/' -e 's/"/\\\\\"/g'); \ + echo "$$SEP\\\"$$f\\\":$$MODIFIED_RESPONSE"; \ + SEP=","; \ + done; \ + echo '}"' \ + ) | tr -d ' \n' > $@ \ + ) plugins/sql.o: plugins/sql-schema_gen.h plugins/sql: $(PLUGIN_SQL_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) common/gossip_store.o gossipd/gossip_store_wiregen.o