@@ -4117,20 +4117,45 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4117
4117
}
4118
4118
}
4119
4119
4120
- /// Called to accept a request to open a channel after [`Event::OpenChannelRequest`] has been
4121
- /// triggered.
4120
+ /// Accepts a request to open a channel after a [`Event::OpenChannelRequest`].
4122
4121
///
4123
4122
/// The `temporary_channel_id` parameter indicates which inbound channel should be accepted,
4124
4123
/// and the `counterparty_node_id` parameter is the id of the peer which has requested to open
4125
4124
/// the channel.
4126
4125
///
4127
- /// For inbound channels, the `user_channel_id` parameter will be provided back in
4126
+ /// The `user_channel_id` parameter will be provided back in
4128
4127
/// [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
4129
- /// with which `accept_inbound_channel` call.
4128
+ /// with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
4130
4129
///
4131
4130
/// [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
4132
4131
/// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
4133
4132
pub fn accept_inbound_channel ( & self , temporary_channel_id : & [ u8 ; 32 ] , counterparty_node_id : & PublicKey , user_channel_id : u64 ) -> Result < ( ) , APIError > {
4133
+ self . do_accept_inbound_channel ( temporary_channel_id, counterparty_node_id, false , user_channel_id)
4134
+ }
4135
+
4136
+ /// Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating
4137
+ /// it as confirmed immediately.
4138
+ ///
4139
+ /// The `user_channel_id` parameter will be provided back in
4140
+ /// [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
4141
+ /// with which `accept_inbound_channel`/`accept_inbound_channel_from_trusted_peer_0conf` call.
4142
+ ///
4143
+ /// Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel
4144
+ /// and (if the counterparty agrees), enables forwarding of payments immediately.
4145
+ ///
4146
+ /// This fully trusts that the counterparty has honestly and correctly constructed the funding
4147
+ /// transaction and blindly assumes that it will eventually confirm.
4148
+ ///
4149
+ /// If it does not confirm before we decide to close the channel, or if the funding transaction
4150
+ /// does not pay to the correct script the correct amount, *you will lose funds*.
4151
+ ///
4152
+ /// [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
4153
+ /// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
4154
+ pub fn accept_inbound_channel_from_trusted_peer_0conf ( & self , temporary_channel_id : & [ u8 ; 32 ] , counterparty_node_id : & PublicKey , user_channel_id : u64 ) -> Result < ( ) , APIError > {
4155
+ self . do_accept_inbound_channel ( temporary_channel_id, counterparty_node_id, true , user_channel_id)
4156
+ }
4157
+
4158
+ fn do_accept_inbound_channel ( & self , temporary_channel_id : & [ u8 ; 32 ] , counterparty_node_id : & PublicKey , accept_0conf : bool , user_channel_id : u64 ) -> Result < ( ) , APIError > {
4134
4159
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
4135
4160
4136
4161
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
@@ -4143,6 +4168,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4143
4168
if * counterparty_node_id != channel. get ( ) . get_counterparty_node_id ( ) {
4144
4169
return Err ( APIError :: APIMisuseError { err : "The passed counterparty_node_id doesn't match the channel's counterparty node_id" . to_owned ( ) } ) ;
4145
4170
}
4171
+ if accept_0conf { channel. get_mut ( ) . set_0conf ( ) ; }
4146
4172
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendAcceptChannel {
4147
4173
node_id : channel. get ( ) . get_counterparty_node_id ( ) ,
4148
4174
msg : channel. get_mut ( ) . accept_inbound_channel ( user_channel_id) ,
0 commit comments