@Override public byte[] bitcoinSerialize(){
  if (headerBytesValid && transactionBytesValid) {
    Preconditions.checkNotNull(payload,"Bytes should never be null if headerBytesValid && transactionBytesValid");
    if (length == payload.length) {
      return payload;
    }
 else {
      byte[] buf=new byte[length];
      System.arraycopy(payload,offset,buf,0,length);
      return buf;
    }
  }
  ByteArrayOutputStream stream=new UnsafeByteArrayOutputStream(length == UNKNOWN_LENGTH ? HEADER_SIZE + guessTransactionsLength() : length);
  try {
    writeHeader(stream);
    writeTransactions(stream);
  }
 catch (  IOException e) {
  }
  return stream.toByteArray();
}

@ Override public byte [ ] bitcoinSerialize ( ) { if ( headerBytesValid && transactionBytesValid ) { Preconditions . checkNotNull ( payload , "Bytes should never be null if headerBytesValid && transactionBytesValid" ) ; if ( length == payload . length ) { return payload ; } else { byte [ ] buf = new byte [ length ] ; System . arraycopy ( payload , offset , buf , 0 , length ) ; return buf ; } } ByteArrayOutputStream stream = new UnsafeByteArrayOutputStream ( length == UNKNOWN_LENGTH ? HEADER_SIZE + guessTransactionsLength ( ) : length ) ; try { writeHeader ( stream ) ; writeTransactions ( stream ) ; } catch ( IOException e ) { } return stream . toByteArray ( ) ; }
special handling to check if we have a valid byte array for both header and transactions
