Crown wallet address labels

Preamble

Crown v0.13.0.0 was released on March 28th and updated to v0.13.2.0 on April 14th. One of the new features is unique address prefixes.

Previous versions of Crown used the Bitcoin addressing scheme. Addresses began with a “1” and looked something like 1BGxZXX6238RiKsJz5da9oCJsFehP3SH3C. From v0.13.0.0 onwards the prefix changed to “CRW” and addresses look something like CRWNEwt5nY8dpDEWnwCfDMdCUXaxGN4Lcojr.

Within a wallet.dat file both of these address representations refer to exactly the same thing; only the external appearance is different. Neither representation is easy for humans to remember so the wallet has the facility to label addresses with something more person-friendly. For example, you might use label “MN01” to refer to (old format) address 1BGxZXX6238RiKsJz5da9oCJsFehP3SH3C.

Actually, as far as the wallet is concerned the relationship is the other way around: address 1BGxZXX6238RiKsJz5da9oCJsFehP3SH3C refers to label “MN01”.

Labels can be created/changed in 4 different places in the QT wallet:

  1. When creating a receiving address:

2. When creating a sending address:

3. Working with receiving addresses:

4. Working with sending addresses:

However, an unforeseen friction point (aka problem) has arisen.

What is the problem?

Those labels are tied to the external address representation. When a user upgrades their Crown version the wallet contents don’t change. They don’t need to for users to be able to send and receive coins. But the label associations also don’t change. And that causes an unfortunate and unforeseen problem.

After upgrading to Crown v0.13 the labels are still referred to by the old format addresses. But you can’t directly use the old format address with the new wallet.

Using our example addresses above, the wallet still thinks 1BGxZXX6238RiKsJz5da9oCJsFehP3SH3C refers to label “MN01”. Because nothing in the wallet changed in the upgrade, it doesn’t know that actually CRWNEwt5nY8dpDEWnwCfDMdCUXaxGN4Lcojr should refer to “MN01”.

NOTE: the problem only affects your wallet. Systemnodes and masternodes neither know nor care about the labels in your wallet. You don’t need to do anything with your nodes apart from upgrade them.

What is the solution?

Preserving the labels across an upgrade takes a bit of preparation and some manual effort to relabel the new format addresses. If you have already upgraded your wallet you can recover the labels but it involves a bit more effort because you briefly need to downgrade to v0.12.5.3. If you haven’t already upgraded your wallet then there are a couple of extra things you need to do before upgrading.

IMPORTANT: before doing any wallet manipulation make a backup of your current wallet.dat and put it somewhere safe. Rename it carefully so you know exactly what state it represents, eg: 20190402_upgraded_to_v13_not_relabelled.dat

The following steps will recover any missing labels. Simply start at the appropriate point for your circumstances. All the example commands assume you’re running linux. Windows and Mac users will probably use the pretty GUI equivalents. There are lots of ways of doing the same thing; the examples attempt to be generic and portable rather than the most efficient. I don’t use Windows or Mac and can’t provide the exact steps for those platforms. Hopefully Windows and Mac users can follow along anyway, and do the equivalent steps in their GUI environment.

Already upgraded (and missing labels)

You need to briefly downgrade to v0.12.5.3. If you are an experienced software user and had the foresight to keep a copy of the old executables, congratulations!

1. Shutdown your wallet.

2. Make a copy of your wallet.dat and give it a meaningful name, eg:

cd
cd .crown
cp wallet.dat 20190402_upgraded_to_v13_not_relabelled.dat

3. Rename your v0.13 executables, eg:

sudo mv /usr/local/bin/crownd /usr/local/bin/jaded
sudo mv /usr/local/bin/crown-qt /usr/local/bin/jade-qt
sudo mv /usr/local/bin/crown-cli /usr/local/bin/jade-cli

4. Download the v0.12.5.3 code for your platform using one of these links

If you need a different format the full set of downloads is available at Github.

5. Extract the crown-qt executable and put it in a directory in your $PATH, eg:

unzip Crown-0.12.5.3-Linux64.zip Crown-0.12.5.3-Linux64/bin/crown-qt
sudo mv Crown-0.12.5.3-Linux64/bin/crown-qt /usr/local/bin

6. Now continue with the instructions below as if you had not yet upgraded.

Not yet upgraded

(Sometimes there are advantages to not being a bleeding-edge early adopter!)

You are going to use dumpwallet to make a plain text backup of your wallet contents. You will also export the sending address labels. There is currently no programmatic way to restore them but if you keep a record of them you can re-add them manually.

7. Start the QT wallet.

8. Unlock your wallet.

9. In the debug console run the dumpwallet command, eg:

You don’t want to lose track of this file. It contains a plain text dump of your private and public keys and the associated (receiving) labels.

WARNING: Do not ever, under any circumstances, share this file with anyone else.

10. Export any sending address labels to /choose/a/path/to/sending.csv

11. Shutdown the wallet.

12. Rename the wallet.dat with a meaningful name, eg:

cd
cd .crown
mv wallet.dat 20190402_wallet_v12.dat

NOTE: renaming the wallet is a deliberate choice. We want the next wallet startup to build a new, empty wallet.

13. Run the usual upgrade script, or switch back to the already upgraded executables, eg:

curl -s https://raw.githubusercontent.com/Crowndev/crowncoin/master/scripts/crown-server-install.sh | bash -s

or

sudo mv /usr/local/bin/jaded /usr/local/bin/crownd
sudo mv /usr/local/bin/jade-qt /usr/local/bin/crown-qt
sudo mv /usr/local/bin/jade-cli /usr/local/bin/crown-cli

14. If you used the upgrade script at step 13 it started the daemon wallet for you. Shut it down by

crown-cli stop

15. Start the QT wallet.

There was no wallet.dat in the datadir following step 12, so either step 14 or this one will create a new one.

16. In the debug console run importwallet to import the dump from step 9.

This will add the private keys, convert the public keys and relabel them. When the import completes you should be able to see your converted receiving addresses with labels, and transaction history with labels.

17. Encrypt the new wallet.

18. Restart the QT wallet and check the labels look the way you expect.

19. (Securely) delete the dump file.

20. There is currently no programmatic way to restore sending address labels. There is a convertaddress function Crown v0.13 which can be used to convert an old format address to the new format. You can use it from the debug console of the QT window or from the command line through the crown-cli command. You will need to feed the addresses in sending.csv through the convertaddress command and re-label the converted sending addresses manually in the QT wallet.