@@ -164,37 +164,43 @@ def to_json(self) -> Mapping[str, Any]:
164
164
"channel_id" : self .id ,
165
165
"channel_created_at" : self .created_at .isoformat (),
166
166
"channel_updated_at" : self .updated_at .isoformat (),
167
- "channel_funding_transaction" : {"id" : self .funding_transaction_id }
168
- if self .funding_transaction_id
169
- else None ,
167
+ "channel_funding_transaction" : (
168
+ {"id" : self .funding_transaction_id }
169
+ if self .funding_transaction_id
170
+ else None
171
+ ),
170
172
"channel_capacity" : self .capacity .to_json () if self .capacity else None ,
171
- "channel_local_balance" : self .local_balance .to_json ()
172
- if self .local_balance
173
- else None ,
174
- "channel_local_unsettled_balance" : self .local_unsettled_balance .to_json ()
175
- if self .local_unsettled_balance
176
- else None ,
177
- "channel_remote_balance" : self .remote_balance .to_json ()
178
- if self .remote_balance
179
- else None ,
180
- "channel_remote_unsettled_balance" : self .remote_unsettled_balance .to_json ()
181
- if self .remote_unsettled_balance
182
- else None ,
183
- "channel_unsettled_balance" : self .unsettled_balance .to_json ()
184
- if self .unsettled_balance
185
- else None ,
186
- "channel_total_balance" : self .total_balance .to_json ()
187
- if self .total_balance
188
- else None ,
173
+ "channel_local_balance" : (
174
+ self .local_balance .to_json () if self .local_balance else None
175
+ ),
176
+ "channel_local_unsettled_balance" : (
177
+ self .local_unsettled_balance .to_json ()
178
+ if self .local_unsettled_balance
179
+ else None
180
+ ),
181
+ "channel_remote_balance" : (
182
+ self .remote_balance .to_json () if self .remote_balance else None
183
+ ),
184
+ "channel_remote_unsettled_balance" : (
185
+ self .remote_unsettled_balance .to_json ()
186
+ if self .remote_unsettled_balance
187
+ else None
188
+ ),
189
+ "channel_unsettled_balance" : (
190
+ self .unsettled_balance .to_json () if self .unsettled_balance else None
191
+ ),
192
+ "channel_total_balance" : (
193
+ self .total_balance .to_json () if self .total_balance else None
194
+ ),
189
195
"channel_status" : self .status .value if self .status else None ,
190
196
"channel_estimated_force_closure_wait_minutes" : self .estimated_force_closure_wait_minutes ,
191
- "channel_commit_fee" : self . commit_fee . to_json ()
192
- if self .commit_fee
193
- else None ,
197
+ "channel_commit_fee" : (
198
+ self . commit_fee . to_json () if self .commit_fee else None
199
+ ) ,
194
200
"channel_fees" : self .fees .to_json () if self .fees else None ,
195
- "channel_remote_node" : { "id" : self . remote_node_id }
196
- if self .remote_node_id
197
- else None ,
201
+ "channel_remote_node" : (
202
+ { "id" : self . remote_node_id } if self .remote_node_id else None
203
+ ) ,
198
204
"channel_local_node" : {"id" : self .local_node_id },
199
205
"channel_short_channel_id" : self .short_channel_id ,
200
206
}
@@ -305,51 +311,63 @@ def from_json(requester: Requester, obj: Mapping[str, Any]) -> Channel:
305
311
id = obj ["channel_id" ],
306
312
created_at = datetime .fromisoformat (obj ["channel_created_at" ]),
307
313
updated_at = datetime .fromisoformat (obj ["channel_updated_at" ]),
308
- funding_transaction_id = obj ["channel_funding_transaction" ]["id" ]
309
- if obj ["channel_funding_transaction" ]
310
- else None ,
311
- capacity = CurrencyAmount_from_json (requester , obj ["channel_capacity" ])
312
- if obj ["channel_capacity" ]
313
- else None ,
314
- local_balance = CurrencyAmount_from_json (requester , obj ["channel_local_balance" ])
315
- if obj ["channel_local_balance" ]
316
- else None ,
317
- local_unsettled_balance = CurrencyAmount_from_json (
318
- requester , obj ["channel_local_unsettled_balance" ]
319
- )
320
- if obj ["channel_local_unsettled_balance" ]
321
- else None ,
322
- remote_balance = CurrencyAmount_from_json (
323
- requester , obj ["channel_remote_balance" ]
324
- )
325
- if obj ["channel_remote_balance" ]
326
- else None ,
327
- remote_unsettled_balance = CurrencyAmount_from_json (
328
- requester , obj ["channel_remote_unsettled_balance" ]
329
- )
330
- if obj ["channel_remote_unsettled_balance" ]
331
- else None ,
332
- unsettled_balance = CurrencyAmount_from_json (
333
- requester , obj ["channel_unsettled_balance" ]
334
- )
335
- if obj ["channel_unsettled_balance" ]
336
- else None ,
337
- total_balance = CurrencyAmount_from_json (requester , obj ["channel_total_balance" ])
338
- if obj ["channel_total_balance" ]
339
- else None ,
314
+ funding_transaction_id = (
315
+ obj ["channel_funding_transaction" ]["id" ]
316
+ if obj ["channel_funding_transaction" ]
317
+ else None
318
+ ),
319
+ capacity = (
320
+ CurrencyAmount_from_json (requester , obj ["channel_capacity" ])
321
+ if obj ["channel_capacity" ]
322
+ else None
323
+ ),
324
+ local_balance = (
325
+ CurrencyAmount_from_json (requester , obj ["channel_local_balance" ])
326
+ if obj ["channel_local_balance" ]
327
+ else None
328
+ ),
329
+ local_unsettled_balance = (
330
+ CurrencyAmount_from_json (requester , obj ["channel_local_unsettled_balance" ])
331
+ if obj ["channel_local_unsettled_balance" ]
332
+ else None
333
+ ),
334
+ remote_balance = (
335
+ CurrencyAmount_from_json (requester , obj ["channel_remote_balance" ])
336
+ if obj ["channel_remote_balance" ]
337
+ else None
338
+ ),
339
+ remote_unsettled_balance = (
340
+ CurrencyAmount_from_json (requester , obj ["channel_remote_unsettled_balance" ])
341
+ if obj ["channel_remote_unsettled_balance" ]
342
+ else None
343
+ ),
344
+ unsettled_balance = (
345
+ CurrencyAmount_from_json (requester , obj ["channel_unsettled_balance" ])
346
+ if obj ["channel_unsettled_balance" ]
347
+ else None
348
+ ),
349
+ total_balance = (
350
+ CurrencyAmount_from_json (requester , obj ["channel_total_balance" ])
351
+ if obj ["channel_total_balance" ]
352
+ else None
353
+ ),
340
354
status = parse_enum_optional (ChannelStatus , obj ["channel_status" ]),
341
355
estimated_force_closure_wait_minutes = obj [
342
356
"channel_estimated_force_closure_wait_minutes"
343
357
],
344
- commit_fee = CurrencyAmount_from_json (requester , obj ["channel_commit_fee" ])
345
- if obj ["channel_commit_fee" ]
346
- else None ,
347
- fees = ChannelFees_from_json (requester , obj ["channel_fees" ])
348
- if obj ["channel_fees" ]
349
- else None ,
350
- remote_node_id = obj ["channel_remote_node" ]["id" ]
351
- if obj ["channel_remote_node" ]
352
- else None ,
358
+ commit_fee = (
359
+ CurrencyAmount_from_json (requester , obj ["channel_commit_fee" ])
360
+ if obj ["channel_commit_fee" ]
361
+ else None
362
+ ),
363
+ fees = (
364
+ ChannelFees_from_json (requester , obj ["channel_fees" ])
365
+ if obj ["channel_fees" ]
366
+ else None
367
+ ),
368
+ remote_node_id = (
369
+ obj ["channel_remote_node" ]["id" ] if obj ["channel_remote_node" ] else None
370
+ ),
353
371
local_node_id = obj ["channel_local_node" ]["id" ],
354
372
short_channel_id = obj ["channel_short_channel_id" ],
355
373
)
0 commit comments