Post
Topic
Board BitcoinJ
Topic OP
Question(BitcoinJ):get the balance from the priv or pubkey
by
ILoveUBtc
on 19/09/2013, 15:14:22 UTC
WHY !  WHY !  WHY!


I  want to use the bitcoinj to get the balance from priv key  OR  public key.

the code is like following .

                        BlockStore blockStore = new BoundedOverheadBlockStore(params, file);
         BlockChain chain = new BlockChain(params, wallet, blockStore);
         System.out.println("Connecting ...");
         PeerGroup peerGroup = new PeerGroup(params, chain);
         peerGroup.setUserAgent("PingService", "1.0");
         if (testNet) {
           peerGroup.addPeerDiscovery(new IrcDiscovery("#bitcoinTEST3"));
         } else {
           peerGroup.addPeerDiscovery(new DnsDiscovery(params));
         }
         
         peerGroup.addWallet(wallet);
         peerGroup.startAndWait();
         peerGroup.downloadBlockChain();
                        System.out.println("You have " + Utils.bitcoinValueToFriendlyString(wallet.getBalance()) + " BTC");


the wallet has had EKeys which have btc.

But why the balance show me is 0.00?  why? Any one help?