<p>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:</p>

<pre><code>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&lt;Wallet&gt; 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) {
            peerGroup.addWallet(w);
        }

        //Starting peerGroup;
        peerGroup.startAsync();

        //Start download blockchain
        peerGroup.downloadBlockChain();
    }

    public static List&lt;Wallet&gt; getWallets() throws UnreadableWalletException {

        List&lt;Wallet&gt; wallets = new ArrayList&lt;&gt;();
        for (int i = 0; i &lt; 5; i++) {
            Wallet w = Wallet.loadFromFile(new File("wallet_" + i + ".dat"), null);
            wallets.add(w);
        }

        return wallets;
    }
}
</code></pre>

CC BY-SA 3.0
2016-11-18T04:05:14.627Z
2016-11-18T04:05:14.627Z
Ander Acosta
<p>You can use bitcoinj with multiple wallets (just use <code>peerGroup.addWallet(wallet)</code> 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.</p>

CC BY-SA 3.0
2017-03-12T10:53:48.200Z
2017-03-12T10:53:48.200Z
Andreas
<p>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:</p>

<p>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?</p>

<p>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?</p>

CC BY-SA 3.0
2016-01-24T21:59:17.970Z
Concerning the second question, I did it using watch addresses.
fcracker79
<wallet><bitcoinj>
Bitcoinj: Multiple wallets
einherjer
# Bitcoinj: Multiple wallets

(Asked by: username_0 on 2015-10-24)

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?

**Tags:** wallet, bitcoinj

> **Comments:**
> **username_1**: Concerning the second question, I did it using watch addresses.  

---

## 2 answers

### Answer by username_2 on 2016-11-18. Score: 1 | Accepted answer

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 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) {
            peerGroup.addWallet(w);
        }

        //Starting peerGroup;
        peerGroup.startAsync();

        //Start download blockchain
        peerGroup.downloadBlockChain();
    }

    public static List getWallets() throws UnreadableWalletException {

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

        return wallets;
    }
}


---

### Answer by username_3 on 2017-03-12. Score: 0

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.


---

