<p>This seems to get change addresses:</p>

<pre><code>public List&lt;String&gt; getChangeAddresses() {
    List&lt;String&gt; ret = new ArrayList&lt;&gt;();
    int issuedKeys = wallet.getActiveKeyChain().getIssuedInternalKeys();

    for (int i = 0; i &lt; issuedKeys; i++) {
        ChildNumber childNumber = new ChildNumber(i, false);
        List&lt;ChildNumber&gt; childNumbers = new ArrayList&lt;&gt;();
        childNumbers.add(ChildNumber.ZERO_HARDENED);
        childNumbers.add(ChildNumber.ONE);
        childNumbers.add(childNumber);
        ECKey key = wallet.getKeyByPath(childNumbers);
        ret.add(new Address(params, key.getPubKeyHash()).toBase58());
    }
    return ret;
}
</code></pre>

CC BY-SA 3.0
2016-02-23T02:25:25.570Z
2016-02-23T02:25:25.570Z
Pavel Niedoba
<p>Bitcoinj generates receiving addresses on demand and change addresses after each transaction. So how do I list all receiving addresses ? I guess I have to deal with KeyChainGroup and BasicKeyChain. I know how to get all issued receive keys</p>

<pre><code>wallet.getActiveKeyChain().getIssuedReceiveKeys();
</code></pre>

<p>but cannot find change keys. So where is getIssuedChangeKeys() method or if there is not such method whta is the reason. I'm trying to imagine how recovery would work if the wallet is restored from seed. </p>

<bitcoinj>
how do I get list of all "used" addresses in bitcoinj
Pavel Niedoba
# how do I get list of all "used" addresses in bitcoinj

(Asked by: username_0 on 2016-02-23)

Bitcoinj generates receiving addresses on demand and change addresses after each transaction. So how do I list all receiving addresses ? I guess I have to deal with KeyChainGroup and BasicKeyChain. I know how to get all issued receive keys
wallet.getActiveKeyChain().getIssuedReceiveKeys();

but cannot find change keys. So where is getIssuedChangeKeys() method or if there is not such method whta is the reason. I'm trying to imagine how recovery would work if the wallet is restored from seed.

**Tags:** bitcoinj


---

## 1 answers

### Answer by username_0 on 2016-02-23. Score: 2

This seems to get change addresses:
public List getChangeAddresses() {
    List ret = new ArrayList<>();
    int issuedKeys = wallet.getActiveKeyChain().getIssuedInternalKeys();

    for (int i = 0; i < issuedKeys; i++) {
        ChildNumber childNumber = new ChildNumber(i, false);
        List childNumbers = new ArrayList<>();
        childNumbers.add(ChildNumber.ZERO_HARDENED);
        childNumbers.add(ChildNumber.ONE);
        childNumbers.add(childNumber);
        ECKey key = wallet.getKeyByPath(childNumbers);
        ret.add(new Address(params, key.getPubKeyHash()).toBase58());
    }
    return ret;
}


---

