doc: fix listnodes schema, doc.

Shows the dangers of "additionalProperties": true.  We didn't have an else
clause, so our incorrect (and, with DF, incomplete!) schema was accepted.

I despair of getting anyone else to write a decent schema with these
semantics :(

Changelog-Fixed: doc: listnodes fields now correctly documented.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2021-08-31 10:03:12 +09:30
parent 372fffac69
commit 1c8294ef1c
3 changed files with 98 additions and 10 deletions

View File

@ -30,11 +30,11 @@ On success, an object containing \fBnodes\fR is returned\. It is an array of ob
.IP \[bu]
\fBnodeid\fR (pubkey): the public key of the node
.IP \[bu]
\fBlast_update\fR (u32, optional): A node_announcement has been received for this node (UNIX timestamp)
\fBlast_timestamp\fR (u32, optional): A node_announcement has been received for this node (UNIX timestamp)
.RE
If \fBlast_update\fR is present:
If \fBlast_timestamp\fR is present:
.RS
.IP \[bu]
@ -56,6 +56,30 @@ If \fBlast_update\fR is present:
.RE
.RE
If \fBoption_will_fund\fR is present:
.RS
.IP \[bu]
\fBoption_will_fund\fR (object):
.RS
.IP \[bu]
\fBlease_fee_base_msat\fR (msat): the fixed fee for a lease (whole number of satoshis)
.IP \[bu]
\fBlease_fee_basis\fR (u32): the proportional fee in basis points (parts per 10,000) for a lease
.IP \[bu]
\fBfunding_weight\fR (u32): the onchain weight you'll have to pay for a lease
.IP \[bu]
\fBchannel_fee_max_base_msat\fR (msat): the maximum base routing fee this node will charge during the lease
.IP \[bu]
\fBchannel_fee_max_proportional_thousandths\fR (u32): the maximum proportional routing fee this node will charge during the lease (in thousandths, not millionths like channel_update)
.IP \[bu]
\fBcompact_lease\fR (hex): the lease as represented in the node_announcement
.RE
.RE
On failure, one of the following error codes may be returned:
@ -101,4 +125,4 @@ FIXME:
Main web site: \fIhttps://github.com/ElementsProject/lightning\fR
\" SHA256STAMP:4366d5c238bccc06cfafc4c2d375dd417049b0b6224f13b2dcc9f25139587649
\" SHA256STAMP:69fff299a28ed38a79e120eb4a7057db1cee86ce9bd85c7624226cbe79d70eb4

View File

@ -29,9 +29,9 @@ RETURN VALUE
[comment]: # (GENERATE-FROM-SCHEMA-START)
On success, an object containing **nodes** is returned. It is an array of objects, where each object contains:
- **nodeid** (pubkey): the public key of the node
- **last_update** (u32, optional): A node_announcement has been received for this node (UNIX timestamp)
- **last_timestamp** (u32, optional): A node_announcement has been received for this node (UNIX timestamp)
If **last_update** is present:
If **last_timestamp** is present:
- **alias** (string): The fun alias this node advertized (up to 32 characters)
- **color** (hex): The favorite RGB color this node advertized (always 6 characters)
- **features** (hex): BOLT #9 features bitmap this node advertized
@ -39,6 +39,15 @@ If **last_update** is present:
- **type** (string): Type of connection (one of "ipv4", "ipv6", "torv2", "torv3")
- **address** (string): address in expected format for *type*
- **port** (u16): port number
If **option_will_fund** is present:
- **option_will_fund** (object):
- **lease_fee_base_msat** (msat): the fixed fee for a lease (whole number of satoshis)
- **lease_fee_basis** (u32): the proportional fee in basis points (parts per 10,000) for a lease
- **funding_weight** (u32): the onchain weight you'll have to pay for a lease
- **channel_fee_max_base_msat** (msat): the maximum base routing fee this node will charge during the lease
- **channel_fee_max_proportional_thousandths** (u32): the maximum proportional routing fee this node will charge during the lease (in thousandths, not millionths like channel_update)
- **compact_lease** (hex): the lease as represented in the node_announcement
[comment]: # (GENERATE-FROM-SCHEMA-END)
On failure, one of the following error codes may be returned:
@ -83,4 +92,4 @@ RESOURCES
---------
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:2f644d55512f5c03e3894341fb039fc1b7d2ebc5f210547fdb324d2f23689b37)
[comment]: # ( SHA256STAMP:08959d1bce493b3d3c28fcc4b54e492feecc1062d960ea685899213327c8e768)

View File

@ -15,7 +15,7 @@
"type": "pubkey",
"description": "the public key of the node"
},
"last_update": {
"last_timestamp": {
"type": "u32",
"description": "A node_announcement has been received for this node (UNIX timestamp)"
}
@ -23,13 +23,15 @@
"allOf": [
{
"if": {
"required": [ "last_update" ]
"required": [ "last_timestamp" ]
},
"then": {
"additionalProperties": false,
"required": [ "last_update", "alias", "color", "features", "addresses" ],
"required": [ "nodeid", "last_timestamp", "alias", "color", "features", "addresses" ],
"properties": {
"last_update": { },
"nodeid": { },
"last_timestamp": { },
"option_will_fund": { },
"alias": {
"type": "string",
"description": "The fun alias this node advertized",
@ -70,6 +72,59 @@
}
}
}
},
"else": {
"additionalProperties": false,
"properties": {
"nodeid": { }
}
}
},
{
"if": {
"required": [ "option_will_fund" ]
},
"then": {
"additionalProperties": true,
"required": [ "option_will_fund" ],
"properties": {
"option_will_fund": {
"type": "object",
"additionalProperties": false,
"required": [ "lease_fee_base_msat",
"lease_fee_basis",
"funding_weight",
"channel_fee_max_base_msat",
"channel_fee_max_proportional_thousandths",
"compact_lease" ],
"properties": {
"lease_fee_base_msat": {
"type": "msat",
"description": "the fixed fee for a lease (whole number of satoshis)"
},
"lease_fee_basis": {
"type": "u32",
"description": "the proportional fee in basis points (parts per 10,000) for a lease"
},
"funding_weight": {
"type": "u32",
"description": "the onchain weight you'll have to pay for a lease"
},
"channel_fee_max_base_msat": {
"type": "msat",
"description": "the maximum base routing fee this node will charge during the lease"
},
"channel_fee_max_proportional_thousandths": {
"type": "u32",
"description": "the maximum proportional routing fee this node will charge during the lease (in thousandths, not millionths like channel_update)"
},
"compact_lease": {
"type": "hex",
"description": "the lease as represented in the node_announcement"
}
}
}
}
}
}
]