Electrum 钱包源码研读(一)

发布时间:2019-10-12 20:08:33编辑:auto阅读(1745)

    一、首先从网上下载代码、导入gpg公钥并验证源码签名,命令如下:

    1. wget https://raw.githubusercontent...
    2. gpg --import ThomasV.asc
    3. wget https://download.electrum.org...
    4. wget https://download.electrum.org...
    5. gpg --verify Electrum-3.1.3.tar.gz.asc Electrum-3.1.3.tar.gz

    二、对代码进行安装,命令如下:

    1. sudo apt-get install python3-setuptools python3-pyqt5 python3-pip
    2. sudo pip3 install Electrum-3.1.3.tar.gz

    三、安装完毕之后,我们可以在终端中输入如下命令来查看帮助:
    electrum -h
    return的信息如下:

    gui                            Run GUI (default)         ---运行GUI
    daemon (start)                Run Daemon                  ---运行守护程序
    addrequest                     Create a payment request, using the first unused address of the wallet   ---使用一个未使用过的地址创建一个付款请求
    addtransaction                 Add a transaction to the wallet history       ---向钱包历史中添加一条交易
    broadcast                      Broadcast a transaction to the network     ---向网络广播一条交易
    clearrequests                  Remove all payment requests                     ---移除全部的付款请求
    commands                       List of commands                            ---命令列表
    create                         Create a new wallet                       ---创建一个新的钱包
    createmultisig                 Create multisig address                   ---创建多重签名的地址
    createnewaddress               Create a new receiving address, beyond the gap limit of the wallet   ---创建一个新的接收地址,超出了钱包的XX限制
    decrypt                        Decrypt a message encrypted with a public key     ---解密使用公钥加密的信息
    deserialize                    Deserialize a serialized transaction                 ---反序列化一个序列化的交易
    dumpprivkeys                   Deprecated                                                                 ---已经废弃
    encrypt                        Encrypt a message with a public key                 ---使用公钥加密一条信息
    freeze                         Freeze address                                 ---冻结地址
    getaddressbalance              Return the balance of any address                        ---返回任何地址的余额
    getaddresshistory              Return the transaction history of any address        ---返回任何地址的交易历史
    getaddressunspent              Returns the UTXO list of any address                      ---返回任何地址的UTXO列表
    getalias                       Retrieve alias                                     ---检索别名
    getbalance                     Return the balance of your wallet                 ---返回钱包的余额 
    getconfig                      Return a configuration variable                     ---返回配置变量
    getfeerate                     Return current optimal fee rate per kilobyte, according to config settings (static/dynamic)    ---根据配置信息,返回当前最优费率
    getmasterprivate               Get master private key                                         ---获取master私钥                
    getmerkle                      Get Merkle branch of a transaction included in a block            ---获取包含在一个区块中的一笔交易的默克尔树
    getmpk                         Get master public key                                    ---获取master公钥
    getprivatekeys                 Get private keys of addresses                                ---获取地址的私钥
    getpubkeys                     Return the public keys for a wallet address                ---返回一个钱包地址的公钥
    getrequest                     Return a payment request                                ---返回一个付款请求
    getseed                        Get seed phrase                                        ---获取种子
    getservers                     Return the list of available servers                        ---返回可用的服务器列表
    gettransaction                 Retrieve a transaction                                    ---检索一笔交易
    getunusedaddress               Returns the first unused address of the  wallet, or None if all addresses are used    ---返回钱包中第一个未使用的地址,如果都在使用则返回空
    help
    history                        Wallet history                                     ---钱包历史
    importprivkey                  Import a private key                            ---导入私钥    
    is_synchronized                return wallet synchronization status                ---返回钱包的同步状态
    ismine                         Check if address is in wallet                        ---检查地址是否在钱包中
    listaddresses                  List wallet addresses                            ---钱包中的地址列表 
    listcontacts                   Show your list of contacts                        ---显示联系人列表
    listrequests                   List the payment requests you made                ---发出的付款请求列表
    listunspent                    List unspent outputs                            ---未使用的输出列表
    make_seed                      Create a seed                                ---创建种子
    notify                         Watch an address                                ---观察一个地址
    password                       Change wallet password                        ---更改钱包密码
    payto                          Create a transaction                            ---创建一笔交易
    paytomany                      Create a multi-output transaction                ---创建一笔多输出交易  
    restore                        Restore a wallet from text                        ---从文本中还原恢复钱包
    rmrequest                      Remove a payment request                        ---移除一个付款请求
    searchcontacts                 Search through contacts, return matching entries    ---搜索联系人,返回匹配的条目
    serialize                      Create a transaction from json inputs                        ---从JSON输入创建一笔交易
    setconfig                      Set a configuration variable                        ---设置配置变量
    setlabel                       Assign a label to an item                        ---为一个项目分配标签
    signmessage                    Sign a message with a key                        ---使用key给一条信息签名
    signrequest                    Sign payment request with an OpenAlias            ---使用OpenAlias给付款请求签名
    signtransaction                Sign a transaction                                ---为一笔交易签名
    sweep                          Sweep private keys                             ---清除私钥
    unfreeze                       Unfreeze address                                 ---解除冻结地址
    validateaddress                Check that an address is valid                    ---检验一个地址是否有效
    verifymessage                  Verify a signature                                ---验证签名
    version                        Return the version of Electrum                    ---返回Electrum 的版本
    
    optional arguments:
    -h, --help                     show this help message and exit                   ---显示帮助信息并退出
    
    global options:
    -v, --verbose                  Show debugging information                    ---显示调试信息
    -D ELECTRUM_PATH, --dir ELECTRUM_PATH       electrum directory            ---Electrum目录
    -P, --portable                Use local 'electrum_data' directory                ---Electrum 的本地目录
    -w WALLET_PATH, --wallet WALLET_PATH         wallet path                ---钱包路径
    --testnet                         Use Testnet                                    ---使用测试网络
    --regtest                         Use Regtest                                    ---使用本地测试网络
    
    Run 'electrum help <command>' to see the help for a command
    

关键字