@@ -610,13 +610,8 @@ pub struct ChannelId {
610610}
611611
612612impl ChannelId {
613- /// Create channel ID based on a funding TX outpoint
614- pub fn from_funding_outpoint(funding_tx_outpoint: &OutPoint) -> Self {
615- Self::from_funding_txid(&funding_tx_outpoint.txid.as_inner(), funding_tx_outpoint.index)
616- }
617-
618- /// Create channel ID based on a funding TX ID and output index
619- pub fn from_funding_txid(txid: &[u8; 32], output_index: u16) -> Self {
613+ /// Create v1 channel ID based on a funding TX ID and output index
614+ pub fn v1_from_funding_txid(txid: &[u8; 32], output_index: u16) -> Self {
620615 let mut res = [0; 32];
621616 res[..].copy_from_slice(&txid[..]);
622617 res[30] ^= ((output_index >> 8) & 0xff) as u8;
@@ -625,13 +620,13 @@ impl ChannelId {
625620 }
626621
627622 /// Create a temporary channel ID randomly, based on an entropy source.
628- pub fn from_entropy_source <ES: Deref>(entropy_source: &ES) -> Self
623+ pub fn temporary_from_entropy_source <ES: Deref>(entropy_source: &ES) -> Self
629624 where ES::Target: EntropySource {
630625 Self::from_bytes(entropy_source.get_secure_random_bytes())
631626 }
632627
633628 /// Generic constructor; create a new channel ID from the provided data.
634- /// Use a more specific from_* constructor when possible.
629+ /// Use a more specific * from_* constructor when possible.
635630 /// This constructor is useful for tests, and internally, e.g. when the channel ID is being deserialized.
636631 pub fn from_bytes(data: [u8; 32]) -> Self {
637632 Self{data}
@@ -646,11 +641,6 @@ impl ChannelId {
646641 pub fn bytes(&self) -> &[u8; 32] {
647642 &self.data
648643 }
649-
650- /// Serialization helper
651- pub fn serialized_length(&self) -> usize {
652- self.bytes().serialized_length()
653- }
654644}
655645
656646impl Writeable for ChannelId {
@@ -5676,7 +5666,7 @@ impl<Signer: WriteableEcdsaChannelSigner> OutboundV1Channel<Signer> {
56765666 Err(_) => return Err(APIError::ChannelUnavailable { err: "Failed to get destination script".to_owned()}),
56775667 };
56785668
5679- let temporary_channel_id = ChannelId::from_entropy_source (entropy_source);
5669+ let temporary_channel_id = ChannelId::temporary_from_entropy_source (entropy_source);
56805670
56815671 Ok(Self {
56825672 context: ChannelContext {
@@ -7575,15 +7565,15 @@ mod tests {
75757565
75767566 #[test]
75777567 fn test_channel_id_from_funding_tx2() {
7578- let channel_id = ChannelId::from_funding_txid (&[2; 32], 1);
7568+ let channel_id = ChannelId::v1_from_funding_txid (&[2; 32], 1);
75797569 assert_eq!(channel_id.to_hex(), "0202020202020202020202020202020202020202020202020202020202020203");
75807570 }
75817571
75827572 #[test]
75837573 fn test_channel_id_equals() {
7584- let channel_id11 = ChannelId::from_funding_txid (&[2; 32], 2);
7585- let channel_id12 = ChannelId::from_funding_txid (&[2; 32], 2);
7586- let channel_id21 = ChannelId::from_funding_txid (&[2; 32], 42);
7574+ let channel_id11 = ChannelId::v1_from_funding_txid (&[2; 32], 2);
7575+ let channel_id12 = ChannelId::v1_from_funding_txid (&[2; 32], 2);
7576+ let channel_id21 = ChannelId::v1_from_funding_txid (&[2; 32], 42);
75877577 assert_eq!(channel_id11, channel_id12);
75887578 assert_ne!(channel_id11, channel_id21);
75897579 }
0 commit comments