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