@@ -27,16 +27,16 @@ pub(crate) const LSPS2_BUY_REQUEST_PAYMENT_SIZE_TOO_LARGE_ERROR_CODE: i32 = 203;
2727
2828#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
2929/// A request made to an LSP to learn their current channel fees and parameters.
30- pub struct GetInfoRequest {
30+ pub struct LSPS2GetInfoRequest {
3131 /// An optional token to provide to the LSP.
3232 pub token : Option < String > ,
3333}
3434
3535/// Fees and parameters for a JIT Channel without the promise.
3636///
3737/// The promise will be calculated automatically for the LSP and this type converted
38- /// into an [`OpeningFeeParams `] for transit over the wire.
39- pub struct RawOpeningFeeParams {
38+ /// into an [`LSPS2OpeningFeeParams `] for transit over the wire.
39+ pub struct LSPS2RawOpeningFeeParams {
4040 /// The minimum fee required for the channel open.
4141 pub min_fee_msat : u64 ,
4242 /// A fee proportional to the size of the initial payment.
@@ -53,8 +53,10 @@ pub struct RawOpeningFeeParams {
5353 pub max_payment_size_msat : u64 ,
5454}
5555
56- impl RawOpeningFeeParams {
57- pub ( crate ) fn into_opening_fee_params ( self , promise_secret : & [ u8 ; 32 ] ) -> OpeningFeeParams {
56+ impl LSPS2RawOpeningFeeParams {
57+ pub ( crate ) fn into_opening_fee_params (
58+ self , promise_secret : & [ u8 ; 32 ] ,
59+ ) -> LSPS2OpeningFeeParams {
5860 let mut hmac = HmacEngine :: < Sha256 > :: new ( promise_secret) ;
5961 hmac. input ( & self . min_fee_msat . to_be_bytes ( ) ) ;
6062 hmac. input ( & self . proportional . to_be_bytes ( ) ) ;
@@ -65,7 +67,7 @@ impl RawOpeningFeeParams {
6567 hmac. input ( & self . max_payment_size_msat . to_be_bytes ( ) ) ;
6668 let promise_bytes = Hmac :: from_engine ( hmac) . to_byte_array ( ) ;
6769 let promise = utils:: hex_str ( & promise_bytes[ ..] ) ;
68- OpeningFeeParams {
70+ LSPS2OpeningFeeParams {
6971 min_fee_msat : self . min_fee_msat ,
7072 proportional : self . proportional ,
7173 valid_until : self . valid_until . clone ( ) ,
@@ -82,9 +84,9 @@ impl RawOpeningFeeParams {
8284/// Fees and parameters for a JIT Channel including the promise.
8385///
8486/// The promise is an HMAC calculated using a secret known to the LSP and the rest of the fields as input.
85- /// It exists so the LSP can verify the authenticity of a client provided OpeningFeeParams by recalculating
87+ /// It exists so the LSP can verify the authenticity of a client provided LSPS2OpeningFeeParams by recalculating
8688/// the promise using the secret. Once verified they can be confident it was not modified by the client.
87- pub struct OpeningFeeParams {
89+ pub struct LSPS2OpeningFeeParams {
8890 /// The minimum fee required for the channel open.
8991 #[ serde( with = "string_amount" ) ]
9092 pub min_fee_msat : u64 ,
@@ -106,18 +108,18 @@ pub struct OpeningFeeParams {
106108 pub promise : String ,
107109}
108110
109- /// A response to a [`GetInfoRequest `]
111+ /// A response to a [`LSPS2GetInfoRequest `]
110112#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
111- pub struct GetInfoResponse {
113+ pub struct LSPS2GetInfoResponse {
112114 /// A set of opening fee parameters.
113- pub opening_fee_params_menu : Vec < OpeningFeeParams > ,
115+ pub opening_fee_params_menu : Vec < LSPS2OpeningFeeParams > ,
114116}
115117
116118/// A request to buy a JIT channel.
117119#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
118- pub struct BuyRequest {
120+ pub struct LSPS2BuyRequest {
119121 /// The fee parameters you would like to use.
120- pub opening_fee_params : OpeningFeeParams ,
122+ pub opening_fee_params : LSPS2OpeningFeeParams ,
121123 /// The size of the initial payment you expect to receive.
122124 #[ serde( default ) ]
123125 #[ serde( skip_serializing_if = "Option::is_none" ) ]
@@ -127,9 +129,9 @@ pub struct BuyRequest {
127129
128130/// A newtype that holds a `short_channel_id` in human readable format of BBBxTTTx000.
129131#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
130- pub struct InterceptScid ( String ) ;
132+ pub struct LSPS2InterceptScid ( String ) ;
131133
132- impl From < u64 > for InterceptScid {
134+ impl From < u64 > for LSPS2InterceptScid {
133135 fn from ( scid : u64 ) -> Self {
134136 let block = scid_utils:: block_from_scid ( scid) ;
135137 let tx_index = scid_utils:: tx_index_from_scid ( scid) ;
@@ -139,20 +141,20 @@ impl From<u64> for InterceptScid {
139141 }
140142}
141143
142- impl InterceptScid {
143- /// Try to convert a [`InterceptScid `] into a u64 used by LDK.
144+ impl LSPS2InterceptScid {
145+ /// Try to convert a [`LSPS2InterceptScid `] into a u64 used by LDK.
144146 pub fn to_scid ( & self ) -> Result < u64 , ( ) > {
145147 utils:: scid_from_human_readable_string ( & self . 0 )
146148 }
147149}
148150
149- /// A response to a [`BuyRequest `].
151+ /// A response to a [`LSPS2BuyRequest `].
150152///
151153/// Includes information needed to construct an invoice.
152154#[ derive( Clone , Debug , PartialEq , Eq , Deserialize , Serialize ) ]
153- pub struct BuyResponse {
155+ pub struct LSPS2BuyResponse {
154156 /// The intercept short channel id used by LSP to identify need to open channel.
155- pub jit_channel_scid : InterceptScid ,
157+ pub jit_channel_scid : LSPS2InterceptScid ,
156158 /// The locktime expiry delta the lsp requires.
157159 pub lsp_cltv_expiry_delta : u32 ,
158160 /// A flag that indicates who is trusting who.
@@ -164,20 +166,20 @@ pub struct BuyResponse {
164166/// An enum that captures all the valid JSON-RPC requests in the bLIP-52 / LSPS2 protocol.
165167pub enum LSPS2Request {
166168 /// A request to learn an LSP's channel fees and parameters.
167- GetInfo ( GetInfoRequest ) ,
169+ GetInfo ( LSPS2GetInfoRequest ) ,
168170 /// A request to buy a JIT channel from an LSP.
169- Buy ( BuyRequest ) ,
171+ Buy ( LSPS2BuyRequest ) ,
170172}
171173
172174#[ derive( Clone , Debug , PartialEq , Eq ) ]
173175/// An enum that captures all the valid JSON-RPC responses in the bLIP-52 / LSPS2 protocol.
174176pub enum LSPS2Response {
175177 /// A successful response to a [`LSPS2Request::GetInfo`] request.
176- GetInfo ( GetInfoResponse ) ,
178+ GetInfo ( LSPS2GetInfoResponse ) ,
177179 /// An error response to a [`LSPS2Request::GetInfo`] request.
178180 GetInfoError ( ResponseError ) ,
179181 /// A successful response to a [`LSPS2Request::Buy`] request.
180- Buy ( BuyResponse ) ,
182+ Buy ( LSPS2BuyResponse ) ,
181183 /// An error response to a [`LSPS2Request::Buy`] request.
182184 BuyError ( ResponseError ) ,
183185}
@@ -226,7 +228,7 @@ mod tests {
226228 let min_payment_size_msat = 1 ;
227229 let max_payment_size_msat = 100_000_000 ;
228230
229- let raw = RawOpeningFeeParams {
231+ let raw = LSPS2RawOpeningFeeParams {
230232 min_fee_msat,
231233 proportional,
232234 valid_until : valid_until. clone ( ) . into ( ) ,
@@ -261,7 +263,7 @@ mod tests {
261263 let min_payment_size_msat = 1 ;
262264 let max_payment_size_msat = 100_000_000 ;
263265
264- let raw = RawOpeningFeeParams {
266+ let raw = LSPS2RawOpeningFeeParams {
265267 min_fee_msat,
266268 proportional,
267269 valid_until : valid_until. into ( ) ,
@@ -288,7 +290,7 @@ mod tests {
288290 let min_payment_size_msat = 1 ;
289291 let max_payment_size_msat = 100_000_000 ;
290292
291- let raw = RawOpeningFeeParams {
293+ let raw = LSPS2RawOpeningFeeParams {
292294 min_fee_msat,
293295 proportional,
294296 valid_until : valid_until. into ( ) ,
@@ -317,7 +319,7 @@ mod tests {
317319 let min_payment_size_msat = 1 ;
318320 let max_payment_size_msat = 100_000_000 ;
319321
320- let raw = RawOpeningFeeParams {
322+ let raw = LSPS2RawOpeningFeeParams {
321323 min_fee_msat,
322324 proportional,
323325 valid_until : valid_until. into ( ) ,
@@ -343,7 +345,7 @@ mod tests {
343345 let min_payment_size_msat = 1 ;
344346 let max_payment_size_msat = 100_000_000 ;
345347
346- let raw = RawOpeningFeeParams {
348+ let raw = LSPS2RawOpeningFeeParams {
347349 min_fee_msat,
348350 proportional,
349351 valid_until : valid_until. into ( ) ,
@@ -362,13 +364,13 @@ mod tests {
362364
363365 let payment_size_msat = Some ( 1234 ) ;
364366 let buy_request_fixed =
365- BuyRequest { opening_fee_params : opening_fee_params. clone ( ) , payment_size_msat } ;
367+ LSPS2BuyRequest { opening_fee_params : opening_fee_params. clone ( ) , payment_size_msat } ;
366368 let json_str = r#"{"opening_fee_params":{"max_client_to_self_delay":128,"max_payment_size_msat":"100000000","min_fee_msat":"100","min_lifetime":144,"min_payment_size_msat":"1","promise":"1134a5c51e3ba2e8f4259610d5e12c1bf4c50ddcd3f8af563e0a00d1fff41dea","proportional":21,"valid_until":"2023-05-20T08:30:45Z"},"payment_size_msat":"1234"}"# ;
367369 assert_eq ! ( json_str, serde_json:: json!( buy_request_fixed) . to_string( ) ) ;
368370 assert_eq ! ( buy_request_fixed, serde_json:: from_str( json_str) . unwrap( ) ) ;
369371
370372 let payment_size_msat = None ;
371- let buy_request_variable = BuyRequest { opening_fee_params, payment_size_msat } ;
373+ let buy_request_variable = LSPS2BuyRequest { opening_fee_params, payment_size_msat } ;
372374
373375 // Check we skip serialization if payment_size_msat is None.
374376 let json_str = r#"{"opening_fee_params":{"max_client_to_self_delay":128,"max_payment_size_msat":"100000000","min_fee_msat":"100","min_lifetime":144,"min_payment_size_msat":"1","promise":"1134a5c51e3ba2e8f4259610d5e12c1bf4c50ddcd3f8af563e0a00d1fff41dea","proportional":21,"valid_until":"2023-05-20T08:30:45Z"}}"# ;
@@ -407,7 +409,7 @@ mod tests {
407409 }
408410 ]
409411 }"# ;
410- let _get_info_response: GetInfoResponse = serde_json:: from_str ( json_str) . unwrap ( ) ;
412+ let _get_info_response: LSPS2GetInfoResponse = serde_json:: from_str ( json_str) . unwrap ( ) ;
411413
412414 let json_str = r#"{
413415 "opening_fee_params": {
@@ -422,13 +424,13 @@ mod tests {
422424 },
423425 "payment_size_msat": "42000"
424426 }"# ;
425- let _buy_request: BuyRequest = serde_json:: from_str ( json_str) . unwrap ( ) ;
427+ let _buy_request: LSPS2BuyRequest = serde_json:: from_str ( json_str) . unwrap ( ) ;
426428
427429 let json_str = r#"{
428430 "jit_channel_scid": "29451x4815x1",
429431 "lsp_cltv_expiry_delta" : 144,
430432 "client_trusts_lsp": false
431433 }"# ;
432- let _buy_response: BuyResponse = serde_json:: from_str ( json_str) . unwrap ( ) ;
434+ let _buy_response: LSPS2BuyResponse = serde_json:: from_str ( json_str) . unwrap ( ) ;
433435 }
434436}
0 commit comments