<p>Use <code>WalletAppKit</code> this class is Utility class that wraps the boilerplate needed to set up a new SPV bitcoinj app. Instantiate it with a directory and file prefix, optionally configure a few things, then use startAsync and optionally awaitRunning. </p>

<p>i created the wallet and send the coins using your the faucet you have mentioned and its works fine and receiving coin, here is my code...</p>

<pre><code>public class Main {
    static NetworkParameters params = NetworkParameters.testNet3();
    static String path = System.getProperty("user.home") + "/Desktop";
    private static File walletFile = new File(path);
    private final static String APP_NAME = "MyWallet";
    private static WalletAppKit kit;

    public static void main(String...args)
    {
        kit = new WalletAppKit(params, walletFile, APP_NAME)
        {
            @Override
            protected Wallet createWallet() {
                Wallet wallet = new Wallet(params);
                return wallet;
            }
            @Override
            protected void onSetupCompleted() {
                super.onSetupCompleted();
                System.out.println(kit.wallet().currentReceiveAddress());
                System.out.println(kit.wallet().getTotalReceived().toFriendlyString());
                txHistory();
            }
        };
        System.out.println("start syncing...");
        kit.startAsync();
        kit.awaitRunning();
    }



    private static void txHistory()
    {
        List&lt;Transaction&gt; txx = kit.wallet().getTransactionsByTime();
        if (!txx.isEmpty())
        {
            int i = 1;
            for (Transaction tx : txx)
            {
                System.out.println(i + "  ________________________");
                System.out.println("Date and Time: " + tx.getUpdateTime().toString());
                System.out.println("From Address: " + tx.getOutput(1).getAddressFromP2PKHScript(params));
                System.out.println("To Address: " + tx.getOutput(0).getAddressFromP2PKHScript(params));
                System.out.println("Amount Sent to me: " + tx.getValueSentToMe(kit.wallet()).toFriendlyString());
                System.out.println("Amount Sent from me: " + tx.getValueSentFromMe(kit.wallet()).toFriendlyString());
                long fee = (tx.getInputSum().getValue() &gt; 0 ? tx.getInputSum().getValue() - tx.getOutputSum().getValue() : 0);
                System.out.println("Fee: " + Coin.valueOf(fee).toFriendlyString());
                System.out.println("Transaction Depth: " + tx.getConfidence().getDepthInBlocks());
                System.out.println("Transaction Blocks: " + tx.getConfidence().toString());
                System.out.println("Tx Hex: " + tx.getHashAsString());
                i++;
            }
        }
        else
        {

            System.err.println("No Transaction Found");
        }
    }
}
</code></pre>

CC BY-SA 4.0
2018-10-06T09:04:05.480Z
2018-10-06T09:04:05.480Z
Zombie
<p>I have a problem with bitcoinj. </p>

<p>I have created a wallet and than trying to send coins to it in Testnet3 using this faucet:
<a href="https://coinfaucet.eu/en/btc-testnet/" rel="nofollow noreferrer">https://coinfaucet.eu/en/btc-testnet/</a></p>

<p>Coins sended, transaction confirmed, but when I trying to get balance - it's always zero (available = available spendable = extimated = estimated spandable = 0). </p>

<p>Here is how I creating a Wallet:</p>

<pre><code>NetworkParameters params = TestNet3Params.get();
Wallet wallet = new Wallet(params);
BlockChain chain = new BlockChain(params, wallet, new MemoryBlockStore(params));
PeerGroup peerGroup = new PeerGroup(params, chain);
peerGroup.addWallet(wallet);
peerGroup.startAsync();
File file = new File("testwallet");
wallet.saveToFile(file);
</code></pre>

<p>Address:</p>

<pre><code>wallet.currentReceiveAddress().toString()
</code></pre>

<p>Balance:</p>

<pre><code>wallet.getBalance()
wallet.getBalance(Wallet.BalanceType.AVAILABLE_SPENDABLE)
wallet.getBalance(Wallet.BalanceType.AVAILABLE)
wallet.getBalance(Wallet.BalanceType.ESTIMATED_SPENDABLE)
wallet.getBalance(Wallet.BalanceType.ESTIMATED)
</code></pre>

<p>And it's always zero.</p>

