My bitcoinj code doesn't work. I'm trying to use SPV mode in Testnet
08:07 25 Nov 2025

I'm trying to make a test program with bitcoinj to make a test payment, but it doesn't work. The code in the addCoinsReceivedEventListener event doesn't execute. I'm using Gradle and IntelliJ.

import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.params.TestNet3Params;

import java.io.File;
import java.util.Scanner;
public class Program {

    public static void main(String[] args)
    {
        NetworkParameters params = TestNet3Params.get();
        WalletAppKit kit = new WalletAppKit(params, new File("."), "test");

        kit.wallet().addCoinsReceivedEventListener((w, tx, r, t) ->
        {
            System.out.println("Received " + " " + r.toFriendlyString() + " " + t.toFriendlyString());
        });
        kit.setBlockingStartup(false);
        kit.startAsync();
        kit.awaitRunning();

        var addr = kit.wallet().freshReceiveAddress().toString();

        System.out.println(addr);

        Scanner scan = new Scanner(System.in);

        scan.nextLine();
        scan.close();
    }
}

I tried moving the following block:

kit.wallet().addCoinsReceivedEventListener((w, tx, r, t) ->
        {
            System.out.println("Received " + " " + r.toFriendlyString() + " " + t.toFriendlyString());
        });

before and after:

kit.startAsync();
kit.awaitRunning();

but the result was the same.

java bitcoinj