1、Grin 节点搭建与 Grin Wallet 创建

1.1 下载 Grin Node 包

在 Grin 的 Github 页面选择对应的安装包进行安装,这里以 Ubuntu 18.04.2 LTS 系统为例

下载 Grin releases 包

wget https://github.com/mimblewimble/grin/releases/download/v2.0.0/grin-v2.0.0-linux-amd64.tar.gz

解压到当前目录

tar -zxvf grin-v2.0.0-linux-amd64.tar.gz

设置环境变量全局路径

mkdir -p ~/grin
tar xzf grin-v1.0.0-479973573-linux-amd64.tgz -C ~/grin
echo export 'PATH=~/grin:$PATH' >> ~/.bashrc
source ~/.bashrc
设置好环境变量路径后则可在任意目录下执行 Grin 命令

连接 Grin 节点

grin

连接 Grin floonet 节点

grin --floonet
如果未设置环境变量全局路径,则需要在 Grin 目录下执行以上的命令

连接主网节点

./grin

连接 floonet 测试网节点

./grin --floonet

第一次执行连接命令后,需要等待节点数据下载与同步操作,同步完成后如下图:

20190715-01.png

1.2 Grin Wallet 安装与创建

保持 Grin 节点开启,重开终端窗口进行 Wallet 创建,因为 Wallet 创建成功后需要连接到刚才创建的节点中,所以务必保持节点开启状态。

在 Grin-Wallet 的 Github 页面选择对应的 Wallet 安装包进行安装,这里以 Ubuntu 18.04.2 LTS 系统为例

下载 Grin-Wallet releases 包

wget https://github.com/mimblewimble/grin-wallet/releases/download/v2.0.0/grin-wallet-v2.0.0-linux-amd64.tar.gz

解压到当前目录

tar -zxvf grin-wallet-v2.0.0-linux-amd64.tar.gz
进入钱包目录并创建钱包

创建主网钱包

./grin-wallet init

创建 floonet 测试网钱包

./grin-wallet --floonet init

当你看到如下内容时则说明钱包创建成功,其中 24 个单词为你钱包的助记词,务必安全保存,以后如果需要恢复钱包时需要使用它来进行恢复。

20190105 17:36:35.814 WARN grin_wallet::types - Generating wallet seed file at: /home/yeastplume/.grin/wallet_data/wallet.seed
Your recovery phrase is:
foster approve pen ancient engage bomb fantasy life short stuff mesh bus design truck oyster ankle shallow torch double melody town century nice report
Please back-up these words in a non-digital format.
Command 'init' completed successfully

1.3 Wallet 连接 Grin 节点

连接 Wallet 到本地 Grin 节点

./grin-wallet --floonet -r http://127.0.0.1:13413 info

连接成功后钱包信息如图所示,新钱包所有余额都为 0

20190715-02.png

  • Confirmed Total 是你当前钱包所有的余额,包括正在等待确认和余额。
  • Awaiting Confirmation 是目前已经广播到 Grin 链上未达到 10 个区块确认的金额,目前暂时不能使用。
  • Locked by previous transaction 是目前正在锁定的金额,比如你收到一笔 30 Grin 以后向另一个人转账 10 Grin,则需要把 30 个 Grin 打包到区块链,其中 10 个转给对方,20 个返回给你的钱包,这时候会有 30 个显示锁定中。

至此,你已经有了一个 Grin 节点和连接到该节点的 Grin Wallet。接下来我们说一下 Grin Wallet 的转账

2、Grin Wallet 转账(文件转账 / Http URL 转账)

2.1 通过文件进行 Grin 转账

如果作为普通用户,在自己的 Mac 或者 Ubuntu 电脑上安装的 Grin 节点和 Grin Wallet,因为本地电脑无法生成可供外网访问的 http URL,所以只能使用文件形式进行 Grin 收款。

Grin Wallet 文件转账主要流程如图所示:

20190715-03.png

  1. 发款人创建转账文件 my_grin_transaction.tx 并分享给收款人
  2. 收款人接受文件并签名,生成 my_grin_transaction.tx.response 分享给发款人
  3. 发款人最终签名文件并广播到 Grin 链

发款人创建 my_grin_transaction.tx 文件,以下命令表示发款人生成向对方转账 10.25 的文件

./grin-wallet --floonet send -m file -d my_grin_transaction.tx 10.25

收款人接受文件,并生成 my_grin_transaction.tx.response 文件分享给发款人

./grin-wallet --floonet receive -i my_grin_transaction.tx

发款人进行最终确认并广播到 Grin 链上

./grin-wallet --floonet finalize -i my_grin_transaction.tx.response

至此,通过文件形式转账 Grin 的流程已经结束,接下来则等待矿工打包确认交易

查看 Grin Wallet 交易记录
./grin-wallet --floonet txs

如图所示,展示了钱包的收付款以及每笔交易状态的记录。由于 Grin 的匿名性,每笔交易看不到收付款人信息

20190715-04.png

取消交易

如果你想取消某一笔交易,使用如下命令,其中 3 为 ID

./grin-wallet --floonet cancel -i 3
Wallet Check

当取消交易或者主链分叉导致 Wallet 不一致状态时,可以使用 check 命令手动遍历所有区块信息,以确保本地钱包数据库和链上数据保持一致。

./grin-wallet --floonet check

2.2 通过 Http URL 方式转账

如果你的 Grin 节点和 Wallet 创建在云服务器上,并能生成可供外网访问的 Http URL,则可以通过 Http ULR 的方式收 Grin 币。目前的交易所在充提 Grin 时都是使用 URL 的方式进行的,所以你如果想从交易所提 Grin 币,则必须拥有一个可供外网访问的 URL。

收 Grin 币前,先开启 Wallet Listen

默认钱包只监听在本地机器,为了别的机器可以连接到该钱包,需要编辑 ~./grin-wallet.toml 文件 api_listen_interface 字段

api_listen_interface = "127.0.0.1"

修改为

api_listen_interface = "0.0.0.0"

然后运行钱包监听

./grin-wallet --floonet listen

或者你也可以传入-e(外部)钱包参数来监听 0.0.0.0

./grin-wallet --floonet -e listen

开启成功后,对方则可以通过外网 IP 地址加端口号给你转 Grin 币了。如下所示,向 http://101.132.243.78:13415 地址转账 1.2 个 Grin floonet 测试币

./grin-wallet --floonet send -d http://101.132.243.78:13415 1.2
发款方生成的文件内容
{
    "version_info": {
        "version": 2,
        "orig_version": 2,
        "block_header_version": 2
    },
    "num_participants": 2,
    "id": "62e081b9-5cf5-482d-a2a2-4f343acb208d",
    "tx": {
        "offset": "06bdc1fdc753df42f8fd2fa0bedc8bcc1b72869529a6406205a6883a07784f19",
        "body": {
            "inputs": [
                {
                    "features": "Plain",
                    "commit": "09a252ab14dbbafe8a85a7829c61ff01b9f0533d9b554f97bea25527bfa672502f"
                }
            ],
            "outputs": [
                {
                    "features": "Plain",
                    "commit": "08c68e5c03945e32d9dcd64316c5e6b937115627b8485961ff76ba61c162c0638a",
                    "proof": "2df4c72fefdc1955f4277289730f77bb769bd30ad653f3cb7833255940fd45fb60c979087261b51754b7a639bd5a5ad8b5d136395f4c5bca15846a249d39725700522917cd5829559b4441bf5fb2376b7b14b48549d35bb3a352efc696fb9e9da601fe2b37cf24ef09aeba2d9d4d47cdb73c183c841656eec092a21c88369ea9858bcf2b1f3f038d996c07e1b4028a073b00f7ec918bf2e3e1a43f431aafc094ec1f0c88ad32b98bc16753be9fabb5566f322a996d32ba7844b8fcf57ee6337ad2eecf0a7d1ae53d9eb0148d7e6d0a4726c7d21a94629a42b4534abc8841f062bd828a3e1f79c781f61d480a797f7a3b9be088fba5290af8655732f6ff56329e512660e89157dc670bfb5a9e4991eb580d6fea7996a1ba7171fc13085fe17aab626f0cac03ff91712634a8027703efe34ef1566aa8d47c12e493d825869e1075632ac9d6dcacf99ca04c91f2c2b399a377777cb4df8c648ebb73d267677ce1ca015e03707d9a2756dca88a198d52777e44024f352159edf4227b9db1183bf8dea6005f4f3fa7d9e8dbbcba0b704884dc17f234aa4a3e57bd20410dc62f03d6a88449c5f5abe38e549f8ecaf7ae6555a1867c4d298649ef5604cb17496eed0c2ab5ae5e9cc2cfc3a854ba37f897c6f455b02fe940a77703f8f709e1f1459e7f2b50a073a7876f35f0d65568a2b27a95fc0c63d6748f6519702214f4dfd5aff218103712560b77dc5210324d83684735896ce4173d870c61297ba20686c36c9dfc93b6e9ce55fd09e80b642de12d65cac8c9d053a4fd9569f541d6d4a149e12b26ce907041f9c66d5bf61d0b2bebbeb31722c151b5a1025802bacd4eb086c5b33c7eb09b71072cbb8f32b29d7a6c5f47aa078db1ba6a278c2719b50206f959b85cfd71a02b442e7f03642b0d7b722d05f6f3f19616581db2fba6f1539fc8a08fb497d464"
                }
            ],
            "kernels": [
                {
                    "features": "Plain",
                    "fee": "8000000",
                    "lock_height": "0",
                    "excess": "000000000000000000000000000000000000000000000000000000000000000000",
                    "excess_sig": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
                }
            ]
        }
    },
    "amount": "10250000000",
    "fee": "8000000",
    "height": "200869",
    "lock_height": "0",
    "participant_data": [
        {
            "id": "0",
            "public_blind_excess": "034addf29e589b814871545096abaf14eee2d6e19da1442a9dfcedea5af660c421",
            "public_nonce": "02c40a211fc4fcf71fac80476ffa3f17c4874ad41712baf94399ceab00126a5293",
            "part_sig": null,
            "message": null,
            "message_sig": null
        }
    ]
}
收款方签名后的文件内容
{
    "version_info": {
        "version": 2,
        "orig_version": 2,
        "block_header_version": 2
    },
    "num_participants": 2,
    "id": "62e081b9-5cf5-482d-a2a2-4f343acb208d",
    "tx": {
        "offset": "06bdc1fdc753df42f8fd2fa0bedc8bcc1b72869529a6406205a6883a07784f19",
        "body": {
            "inputs": [
                {
                    "features": "Plain",
                    "commit": "09a252ab14dbbafe8a85a7829c61ff01b9f0533d9b554f97bea25527bfa672502f"
                }
            ],
            "outputs": [
                {
                    "features": "Plain",
                    "commit": "089b91177229611f4fe58cf7c8aa0783c8a642931dad158ab7589abe8f79e48e04",
                    "proof": "818a4a2f954bc09ebcc15a074b3e30a987df98e63682ca9b51fe3d88157e0cd9228b99a3f0c59597be4e2f63b0d4dfacd1686dc5eb51db663ad604f36eaef1cd0332475cdab969dd370778ba466b85d086be478c9ceb5b068219564f7265a490827c155e4e5839b02207391905ed1ee04909da7aad697876e383cb655798cd711da2c3b053647dfc9a3cf0d8d62f894201d1b134349ec975c41dca90d5e5dca23dbfeaceb8038f94b84c54d596c29bde04350b2a4415737f455e98eadb1dde098d64b248b510a371bdc96039a469615df6bac0d21025e92b329e1ae81de846e7f8d406cb48f792ad872a37ea7547b4aa025929ea6446af694623b69f19cb1cb7b4f65b4a9f4f3bc9eeda6aae13a8c6f9cbb61eab87a36387b819b7f222dd2940f9b01753ed923ad8249c6cc644c8ec202c9a5a8c6caaa3e3677bcf6771368aaea1a8742d9671ca77ddf037603c31bf648c1a74d21ab0c40233661837d5affc1c15e60051955626ee979732fc2aa24fddf053b20d07c3e15bb413ccb65bd0e01835c954daee995e69cd607aa527aec22806d0a539de6a91f46eeb497e2e02e2efbd52fbe62fdd5698b4db3f0ecd535a38aa9a5da944397573c7e525631f2d396b2cbf2e4471f85562faedb4192d404187ef6e06adf35fb5125a3ff32678942e0206b7aeb9d6b34fb9732df979b04983b8293b897942945e991fb4f3098344e3d98fe684c57ab50024e5bc5b28a2ab3b7f89a7bde67ae79022c861aa079098e47788e2a02718be4b6431c9bb14cad131ed6a8955a77d73ee631018c70feac365875abbef41d971e536bd0c9948430ee1a2b47b62d673e7b0687d49893ed7c26c1bd1dd00768062888c9f124f42ac6a53fcf1b62d67e514a72239251456663222441773afd7ad02991c93ef975917ffa200f4807f03f7ee98586236e694544644d394c4f8"
                },
                {
                    "features": "Plain",
                    "commit": "08c68e5c03945e32d9dcd64316c5e6b937115627b8485961ff76ba61c162c0638a",
                    "proof": "2df4c72fefdc1955f4277289730f77bb769bd30ad653f3cb7833255940fd45fb60c979087261b51754b7a639bd5a5ad8b5d136395f4c5bca15846a249d39725700522917cd5829559b4441bf5fb2376b7b14b48549d35bb3a352efc696fb9e9da601fe2b37cf24ef09aeba2d9d4d47cdb73c183c841656eec092a21c88369ea9858bcf2b1f3f038d996c07e1b4028a073b00f7ec918bf2e3e1a43f431aafc094ec1f0c88ad32b98bc16753be9fabb5566f322a996d32ba7844b8fcf57ee6337ad2eecf0a7d1ae53d9eb0148d7e6d0a4726c7d21a94629a42b4534abc8841f062bd828a3e1f79c781f61d480a797f7a3b9be088fba5290af8655732f6ff56329e512660e89157dc670bfb5a9e4991eb580d6fea7996a1ba7171fc13085fe17aab626f0cac03ff91712634a8027703efe34ef1566aa8d47c12e493d825869e1075632ac9d6dcacf99ca04c91f2c2b399a377777cb4df8c648ebb73d267677ce1ca015e03707d9a2756dca88a198d52777e44024f352159edf4227b9db1183bf8dea6005f4f3fa7d9e8dbbcba0b704884dc17f234aa4a3e57bd20410dc62f03d6a88449c5f5abe38e549f8ecaf7ae6555a1867c4d298649ef5604cb17496eed0c2ab5ae5e9cc2cfc3a854ba37f897c6f455b02fe940a77703f8f709e1f1459e7f2b50a073a7876f35f0d65568a2b27a95fc0c63d6748f6519702214f4dfd5aff218103712560b77dc5210324d83684735896ce4173d870c61297ba20686c36c9dfc93b6e9ce55fd09e80b642de12d65cac8c9d053a4fd9569f541d6d4a149e12b26ce907041f9c66d5bf61d0b2bebbeb31722c151b5a1025802bacd4eb086c5b33c7eb09b71072cbb8f32b29d7a6c5f47aa078db1ba6a278c2719b50206f959b85cfd71a02b442e7f03642b0d7b722d05f6f3f19616581db2fba6f1539fc8a08fb497d464"
                }
            ],
            "kernels": [
                {
                    "features": "Plain",
                    "fee": "8000000",
                    "lock_height": "0",
                    "excess": "000000000000000000000000000000000000000000000000000000000000000000",
                    "excess_sig": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
                }
            ]
        }
    },
    "amount": "10250000000",
    "fee": "8000000",
    "height": "200869",
    "lock_height": "0",
    "participant_data": [
        {
            "id": "0",
            "public_blind_excess": "034addf29e589b814871545096abaf14eee2d6e19da1442a9dfcedea5af660c421",
            "public_nonce": "02c40a211fc4fcf71fac80476ffa3f17c4874ad41712baf94399ceab00126a5293",
            "part_sig": null,
            "message": null,
            "message_sig": null
        },
        {
            "id": "1",
            "public_blind_excess": "0368dc05a419dce86a2530d97d5593924da35f2cec06569f8d94af763dda5171d3",
            "public_nonce": "02e626a44219a2271c333611b60c7c380e9e310f8ceb0e39a195a8affa50e40b05",
            "part_sig": "050be450faafa895a1390eeb8c0f319e0e387c0cb61136331c27a21942a426e692e463fa6aff56dc946f533fd84b963991bd49db7ca6410f0354430dd90aab61",
            "message": null,
            "message_sig": null
        }
    ]
}
Grin 相关资料:
Grin 相关钱包: