Bitcoinj stuck after chain split

2017-05-23 Thread BitcoinUser


I am using LevelDBFullPrunedBlockStore as a BlockChain. once in every 2-3 
chainsplit in the network my bitcoinJ node stops to download new block. The 
scenario is always the same

1)My node get block on height x that network will mark as orphaned later
2)My node gets block x+1 (from mainchain) and says that block x (orphaned 
by the network later) will be orphaned 
3)My node get the mainchain block on height x and says that "could not 
verify block"

Later peers are sending me single transactions, but I am unable to download 
any more blocks, there is no logs about the new block at all. I did not 
change anything in the code that is responsible for block persistence. When 
I restart the application it does not download any new block as well.

Here is log form Saturday where it happend:

2017-05-13 22:45:56 INFO  AbstractBlockChain:597 - Block forks the chain at 
height 466251/block 
00c0b4c4e062b8cc77a5fd3dc5594bee9fd5a8cacdeba92b, but it did 
not cause a reorganize:
01b3699313793566fb947d554173c5f19fe790e597adedbf
2017-05-13 22:45:56 INFO  AbstractBlockChain:926 - Connected orphan 
0005b2d8a9d429b050a5a9ba4d44dbe1543280d6e89b77af
2017-05-13 22:45:56 INFO  AbstractBlockChain:576 - Block is causing a 
re-organize
2017-05-13 22:45:56 INFO  AbstractBlockChain:752 - Re-organize after split at 
height 466251
2017-05-13 22:45:56 INFO  AbstractBlockChain:753 - Old chain head: 
00c89a56fec1a04a5981e7f614e6ba2f877559fc2ef9e138
2017-05-13 22:45:56 INFO  AbstractBlockChain:754 - New chain head: 
0005b2d8a9d429b050a5a9ba4d44dbe1543280d6e89b77af
2017-05-13 22:45:56 INFO  AbstractBlockChain:755 - Split at block: 
00c0b4c4e062b8cc77a5fd3dc5594bee9fd5a8cacdeba92b
2017-05-13 22:45:57 WARN  Peer:1025 - [2a03:4000:2:496:0:0:0:8]:8333: Block 
verification failed
org.bitcoinj.core.VerificationException: Could not verify block:
 block: 
   hash: 01b3699313793566fb947d554173c5f19fe790e597adedbf
   version: 536870912 (BIP34, BIP66, BIP65)
   previous block: 
00c0b4c4e062b8cc77a5fd3dc5594bee9fd5a8cacdeba92b
   merkle root: dcf81e3a220fa3a14ed09cd76497e13fb9c9affeef9c9ce052c9c1e1854fac26
   time: 1494708074 (2017-05-13T20:41:14Z)
   difficulty target (nBits): 402781863
   nonce: 2897470832
   with 2100 transaction(s):
  8a0d0a5f11ef31f974f59658c27824b2ddacba88e6b6dfa1865caa48bf4bb444

Did anyone had the same issue? I have no clue what I suppose to do.

-- 
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 bitcoinj+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Wallet Balance become 0 BTC After Transaction and Actual balance reflect after more than 1 confirm

2017-05-23 Thread vishal . kumar
I am also facing this issue. Can you tell how to fix this issue ? 

