public static Transaction roundTripTransaction(NetworkParameters params,Transaction tx) throws IOException, ProtocolException {
  BitcoinSerializer bs=new BitcoinSerializer(params);
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  bs.serialize(tx,bos);
  return (Transaction)bs.deserialize(ByteBuffer.wrap(bos.toByteArray()));
}

public static Transaction roundTripTransaction ( NetworkParameters params , Transaction tx ) throws IOException , ProtocolException { BitcoinSerializer bs = new BitcoinSerializer ( params ) ; ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; bs . serialize ( tx , bos ) ; return ( Transaction ) bs . deserialize ( ByteBuffer . wrap ( bos . toByteArray ( ) ) ) ; }
roundtrip a transaction so that it appears as if it has just come from the wire
