@@ -1267,22 +1267,30 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
12671267
12681268 /// Creates a new outbound channel to the given remote node and with the given value.
12691269 ///
1270- /// user_id will be provided back as user_channel_id in FundingGenerationReady events to allow
1271- /// tracking of which events correspond with which create_channel call. Note that the
1272- /// user_channel_id defaults to 0 for inbound channels, so you may wish to avoid using 0 for
1273- /// user_id here. user_id has no meaning inside of LDK, it is simply copied to events and
1274- /// otherwise ignored.
1270+ /// ` user_id` will be provided back as ` user_channel_id` in [`Event:: FundingGenerationReady`]
1271+ /// to allow tracking of which events correspond with which ` create_channel` call. Note that
1272+ /// the ` user_channel_id` defaults to 0 for inbound channels, so you may wish to avoid using 0
1273+ /// for ` user_id` here. ` user_id` has no meaning inside of LDK, it is simply copied to events
1274+ /// and otherwise ignored.
12751275 ///
1276- /// If successful, will generate a SendOpenChannel message event, so you should probably poll
1277- /// PeerManager::process_events afterwards.
1278- ///
1279- /// Raises APIError::APIMisuseError when channel_value_satoshis > 2**24 or push_msat is
1280- /// greater than channel_value_satoshis * 1k or channel_value_satoshis is < 1000.
1276+ /// Raises [`APIError::APIMisuseError`] when `channel_value_satoshis` > 2**24 or `push_msat` is
1277+ /// greater than `channel_value_satoshis * 1k` or `channel_value_satoshis < 1000`.
12811278 ///
12821279 /// Note that we do not check if you are currently connected to the given peer. If no
12831280 /// connection is available, the outbound `open_channel` message may fail to send, resulting in
1284- /// the channel eventually being silently forgotten.
1285- pub fn create_channel ( & self , their_network_key : PublicKey , channel_value_satoshis : u64 , push_msat : u64 , user_id : u64 , override_config : Option < UserConfig > ) -> Result < ( ) , APIError > {
1281+ /// the channel eventually being silently forgotten (dropped on reload).
1282+ ///
1283+ /// Returns the new Channel's temporary `channel_id`. This ID will appear as
1284+ /// [`Event::FundingGenerationReady::temporary_channel_id`] and in
1285+ /// [`ChannelDetails::channel_id`] until after
1286+ /// [`ChannelManager::funding_transaction_generated`] is called, swapping the Channel's ID for
1287+ /// one derived from the funding transaction's TXID. If the counterparty rejects the channel
1288+ /// immediately, this temporary ID will appear in [`Event::ChannelClosed::channel_id`].
1289+ ///
1290+ /// [`Event::FundingGenerationReady`]: events::Event::FundingGenerationReady
1291+ /// [`Event::FundingGenerationReady::temporary_channel_id`]: events::Event::FundingGenerationReady::temporary_channel_id
1292+ /// [`Event::ChannelClosed::channel_id`]: events::Event::ChannelClosed::channel_id
1293+ pub fn create_channel ( & self , their_network_key : PublicKey , channel_value_satoshis : u64 , push_msat : u64 , user_id : u64 , override_config : Option < UserConfig > ) -> Result < [ u8 ; 32 ] , APIError > {
12861294 if channel_value_satoshis < 1000 {
12871295 return Err ( APIError :: APIMisuseError { err : format ! ( "Channel value must be at least 1000 satoshis. It was {}" , channel_value_satoshis) } ) ;
12881296 }
@@ -1305,8 +1313,9 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
13051313 // We want to make sure the lock is actually acquired by PersistenceNotifierGuard.
13061314 debug_assert ! ( & self . total_consistency_lock. try_write( ) . is_err( ) ) ;
13071315
1316+ let temporary_channel_id = channel. channel_id ( ) ;
13081317 let mut channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
1309- match channel_state. by_id . entry ( channel . channel_id ( ) ) {
1318+ match channel_state. by_id . entry ( temporary_channel_id ) {
13101319 hash_map:: Entry :: Occupied ( _) => {
13111320 if cfg ! ( feature = "fuzztarget" ) {
13121321 return Err ( APIError :: APIMisuseError { err : "Fuzzy bad RNG" . to_owned ( ) } ) ;
@@ -1320,7 +1329,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
13201329 node_id : their_network_key,
13211330 msg : res,
13221331 } ) ;
1323- Ok ( ( ) )
1332+ Ok ( temporary_channel_id )
13241333 }
13251334
13261335 fn list_channels_with_filter < Fn : FnMut ( & ( & [ u8 ; 32 ] , & Channel < Signer > ) ) -> bool > ( & self , f : Fn ) -> Vec < ChannelDetails > {
0 commit comments