@@ -4352,18 +4352,43 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4352
4352
}
4353
4353
}
4354
4354
4355
- /// Called to accept a request to open a channel after [`Event::OpenChannelRequest`] has been
4356
- /// triggered.
4355
+ /// Accepts a request to open a channel after a [`Event::OpenChannelRequest`].
4357
4356
///
4358
4357
/// The `temporary_channel_id` parameter indicates which inbound channel should be accepted.
4359
4358
///
4360
- /// For inbound channels, the `user_channel_id` parameter will be provided back in
4359
+ /// The `user_channel_id` parameter will be provided back in
4361
4360
/// [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
4362
4361
/// with which `accept_inbound_channel` call.
4363
4362
///
4364
4363
/// [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
4365
4364
/// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
4366
4365
pub fn accept_inbound_channel ( & self , temporary_channel_id : & [ u8 ; 32 ] , user_channel_id : u64 ) -> Result < ( ) , APIError > {
4366
+ self . do_accept_inbound_channel ( temporary_channel_id, false , user_channel_id)
4367
+ }
4368
+
4369
+ /// Accepts a request to open a channel after a [`events::Event::OpenChannelRequest`], treating
4370
+ /// it as confirmed immediately.
4371
+ ///
4372
+ /// The `user_channel_id` parameter will be provided back in
4373
+ /// [`Event::ChannelClosed::user_channel_id`] to allow tracking of which events correspond
4374
+ /// with which `accept_inbound_channel` call.
4375
+ ///
4376
+ /// Unlike [`ChannelManager::accept_inbound_channel`], this method accepts the incoming channel
4377
+ /// and (if the counterparty agrees), enables forwarding of payments immediately.
4378
+ ///
4379
+ /// This fully trusts that the counterparty has honestly and correctly constructed the funding
4380
+ /// transaction and blindly assumes that it will eventually confirm.
4381
+ ///
4382
+ /// If it does not confirm before we decide to close the channel, or if the funding transaction
4383
+ /// does not pay to the correct script the correct amount, *you will lose funds*.
4384
+ ///
4385
+ /// [`Event::OpenChannelRequest`]: events::Event::OpenChannelRequest
4386
+ /// [`Event::ChannelClosed::user_channel_id`]: events::Event::ChannelClosed::user_channel_id
4387
+ pub fn accept_inbound_channel_from_trusted_peer_0conf ( & self , temporary_channel_id : & [ u8 ; 32 ] , user_channel_id : u64 ) -> Result < ( ) , APIError > {
4388
+ self . do_accept_inbound_channel ( temporary_channel_id, true , user_channel_id)
4389
+ }
4390
+
4391
+ fn do_accept_inbound_channel ( & self , temporary_channel_id : & [ u8 ; 32 ] , accept_0conf : bool , user_channel_id : u64 ) -> Result < ( ) , APIError > {
4367
4392
let _persistence_guard = PersistenceNotifierGuard :: notify_on_drop ( & self . total_consistency_lock , & self . persistence_notifier ) ;
4368
4393
4369
4394
let mut channel_state_lock = self . channel_state . lock ( ) . unwrap ( ) ;
@@ -4373,6 +4398,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
4373
4398
if !channel. get ( ) . inbound_is_awaiting_accept ( ) {
4374
4399
return Err ( APIError :: APIMisuseError { err : "The channel isn't currently awaiting to be accepted." . to_owned ( ) } ) ;
4375
4400
}
4401
+ if accept_0conf { channel. get_mut ( ) . set_0conf ( ) ; }
4376
4402
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendAcceptChannel {
4377
4403
node_id : channel. get ( ) . get_counterparty_node_id ( ) ,
4378
4404
msg : channel. get_mut ( ) . accept_inbound_channel ( user_channel_id) ,
0 commit comments