How do I check if an address belongs to my wallet using bitcoinJ?

3

1

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?

Ander Acosta

Posted 2015-09-10T13:37:06.077

Reputation: 372

Answers

1

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;

Badr Bellaj

Posted 2015-09-10T13:37:06.077

Reputation: 862

What is the object w in snippet above?cogitoergosum 2017-02-06T09:35:44.873

The wallet objectBadr Bellaj 2017-02-06T10:42:42.643