Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incoming coins not become "available" #29

Open
kodmanyagha opened this issue Mar 24, 2018 · 2 comments
Open

Incoming coins not become "available" #29

kodmanyagha opened this issue Mar 24, 2018 · 2 comments

Comments

@kodmanyagha
Copy link

kodmanyagha commented Mar 24, 2018

I'm receiving coin to my wallet. I can see it as estimated balance. After half hour transaction getting 1 confirmation. It coin is still in estimated. Must it be available but it doesn't. This is my wallet app kit initialization:

context = new Context(this.params);

// If seed is non-null it means we are restoring from backup.
bitcoin = new WalletAppKit(context, new File("./wallets/bitcoincash/"), WALLET_FILE_NAME) {

	@Override
	protected void onSetupCompleted() {
		logger.info("Wallet App Kit setup completed.");
		// WARN Don't try to spend unconfirmed transaction. Becouse bitcoinj is bullshit.
		// getBitcoin().wallet().allowSpendingUnconfirmedTransactions();

		getBitcoin().peerGroup().setMinBroadcastConnections(MIN_PEER_COUNT);
		getBitcoin().peerGroup().setMaxConnections(15);

		WalletCoinsReceivedEventListener walletCoinsReceivedEventListener = new WalletCoinsReceivedEventListener() {
			@Override
			public synchronized void onCoinsReceived(org.bitcoinj.wallet.Wallet wallet, Transaction tx, Coin prevBalance,
					Coin newBalance) {
				try {
					if (newBalance.value < prevBalance.value)
						return;

					Context.propagate(createContext());
					logger.debug("txid: " + tx.getHashAsString() );
				} catch (Exception e) {
					e.printStackTrace();
					logger.error(e);
				}
			}
		};
		getBitcoin().wallet().addCoinsReceivedEventListener(walletCoinsReceivedEventListener);

		TransactionConfidenceEventListener transactionConfidenceEventListener = new TransactionConfidenceEventListener() {
			@Override
			public synchronized void onTransactionConfidenceChanged(org.bitcoinj.wallet.Wallet wallet, Transaction tx) {
				try {
					logger.debug("Confirmation: " + tx.getConfidence().getDepthInBlocks());
				} catch (Exception e) {
					e.printStackTrace();
					logger.error(e);
				}
			}
		};

		getBitcoin().wallet().addTransactionConfidenceEventListener(transactionConfidenceEventListener);
		logger.info("Wallet event listeners added.");
	}
};

getBitcoin().setAutoSave(true).setDownloadListener(new BitcoinDownloadProgressTracker()).setBlockingStartup(false)
		.setUserAgent(Main.WALLET_FILE_NAME_PREFIX, "1.0");

if (seed != null)
	getBitcoin().restoreWalletFromSeed(seed);

if (getBitcoin().isChainFileLocked()) {
	logger.error("This application is already running and cannot be started twice.");
	System.exit(1);
}

getBitcoin().startAsync();
getBitcoin().awaitRunning();

When I try to get wallet info the result is like that:

{
	"currentAddr": "mo4P88sqzNW473XYrQESsjmSDq77Vtx7Lf",
	"balance": 0,
	"balanceAvailableSpendable": 0,
	"balanceEstimated": 2699595500,
	"balanceEstimatedSpendable": 2699595500,
	"balanceBtc": "0.00 BCH",
	"balanceEstimatedBtc": "26.995955 BCH",
	"peersCount": 4,
	"transactions": [
		{
			"txid": "7afcc13c6bf48a1130e2f428c434c7ae3effe90ea8d76e520d5d247b66968e64",
			"pending": true,
			"cached": false,
			"coinBase": false
		},
		{
			"txid": "793a1cadec14519891b87b0d728107df2938a246a038a5e62d28de4466fcb169",
			"pending": true,
			"cached": false,
			"coinBase": false
		},
		{
			"txid": "fdc907b8dbc503264daf55c95beff03967e427c95131f5af9b559b12cd9e740b",
			"pending": true,
			"cached": false,
			"coinBase": false
		},
		{
			"txid": "97e36ee4bd7ad7763502099dc449a4230ca3cf1e458db9e258a7c6845a58714e",
			"pending": true,
			"cached": false,
			"coinBase": false
		},
		{
			"txid": "4961b0cf6aca77956199c73ada165b91e4820107e601e422d6a60daf6a510246",
			"pending": true,
			"cached": false,
			"coinBase": false
		},
		{
			"txid": "fee29f42e10e0388b6155e77c9a1c91bf924b4f28631d175d1357edb085f0696",
			"pending": true,
			"cached": false,
			"coinBase": false
		},
		{
			"txid": "6ccbe252c6cce6c95583e8567fb061cbd675e222aa26df47123f3e0f3985a93c",
			"pending": true,
			"cached": false,
			"coinBase": false
		},
		{
			"txid": "2275312fd48c04e55b4817a25dda39b41f0c823185f789ac55e263f88694baef",
			"pending": true,
			"cached": false,
			"coinBase": false
		},
		{
			"txid": "a5b106f7c5efaf494558d57f0ec19d9483c9372784779261ed8402f7eecdeb01",
			"pending": true,
			"cached": false,
			"coinBase": false
		},
		{
			"txid": "e2e4f601a9c5dee3eb0e466b168ddfeb4bca4c86ef546fa6ff14785f426bec56",
			"pending": true,
			"cached": false,
			"coinBase": false
		},
		{
			"txid": "40764acae96919e8ddc31a4a01b2295b3adcb9b2b61669b46fef1b68ea7b46b6",
			"pending": true,
			"cached": false,
			"coinBase": false
		}
	],
	"addresses": [
		"mo4P88sqzNW473XYrQESsjmSDq77Vtx7Lf",
		"n2mFHsi4fGmsTViJtyd1PPEdWtWBCCy5GC",
		"mgCY2PJiu4HqVijPHNUTGZ4Doi78vLpFva"
	]
}

This is my incoming transaction: https://www.blocktrail.com/tBCC/tx/97e36ee4bd7ad7763502099dc449a4230ca3cf1e458db9e258a7c6845a58714e
This transaction is increased my estimatedBalance value in first come. When it get one confirmation it must be available but it didn't. Where I'm making mistake? Please help. Thanks.

@kodmanyagha
Copy link
Author

Probably I found the main problem. Library can't get transaction confidence changes. I can't receive confirmed transaction in onTransactionConfidenceChanged(). Is it about the peer address is wrong?

@HashEngineering
Copy link
Collaborator

We may need to see the logs after the transaction was sent.

Transaction confidence changes when the transaction is included in a block (it goes from pending to building). It seems as if your program isn't getting new blocks.

Is the PeerGroup still connected to the Bitcoin Cash work? Was there another problem? The logs may help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants