@@ -142,6 +142,10 @@ pub struct LSPS2ServiceConfig {
142142 ///
143143 /// [`bLIP-52`]: https://github.com/lightning/blips/blob/master/blip-0052.md#trust-models
144144 pub client_trusts_lsp : bool ,
145+ /// When set, clients will be allowed to spend their entire balance in the channel. This
146+ /// allows clients to try to steal your funds with no financial penalty, so this should only
147+ /// be set if you trust your clients.
148+ pub allow_client_0reserve : bool ,
145149}
146150
147151pub ( crate ) struct LiquiditySourceBuilder < L : Deref >
@@ -786,22 +790,38 @@ where
786790 config. channel_config . forwarding_fee_base_msat = 0 ;
787791 config. channel_config . forwarding_fee_proportional_millionths = 0 ;
788792
789- match self . channel_manager . create_channel (
790- their_network_key,
791- channel_amount_sats,
792- 0 ,
793- user_channel_id,
794- None ,
795- Some ( config) ,
796- ) {
793+ let result = if service_config. allow_client_0reserve {
794+ self . channel_manager . create_channel_to_trusted_peer_0reserve (
795+ their_network_key,
796+ channel_amount_sats,
797+ 0 ,
798+ user_channel_id,
799+ None ,
800+ Some ( config) ,
801+ )
802+ } else {
803+ self . channel_manager . create_channel (
804+ their_network_key,
805+ channel_amount_sats,
806+ 0 ,
807+ user_channel_id,
808+ None ,
809+ Some ( config) ,
810+ )
811+ } ;
812+
813+ match result {
797814 Ok ( _) => { } ,
798815 Err ( e) => {
799816 // TODO: We just silently fail here. Eventually we will need to remember
800817 // the pending requests and regularly retry opening the channel until we
801818 // succeed.
819+ let zero_reserve_string =
820+ if service_config. allow_client_0reserve { "0reserve " } else { "" } ;
802821 log_error ! (
803822 self . logger,
804- "Failed to open LSPS2 channel to {}: {:?}" ,
823+ "Failed to open LSPS2 {}channel to {}: {:?}" ,
824+ zero_reserve_string,
805825 their_network_key,
806826 e
807827 ) ;
0 commit comments