Skip to content

Commit d62abad

Browse files
committed
Add more docs to transaction::OutPoint
1 parent 56842c2 commit d62abad

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/chain/transaction.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use bitcoin::util::hash::Sha256dHash;
22
use bitcoin::util::uint::Uint256;
33

44
/// A reference to a transaction output.
5+
/// Differs from bitcoin::blockdata::transaction::TxOutRef as the index is a u16 instead of usize
6+
/// due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way.
57
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
68
pub struct OutPoint {
79
/// The referenced transaction's txid.
@@ -16,9 +18,9 @@ impl OutPoint {
1618
OutPoint { txid, index }
1719
}
1820

19-
/// Convert an `OutPoint` to a lightning channel id.
20-
pub fn to_channel_id(&self) -> Uint256 {
21-
// TODO: or le?
22-
self.txid.into_be() ^ Uint256::from_u64(self.index as u64).unwrap()
23-
}
21+
/// Convert an `OutPoint` to a lightning channel id.
22+
pub fn to_channel_id(&self) -> Uint256 {
23+
// TODO: or le?
24+
self.txid.into_be() ^ Uint256::from_u64(self.index as u64).unwrap()
25+
}
2426
}

0 commit comments

Comments
 (0)