diff --git a/core/src/main/java/com/google/bitcoin/testing/FakeTxBuilder.java b/core/src/main/java/com/google/bitcoin/testing/FakeTxBuilder.java index 83123435..91093584 100644 --- a/core/src/main/java/com/google/bitcoin/testing/FakeTxBuilder.java +++ b/core/src/main/java/com/google/bitcoin/testing/FakeTxBuilder.java @@ -26,8 +26,7 @@ import java.math.BigInteger; import java.nio.ByteBuffer; public class FakeTxBuilder { - public static Transaction createFakeTxWithChangeAddress(NetworkParameters params, BigInteger nanocoins, Address to, Address changeOutput) - throws IOException, ProtocolException { + public static Transaction createFakeTxWithChangeAddress(NetworkParameters params, BigInteger nanocoins, Address to, Address changeOutput) { // Create a fake TX of sufficient realism to exercise the unit tests. Two outputs, one to us, one to somewhere // else to simulate change. Transaction t = new Transaction(params); @@ -46,11 +45,11 @@ public class FakeTxBuilder { return roundTripTransaction(params, t); } - public static Transaction createFakeTx(NetworkParameters params, BigInteger nanocoins, Address to) throws IOException, ProtocolException { + public static Transaction createFakeTx(NetworkParameters params, BigInteger nanocoins, Address to) { return createFakeTxWithChangeAddress(params, nanocoins, to, new ECKey().toAddress(params)); } - public static Transaction createFakeTx(NetworkParameters params, BigInteger nanocoins, ECKey to) throws IOException, ProtocolException { + public static Transaction createFakeTx(NetworkParameters params, BigInteger nanocoins, ECKey to) { // Create a fake TX of sufficient realism to exercise the unit tests. Two outputs, one to us, one to somewhere // else to simulate change. Transaction t = new Transaction(params); @@ -73,7 +72,7 @@ public class FakeTxBuilder { * @return Transaction[] Transaction[0] is a feeder transaction, supplying BTC to Transaction[1] */ public static Transaction[] createFakeTx(NetworkParameters params, BigInteger nanocoins, - Address to, Address from) throws IOException, ProtocolException { + Address to, Address from) { // Create fake TXes of sufficient realism to exercise the unit tests. This transaction send BTC from the // from address, to the to address with to one to somewhere else to simulate change. Transaction t = new Transaction(params); @@ -103,11 +102,15 @@ public class FakeTxBuilder { /** * Roundtrip a transaction so that it appears as if it has just come from the wire */ - 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) { + try { + BitcoinSerializer bs = new BitcoinSerializer(params); + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + bs.serialize(tx, bos); + return (Transaction) bs.deserialize(ByteBuffer.wrap(bos.toByteArray())); + } catch (IOException e) { + throw new RuntimeException(e); // Should not happen. + } } public static class DoubleSpends {