Skip to content

Commit 8a281d0

Browse files
committed
make message fields public, part 1
1 parent 99eef23 commit 8a281d0

File tree

1 file changed

+83
-39
lines changed

1 file changed

+83
-39
lines changed

lightning/src/ln/msgs.rs

Lines changed: 83 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -65,63 +65,107 @@ pub struct Init {
6565
/// An error message to be sent or received from a peer
6666
#[derive(Clone)]
6767
pub struct ErrorMessage {
68-
pub(crate) channel_id: [u8; 32],
69-
pub(crate) data: String,
68+
/// The channel ID involved in the error
69+
pub channel_id: [u8; 32],
70+
/// A possibly human-readable error description.
71+
/// The string should be sanitized before it is used (e.g. emitted to logs
72+
/// or printed to stdout). Otherwise, a well crafted error message may trigger a security
73+
/// vulnerability in the terminal emulator or the logging subsystem.
74+
pub data: String,
7075
}
7176

7277
/// A ping message to be sent or received from a peer
7378
pub struct Ping {
74-
pub(crate) ponglen: u16,
75-
pub(crate) byteslen: u16,
79+
/// The desired response length
80+
pub ponglen: u16,
81+
/// The ping packet size.
82+
/// This field is not sent on the wire. byteslen zeros are sent.
83+
pub byteslen: u16,
7684
}
7785

7886
/// A pong message to be sent or received from a peer
7987
pub struct Pong {
80-
pub(crate) byteslen: u16,
88+
/// The pong packet size.
89+
/// This field is not sent on the wire. byteslen zeros are sent.
90+
pub byteslen: u16,
8191
}
8292

8393
/// An open_channel message to be sent or received from a peer
8494
#[derive(Clone)]
8595
pub struct OpenChannel {
86-
pub(crate) chain_hash: BlockHash,
87-
pub(crate) temporary_channel_id: [u8; 32],
88-
pub(crate) funding_satoshis: u64,
89-
pub(crate) push_msat: u64,
90-
pub(crate) dust_limit_satoshis: u64,
91-
pub(crate) max_htlc_value_in_flight_msat: u64,
92-
pub(crate) channel_reserve_satoshis: u64,
93-
pub(crate) htlc_minimum_msat: u64,
94-
pub(crate) feerate_per_kw: u32,
95-
pub(crate) to_self_delay: u16,
96-
pub(crate) max_accepted_htlcs: u16,
97-
pub(crate) funding_pubkey: PublicKey,
98-
pub(crate) revocation_basepoint: PublicKey,
99-
pub(crate) payment_point: PublicKey,
100-
pub(crate) delayed_payment_basepoint: PublicKey,
101-
pub(crate) htlc_basepoint: PublicKey,
102-
pub(crate) first_per_commitment_point: PublicKey,
103-
pub(crate) channel_flags: u8,
104-
pub(crate) shutdown_scriptpubkey: OptionalField<Script>,
96+
/// The genesis hash of the blockchain where the channel is to be opened
97+
pub chain_hash: BlockHash,
98+
/// A temporary channel ID, until the funding is established
99+
pub temporary_channel_id: [u8; 32],
100+
/// The channel value
101+
pub funding_satoshis: u64,
102+
/// The amount to push to the counterparty as part of the open, in milli-satoshi
103+
pub push_msat: u64,
104+
/// The threshold below which outputs should be omitted
105+
pub dust_limit_satoshis: u64,
106+
/// The maximum total HTLC value in flight, in milli-satoshi
107+
pub max_htlc_value_in_flight_msat: u64,
108+
/// The minimum value for the counterparty to keep in the channel
109+
pub channel_reserve_satoshis: u64,
110+
/// The minimum HTLC size, in milli-satoshi
111+
pub htlc_minimum_msat: u64,
112+
/// The feerate per 1000-weight of the transaction
113+
pub feerate_per_kw: u32,
114+
/// The minimum to_self_delay for the counterparty's transactions
115+
pub to_self_delay: u16,
116+
/// The maximum number of accepted HTLCs
117+
pub max_accepted_htlcs: u16,
118+
/// The funding public key
119+
pub funding_pubkey: PublicKey,
120+
/// The funding public key
121+
pub revocation_basepoint: PublicKey,
122+
/// The payment point
123+
pub payment_point: PublicKey,
124+
/// The delayed payment basepoint
125+
pub delayed_payment_basepoint: PublicKey,
126+
/// The HTLC basepoint
127+
pub htlc_basepoint: PublicKey,
128+
/// The first transaction's per commitment point
129+
pub first_per_commitment_point: PublicKey,
130+
/// Channel flags
131+
pub channel_flags: u8,
132+
/// Optionally, the scriptPubkey when we collaboratively close
133+
pub shutdown_scriptpubkey: OptionalField<Script>,
105134
}
106135

107136
/// An accept_channel message to be sent or received from a peer
108137
#[derive(Clone)]
109138
pub struct AcceptChannel {
110-
pub(crate) temporary_channel_id: [u8; 32],
111-
pub(crate) dust_limit_satoshis: u64,
112-
pub(crate) max_htlc_value_in_flight_msat: u64,
113-
pub(crate) channel_reserve_satoshis: u64,
114-
pub(crate) htlc_minimum_msat: u64,
115-
pub(crate) minimum_depth: u32,
116-
pub(crate) to_self_delay: u16,
117-
pub(crate) max_accepted_htlcs: u16,
118-
pub(crate) funding_pubkey: PublicKey,
119-
pub(crate) revocation_basepoint: PublicKey,
120-
pub(crate) payment_point: PublicKey,
121-
pub(crate) delayed_payment_basepoint: PublicKey,
122-
pub(crate) htlc_basepoint: PublicKey,
123-
pub(crate) first_per_commitment_point: PublicKey,
124-
pub(crate) shutdown_scriptpubkey: OptionalField<Script>
139+
/// A temporary channel ID, until the funding is established
140+
pub temporary_channel_id: [u8; 32],
141+
/// The threshold below which outputs should be omitted
142+
pub dust_limit_satoshis: u64,
143+
/// The maximum total HTLC value in flight, in milli-satoshi
144+
pub max_htlc_value_in_flight_msat: u64,
145+
/// The minimum value for the counterparty to keep in the channel
146+
pub channel_reserve_satoshis: u64,
147+
/// The minimum HTLC size, in milli-satoshi
148+
pub htlc_minimum_msat: u64,
149+
/// Minimum depth of the funding transaction before the channel is considered open
150+
pub minimum_depth: u32,
151+
/// The minimum to_self_delay for the counterparty's transactions
152+
pub to_self_delay: u16,
153+
/// The maximum number of accepted HTLCs
154+
pub max_accepted_htlcs: u16,
155+
/// The funding public key
156+
pub funding_pubkey: PublicKey,
157+
/// The funding public key
158+
pub revocation_basepoint: PublicKey,
159+
/// The payment point
160+
pub payment_point: PublicKey,
161+
/// The delayed payment basepoint
162+
pub delayed_payment_basepoint: PublicKey,
163+
/// The HTLC basepoint
164+
pub htlc_basepoint: PublicKey,
165+
/// The first transaction's per commitment point
166+
pub first_per_commitment_point: PublicKey,
167+
/// Optionally, the scriptPubkey when we collaboratively close
168+
pub shutdown_scriptpubkey: OptionalField<Script>,
125169
}
126170

127171
/// A funding_created message to be sent or received from a peer

0 commit comments

Comments
 (0)