How to read the log?

From the “conflicts with wallet transaction” log line take both transaction IDs and search for them in Explorer.qtum.org. You may see that neither of these transaction IDs can be found in the blockchain or they could show an orphan block. Either result means you definitely mined an orphan block.

Let’s review what your wallet does when it wins a block reward. The block reward winning wallet will 1) select one or more previous transaction amounts (UTXOs) to stake for 500 blocks, 2) grab as many waiting transactions as it can from the memory pool and assemble them into the new block, 3) execute all the smart contract calls in those transactions against its local copy of the blockchain, and 4) publish the new block to the network. When your wallet does all this it cannot know if it creating a Mainchain block or an orphan block, so it does all this and commits the stake.

The best thing to do when your wallet mines an orphan block is to do nothing and chill. Your wallet will figure out it mined an orphan and sooner or later cancel out all the orphan block activity, including returning the stake.

However, very rarely this orphan unwinding process can be disrupted. I’ll be honest, I don’t fully understand the orphan disruption process but can guess that if you are nervous in the service, are watching your wallet closely, and start restoring it and swapping wallet.dat files to get back the orphan stake — that could strand the orphan stake. In this case, the Explorer will show the correct balance for an address(es) but your wallet will show a balance at that address lower by the amount of the staked UTXO. The amount missing from your wallet probably matches exactly the amount of a previous unspent transaction, which your wallet selected to stake for the orphan block.

If you find yourself in this situation it is time for some command line tools. For recovering from orphan stakes “salvage wallet” is not effective since it can fix corrupted wallet.dat files, and that is not the issue.

Note we are looking at command line parameters used when launching the wallet, not debug console/qtum-cli commands entered after the wallet is running. These command line tools are used when you launch the wallet from the command line. For Mac OS X you will enter command lines in the Terminal, as described in this blog. For Windows, you will enter commands using the Windows Command Prompt as described in this blog. If you are running the server wallet qtumd you would add the command line parameters when you launch qtumd (do not use qtum-cli with these commands).

Use these steps ONLY IF YOU HAVE A GOOD BACKUP of the wallet.dat file and have completed the troubleshooting above to confirm an orphan block.

The Rescan Command

The rescan command will go through your local copy of the blockchain and rebuild the database from scratch. See how the rescan works in this post.

Enter the rescan command as:

qtum-qt.exe -rescan

When you enter the command for qtum-qt the splash screen will open and give status “Rescanning…XX%” for a minute or two, then the main wallet will open.

The Zapwallettxes Command

The zapwalletxes command will rescan the local blockchain and remove (“zap”) any transactions for your wallet that are not published on the blockchain. Read more about zapwallettxes in this wiki.

Enter the zapwallettxes command as

qtum-qt.exe –zapwallettxes=2

.

After entering the command, qtum-qt will launch and show “Rescanning…” in the lower right-hand corner. After a minute or two, the full wallet window will appear, hopefully with the orphan stake restored.

If you are using these commands with qtumd, give it a minute or two to complete the rescanning, it will not respond to info commands before that.

By the end of the musical and movie, little orphan Annie is adopted by the millionaire industrialist Daddy Warbucks and goes on to lead a life of luxury. Likewise, the Qtum orphan blocks return their stakes and go on to a fulfilling life staking and securing the Qtum blockchain.

Orphan blocks are a necessary part of decentralized mining, and I hope this blog gives you the understanding to treat these orphans with the recognition and respect they deserve.

Stay safe online,

Jackson

References

1. See my past blogs, with these topics:

QRC20 Token Update, setting the Gas Limit and Gas Price for sending QRC20 tokens, Published on May 28, 2018

Qtum Peer Connections, a detailed look at now Qtum nodes connect to other nodes, outgoing/incoming connections, and some tools for monitoring the traffic, published on May 21, 2018

Top 10 Qtum New User Questions, and answers for new Qtum users, Published on Apr 22, 2018

Network Hash Rates, a comparison of network hash rates for bitcoin, Ethereum and Qtum, the numbers may surprise you, published on Apr 6, 2018

Newbie Wallets, an analysis of block reward winning wallets and the new Chinese nodes, published on Apr 1, 2018

The Debug Log, the Virtual Machine Log, the debug.log (and the virtual machine log) is your friend, how to find and read the debug log, published on Mar 13, 2018

QTUM Capped Supply — The Halving, is the supply of QTUM capped, how many will there ever be? The cap for QTUM, how “halving” works, and the new Explorer, published on Mar 4, 2018

QRC20 Token Report, QRC20 tokens, BOT airdrop, published on Feb 25, 2018

A Qtum PoS Simulator, Published on Feb 16, 2018

Testnet, the Qtum Test Network, published on Jan 7, 2018

Virtual Private Networks (VPNs), using VPNs for staking, published on Dec 31, 2017

Transaction Fees, Published on Dec 24, 2017

Passphrases, passphrases and a passphrase guessing script, published on Dec 17, 2017

The Memory Pool (mempool), the memory pool and processing of unconfirmed transactions, published on Dec 10, 2017

Orphan Blocks, published on Dec 3, 2017

The QTUM.explorer.io Contracts Page, published on Nov 26, 2017

The SHA256 Hash Algorithm and Difficulty, published on Nov 20, 2017

Distribution of Wallets Winning Block Rewards, published on Nov 12, 2017

The SHA256 Hash Algorithm, Target and Difficulty, published on Nov 5, 2017

An Introduction to Qtum Proof of Stake Mining — A Racing Story, an ELI5 story about PoS mining, published on Oct 29, 2017

Foundation Wallets Leave the Field, published on Oct 29, 2017

Unofficial Staking FAQ, published on Oct 26, 2017

Network Weight, Time to Reward, Nodemap, published on Oct 22, 2017

Simulating Proof of Stake Mining for Qtum, published on Oct 21, 2017

Qtum Proof of Stake Mining, an early simulator for PoS mining, published on Oct 16, 2017

Qtum Mainnet Ignition Results October 9–15, introduction to Mainnet charts and graphs, published on Oct 15, 2017

2. Another bad Jackson joke. There is no FINDNEEDLE function in Excel, but these formula work nicely for debug.log data loaded with the block transaction IDs in column E and block numbers in column F. Use string functions to extract the transaction ID and block number:

=IF(FIND(“height”, F2),MID(F2, 8, 6)) — extract the block number =IF(FIND(“height”, F2),MID(E, 6, 64)) — extract the transaction ID

3. “Orphan” is not the best term for these blocks. An orphan block has a parent, and we know the parents of orphan blocks, but they have no children. I think a better term would be Freemartin. Apparently, Satoshi was not a word maven.

4. Bitcoin orphaned blocks are shown on blockchain.info

The Broadway musical Annie opening night was April 21, 1977, at the Alvin Theater in New York City. The production had 2,377 performances and closed on January 2, 1983.

5. Music for orphan research, Aileen Quinn singing “Tomorrow” from the 1982 movie Annie. The sun’ll come up tomorrow, and you’ll win a block reward tomorrow.

.

6. Spotify album link, Annie: The Broadway Musical 30th Anniversary Cast Recording

.

.

7. New York City Drone flight, watch in 4k

.