public Sha256Hash getTxId ( ) { if ( cachedTxId == null ) { if ( ! hasWitnesses ( ) && cachedWTxId != null ) { cachedTxId = cachedWTxId ; } else { ByteArrayOutputStream stream = new UnsafeByteArrayOutputStream ( length < 32 ? 32 : length + 32 ) ; try { bitcoinSerializeToStream ( stream , false ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; // cannot happen } cachedTxId = Sha256Hash . wrapReversed ( Sha256Hash . hashTwice ( stream . toByteArray ( ) ) ) ; } } return cachedTxId ; }
Returns the transaction id as you see them in block explorers . It is used as a reference by transaction inputs via outpoints .