Add more docs to transaction::OutPoint 2018-08-33-cleanups
authorMatt Corallo <git@bluematt.me>
Fri, 29 Jun 2018 21:38:05 +0000 (17:38 -0400)
committerMatt Corallo <git@bluematt.me>
Fri, 29 Jun 2018 21:38:05 +0000 (17:38 -0400)
src/chain/transaction.rs

index 00728b45033a53844ba94451d4d6907475b1d419..dad3c1271e4f0e5459691d44ddd092b101e6299c 100644 (file)
@@ -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()
+       }
 }