Skip to content

Commit 3e284f5

Browse files
committed
Indiciate if a channel is outbound/confirmed in ChannelDetails
1 parent 3dea9fb commit 3e284f5

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

fuzz/src/router.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
213213
channel_value_satoshis: slice_to_be64(get_slice!(8)),
214214
user_id: 0,
215215
inbound_capacity_msat: 0,
216+
is_outbound: true,
217+
is_confirmed: true,
216218
is_live: true,
217219
is_public: true,
218220
outbound_capacity_msat: 0,

lightning/src/ln/channelmanager.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,18 @@ pub struct ChannelDetails {
634634
/// Note that there are some corner cases not fully handled here, so the actual available
635635
/// inbound capacity may be slightly higher than this.
636636
pub inbound_capacity_msat: u64,
637+
/// True if the channel was initiated (and thus funded) by us.
638+
pub is_outbound: bool,
639+
/// True if the channel is confirmed, funding_locked messages have been exchanged, and the
640+
/// channel is not currently being shut down. `funding_locked` message exchange implies the
641+
/// required confirmation count has been reached (and we were connected to the peer at some
642+
/// point after the funding transaction received enough confirmations).
643+
pub is_confirmed: bool,
637644
/// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
638-
/// the peer is connected, and (c) no monitor update failure is pending resolution.
645+
/// the peer is connected, (c) no monitor update failure is pending resolution, and (d) the
646+
/// channel is not currently negotiating a shutdown.
647+
///
648+
/// This is a strict superset of `is_confirmed`.
639649
pub is_live: bool,
640650
/// True if this channel is (or will be) publicly-announced.
641651
pub is_public: bool,
@@ -969,6 +979,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
969979
inbound_capacity_msat,
970980
outbound_capacity_msat,
971981
user_id: channel.get_user_id(),
982+
is_outbound: channel.is_outbound(),
983+
is_confirmed: channel.is_usable(),
972984
is_live: channel.is_live(),
973985
is_public: channel.should_announce(),
974986
counterparty_forwarding_info: channel.counterparty_forwarding_info(),

lightning/src/routing/router.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,7 @@ mod tests {
16341634
user_id: 0,
16351635
outbound_capacity_msat: 100000,
16361636
inbound_capacity_msat: 100000,
1637+
is_outbound: true, is_confirmed: true,
16371638
is_live: true, is_public: true,
16381639
counterparty_forwarding_info: None,
16391640
}];
@@ -1953,6 +1954,7 @@ mod tests {
19531954
user_id: 0,
19541955
outbound_capacity_msat: 250_000_000,
19551956
inbound_capacity_msat: 0,
1957+
is_outbound: true, is_confirmed: true,
19561958
is_live: true, is_public: true,
19571959
counterparty_forwarding_info: None,
19581960
}];
@@ -2002,6 +2004,7 @@ mod tests {
20022004
user_id: 0,
20032005
outbound_capacity_msat: 250_000_000,
20042006
inbound_capacity_msat: 0,
2007+
is_outbound: true, is_confirmed: true,
20052008
is_live: true, is_public: true,
20062009
counterparty_forwarding_info: None,
20072010
}];
@@ -2068,6 +2071,7 @@ mod tests {
20682071
user_id: 0,
20692072
outbound_capacity_msat: 250_000_000,
20702073
inbound_capacity_msat: 0,
2074+
is_outbound: true, is_confirmed: true,
20712075
is_live: true, is_public: true,
20722076
counterparty_forwarding_info: None,
20732077
}];
@@ -2206,6 +2210,7 @@ mod tests {
22062210
user_id: 0,
22072211
outbound_capacity_msat: 250_000_000,
22082212
inbound_capacity_msat: 0,
2213+
is_outbound: true, is_confirmed: true,
22092214
is_live: true, is_public: true,
22102215
counterparty_forwarding_info: None,
22112216
}];
@@ -2336,6 +2341,7 @@ mod tests {
23362341
user_id: 0,
23372342
outbound_capacity_msat: 100000,
23382343
inbound_capacity_msat: 100000,
2344+
is_outbound: true, is_confirmed: true,
23392345
is_live: true, is_public: true,
23402346
counterparty_forwarding_info: None,
23412347
}];
@@ -2469,6 +2475,7 @@ mod tests {
24692475
user_id: 0,
24702476
outbound_capacity_msat: 200_000_000,
24712477
inbound_capacity_msat: 0,
2478+
is_outbound: true, is_confirmed: true,
24722479
is_live: true, is_public: true,
24732480
counterparty_forwarding_info: None,
24742481
}];

0 commit comments

Comments
 (0)