Bitcoin Forum

Bitcoin => BitcoinJ => Topic started by: profil3r on October 22, 2014, 03:06:55 PM



Title: WalletEventListener
Post by: profil3r on October 22, 2014, 03:06:55 PM
Just started messing around with bitcoinj 0.12 in eclipse as a java-newbie.

My simple goal is an app that tells me when a given address of my Wallet received coins.
pretty sure I have to use:

Code:
wallet.addEventListener(new AbstractWalletEventListener() {
public void onCoinsReceived(Wallet w, Transaction tx,
BigInteger prevBalance, BigInteger newBalance) {

System.out.println("You have received some Coins");

}
});

But how can I specify the wallet respectively the address that I want to be watched.
I can't figure it out with the help of the documentation:(


Title: Re: WalletEventListener
Post by: Mike Hearn on November 05, 2014, 01:30:12 PM
If it's an address the wallet generated itself, it'll already be "watched". If you want to watch an address you don't have the key for, use wallet.addWatchedAddress.