Bitcoin Stack Change is a query and reply website for Bitcoin crypto-currency fans. It solely takes a minute to enroll.
Anyone can ask a query
Anyone can reply
The very best solutions are voted up and rise to the highest
Requested
Seen
603 instances
I’m new to bitcoinj. I wish to print out the checklist of transactions like as observe for a pockets:
1- Despatched 1 BTC to Adress1 on 'A' Time
2- Acquired 5 BTC from Adress2 on 'B' time
3- Despatched 2 BTC to Deal with 3 on 'C' time
How can I do that?
2
Create an object of pockets app equipment like:
WalletAppKit equipment = new WalletAppKit(params, new File("."), "filename");
equipment.startAsync();
equipment.awaitRunning();
Iterable<WalletTransaction> walletTransactions = equipment.pockets().getWalletTransactions();
this walletTransactions provides you with all transactions associated to the pockets.
You will get transaction historical past of any transaction like this
non-public void txHistory()
{
Set<Transaction> txx = equipment.pockets().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 Deal with: " + tx.getOutput(0).getAddressFromP2PKHScript(params));
System.out.println("To Deal with: " + tx.getOutput(0).getAddressFromP2PKHScript(params));
System.out.println("Quantity Despatched to me: " + tx.getValueSentToMe(equipment.pockets()).toFriendlyString());
System.out.println("Quantity Despatched from me: " + tx.getValueSentFromMe(equipment.pockets()).toFriendlyString());
lengthy payment = (tx.getInputSum().getValue() > 0 ? tx.getInputSum().getValue() - tx.getOutputSum().getValue() : 0);
System.out.println("Charge: " + Coin.valueOf(payment).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 Discovered");
}
}