@@ -610,13 +610,8 @@ pub struct ChannelId {
610
610
}
611
611
612
612
impl 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 {
620
615
let mut res = [0; 32];
621
616
res[..].copy_from_slice(&txid[..]);
622
617
res[30] ^= ((output_index >> 8) & 0xff) as u8;
@@ -625,13 +620,13 @@ impl ChannelId {
625
620
}
626
621
627
622
/// 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
629
624
where ES::Target: EntropySource {
630
625
Self::from_bytes(entropy_source.get_secure_random_bytes())
631
626
}
632
627
633
628
/// 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.
635
630
/// This constructor is useful for tests, and internally, e.g. when the channel ID is being deserialized.
636
631
pub fn from_bytes(data: [u8; 32]) -> Self {
637
632
Self{data}
@@ -646,11 +641,6 @@ impl ChannelId {
646
641
pub fn bytes(&self) -> &[u8; 32] {
647
642
&self.data
648
643
}
649
-
650
- /// Serialization helper
651
- pub fn serialized_length(&self) -> usize {
652
- self.bytes().serialized_length()
653
- }
654
644
}
655
645
656
646
impl Writeable for ChannelId {
@@ -5676,7 +5666,7 @@ impl<Signer: WriteableEcdsaChannelSigner> OutboundV1Channel<Signer> {
5676
5666
Err(_) => return Err(APIError::ChannelUnavailable { err: "Failed to get destination script".to_owned()}),
5677
5667
};
5678
5668
5679
- let temporary_channel_id = ChannelId::from_entropy_source (entropy_source);
5669
+ let temporary_channel_id = ChannelId::temporary_from_entropy_source (entropy_source);
5680
5670
5681
5671
Ok(Self {
5682
5672
context: ChannelContext {
@@ -7575,15 +7565,15 @@ mod tests {
7575
7565
7576
7566
#[test]
7577
7567
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);
7579
7569
assert_eq!(channel_id.to_hex(), "0202020202020202020202020202020202020202020202020202020202020203");
7580
7570
}
7581
7571
7582
7572
#[test]
7583
7573
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);
7587
7577
assert_eq!(channel_id11, channel_id12);
7588
7578
assert_ne!(channel_id11, channel_id21);
7589
7579
}
0 commit comments