1 use bitcoin::util::hash::Sha256dHash;
2 use bitcoin::util::uint::Uint256;
4 /// 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.
7 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
9 /// The referenced transaction's txid.
10 pub txid: Sha256dHash,
11 /// The index of the referenced output in its transaction's vout.
16 /// Creates a new `OutPoint` from the txid an the index.
17 pub fn new(txid: Sha256dHash, index: u16) -> OutPoint {
18 OutPoint { txid, index }
21 /// Convert an `OutPoint` to a lightning channel id.
22 pub fn to_channel_id(&self) -> Uint256 {
24 self.txid.into_be() ^ Uint256::from_u64(self.index as u64).unwrap()