zoukankan      html  css  js  c++  java
  • win10下btcd的安装和简单配置

    btcd

    btcd github地址

    1. 安装

    1) 安装go的包管理工具glide

    glide github地址

    $ go get -u github.com/Masterminds/glide
    

    出现的问题

    [ERROR] Unable to export dependencies to vendor directory: Error moving files: exit status 1. output: Access is denied. 0 dir(s) moved
    

    解决方法

    修改%GOPATH%/src/github.com/Masterminds/glide/path/winbug.go中的CustomRename函数的75行
    修改前:

    cmd := exec.Command("cmd.exe", "/c", "move", o, n)
    

    修改后:

    cmd := exec.Command("cmd.exe", "/c", "xcopy /s/y", o, n+"\")
    

    修改完成后需要重新编译生成glide.exe

    go  install github.com/Masterminds/glide
    

    2) 安装btcd

    git clone https://github.com/btcsuite/btcd %GOPATH%srcgithub.comtcsuitetcd
    cd %GOPATH%srcgithub.comtcsuitetcd
    glide install
    go install . ./cmd/...
    

    附: linux下对应操作:

    $ git clone https://github.com/btcsuite/btcd $GOPATH/src/github.com/btcsuite/btcd
    $ cd $GOPATH/src/github.com/btcsuite/btcd
    $ glide install
    $ go install . ./cmd/...
    

    遇到的问题

    由于墙的原因,go get可能无法安装需要的golang.org/x/crypto等包

    解决方法

    可参考go get golang.org/x 包失败解决方法
    有条件的话,建议使用代理下载,方便很多,避免安装过程中手动解决依赖问题

    安装成功的话会在%GOPATH%/bin 目录下生成以下可执行程序:

    addblock  btcctl  btcd  findcheckpoint  gencerts  glide
    

    3)安装btcwallet [可选]

    git clone https://github.com/btcsuite/btcwallet %GOPATH%srcgithub.comtcsuitetcwallet
    cd %GOPATH%srcgithub.comtcsuitetcwallet
    glide install
    go install . ./cmd/...
    

    附: linux下对应操作:

    $ git clone https://github.com/btcsuite/btcwallet $GOPATH/src/github.com/btcsuite/btcwallet
    $ cd $GOPATH/src/github.com/btcsuite/btcwallet
    $ glide install
    $ go install . ./cmd/...
    

    安装btcwallet之后

    $ ls ~/go/bin/
    addblock  btcctl  btcd  btcwallet  dropwtxmgr  findcheckpoint  gencerts  glide  sweepaccount
    

    2. 配置

    配置btcd.conf

    在%GOPATH%/bin下创建sample-btcd.conf
    完整版参考: sample-btcd.conf
    内容如下:

    [Application Options]
    rpcuser=+9AqUHnIIJIAmYt7Et+jpwxOci8=
    rpcpass=7sMYDaq4K8hRxUsCsTs1tJoaw/Q=
    #rpclimituser=mylimituser
    #rpclimitpass=Limitedp4ssw0rd
    #configfile=H:/btcd/btcd.conf  # 貌似修改无效,为了使用方便,直接放在默认位置(C:Users你的用户名AppDataLocalBtcdtcd.conf)好了
    datadir=H:/btcd/data
    logdir=H:/btcd/logs
    rpccert=H:/btcd/rpc.cert  
    rpckey=H:/btcd/rpc.key
    debuglevel=debug
    #maxpeers=50
    

    其中#开头的都是注释内容
    默认配置文件路径:

    #切换中%GOPATH%目录
    E:>cd %GOPATH%in
    E:>F:
    # 执行btcd.exe,第一次初始化的时候会加载相同目录下的sample-btcd.conf文件,之后使用如果不用-C指定配置文件则加载默认配置C:Users你的用户名AppDataLocalBtcdtcd.conf
    F:Goin>btcd.exe
    

    配置btcct.conf

    在%GOPATH%in目录下创建btcctl.conf
    内容如下:

    [Application Options]
    rpcuser=+9AqUHnIIJIAmYt7Et+jpwxOci8=
    rpcpass=7sMYDaq4K8hRxUsCsTs1tJoaw/Q=
    rpccert=H:/btcd/rpc.cert
    

    注意
    这里的rpcuserrpcpass 是btcd随机生成
    ,在C:Users你的用户名AppDataLocalBtcdtcd.conf中

    测试访问

    F:Goin>btcctl ping
    open C:UsershupengAppDataLocalBtcd
    pc.cert: The system cannot find the file specified.
    

    和btcd.exe相同,如果不指定-C,会加载默认配置
    ,默认配置文件在C:Users你的用户名AppDataLocalBtcctltcctl.conf
    查看默认配置文件,内容如下:

    [Application Options]
    rpcuser=+9AqUHnIIJIAmYt7Et+jpwxOci8=
    rpcpass=7sMYDaq4K8hRxUsCsTs1tJoaw/Q=
    

    发现缺少rpccert,加入:

    rpccert=H:/btcd/rpc.cert
    

    再次尝试

    F:Goin>btcctl.exe ping
    
    # 打开新的cmd命令终端
    C:Usershupeng>btcctl.exe getblockcount
    141953
    C:Usershupeng>btcctl.exe getblockhash 0
    000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
    

    访问网站(如:https://blockexplorer.com)验证hash。发现hash相同,至此环境搭建完毕

    默认端口

    Name Port
    Default Bitcoin peer-to-peer port TCP 8333
    Default RPC port TCP 8334

    其他

    By default, the rpc server now uses certs to protect the connection by default.
    You can also check out https://github.com/conformal/btcd/tree/master/util/btcctl for an example of making an rpc connection using the cert btcd generates on initial startup.

    When running btcd, if no configuration file is found, the sample-btcd.conf file is copied to the default path,
    with the rpcuser and rpcpass lines populated with random base64 encoded values.

    When running btcctl, if no configuration file is found, it attempts to read the btcd.conf file at its default path,
    and create a basic btcctl.conf file by copying the rpcuser and rpcpass.

    参考:

  • 相关阅读:
    遥控按键上报键值映射问题
    AutoLock类
    Mutex互斥锁
    c++ 字符串和数字转换时的特殊处理
    pytorch实现MLP并在MNIST数据集上验证
    python实现直方图均衡化,理想高通滤波与高斯低通滤波
    python实现贝叶斯网络的概率推导(Probabilistic Inference)
    python+opencv实现车牌定位
    python添加高斯噪声和椒盐噪声,实现中值滤波和均值滤波,实现Roberts算子和Sobel算子
    c++学习笔记_6
  • 原文地址:https://www.cnblogs.com/hupeng1234/p/9729180.html
Copyright © 2011-2022 走看看