Skip to content

Commit 1a3f65f

Browse files
committed
Add flags for if a channel is pub and funding txo in ChannelDetails
1 parent c60543c commit 1a3f65f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

fuzz/src/router.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use bitcoin::blockdata::transaction::TxOut;
1212
use bitcoin::hash_types::BlockHash;
1313

1414
use lightning::chain;
15+
use lightning::chain::transaction::OutPoint;
1516
use lightning::ln::channelmanager::ChannelDetails;
1617
use lightning::ln::features::InitFeatures;
1718
use lightning::ln::msgs;
@@ -20,6 +21,7 @@ use lightning::util::logger::Logger;
2021
use lightning::util::ser::Readable;
2122
use lightning::routing::network_graph::{NetworkGraph, RoutingFees};
2223

24+
use bitcoin::hashes::Hash;
2325
use bitcoin::secp256k1::key::PublicKey;
2426
use bitcoin::network::constants::Network;
2527
use bitcoin::blockdata::constants::genesis_block;
@@ -204,13 +206,15 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
204206
let rnid = node_pks.iter().skip(slice_to_be16(get_slice!(2))as usize % node_pks.len()).next().unwrap();
205207
first_hops_vec.push(ChannelDetails {
206208
channel_id: [0; 32],
209+
funding_txo: Some(OutPoint { txid: bitcoin::Txid::from_slice(&[0; 32]).unwrap(), index: 0 }),
207210
short_channel_id: Some(scid),
208211
remote_network_id: *rnid,
209212
counterparty_features: InitFeatures::known(),
210213
channel_value_satoshis: slice_to_be64(get_slice!(8)),
211214
user_id: 0,
212215
inbound_capacity_msat: 0,
213216
is_live: true,
217+
is_public: true,
214218
outbound_capacity_msat: 0,
215219
counterparty_forwarding_info: None,
216220
});

lightning/src/ln/channelmanager.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,12 @@ pub struct ChannelDetails {
604604
/// Note that this means this value is *not* persistent - it can change once during the
605605
/// lifetime of the channel.
606606
pub channel_id: [u8; 32],
607+
/// The Channel's funding transaction output, if we've negotiated the funding transaction with
608+
/// our counterparty already.
609+
///
610+
/// Note that, if this has been set, `channel_id` will be equivalent to
611+
/// `funding_txo.unwrap().to_channel_id()`.
612+
pub funding_txo: Option<OutPoint>,
607613
/// The position of the funding transaction in the chain. None if the funding transaction has
608614
/// not yet been confirmed and the channel fully opened.
609615
pub short_channel_id: Option<u64>,
@@ -631,7 +637,8 @@ pub struct ChannelDetails {
631637
/// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
632638
/// the peer is connected, and (c) no monitor update failure is pending resolution.
633639
pub is_live: bool,
634-
640+
/// True if this channel is (or will be) publicly-announced.
641+
pub is_public: bool,
635642
/// Information on the fees and requirements that the counterparty requires when forwarding
636643
/// payments to us through this channel.
637644
pub counterparty_forwarding_info: Option<CounterpartyForwardingInfo>,
@@ -954,6 +961,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
954961
let (inbound_capacity_msat, outbound_capacity_msat) = channel.get_inbound_outbound_available_balance_msat();
955962
res.push(ChannelDetails {
956963
channel_id: (*channel_id).clone(),
964+
funding_txo: channel.get_funding_txo(),
957965
short_channel_id: channel.get_short_channel_id(),
958966
remote_network_id: channel.get_counterparty_node_id(),
959967
counterparty_features: InitFeatures::empty(),
@@ -962,6 +970,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
962970
outbound_capacity_msat,
963971
user_id: channel.get_user_id(),
964972
is_live: channel.is_live(),
973+
is_public: channel.should_announce(),
965974
counterparty_forwarding_info: channel.counterparty_forwarding_info(),
966975
});
967976
}

0 commit comments

Comments
 (0)