import { reverseHex } from '../utils' ; import { num2hexstring , StringReader } from './../utils' ; export class TransactionInput { static deserialize ( hexstr ) { const sr = new StringReader ( hexstr ) ; const input = new TransactionInput ( ) ; input . prevHash = sr . read ( 20 ) ; input . prevIndex = parseInt ( reverseHex ( sr . read ( 2 ) ) , 16 ) ; return input ; } /**
     * 32 bytes
     */ prevHash : string ; prevIndex : number ; equals ( o ) { if ( o === this ) { return true ; } if ( null === o ) { return false ; } if ( ! ( o instanceof TransactionInput ) ) { return false ; } return this . prevHash === o . prevHash && this . prevIndex === o . prevIndex ; } hashCode ( ) { return parseInt ( reverseHex ( this . prevHash ) , 16 ) + this . prevIndex ; } serialize ( ) { let result = '' ; result += this . prevHash ; result += num2hexstring ( this . prevIndex , 2 , true ) ; return result ; } }