WalletAppKit kit=new WalletAppKit(MainNetParams.get(), new File("."), "mywalletfilename");
kit.setAutoSave(true);
kit.startAsync();
kit.awaitRunning();
kit.wallet().addEventListener(new WalletListener());
while listener looks like:
public class WalletListener extends AbstractWalletEventListener {
public WalletListener() {
}
@Override
public void onCoinsReceived(org.bitcoinj.core.Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
System.out.println("-----> coins resceived: " + tx.getHashAsString()+" prevBalance = "+prevBalance.getValue()+" newBal="+newBalance.getValue());
System.out.println("received: " + tx.getValue(wallet));
}
@Override
public void onTransactionConfidenceChanged(org.bitcoinj.core.Wallet wallet, Transaction tx) {
System.out.println("-----> confidence changed: " + tx.getHashAsString());
TransactionConfidence confidence = tx.getConfidence();
System.out.println("new block depth: " + confidence.getDepthInBlocks());
}
@Override
public void onCoinsSent(org.bitcoinj.core.Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
System.out.println("coins sent");
}
@Override
public void onReorganize(org.bitcoinj.core.Wallet wallet) {
}
@Override
public void onWalletChanged(org.bitcoinj.core.Wallet wallet) {
}
@Override
public void onKeysAdded(List<ECKey> keys) {
System.out.println("new key added");
}
/*@Override
public void onScriptsAdded(Wallet wallet, List<Script> scripts) {
System.out.println("new script added");
}*/
}
Should be working enough for receiving BTC ;) dont forget TXConfidence changed where it tells you that TX confirmations count changed and to what it changed...
;-)