<p>You can get transaction history of any transaction like this</p>

<pre><code> private void txHistory()
            {
                Set&lt;Transaction&gt; txx = kit.wallet().getTransactions(true);
                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(0).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());
                        System.out.println("Tx: " + tx.toString());
                        i++;
                    }
                }
                else
                {
                    System.err.println("No Transaction Found");
                }
            }
</code></pre>

CC BY-SA 4.0
2018-06-17T08:23:42.180Z
2018-06-17T08:23:42.180Z
Zombie
<p>Create an object of wallet app kit like:</p>

<pre><code>WalletAppKit kit = new WalletAppKit(params, new File("."), "filename");
kit.startAsync();
kit.awaitRunning();
Iterable&lt;WalletTransaction&gt; walletTransactions = kit.wallet().getWalletTransactions();
</code></pre>

<p>this walletTransactions will give you all transactions related to the wallet.</p>

CC BY-SA 3.0
2018-03-16T10:49:27.287Z
2018-03-16T10:49:27.287Z
Sanjay Rao
<p>I am new to bitcoinj. I want to print out the list of transactions like as follow for a wallet:</p>

<pre><code>1- Sent 1 BTC to Adress1 on 'A' Time
2- Received 5 BTC from Adress2 on 'B' time
3- Sent 2 BTC to Address 3 on 'C' time
</code></pre>

<p>How can I do this?</p>

CC BY-SA 3.0
2018-02-20T11:30:08.210Z
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.
Tailer
CC BY-SA 3.0
2018-02-20T12:03:18.187Z
It seems clear to me!. however I am using walletappkit and I have received and sent bitcoins on testnet. Now I want to get the list of transactions and should be able to know whether this amount came into my wallet or went out.
ArslanAnjum
<bitcoinj>
Transaction history with bitcoinj
ArslanAnjum
# Transaction history with bitcoinj

(Asked by: username_0 on 2018-02-20)

I am new to bitcoinj. I want to print out the list of transactions like as follow for a wallet:
1- Sent 1 BTC to Adress1 on 'A' Time
2- Received 5 BTC from Adress2 on 'B' time
3- Sent 2 BTC to Address 3 on 'C' time

How can I do this?

**Tags:** bitcoinj

> **Comments:**
> **username_1**: Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.  
> **username_0**: It seems clear to me!. however I am using walletappkit and I have received and sent bitcoins on testnet. Now I want to get the list of transactions and should be able to know whether this amount came into my wallet or went out.  

---

## 2 answers

### Answer by username_2 on 2018-06-17. Score: 0

You can get transaction history of any transaction like this
 private void txHistory()
            {
                Set txx = kit.wallet().getTransactions(true);
                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(0).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());
                        System.out.println("Tx: " + tx.toString());
                        i++;
                    }
                }
                else
                {
                    System.err.println("No Transaction Found");
                }
            }


---

### Answer by username_3 on 2018-03-16. Score: 0

Create an object of wallet app kit like:
WalletAppKit kit = new WalletAppKit(params, new File("."), "filename");
kit.startAsync();
kit.awaitRunning();
Iterable walletTransactions = kit.wallet().getWalletTransactions();

this walletTransactions will give you all transactions related to the wallet.


---

