@@ -1267,22 +1267,30 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
1267
1267
1268
1268
/// Creates a new outbound channel to the given remote node and with the given value.
1269
1269
///
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.
1275
1275
///
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`.
1281
1278
///
1282
1279
/// Note that we do not check if you are currently connected to the given peer. If no
1283
1280
/// 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 > {
1286
1294
if channel_value_satoshis < 1000 {
1287
1295
return Err ( APIError :: APIMisuseError { err : format ! ( "Channel value must be at least 1000 satoshis. It was {}" , channel_value_satoshis) } ) ;
1288
1296
}
@@ -1305,8 +1313,9 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
1305
1313
// We want to make sure the lock is actually acquired by PersistenceNotifierGuard.
1306
1314
debug_assert ! ( & self . total_consistency_lock. try_write( ) . is_err( ) ) ;
1307
1315
1316
+ let temporary_channel_id = channel. channel_id ( ) ;
1308
1317
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 ) {
1310
1319
hash_map:: Entry :: Occupied ( _) => {
1311
1320
if cfg ! ( feature = "fuzztarget" ) {
1312
1321
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
1320
1329
node_id : their_network_key,
1321
1330
msg : res,
1322
1331
} ) ;
1323
- Ok ( ( ) )
1332
+ Ok ( temporary_channel_id )
1324
1333
}
1325
1334
1326
1335
fn list_channels_with_filter < Fn : FnMut ( & ( & [ u8 ; 32 ] , & Channel < Signer > ) ) -> bool > ( & self , f : Fn ) -> Vec < ChannelDetails > {
0 commit comments