@@ -180,123 +180,172 @@ pub struct AcceptChannel {
180180/// A funding_created message to be sent or received from a peer
181181#[ derive( Clone ) ]
182182pub 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 ,
187191}
188192
189193/// A funding_signed message to be sent or received from a peer
190194#[ derive( Clone ) ]
191195pub 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 ,
194200}
195201
196202/// A funding_locked message to be sent or received from a peer
197203#[ derive( Clone , PartialEq ) ]
198- #[ allow( missing_docs) ]
199204pub struct FundingLocked {
205+ /// The channel ID
200206 pub channel_id : [ u8 ; 32 ] ,
207+ /// The per-commitment point of the second commitment transaction
201208 pub next_per_commitment_point : PublicKey ,
202209}
203210
204211/// A shutdown message to be sent or received from a peer
205212#[ derive( Clone , PartialEq ) ]
206213pub 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 ,
209219}
210220
211221/// A closing_signed message to be sent or received from a peer
212222#[ derive( Clone , PartialEq ) ]
213223pub 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 ,
217230}
218231
219232/// An update_add_htlc message to be sent or received from a peer
220233#[ derive( Clone , PartialEq ) ]
221234pub 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 ,
227245 pub ( crate ) onion_routing_packet : OnionPacket ,
228246}
229247
230248/// An update_fulfill_htlc message to be sent or received from a peer
231249#[ derive( Clone , PartialEq ) ]
232250pub 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 ,
236257}
237258
238259/// An update_fail_htlc message to be sent or received from a peer
239260#[ derive( Clone , PartialEq ) ]
240261pub 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 ,
243266 pub ( crate ) reason : OnionErrorPacket ,
244267}
245268
246269/// An update_fail_malformed_htlc message to be sent or received from a peer
247270#[ derive( Clone , PartialEq ) ]
248271pub 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 ,
251276 pub ( crate ) sha256_of_onion : [ u8 ; 32 ] ,
252- pub ( crate ) failure_code : u16 ,
277+ /// The failure code
278+ pub failure_code : u16 ,
253279}
254280
255281/// A commitment_signed message to be sent or received from a peer
256282#[ derive( Clone , PartialEq ) ]
257283pub 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 > ,
261290}
262291
263292/// A revoke_and_ack message to be sent or received from a peer
264293#[ derive( Clone , PartialEq ) ]
265294pub 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 ,
269301}
270302
271303/// An update_fee message to be sent or received from a peer
272304#[ derive( PartialEq , Clone ) ]
273305pub 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 ,
276310}
277311
278312#[ 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 ,
282323}
283324
284325/// A channel_reestablish message to be sent or received from a peer
285326#[ derive( PartialEq , Clone ) ]
286327pub 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 > ,
291336}
292337
293338/// An announcement_signatures message to be sent or received from a peer
294339#[ derive( PartialEq , Clone , Debug ) ]
295340pub 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 ,
300349}
301350
302351/// An address which can be used to connect to a remote peer
@@ -426,73 +475,100 @@ impl Readable for Result<NetAddress, u8> {
426475 }
427476}
428477
429- // Only exposed as broadcast of node_announcement should be filtered by node_id
430478/// The unsigned part of a node_announcement
431479#[ derive( PartialEq , Clone , Debug ) ]
432480pub 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 ,
435485 /// The node_id this announcement originated from (don't rebroadcast the node_announcement back
436486 /// 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 ] ,
440493 /// List of addresses on which this node is reachable. Note that you may only have up to one
441494 /// 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 > ,
443496 pub ( crate ) excess_address_data : Vec < u8 > ,
444497 pub ( crate ) excess_data : Vec < u8 > ,
445498}
446499#[ derive( PartialEq , Clone , Debug ) ]
447500/// A node_announcement message to be sent or received from a peer
448501pub 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 ,
451506}
452507
453- // Only exposed as broadcast of channel_announcement should be filtered by node_id
454508/// The unsigned part of a channel_announcement
455509#[ derive( PartialEq , Clone , Debug ) ]
456510pub 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 ,
460517 /// One of the two node_ids which are endpoints of this channel
461- pub node_id_1 : PublicKey ,
518+ pub node_id_1 : PublicKey ,
462519 /// 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 ,
466525 pub ( crate ) excess_data : Vec < u8 > ,
467526}
468527/// A channel_announcement message to be sent or received from a peer
469528#[ derive( PartialEq , Clone , Debug ) ]
470529pub 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
478543#[ 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 ,
489563 pub ( crate ) excess_data : Vec < u8 > ,
490564}
491565/// A channel_update message to be sent or received from a peer
492566#[ derive( PartialEq , Clone , Debug ) ]
493567pub 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 ,
496572}
497573
498574/// Used to put an error message in a LightningError
0 commit comments