In my Java application I am now required to handle multiple bitcoin wallets (HD wallets?). This means sending and receiving BTC. Unfortunately bitcoin is quite new for me, so there are some questions:

Would it be possible to use BitcoinJ in order to do this? Is it performing well with hundrets of wallets (or more)? If not, what would be the alternative?

Regarding the workflow: Of course the private key will stay on the user side and thus cannot be read by the application itself. Would it still be possible to raise events like "money received" without having the private key of the wallet?

  • Concerning the second question, I did it using watch addresses.
    – fcracker79
    Jan 24, 2016 at 21:59

2 Answers 2


I had the same doubt. I've done a little research in the library bitcoinj, and I think that it is possible to use multiple wallets at the same time. I recommend you first work with a single wallet so that you can understand a little how it works the library. I leave an example:

public class MainClass {
    private static final File BLOCKCHAIN_FILE = new File("block.dat");
    private static final NetworkParameters NET_PARAMS = MainNetParams.get();

    public static void main(String[] args) throws Exception {

        List<Wallet> wallets = getWallets();
        BlockStore blockStore = new SPVBlockStore(NET_PARAMS, BLOCKCHAIN_FILE);
        BlockChain blockChain = new BlockChain(NET_PARAMS, wallets, blockStore);
        PeerGroup peerGroup = new PeerGroup(NET_PARAMS, blockChain);

        for (Wallet w : wallets) {

        //Starting peerGroup;

        //Start download blockchain

    public static List<Wallet> getWallets() throws UnreadableWalletException {

        List<Wallet> wallets = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            Wallet w = Wallet.loadFromFile(new File("wallet_" + i + ".dat"), null);

        return wallets;

You can use bitcoinj with multiple wallets (just use peerGroup.addWallet(wallet) multiple times), but it isn't designed to scale well in such a scenario. Depending on your resources and the activity on the wallets, two, three or five wallets might work ok. But hundreds will almost certainly not work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.