Blockchain By Example
上QQ阅读APP看书,第一时间看更新

Readercoin rebranding

We kick off by rebranding the Bitcoin project as Readercoin by renaming the bitcoin filenames to readercoin using the following commands:

find . -exec rename 's/bitcoin/readercoin/' {} ";"
find . -exec rename 's/btc/rdc/' {} ";"

These Linux commands will rename every file that has bitcoin or btc in the name, recursing into subdirectories as needed. 

If rename isn't available on your system you can install it using  sudo apt install rename

As changing filenames will affect source files and make files, breaking paths and include statements, we need to replace all the occurrences of the old Bitcoin name and its abbreviation as BTC recursively in the code with the new name Readercoin and the acronym RDC. To be sure of replacing all occurrences, we use different capitalizations:

find ./ -type f -readable -writable -exec sed -i "s/bitcoin/readercoin/g" {} ";"
find ./ -type f -readable -writable -exec sed -i "s/Bitcoin/Readercoin/g" {} ";"
find ./ -type f -readable -writable -exec sed -i "s/BitCoin/ReaderCoin/g" {} ";"
find ./ -type f -readable -writable -exec sed -i "s/BITCOIN/READERCOIN/g" {} ";"
find ./ -type f -readable -writable -exec sed -i "s/bitcoind/readercoind/g" {} ";"
find ./ -type f -readable -writable -exec sed -i "s/BTC/RDC/g" {} ";"
find ./ -type f -readable -writable -exec sed -i "s/btc/rdc/g" {} ";"

Instead of running these commands separately, you can put them in a single Bash script. The preceding command will take a few minutes to complete. To check whether there are any remaining occurrences of the Bitcoin string, use grep -ri "bitcoin".

Alternatively, you can use a text editor such as gedit to find and replace all Bitcoin and BTC occurrences in the project source files.

Changing the Bitcoin occurrences will also affect the git files. Hence, if you want to keep using git, you have to use the following commands to avoid git's bad index file signature error:

rm -f .git/index
git reset
git add -A
git commit -m "rename bitcoin into readercoin occurrences"
git push origin master

To start code editing, change the working directory to src(cd src).