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