Add TxOutRef type to blockdata::transaction; don't use it anywhere in the library itself

This is just a convenience type for the (txid, vout) pairs that get produced
a lot in Bitcoin code. To the best of my knowledge there is nowhere this can
be used in the actual library (in particular, TxOutRef.index is a usize for
convenience while TxIn.prev_index is a u32 for correct consensus encoding,
so there is not redundancy here).
This commit is contained in:
Andrew Poelstra 2015-12-04 15:57:17 -06:00
parent e393d0ec3b
commit c1993a12c6
1 changed files with 16 additions and 0 deletions

View File

@ -24,6 +24,7 @@
//!
use std::default::Default;
use std::fmt;
use serde;
use secp256k1::Secp256k1;
@ -33,6 +34,21 @@ use blockdata::utxoset::UtxoSet;
use network::encodable::ConsensusEncodable;
use network::serialize::BitcoinHash;
/// A reference to a transaction output
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
pub struct TxOutRef {
/// The referenced transaction's txid
pub txid: Sha256dHash,
/// The index of the referenced output in its transaction's vout
pub index: usize
}
impl fmt::Display for TxOutRef {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}:{}", self.txid, self.index)
}
}
/// A transaction input, which defines old coins to be consumed
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct TxIn {