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

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

CC BY-SA 3.0
2013-02-16T19:18:14.153Z
2013-02-16T19:18:14.153Z
jim618
<pre><code>WalletAppKit kit=new WalletAppKit(MainNetParams.get(), new File("."), "mywalletfilename");
kit.setAutoSave(true);
kit.startAsync();
kit.awaitRunning();
kit.wallet().addEventListener(new WalletListener());
</code></pre>

<p>while listener looks like:</p>

<pre><code>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("-----&gt; 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("-----&gt; 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&lt;ECKey&gt; keys) {
    System.out.println("new key added");
}

    /*@Override
    public void onScriptsAdded(Wallet wallet, List&lt;Script&gt; scripts) {
        System.out.println("new script added");
    }*/
</code></pre>

<p>}</p>

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

CC BY-SA 3.0
2016-02-06T14:33:59.280Z
2016-02-06T14:33:59.280Z
Wenza
<p>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.</p>

<bitcoinj><java>
BitCoinJ for Cloud based application
Raghav Bali
# BitCoinJ for Cloud based application

(Asked by: username_0 on 2013-02-16)

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.

**Tags:** bitcoinj, java


---

## 2 answers

### Answer by username_1 on 2013-02-16. Score: 1

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.


---

### Answer by username_2 on 2016-02-06. Score: 1

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


---