On Saturday, May 13, 2017 at 8:15:16 PM UTC+5:30, Andreas Schildbach wrote:
>
> Yes, using ESTIMATED_SPENDABLE your balance should behave more like you 
> expect. Just beware that you can only spend confirmed coins (as long as 
> you're using the default CoinSelector). 
>
>
> On 05/12/2017 06:53 PM, Ajit Soman wrote: 
> > Hi Oscar, 
> > 
> > I am using this: wallet.getBalance(BalanceType.AVAILABLE_SPENDABLE) to 
> > get balance. 
> > 
> > I am facing this issue in 1 out of 10 transactions . i did a transaction 
> > right now it works fine. i am unable to figure out what is the issue. 
> > 
> > On Friday, May 12, 2017 at 6:32:50 PM UTC+5:30, Oscar Guindzberg wrote: 
> > 
> > Hi, 
> > 
> > wallet.getBalance() returns the confirmed balance 
> > You can use 
> > wallet.getBalance(Wallet.BalanceType.ESTIMATED) 
> > to get the unconfirmed balance. 
> > 
> > Oscar 
> > 
> > On Thu, May 11, 2017 at 2:04 PM, Ajit Soman  
> wrote: 
> > > Hi , 
> > > 
> > > Initially my wallet has 2 BTC . I did a transaction of 1 BTC to a 
> > wallet 
> > > address . Transaction was successful i got a transaction hash now 
> > when i 
> > > check my wallet balance it shows 0 BTC . After getting more than 1 
> > > confirmation i got my actual wallet balance i.e 1 BTC. Here is my 
> > > bitcoinTransaction code: 
> > > 
> > > public String createTransaction(TransactionParams 
> > transactionparams) throws 
> > > Exception { // TransactionParams is a entity 
> > > String transactionHash = null; 
> > > Wallet wallet = null; 
> > > 
> > > Address receiverAddress; 
> > > Context.propagate(new Context(netparams.getNetworkParameters())); 
> // 
> > > netparams is a util through which we are getting testnet3 or 
> mainnet 
> > > depending upon environment 
> > > receiverAddress = new Address(netparams.getNetworkParameters(), 
> > > transactionparams.getReceiverAddress()); 
> > > String amount = 
> > > String.valueOf(transactionparams.getTransactionTradeAmount()); 
> > > System.out.println("Address " + 
> > transactionparams.getReceiverAddress()); 
> > > 
> > > final File walletFile = new File(configuration.getWalletLocation() 
> > + "/" + 
> > > transactionparams.getWalletId() + ".dat"); 
> > > wallet = (Wallet) 
> > > 
> > 
> walletStoreService.getWalletMap().get(transactionparams.getWalletId()); 
> > // 
> > > walletStoreService that has information about wallet object 
> > > 
> > > if (walletFile.exists()) { 
> > > Coin btcCoin = Coin.parseCoin(amount); 
> > > Wallet.SendRequest.DEFAULT_FEE_PER_KB = Coin.ZERO; 
> > > 
> > > SendRequest request = SendRequest.to(receiverAddress, btcCoin); 
> > > request.ensureMinRequiredFee = false; 
> > > request.fee = Coin.valueOf(1); 
> > > request.feePerKb = Coin.ZERO; 
> > > request.changeAddress = wallet.currentReceiveAddress(); // one of 
> > my friend 
> > > think this line is making this issue 
> > > 
> > > Transaction transaction = wallet.sendCoinsOffline(request); 
> > > TransactionPoolManager.addTransaction(transaction); // 
> > addTransaction is a 
> > > method in TransactioPoolManager service 
> > > walletStoreService.saveWallet(wallet); // saves the wallet object 
> > > transactionHash = request.tx.getHashAsString(); 
> > > return transactionHash; 
> > > } else { 
> > > throw new FileNotFoundException("Wallet not found"); 
> > > } 
> > > } 
> > > 
> > > 
> > > addTransaction method in TransactioPoolManager service: 
> > > 
> > > private static Vector transactionPool; 
> > > 
> > > public static void addTransaction(Transaction tx) { 
> > > if (find(tx) != null) { 
> > > return; 
> > > } 
> > > for (Map.Entry entry : 
> > > walletStoreService.getWalletMap().entrySet()) { 
> > > if (entry.getValue().isPendingTransactionRelevant(tx)) { 
> > > transactionPool.add(new Entry(entry.getKey(), tx)); 
> > > break; 
> > > } 
> > > } 
> > > } 
> > > 
> > > Thanks in advance 
> > > 
> > > -- 
> > > 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 bitcoinj+u...@googlegroups.com. 
> > > For more options, visit https://groups.google.com/d/optout 
> > . 
> > 
> > 
> > 
> > -- 
> > Oscar Guindzberg 
> > 
> > -- 
> > 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