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