From: Matt Corallo Date: Fri, 29 Jun 2018 21:38:05 +0000 (-0400) Subject: Add more docs to transaction::OutPoint X-Git-Tag: v0.0.12~398^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=refs%2Fheads%2F2018-08-33-cleanups;p=rust-lightning Add more docs to transaction::OutPoint --- diff --git a/src/chain/transaction.rs b/src/chain/transaction.rs index 00728b450..dad3c1271 100644 --- a/src/chain/transaction.rs +++ b/src/chain/transaction.rs @@ -2,6 +2,8 @@ use bitcoin::util::hash::Sha256dHash; use bitcoin::util::uint::Uint256; /// A reference to a transaction output. +/// Differs from bitcoin::blockdata::transaction::TxOutRef as the index is a u16 instead of usize +/// due to LN's restrictions on index values. Should reduce (possibly) unsafe conversions this way. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] pub struct OutPoint { /// The referenced transaction's txid. @@ -16,9 +18,9 @@ impl OutPoint { OutPoint { txid, index } } - /// Convert an `OutPoint` to a lightning channel id. - pub fn to_channel_id(&self) -> Uint256 { - // TODO: or le? - self.txid.into_be() ^ Uint256::from_u64(self.index as u64).unwrap() - } + /// Convert an `OutPoint` to a lightning channel id. + pub fn to_channel_id(&self) -> Uint256 { + // TODO: or le? + self.txid.into_be() ^ Uint256::from_u64(self.index as u64).unwrap() + } }