Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. WalletAppKit kit=new WalletAppKit(MainNetParams.get(), new File("."), "mywalletfilename");
  2. kit.setAutoSave(true);
  3. kit.startAsync();
  4. kit.awaitRunning();
  5. kit.wallet().addEventListener(new WalletListener());
  6.  
  7. public class WalletListener extends AbstractWalletEventListener {
  8. public WalletListener() {
  9. }
  10.  
  11. @Override
  12. public void onCoinsReceived(org.bitcoinj.core.Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
  13. System.out.println("-----> coins resceived: " + tx.getHashAsString()+" prevBalance = "+prevBalance.getValue()+" newBal="+newBalance.getValue());
  14. System.out.println("received: " + tx.getValue(wallet));
  15. }
  16.  
  17. @Override
  18. public void onTransactionConfidenceChanged(org.bitcoinj.core.Wallet wallet, Transaction tx) {
  19. System.out.println("-----> confidence changed: " + tx.getHashAsString());
  20. TransactionConfidence confidence = tx.getConfidence();
  21. System.out.println("new block depth: " + confidence.getDepthInBlocks());
  22. }
  23.  
  24. @Override
  25. public void onCoinsSent(org.bitcoinj.core.Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
  26. System.out.println("coins sent");
  27. }
  28.  
  29. @Override
  30. public void onReorganize(org.bitcoinj.core.Wallet wallet) {
  31. }
  32.  
  33. @Override
  34. public void onWalletChanged(org.bitcoinj.core.Wallet wallet) {
  35. }
  36.  
  37. @Override
  38. public void onKeysAdded(List<ECKey> keys) {
  39. System.out.println("new key added");
  40. }
  41.  
  42. /*@Override
  43. public void onScriptsAdded(Wallet wallet, List<Script> scripts) {
  44. System.out.println("new script added");
  45. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement