1. 程式人生 > >山寨幣創世塊的快速製作

山寨幣創世塊的快速製作


       比特幣在工作,首先是通過創世塊來啟動,所以要製作一個山寨幣,首先要解決的第一個問題,就是建立創世塊,在網上有大神已經分享了它的創世塊工具,一段python指令碼,在這個指令碼中可以分別對萊特幣使用的scrypt加密演算法和比特幣的使用SHA256進行快速的計算出創世塊資訊。有了創世塊資料,就可以用於打造自己的山寨幣了。首先需要準備一臺linux系統,最好的方法是,準備一臺虛擬機器,在虛擬機器安裝最新的版的linux系統,我安裝的是ubuntu14.04..

下載地址:一段python指令碼,在這個指令碼中可以分別對萊特幣使用的scrypt加密演算法和比特幣的使用SHA256進行快速的計算出創世塊資訊。有了創世塊資料,就可以用於打造自己的山寨幣了。

http://download.csdn.net/detail/vs9841/7261525

       要使用這段指令碼,首先需要在linux系統中安裝pip,然後為python安裝scrypt模組,(重要提醒:升級最新版的openssl1.0.1g)。

       1、安裝pip,方法如下:

sudo apt-get install python-pip python-dev build-essential 
sudo pip install --upgrade pip 
sudo pip install --upgrade virtualenv 
     2、安裝scrypt模組為python
sudo pip install scrypt construct
3、接下來就可以使有指令碼了,指令碼使用方法,基本如下:
下面的命令是建立了一個SHA256,基於比特幣的創世塊資訊,之後,你將這些資訊替換到比特幣原始碼即可中,恭喜你已經山寨了一個比特幣。。

    python genesis.py  -z "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks" -n 2083236893 -t 1231006505
Output:

    algorithm: sha256
    merkle hash: 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
    pszTimestamp: The Times 03/Jan/2009 Chancellor on brink of second bailout for banks
    pubkey: 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f
    time: 1231006505
    bits: 0x1d00ffff
    Searching for genesis hash..
    genesis hash found!
    nonce: 2083236893
    genesis hash: 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f

=========================================
下面的命令用於建立scrypt加密演算法的創世塊命令格式,只是比上面的多了一個scrypt關鍵字。。

    python genesis.py --scrypt -z "NY Times 05/Oct/2011 Steve Jobs, Apple’s Visionary, Dies at 56" -p "040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9" -t 1317972665 -n 2084524493
    
在裡說一下,-z引數後面的文字串,對應了比特幣或是萊特幣原始碼中的,pszTimestamp變數值。

##命令引數選項說明
    python genesis.py -h
    
    使用: genesis.py [引數選項]

    引數選項:
    -h, --help            顯示幫助提示資訊並退出
    -t TIME, --time=TIME   TIME 是一個unix時間,可以通過python的time.time()得到。它是代表創世塊的生成時間
    -z TIMESTAMP, --timestamp=TIMESTAMP
                          the pszTimestamp found in the coinbase of the
                          genesisblock
    -n NONCE, --nonce=NONCE
                          the first value of the nonce that will be incremented
                          when searching the genesis hash
    -s, --scrypt          calculate genesis block using scrypt
    -p PUBKEY, --pubkey=PUBKEY
                          The pubkey found in the output script