HugeDeclaredSizeTransaction: in constructor send to a throwaway keys rather than addresses

Addresses are expensive to create, as we need to know a network they are created for.
This commit is contained in:
Andreas Schildbach 2023-04-01 23:25:59 +02:00
parent cd57fea864
commit ff6499baab

View file

@ -710,14 +710,13 @@ public class TransactionTest {
public HugeDeclaredSizeTransaction(NetworkParameters params, boolean hackInputsSize, boolean hackOutputsSize, boolean hackWitnessPushCountSize) {
super(params);
Transaction inputTx = new Transaction(params);
inputTx.addOutput(Coin.FIFTY_COINS, ECKey.fromPrivate(BigInteger.valueOf(123456)).toAddress(ScriptType.P2PKH, params.network()));
inputTx.addOutput(Coin.FIFTY_COINS, new ECKey());
this.addInput(inputTx.getOutput(0));
this.getInput(0).disconnect();
TransactionWitness witness = new TransactionWitness(1);
witness.setPush(0, new byte[] {0});
this.getInput(0).setWitness(witness);
Address to = ECKey.fromPrivate(BigInteger.valueOf(1000)).toAddress(ScriptType.P2PKH, params.network());
this.addOutput(Coin.COIN, to);
this.addOutput(Coin.COIN, new ECKey());
this.hackInputsSize = hackInputsSize;
this.hackOutputsSize = hackOutputsSize;