<p>you could check thepubkey hash in the transaction outputs</p>

<p>this code for exemple check if an adresse belonging to your wallet is in the output</p>

<pre><code>    Address to= null;
        boolean tome= false;
        //from = tx.getInputs().get(0).getFromAddress();
        to=tx.getOutputs().get(0).getScriptPubKey().getToAddress(Constants.NETWORK_PARAMETERS);
tome= w.isPubKeyHashMine(from.getHash160());
        return tome;
</code></pre>

CC BY-SA 3.0
2017-02-06T09:35:44.873Z
What is the object `w` in snippet above?
cogitoergosum
CC BY-SA 3.0
2017-02-06T10:42:42.643Z
The wallet object
Badr Bellaj
CC BY-SA 3.0
2016-02-04T12:22:42.960Z
2016-02-04T12:27:43.407Z
2016-02-04T12:27:43.407Z
Badr Bellaj
<p>I'm using bitcoinJ and I want to verify if some of the destination addresses in a transaction belongs to my wallet when I receive a amount of bitcoin. How can I verify it?</p>

<transactions><wallet><address><bitcoinj><verification>
How do I check if an address belongs to my wallet using bitcoinJ?
Ander Acosta
# How do I check if an address belongs to my wallet using bitcoinJ?

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

I'm using bitcoinJ and I want to verify if some of the destination addresses in a transaction belongs to my wallet when I receive a amount of bitcoin. How can I verify it?

**Tags:** transactions, wallet, address, bitcoinj, verification


---

## 1 answers

### Answer by username_1 on 2016-02-04. Score: 1 | Accepted answer

you could check thepubkey hash in the transaction outputs

this code for exemple check if an adresse belonging to your wallet is in the output

```
    Address to= null;
        boolean tome= false;
        //from = tx.getInputs().get(0).getFromAddress();
        to=tx.getOutputs().get(0).getScriptPubKey().getToAddress(Constants.NETWORK_PARAMETERS);
tome= w.isPubKeyHashMine(from.getHash160());
        return tome;

```

> **Comments:**
> **username_2**: What is the object `w` in snippet above?  
> **username_1**: The wallet object  

---

