@@ -0,0 +1,2659 @@
+package com.google.bitcoin.tools;%0A%0Aimport com.google.bitcoin.core.*;%0Aimport com.google.bitcoin.kits.WalletAppKit;%0Aimport com.google.bitcoin.params.MainNetParams;%0Aimport com.google.bitcoin.utils.BriefLogFormatter;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport java.io.File;%0Aimport java.math.BigInteger;%0A%0A/**%0A * A program that sends a transaction with the specified fee and measures how long it takes to confirm.%0A */%0Apublic class TestFeeLevel %7B%0A    private static Logger log = LoggerFactory.getLogger(TestFeeLevel.class);%0A%0A    public static final MainNetParams PARAMS = MainNetParams.get();%0A    private static WalletAppKit kit;%0A%0A    public static void main(String%5B%5D args) throws Exception %7B%0A        BriefLogFormatter.init();%0A        if (args.length == 0) %7B%0A            System.err.println(%22Specify the fee level to test in satoshis as the first argument.%22);%0A            return;%0A        %7D%0A%0A        BigInteger feeToTest = new BigInteger(args%5B0%5D);%0A%0A        kit = new WalletAppKit(PARAMS, new File(%22.%22), %22testfeelevel%22);%0A        kit.startAsync();%0A        kit.awaitRunning();%0A        try %7B%0A            go(feeToTest);%0A        %7D finally %7B%0A            kit.stopAsync();%0A            kit.awaitTerminated();%0A        %7D%0A    %7D%0A%0A    private static void go(BigInteger feeToTest) throws InterruptedException, java.util.concurrent.ExecutionException, InsufficientMoneyException %7B%0A        kit.peerGroup().setMaxConnections(50);%0A%0A        final Address address = kit.wallet().currentReceiveKey().toAddress(PARAMS);%0A%0A        if (kit.wallet().getBalance().compareTo(feeToTest) %3C 0) %7B%0A            log.info(%22Send some money to %7B%7D%22, address);%0A            log.info(%22... and wait for it to confirm%22);%0A            kit.wallet().getBalanceFuture(feeToTest, Wallet.BalanceType.AVAILABLE).get();%0A        %7D%0A%0A        int heightAtStart = kit.chain().getBestChainHeight();%0A        log.info(%22Height at start is %7B%7D%22, heightAtStart);%0A%0A        Wallet.SendRequest request = Wallet.SendRequest.to(address, kit.wallet().getBalance().subtract(feeToTest));%0A        request.feePerKb = feeToTest;%0A        request.ensureMinRequiredFee = false;%0A        kit.wallet().completeTx(request);%0A        log.info(%22Fee paid is %7B%7D%22, request.fee);%0A        log.info(%22TX is %7B%7D%22, request.tx);%0A        kit.peerGroup().broadcastTransaction(request.tx).get();%0A        log.info(%22Send complete, waiting for confirmation%22);%0A        request.tx.getConfidence().getDepthFuture(1).get();%0A%0A        int heightNow = kit.chain().getBestChainHeight();%0A        log.info(%22Height after confirmation is %7B%7D%22, heightNow);%0A        log.info(%22Result: took %7B%7D blocks to confirm at this fee level%22, heightNow - heightAtStart);%0A    %7D%0A%7D%0A

Add a program that measures confirmation time for a given fee level.