Transaction and header version is signed int

This commit is contained in:
Braydon Fuller 2020-08-17 10:28:33 -07:00
parent e8bcde4d38
commit e9f1f11c2c
No known key found for this signature in database
GPG Key ID: F24F232D108B3AD4
3 changed files with 5 additions and 7 deletions

View File

@ -37,7 +37,7 @@ use VarInt;
#[derive(Copy, PartialEq, Eq, Clone, Debug)]
pub struct BlockHeader {
/// The protocol version. Should always be 1.
pub version: u32,
pub version: i32,
/// Reference to the previous block in the chain
pub prev_blockhash: BlockHash,
/// The root hash of the merkle tree of transactions in the block
@ -320,4 +320,3 @@ mod tests {
assert_eq!(header.bits, BlockHeader::compact_target_from_u256(&header.target()));
}
}

View File

@ -260,7 +260,7 @@ impl Default for TxOut {
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
pub struct Transaction {
/// The protocol version, is currently expected to be 1 or 2 (BIP 68).
pub version: u32,
pub version: i32,
/// Block number before which this transaction is valid, or 0 for
/// valid immediately.
pub lock_time: u32,
@ -531,7 +531,7 @@ impl Encodable for Transaction {
impl Decodable for Transaction {
fn consensus_decode<D: io::Read>(mut d: D) -> Result<Self, encode::Error> {
let version = u32::consensus_decode(&mut d)?;
let version = i32::consensus_decode(&mut d)?;
let input = Vec::<TxIn>::consensus_decode(&mut d)?;
// segwit
if input.is_empty() {
@ -1229,4 +1229,3 @@ mod tests {
}
}
}

View File

@ -30,7 +30,7 @@ use consensus::encode::Encodable;
#[derive(Clone, PartialEq, Eq, Debug)]
#[deprecated(since="0.24.0", note="please use `SigHashCache` instead")]
pub struct SighashComponents {
tx_version: u32,
tx_version: i32,
tx_locktime: u32,
/// Hash of all the previous outputs
pub hash_prevouts: SigHash,