0.08125 BTC seems to be correct, as that's what wallet-tool is telling
too. I suggest looking at the logfile of your second case. You're
connecting to a local full node, does it receive anything from it? Maybe
even look at the log of the full node.
On 07/09/2017 03:02 PM, Vishal Kumar wrote:
> I have attached a wallet (1499237862.dat) I am getting a balance
> mismatch. Could you explain why this happens. I am getting *0.08125 BTC
> *via this code:
> |
>
>
> publicclassWalletBalanceWithoutSync{
> publicstaticvoidmain(String[]args)throwsUnreadableWalletException{
> Filefile =newFile("1499237862.dat");
> Walletwallet =Wallet.loadFromFile(file);
> System.out.println(wallet);
>
> System.out.println(wallet.getBalance(BalanceType.AVAILABLE_SPENDABLE).toFriendlyString());//
> 0.08125 BTC
>
> System.out.println(wallet.getBalance(BalanceType.ESTIMATED_SPENDABLE).toFriendlyString());//
> 0.08125 BTC
> }
> }
> |
>
>
> But with this code i am getting *0.06105 BTC:*
>
> |
> publicclassReadHdWallet{
> publicstaticvoidmain(String[]args){
> Filefile =newFile("1499237862.dat");
> NetworkParametersparams=TestNet3Params.get();
> try{
> Walletwallet =Wallet.loadFromFile(file);
> BlockStoreblockStore =newMemoryBlockStore(params);
> BlockChainblockChain =newBlockChain(params,blockStore);
> blockChain.addWallet(wallet);
> PeerGrouppeerGroup =newPeerGroup(params,blockChain);
>
> peerGroup.addAddress(newPeerAddress(InetAddress.getByName("127.0.0.1"),18333));
>
>
> peerGroup.startAsync();
> peerGroup.downloadBlockChain();
> wallet.saveToFile(file);
>
>
>
> System.out.println(wallet.getBalance(BalanceType.AVAILABLE_SPENDABLE).toFriendlyString());//
> 0.06105 BTC
>
> System.out.println(wallet.getBalance(BalanceType.ESTIMATED_SPENDABLE).toFriendlyString());//
> 0.06105 BTC
> System.out.println(wallet.toString());
> }catch(UnreadableWalletExceptionex){
> ex.printStackTrace();
> }catch(BlockStoreExceptione){
> e.printStackTrace();
> }catch(IOExceptione){
> e.printStackTrace();
> }
> }
> }
> |
>
>
>
>
>
> On Friday, June 30, 2017 at 11:19:21 PM UTC+5:30, Andreas Schildbach wrote:
>
> For each wallet you want to query the balance of, you will need to sync
> the blockchain. You can batch-process a number of wallets at the same
> time though, as you can add multiple wallets to PeerGroup.
>
> Bitcoinj does not "download" the blockchain, at least it doesn't keep
> enough information to query balances (UTXOs).
>
>
>
> On 06/30/2017 02:36 PM, [email protected] wrote:
> > I have a myWallet.dat file which has 3 BTC . I have created a
> program to
> > listen changes in a directory (/opt/bitcoin/wallet) and i have
> used this
> > listener program with my bitcoin project , What i want is that if
> i put
> > myWallet.dat file in that directory i want it to synchronize with
> block
> > chain and get actual balance from it.
> >
> > If i use *Wallet.loadFromFile("WALLET_LOCATION")* method to get
> wallet
> > object of wallet file and add to block chain like this
> > *abstractBlockChainObject.addWallet(wallet) , *Consider The block
> chain
> > is 100% downloaded , So my question is if i add wallet object like
> this
> > will it synchronize my wallet with block chain.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "bitcoinj" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to [email protected]
> > <mailto:[email protected]>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "bitcoinj" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.