@@ -968,9 +968,25 @@ pub struct ChannelDetails {
968
968
/// Note that if [`inbound_scid_alias`] is set, it must be used for invoices and inbound
969
969
/// payments instead of this. See [`get_inbound_payment_scid`].
970
970
///
971
+ /// For channels with [`confirmations_required`] set to `Some(0)`, [`outbound_scid_alias`] may
972
+ /// be used in place of this in outbound routes. See [`get_outbound_payment_scid`].
973
+ ///
971
974
/// [`inbound_scid_alias`]: Self::inbound_scid_alias
975
+ /// [`outbound_scid_alias`]: Self::outbound_scid_alias
972
976
/// [`get_inbound_payment_scid`]: Self::get_inbound_payment_scid
977
+ /// [`get_outbound_payment_scid`]: Self::get_outbound_payment_scid
978
+ /// [`confirmations_required`]: Self::confirmations_required
973
979
pub short_channel_id : Option < u64 > ,
980
+ /// An optional [`short_channel_id`] alias for this channel, randomly generated by us and
981
+ /// usable in place of [`short_channel_id`] to reference the channel in outbound routes when
982
+ /// the channel has not yet been confirmed (as long as [`confirmations_required`] is
983
+ /// `Some(0)`).
984
+ ///
985
+ /// This will be `None` as long as the channel is not available for routing outbound payments.
986
+ ///
987
+ /// [`short_channel_id`]: Self::short_channel_id
988
+ /// [`confirmations_required`]: Self::confirmations_required
989
+ pub outbound_scid_alias : Option < u64 > ,
974
990
/// An optional [`short_channel_id`] alias for this channel, randomly generated by our
975
991
/// counterparty and usable in place of [`short_channel_id`] in invoice route hints. Our
976
992
/// counterparty will recognize the alias provided here in place of the [`short_channel_id`]
@@ -1088,6 +1104,16 @@ impl ChannelDetails {
1088
1104
pub fn get_inbound_payment_scid ( & self ) -> Option < u64 > {
1089
1105
self . inbound_scid_alias . or ( self . short_channel_id )
1090
1106
}
1107
+
1108
+ /// Gets the current SCID which should be used to identify this channel for outbound payments.
1109
+ /// This should be used in [`Route`]s to describe the first hop or in other contexts where
1110
+ /// we're sending or forwarding a payment outbound over this channel.
1111
+ ///
1112
+ /// This is either the [`ChannelDetails::short_channel_id`], if set, or the
1113
+ /// [`ChannelDetails::outbound_scid_alias`]. See those for more information.
1114
+ pub fn get_outbound_payment_scid ( & self ) -> Option < u64 > {
1115
+ self . short_channel_id . or ( self . outbound_scid_alias )
1116
+ }
1091
1117
}
1092
1118
1093
1119
/// If a payment fails to send, it can be in one of several states. This enum is returned as the
@@ -1714,6 +1740,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
1714
1740
// `have_received_message` indicates that type negotiation has completed.
1715
1741
channel_type : if channel. have_received_message ( ) { Some ( channel. get_channel_type ( ) . clone ( ) ) } else { None } ,
1716
1742
short_channel_id : channel. get_short_channel_id ( ) ,
1743
+ outbound_scid_alias : if channel. is_usable ( ) { Some ( channel. outbound_scid_alias ( ) ) } else { None } ,
1717
1744
inbound_scid_alias : channel. latest_inbound_scid_alias ( ) ,
1718
1745
channel_value_satoshis : channel. get_value_satoshis ( ) ,
1719
1746
unspendable_punishment_reserve : to_self_reserve_satoshis,
@@ -5984,6 +6011,7 @@ impl_writeable_tlv_based!(ChannelDetails, {
5984
6011
( 2 , channel_id, required) ,
5985
6012
( 3 , channel_type, option) ,
5986
6013
( 4 , counterparty, required) ,
6014
+ ( 5 , outbound_scid_alias, option) ,
5987
6015
( 6 , funding_txo, option) ,
5988
6016
( 8 , short_channel_id, option) ,
5989
6017
( 10 , channel_value_satoshis, required) ,
0 commit comments