@@ -0,0 +1,2028 @@
+import java.io.File;%0A%0Aimport com.google.bitcoin.core.AbstractPeerEventListener;%0Aimport com.google.bitcoin.core.Block;%0Aimport com.google.bitcoin.core.ECKey;%0Aimport com.google.bitcoin.core.Message;%0Aimport com.google.bitcoin.core.NetworkParameters;%0Aimport com.google.bitcoin.core.Peer;%0Aimport com.google.bitcoin.kits.WalletAppKit;%0Aimport com.google.bitcoin.params.MainNetParams;%0Aimport com.google.bitcoin.utils.Threading;%0A%0A%0Apublic class TestWallet %7B%0A%0A%09private WalletAppKit appKit;%0A%0A%09public static void main(String%5B%5D args) throws Exception %7B%0A%09%09new TestWallet().run();%0A%09%7D%0A%0A%09public void run() throws Exception %7B%0A%09%09NetworkParameters params = MainNetParams.get();%0A%09%09%0A%09%09appKit = new WalletAppKit(params, new File(%22.%22), %22dogecoins%22) %7B%0A%09%09%09@Override%0A%09%09%09protected void onSetupCompleted() %7B%0A%09%09%09%09if (wallet().getKeychainSize() %3C 1) %7B%0A%09%09%09%09%09ECKey key = new ECKey();%0A%09%09%09%09%09wallet().addKey(key);%0A%09%09%09%09%7D%0A%09%09%09%09%0A%09%09%09%09peerGroup().setConnectTimeoutMillis(1000);%0A%09%09%09%09%0A%09%09%09%09System.out.println(appKit.wallet());%0A%09%09%09%09%0A%09%09%09%09peerGroup().addEventListener(new AbstractPeerEventListener() %7B%0A%09%09%09%09%09@Override%0A%09%09%09%09%09public void onPeerConnected(Peer peer, int peerCount) %7B%0A%09%09%09%09%09%09super.onPeerConnected(peer, peerCount);%0A%09%09%09%09%09%09System.out.println(String.format(%22onPeerConnected: %25s %25s%22,peer,peerCount));%0A%09%09%09%09%09%7D%0A%09%09%09%09%09@Override%0A%09%09%09%09%09public void onPeerDisconnected(Peer peer, int peerCount) %7B%0A%09%09%09%09%09%09super.onPeerDisconnected(peer, peerCount);%0A%09%09%09%09%09%09System.out.println(String.format(%22onPeerDisconnected: %25s %25s%22,peer,peerCount));%0A%09%09%09%09%09%7D%0A%09%09%09%09%09@Override public void onBlocksDownloaded(Peer peer, Block block, int blocksLeft) %7B%0A%09%09%09%09%09%09super.onBlocksDownloaded(peer, block, blocksLeft);%0A%09%09%09%09%09%09System.out.println(String.format(%22%25s blocks left (downloaded %25s)%22,blocksLeft,block.getHashAsString()));%0A%09%09%09%09%09%7D%0A%09%09%09%09%09%0A%09%09%09%09%09@Override public Message onPreMessageReceived(Peer peer, Message m) %7B%0A%09%09%09%09%09%09System.out.println(String.format(%22%25s -%3E %25s%22,peer,m.getClass()));%0A%09%09%09%09%09%09return super.onPreMessageReceived(peer, m);%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D,Threading.SAME_THREAD);%0A%09%09%09%7D%0A%09%09%7D;%0A%09%09%0A%09%09appKit.startAndWait();%0A%09%7D%0A%0A%7D%0A

test wallet