@@ -180,123 +180,172 @@ pub struct AcceptChannel {
180
180
/// A funding_created message to be sent or received from a peer
181
181
#[ derive( Clone ) ]
182
182
pub struct FundingCreated {
183
- pub ( crate ) temporary_channel_id : [ u8 ; 32 ] ,
184
- pub ( crate ) funding_txid : Txid ,
185
- pub ( crate ) funding_output_index : u16 ,
186
- pub ( crate ) signature : Signature ,
183
+ /// A temporary channel ID, until the funding is established
184
+ pub temporary_channel_id : [ u8 ; 32 ] ,
185
+ /// The funding transaction ID
186
+ pub funding_txid : Txid ,
187
+ /// The specific output index funding this channel
188
+ pub funding_output_index : u16 ,
189
+ /// The signature of the channel initiator (funder) on the funding transaction
190
+ pub signature : Signature ,
187
191
}
188
192
189
193
/// A funding_signed message to be sent or received from a peer
190
194
#[ derive( Clone ) ]
191
195
pub struct FundingSigned {
192
- pub ( crate ) channel_id : [ u8 ; 32 ] ,
193
- pub ( crate ) signature : Signature ,
196
+ /// The channel ID, which is the funding transaction ID mixed with the funding output index
197
+ pub channel_id : [ u8 ; 32 ] ,
198
+ /// The signature of the channel acceptor (fundee) on the funding transaction
199
+ pub signature : Signature ,
194
200
}
195
201
196
202
/// A funding_locked message to be sent or received from a peer
197
203
#[ derive( Clone , PartialEq ) ]
198
- #[ allow( missing_docs) ]
199
204
pub struct FundingLocked {
205
+ /// The channel ID
200
206
pub channel_id : [ u8 ; 32 ] ,
207
+ /// The per-commitment point of the second commitment transaction
201
208
pub next_per_commitment_point : PublicKey ,
202
209
}
203
210
204
211
/// A shutdown message to be sent or received from a peer
205
212
#[ derive( Clone , PartialEq ) ]
206
213
pub struct Shutdown {
207
- pub ( crate ) channel_id : [ u8 ; 32 ] ,
208
- pub ( crate ) scriptpubkey : Script ,
214
+ /// The channel ID
215
+ pub channel_id : [ u8 ; 32 ] ,
216
+ /// The destination of this peer's funds on closing.
217
+ /// Must be in one of these forms: p2pkh, p2sh, p2wpkh, p2wsh.
218
+ pub scriptpubkey : Script ,
209
219
}
210
220
211
221
/// A closing_signed message to be sent or received from a peer
212
222
#[ derive( Clone , PartialEq ) ]
213
223
pub struct ClosingSigned {
214
- pub ( crate ) channel_id : [ u8 ; 32 ] ,
215
- pub ( crate ) fee_satoshis : u64 ,
216
- pub ( crate ) signature : Signature ,
224
+ /// The channel ID
225
+ pub channel_id : [ u8 ; 32 ] ,
226
+ /// The proposed fee
227
+ pub fee_satoshis : u64 ,
228
+ /// A signature on the closing transaction
229
+ pub signature : Signature ,
217
230
}
218
231
219
232
/// An update_add_htlc message to be sent or received from a peer
220
233
#[ derive( Clone , PartialEq ) ]
221
234
pub struct UpdateAddHTLC {
222
- pub ( crate ) channel_id : [ u8 ; 32 ] ,
223
- pub ( crate ) htlc_id : u64 ,
224
- pub ( crate ) amount_msat : u64 ,
225
- pub ( crate ) payment_hash : PaymentHash ,
226
- pub ( crate ) cltv_expiry : u32 ,
235
+ /// The channel ID
236
+ pub channel_id : [ u8 ; 32 ] ,
237
+ /// The HTLC ID
238
+ pub htlc_id : u64 ,
239
+ /// The HTLC value in milli-satoshi
240
+ pub amount_msat : u64 ,
241
+ /// The payment hash
242
+ pub payment_hash : PaymentHash ,
243
+ /// The expiry height of the HTLC
244
+ pub cltv_expiry : u32 ,
227
245
pub ( crate ) onion_routing_packet : OnionPacket ,
228
246
}
229
247
230
248
/// An update_fulfill_htlc message to be sent or received from a peer
231
249
#[ derive( Clone , PartialEq ) ]
232
250
pub struct UpdateFulfillHTLC {
233
- pub ( crate ) channel_id : [ u8 ; 32 ] ,
234
- pub ( crate ) htlc_id : u64 ,
235
- pub ( crate ) payment_preimage : PaymentPreimage ,
251
+ /// The channel ID
252
+ pub channel_id : [ u8 ; 32 ] ,
253
+ /// The HTLC ID
254
+ pub htlc_id : u64 ,
255
+ /// The pre-image of the payment hash
256
+ pub payment_preimage : PaymentPreimage ,
236
257
}
237
258
238
259
/// An update_fail_htlc message to be sent or received from a peer
239
260
#[ derive( Clone , PartialEq ) ]
240
261
pub struct UpdateFailHTLC {
241
- pub ( crate ) channel_id : [ u8 ; 32 ] ,
242
- pub ( crate ) htlc_id : u64 ,
262
+ /// The channel ID
263
+ pub channel_id : [ u8 ; 32 ] ,
264
+ /// The HTLC ID
265
+ pub htlc_id : u64 ,
243
266
pub ( crate ) reason : OnionErrorPacket ,
244
267
}
245
268
246
269
/// An update_fail_malformed_htlc message to be sent or received from a peer
247
270
#[ derive( Clone , PartialEq ) ]
248
271
pub struct UpdateFailMalformedHTLC {
249
- pub ( crate ) channel_id : [ u8 ; 32 ] ,
250
- pub ( crate ) htlc_id : u64 ,
272
+ /// The channel ID
273
+ pub channel_id : [ u8 ; 32 ] ,
274
+ /// The HTLC ID
275
+ pub htlc_id : u64 ,
251
276
pub ( crate ) sha256_of_onion : [ u8 ; 32 ] ,
252
- pub ( crate ) failure_code : u16 ,
277
+ /// The failure code
278
+ pub failure_code : u16 ,
253
279
}
254
280
255
281
/// A commitment_signed message to be sent or received from a peer
256
282
#[ derive( Clone , PartialEq ) ]
257
283
pub struct CommitmentSigned {
258
- pub ( crate ) channel_id : [ u8 ; 32 ] ,
259
- pub ( crate ) signature : Signature ,
260
- pub ( crate ) htlc_signatures : Vec < Signature > ,
284
+ /// The channel ID
285
+ pub channel_id : [ u8 ; 32 ] ,
286
+ /// A signature on the commitment transaction
287
+ pub signature : Signature ,
288
+ /// Signatures on the HTLC transactions
289
+ pub htlc_signatures : Vec < Signature > ,
261
290
}
262
291
263
292
/// A revoke_and_ack message to be sent or received from a peer
264
293
#[ derive( Clone , PartialEq ) ]
265
294
pub struct RevokeAndACK {
266
- pub ( crate ) channel_id : [ u8 ; 32 ] ,
267
- pub ( crate ) per_commitment_secret : [ u8 ; 32 ] ,
268
- pub ( crate ) next_per_commitment_point : PublicKey ,
295
+ /// The channel ID
296
+ pub channel_id : [ u8 ; 32 ] ,
297
+ /// The secret corresponding to the per-commitment point
298
+ pub per_commitment_secret : [ u8 ; 32 ] ,
299
+ /// The next transaction's per-commitment point
300
+ pub next_per_commitment_point : PublicKey ,
269
301
}
270
302
271
303
/// An update_fee message to be sent or received from a peer
272
304
#[ derive( PartialEq , Clone ) ]
273
305
pub struct UpdateFee {
274
- pub ( crate ) channel_id : [ u8 ; 32 ] ,
275
- pub ( crate ) feerate_per_kw : u32 ,
306
+ /// The channel ID
307
+ pub channel_id : [ u8 ; 32 ] ,
308
+ /// Fee rate per 1000-weight of the transaction
309
+ pub feerate_per_kw : u32 ,
276
310
}
277
311
278
312
#[ derive( PartialEq , Clone ) ]
279
- pub ( crate ) struct DataLossProtect {
280
- pub ( crate ) your_last_per_commitment_secret : [ u8 ; 32 ] ,
281
- pub ( crate ) my_current_per_commitment_point : PublicKey ,
313
+ /// Proof that the sender knows the per-commitment secret of the previous commitment transaction.
314
+ /// This is used to convince the recipient that the channel is at a certain commitment
315
+ /// number even if they lost that data due to a local failure. Of course, the peer may lie
316
+ /// and even later commitments may have been revoked.
317
+ pub struct DataLossProtect {
318
+ /// Proof that the sender knows the per-commitment secret of a specific commitment transaction
319
+ /// belonging to the recipient
320
+ pub your_last_per_commitment_secret : [ u8 ; 32 ] ,
321
+ /// The sender's per-commitment point for their current commitment transaction
322
+ pub my_current_per_commitment_point : PublicKey ,
282
323
}
283
324
284
325
/// A channel_reestablish message to be sent or received from a peer
285
326
#[ derive( PartialEq , Clone ) ]
286
327
pub struct ChannelReestablish {
287
- pub ( crate ) channel_id : [ u8 ; 32 ] ,
288
- pub ( crate ) next_local_commitment_number : u64 ,
289
- pub ( crate ) next_remote_commitment_number : u64 ,
290
- pub ( crate ) data_loss_protect : OptionalField < DataLossProtect > ,
328
+ /// The channel ID
329
+ pub channel_id : [ u8 ; 32 ] ,
330
+ /// The next commitment number for the sender
331
+ pub next_local_commitment_number : u64 ,
332
+ /// The next commitment number for the recipient
333
+ pub next_remote_commitment_number : u64 ,
334
+ /// Optionally, a field proving that next_remote_commitment_number-1 has been revoked
335
+ pub data_loss_protect : OptionalField < DataLossProtect > ,
291
336
}
292
337
293
338
/// An announcement_signatures message to be sent or received from a peer
294
339
#[ derive( PartialEq , Clone , Debug ) ]
295
340
pub struct AnnouncementSignatures {
296
- pub ( crate ) channel_id : [ u8 ; 32 ] ,
297
- pub ( crate ) short_channel_id : u64 ,
298
- pub ( crate ) node_signature : Signature ,
299
- pub ( crate ) bitcoin_signature : Signature ,
341
+ /// The channel ID
342
+ pub channel_id : [ u8 ; 32 ] ,
343
+ /// The short channel ID
344
+ pub short_channel_id : u64 ,
345
+ /// A signature by the node key
346
+ pub node_signature : Signature ,
347
+ /// A signature by the funding key
348
+ pub bitcoin_signature : Signature ,
300
349
}
301
350
302
351
/// An address which can be used to connect to a remote peer
@@ -426,73 +475,100 @@ impl Readable for Result<NetAddress, u8> {
426
475
}
427
476
}
428
477
429
- // Only exposed as broadcast of node_announcement should be filtered by node_id
430
478
/// The unsigned part of a node_announcement
431
479
#[ derive( PartialEq , Clone , Debug ) ]
432
480
pub struct UnsignedNodeAnnouncement {
433
- pub ( crate ) features : NodeFeatures ,
434
- pub ( crate ) timestamp : u32 ,
481
+ /// The advertised features
482
+ pub features : NodeFeatures ,
483
+ /// A strictly monotonic announcement counter, with gaps allowed
484
+ pub timestamp : u32 ,
435
485
/// The node_id this announcement originated from (don't rebroadcast the node_announcement back
436
486
/// to this node).
437
- pub node_id : PublicKey ,
438
- pub ( crate ) rgb : [ u8 ; 3 ] ,
439
- pub ( crate ) alias : [ u8 ; 32 ] ,
487
+ pub node_id : PublicKey ,
488
+ /// An RGB color for UI purposes
489
+ pub rgb : [ u8 ; 3 ] ,
490
+ /// An alias, for UI purposes. This should be sanitized before use. There is no guarantee
491
+ /// of uniqueness.
492
+ pub alias : [ u8 ; 32 ] ,
440
493
/// List of addresses on which this node is reachable. Note that you may only have up to one
441
494
/// address of each type, if you have more, they may be silently discarded or we may panic!
442
- pub ( crate ) addresses : Vec < NetAddress > ,
495
+ pub addresses : Vec < NetAddress > ,
443
496
pub ( crate ) excess_address_data : Vec < u8 > ,
444
497
pub ( crate ) excess_data : Vec < u8 > ,
445
498
}
446
499
#[ derive( PartialEq , Clone , Debug ) ]
447
500
/// A node_announcement message to be sent or received from a peer
448
501
pub struct NodeAnnouncement {
449
- pub ( crate ) signature : Signature ,
450
- pub ( crate ) contents : UnsignedNodeAnnouncement ,
502
+ /// The signature by the node key
503
+ pub signature : Signature ,
504
+ /// The actual content of the announcement
505
+ pub contents : UnsignedNodeAnnouncement ,
451
506
}
452
507
453
- // Only exposed as broadcast of channel_announcement should be filtered by node_id
454
508
/// The unsigned part of a channel_announcement
455
509
#[ derive( PartialEq , Clone , Debug ) ]
456
510
pub struct UnsignedChannelAnnouncement {
457
- pub ( crate ) features : ChannelFeatures ,
458
- pub ( crate ) chain_hash : BlockHash ,
459
- pub ( crate ) short_channel_id : u64 ,
511
+ /// The advertised features
512
+ pub features : ChannelFeatures ,
513
+ /// The genesis hash of the blockchain where the channel is to be opened
514
+ pub chain_hash : BlockHash ,
515
+ /// The short channel ID
516
+ pub short_channel_id : u64 ,
460
517
/// One of the two node_ids which are endpoints of this channel
461
- pub node_id_1 : PublicKey ,
518
+ pub node_id_1 : PublicKey ,
462
519
/// The other of the two node_ids which are endpoints of this channel
463
- pub node_id_2 : PublicKey ,
464
- pub ( crate ) bitcoin_key_1 : PublicKey ,
465
- pub ( crate ) bitcoin_key_2 : PublicKey ,
520
+ pub node_id_2 : PublicKey ,
521
+ /// The funding key for the first node
522
+ pub bitcoin_key_1 : PublicKey ,
523
+ /// The funding key for the second node
524
+ pub bitcoin_key_2 : PublicKey ,
466
525
pub ( crate ) excess_data : Vec < u8 > ,
467
526
}
468
527
/// A channel_announcement message to be sent or received from a peer
469
528
#[ derive( PartialEq , Clone , Debug ) ]
470
529
pub struct ChannelAnnouncement {
471
- pub ( crate ) node_signature_1 : Signature ,
472
- pub ( crate ) node_signature_2 : Signature ,
473
- pub ( crate ) bitcoin_signature_1 : Signature ,
474
- pub ( crate ) bitcoin_signature_2 : Signature ,
475
- pub ( crate ) contents : UnsignedChannelAnnouncement ,
476
- }
477
-
530
+ /// A signature of the announcement by the node key of the first node
531
+ pub node_signature_1 : Signature ,
532
+ /// A signature of the announcement by the node key of the second node
533
+ pub node_signature_2 : Signature ,
534
+ /// The funding signature of the first node
535
+ pub bitcoin_signature_1 : Signature ,
536
+ /// The funding signature of the second node
537
+ pub bitcoin_signature_2 : Signature ,
538
+ /// The actual announcement
539
+ pub contents : UnsignedChannelAnnouncement ,
540
+ }
541
+
542
+ /// The unsigned part of a channel_update
478
543
#[ derive( PartialEq , Clone , Debug ) ]
479
- pub ( crate ) struct UnsignedChannelUpdate {
480
- pub ( crate ) chain_hash : BlockHash ,
481
- pub ( crate ) short_channel_id : u64 ,
482
- pub ( crate ) timestamp : u32 ,
483
- pub ( crate ) flags : u8 ,
484
- pub ( crate ) cltv_expiry_delta : u16 ,
485
- pub ( crate ) htlc_minimum_msat : u64 ,
486
- pub ( crate ) htlc_maximum_msat : OptionalField < u64 > ,
487
- pub ( crate ) fee_base_msat : u32 ,
488
- pub ( crate ) fee_proportional_millionths : u32 ,
544
+ pub struct UnsignedChannelUpdate {
545
+ /// The genesis hash of the blockchain where the channel is to be opened
546
+ pub chain_hash : BlockHash ,
547
+ /// The short channel ID
548
+ pub short_channel_id : u64 ,
549
+ /// A strictly monotonic announcement counter, with gaps allowed, specific to this channel
550
+ pub timestamp : u32 ,
551
+ /// Channel flags
552
+ pub flags : u8 ,
553
+ /// The number of blocks to subtract from incoming HTLC cltv_expiry values
554
+ pub cltv_expiry_delta : u16 ,
555
+ /// The minimum HTLC value in milli-satoshi
556
+ pub htlc_minimum_msat : u64 ,
557
+ /// Optionally, the maximum HTLC value in milli-satoshi
558
+ pub htlc_maximum_msat : OptionalField < u64 > ,
559
+ /// The base HTLC fee in milli-satoshi
560
+ pub fee_base_msat : u32 ,
561
+ /// The amount to fee multiplier, in micro-satoshi
562
+ pub fee_proportional_millionths : u32 ,
489
563
pub ( crate ) excess_data : Vec < u8 > ,
490
564
}
491
565
/// A channel_update message to be sent or received from a peer
492
566
#[ derive( PartialEq , Clone , Debug ) ]
493
567
pub struct ChannelUpdate {
494
- pub ( crate ) signature : Signature ,
495
- pub ( crate ) contents : UnsignedChannelUpdate ,
568
+ /// A signature of the channel update
569
+ pub signature : Signature ,
570
+ /// The actual channel update
571
+ pub contents : UnsignedChannelUpdate ,
496
572
}
497
573
498
574
/// Used to put an error message in a LightningError
0 commit comments