1{
2    "$schema": "http://json-schema.org/draft-07/schema#",
3    "type": "object",
4    "additionalProperties": false,
5    "required": [ "outputs", "channels" ],
6    "properties": {
7	"outputs": {
8	    "type": "array",
9	    "items": {
10		"type": "object",
11		"additionalProperties": true,
12		"required": [ "txid", "output", "amount_msat", "scriptpubkey", "status", "reserved" ],
13		"properties": {
14		    "txid": {
15			"type": "txid",
16			"description": "the ID of the spendable transaction"
17		    },
18		    "output": {
19			"type": "u32",
20			"description": "the index within *txid*"
21		    },
22		    "amount_msat": {
23			"type": "msat",
24			"description": "the amount of the output"
25		    },
26		    "value": {
27			"type": "u64",
28			"deprecated": true
29		    },
30		    "scriptpubkey": {
31			"type": "hex",
32			"description": "the scriptPubkey of the output"
33		    },
34		    "address": {
35			"type": "string",
36			"description": "the bitcoin address of the output"
37		    },
38		    "redeemscript": {
39			"type": "hex",
40			"description": "the redeemscript, only if it's p2sh-wrapped"
41		    },
42		    "status": {
43			"type": "string",
44			"enum": [ "unconfirmed", "confirmed", "spent" ]
45		    }
46		},
47		"allOf": [
48		    {
49			"if": {
50			    "properties": {
51				"status": {
52				    "type": "string",
53				    "enum": [ "confirmed" ]
54				}
55			    }
56			},
57			"then": {
58			    "additionalProperties": false,
59			    "required": [ "blockheight" ],
60			    "properties": {
61				"txid": { },
62				"output": { },
63				"amount_msat": { },
64				"scriptpubkey": { },
65				"address": { },
66				"value": { },
67				"redeemscript": { },
68				"status": { },
69				"reserved": { },
70				"reserved_to_block": { },
71				"blockheight": {
72				    "type": "u32",
73				    "description": "Block height where it was confirmed"
74				}
75			    }
76			}
77		    },
78		    {
79			"if": {
80			    "properties": {
81				"reserved": {
82				    "type": "boolean",
83				    "enum": [ "true" ]
84				}
85			    }
86			},
87			"then": {
88			    "additionalProperties": false,
89			    "required": [ "reserved_to_block" ],
90			    "properties": {
91				"txid": { },
92				"output": { },
93				"amount_msat": { },
94				"scriptpubkey": { },
95				"address": { },
96				"value": { },
97				"redeemscript": { },
98				"status": { },
99				"blockheight": { },
100				"reserved": { },
101				"reserved_to_block": {
102				    "type": "u32",
103				    "description": "Block height where reservation will expire"
104				}
105			    }
106			}
107		    }
108		]
109	    }
110	},
111	"channels": {
112	    "type": "array",
113	    "items": {
114		"type": "object",
115		"additionalProperties": true,
116		"required": [ "peer_id", "our_amount_msat", "amount_msat", "funding_txid", "funding_output", "connected", "state" ],
117		"properties": {
118		    "peer_id": {
119			"type": "pubkey",
120			"description": "the peer with which the channel is opened"
121		    },
122		    "our_amount_msat": {
123			"type": "msat",
124			"description": "available satoshis on our node’s end of the channel"
125		    },
126		    "channel_sat": {
127			"deprecated": true
128		    },
129		    "amount_msat": {
130			"type": "msat",
131			"description": "total channel value"
132		    },
133		    "channel_total_sat": {
134			"deprecated": true
135		    },
136		    "funding_txid": {
137			"type": "txid",
138			"description": "funding transaction id"
139		    },
140		    "funding_output": {
141			"type": "u32",
142			"description": "the 0-based index of the output in the funding transaction"
143		    },
144		    "connected": {
145			"type": "boolean",
146			"description": "whether the channel peer is connected"
147		    },
148		    "state": {
149			"type": "string",
150			"enum": [ "OPENINGD", "CHANNELD_AWAITING_LOCKIN", "CHANNELD_NORMAL", "CHANNELD_SHUTTING_DOWN", "CLOSINGD_SIGEXCHANGE", "CLOSINGD_COMPLETE", "AWAITING_UNILATERAL", "FUNDING_SPEND_SEEN", "ONCHAIN", "DUALOPEND_OPEN_INIT", "DUALOPEND_AWAITING_LOCKIN" ],
151			"description": "the channel state, in particular \"CHANNELD_NORMAL\" means the channel can be used normally"
152		    }
153		},
154		"allOf": [
155		    {
156			"if": {
157			    "properties": {
158				"state": {
159				    "type": "string",
160				    "enum": [ "CHANNELD_NORMAL" ]
161				}
162			    }
163			},
164			"then": {
165			    "additionalProperties": false,
166			    "required": [ "short_channel_id" ],
167			    "properties": {
168				"peer_id": { },
169				"our_amount_msat": { },
170				"channel_sat": { },
171				"amount_msat": { },
172				"channel_total_sat": { },
173				"funding_txid": { },
174				"funding_output": { },
175				"connected": { },
176				"state": { },
177				"short_channel_id": {
178				    "type": "short_channel_id",
179				    "description": "short channel id of channel"
180				}
181			    }
182			}
183		    },
184		    {
185			"if": {
186			    "properties": {
187				"state": {
188				    "type": "string",
189				    "enum": [ "CHANNELD_SHUTTING_DOWN", "CLOSINGD_SIGEXCHANGE", "CLOSINGD_COMPLETE", "AWAITING_UNILATERAL", "FUNDING_SPEND_SEEN", "ONCHAIN" ]
190				}
191			    }
192			},
193			"then": {
194			    "additionalProperties": false,
195			    "required": [ ],
196			    "properties": {
197				"peer_id": { },
198				"our_amount_msat": { },
199				"channel_sat": { },
200				"amount_msat": { },
201				"channel_total_sat": { },
202				"funding_txid": { },
203				"funding_output": { },
204				"connected": { },
205				"state": { },
206				"short_channel_id": {
207				    "type": "short_channel_id",
208				    "description": "short channel id of channel (only if funding reached lockin depth before closing)"
209				}
210			    }
211			}
212		    }
213		]
214	    }
215	}
216    }
217}
218