<p>What I'm doing wrong? Why I can't receive coins?</p>

<testnet><bitcoinj><java><receiving>
Bitcoinj wallet can't receive coins in Testnet3
Ilyam
# Bitcoinj wallet can't receive coins in Testnet3

(Asked by: username_0 on 2018-10-05)

I have a problem with bitcoinj.

I have created a wallet and than trying to send coins to it in Testnet3 using this faucet:
<https://coinfaucet.eu/en/btc-testnet/>

Coins sended, transaction confirmed, but when I trying to get balance - it's always zero (available = available spendable = extimated = estimated spandable = 0).

Here is how I creating a Wallet:

```
NetworkParameters params = TestNet3Params.get();
Wallet wallet = new Wallet(params);
BlockChain chain = new BlockChain(params, wallet, new MemoryBlockStore(params));
PeerGroup peerGroup = new PeerGroup(params, chain);
peerGroup.addWallet(wallet);
peerGroup.startAsync();
File file = new File("testwallet");
wallet.saveToFile(file);

```

Address:

```
wallet.currentReceiveAddress().toString()

```

Balance:

```
wallet.getBalance()
wallet.getBalance(Wallet.BalanceType.AVAILABLE_SPENDABLE)
wallet.getBalance(Wallet.BalanceType.AVAILABLE)
wallet.getBalance(Wallet.BalanceType.ESTIMATED_SPENDABLE)
wallet.getBalance(Wallet.BalanceType.ESTIMATED)

```

And it's always zero.

What I'm doing wrong? Why I can't receive coins?

**Tags:** testnet, bitcoinj, java, receiving


---

## 1 answers

### Answer by username_1 on 2018-10-06. Score: 1

Use `WalletAppKit` this class is Utility class that wraps the boilerplate needed to set up a new SPV bitcoinj app. Instantiate it with a directory and file prefix, optionally configure a few things, then use startAsync and optionally awaitRunning.

i created the wallet and send the coins using your the faucet you have mentioned and its works fine and receiving coin, here is my code...

```
public class Main {
    static NetworkParameters params = NetworkParameters.testNet3();
    static String path = System.getProperty("user.home") + "/Desktop";
    private static File walletFile = new File(path);
    private final static String APP_NAME = "MyWallet";
    private static WalletAppKit kit;

    public static void main(String...args)
    {
        kit = new WalletAppKit(params, walletFile, APP_NAME)
        {
            @Override
            protected Wallet createWallet() {
                Wallet wallet = new Wallet(params);
                return wallet;
            }
            @Override
            protected void onSetupCompleted() {
                super.onSetupCompleted();
                System.out.println(kit.wallet().currentReceiveAddress());
                System.out.println(kit.wallet().getTotalReceived().toFriendlyString());
                txHistory();
            }
        };
        System.out.println("start syncing...");
        kit.startAsync();
        kit.awaitRunning();
    }

    private static void txHistory()
    {
        List<Transaction> txx = kit.wallet().getTransactionsByTime();
        if (!txx.isEmpty())
        {
            int i = 1;
            for (Transaction tx : txx)
            {
                System.out.println(i + "  ________________________");
                System.out.println("Date and Time: " + tx.getUpdateTime().toString());
                System.out.println("From Address: " + tx.getOutput(1).getAddressFromP2PKHScript(params));
                System.out.println("To Address: " + tx.getOutput(0).getAddressFromP2PKHScript(params));
                System.out.println("Amount Sent to me: " + tx.getValueSentToMe(kit.wallet()).toFriendlyString());
                System.out.println("Amount Sent from me: " + tx.getValueSentFromMe(kit.wallet()).toFriendlyString());
                long fee = (tx.getInputSum().getValue() > 0 ? tx.getInputSum().getValue() - tx.getOutputSum().getValue() : 0);
                System.out.println("Fee: " + Coin.valueOf(fee).toFriendlyString());
                System.out.println("Transaction Depth: " + tx.getConfidence().getDepthInBlocks());
                System.out.println("Transaction Blocks: " + tx.getConfidence().toString());
                System.out.println("Tx Hex: " + tx.getHashAsString());
                i++;
            }
        }
        else
        {

            System.err.println("No Transaction Found");
        }
    }
}

```


---

