Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently working on a cloud based project that will be accepting payments using bitcoins. I intend to use BitCoinJ to handle the payment. Unfortunately the only help I am able to get is from the JavaWorld demo, which seems to be out of sync with the current code. Could you please point me to some better/updated helping links/material.

share|improve this question

There are some examples in the bitcoinj library itself which are always up to date (as they are part of the build).

The command line tool 'WalletTool' that Mike wrote is pretty useful for the basics of wallet creation, sending, receiving etc.

share|improve this answer
Thanks jim, I'll check them out. – Raghav Bali Feb 17 '13 at 4:57
WalletAppKit kit=new WalletAppKit(MainNetParams.get(), new File("."), "mywalletfilename");
kit.wallet().addEventListener(new WalletListener());

while listener looks like:

public class WalletListener  extends AbstractWalletEventListener {
public WalletListener() {

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));

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());

public void onCoinsSent(org.bitcoinj.core.Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
    System.out.println("coins sent");

public void onReorganize(org.bitcoinj.core.Wallet wallet) {

public void onWalletChanged(org.bitcoinj.core.Wallet wallet) {

public void onKeysAdded(List<ECKey> keys) {
    System.out.println("new key added");

    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... ;-)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.