2 个版本

0.1.1 2019年5月21日
0.1.0 2019年5月21日

#45#完整

CC0 许可证

13KB
156

btc-cli

一个用 Rust 编写的 Bitcoin 命令行工具

  • 通过 p2p 协议与完整节点交互
  • 通过 RPC 接口与完整节点交互
  • 与 Electrum 服务器交互
  • 提供密钥管理工具

免责声明:此项目是实验性的,代码尚未准备好用于生产。请勿在生产环境中使用!!!!

用法示例

"key-management" 子命令

此子命令提供密钥管理工具。

➜  btc-cli git:(development) ✗ cargo run key-management --action generate-xpub-from-seed --seed="000102030405060708090a0b0c0d0e0a" --network bitcoin --path "m/0/1"
    Finished dev [unoptimized + debuginfo] target(s) in 0.14s
     Running `target/debug/main key-management --action generate-xpub-from-seed --seed=000102030405060708090a0b0c0d0e0a --network bitcoin --path m/0/1`
xpub: xpub6BJNgwRThSd6DEqbxGYdYPuEWhKFtzEMPPxmDHLfWdWjHEWaeGvQukNtAjw2rFpYb4cUzvJF1VG8pwWcr7bv9oMJqHaJqLfYhUy4hknreS9
public key: 02fb62886536544edbd8d8c257ab7014f54988b386c867f9d6ec68b5305af1beb9
➜  btc-cli git:(development)

"p2p" 子命令

此子命令允许用户使用 p2p 协议与比特币节点交互

➜  btc-cli git:(development) ✗ cargo run  p2p --action raw-message --node localhost:8333 --message "f9beb4d976657273696f6e000000000066000000be61b8277f1101000d04000000000000f00f4d5c00000000000000000000000000000000000000000000ffff5bf08c80b4bd0d04000000000000000000000000000000000000000000000000faa99559cc68a1c1102f5361746f7368693a302e31372e312f938c080001"
    Finished dev [unoptimized + debuginfo] target(s) in 0.14s
     Running `target/debug/main p2p --action raw-message --node 'localhost:8333' --message f9beb4d976657273696f6e000000000066000000be61b8277f1101000d04000000000000f00f4d5c00000000000000000000000000000000000000000000ffff5bf08c80b4bd0d04000000000000000000000000000000000000000000000000faa99559cc68a1c1102f5361746f7368693a302e31372e312f938c080001`
|f9beb4d9 76657273 696f6e00 00000000| ....version..... 00000000
|66000000 ed89e2e7 7f110100 0d040000| f............... 00000010
|00000000 b92de35c 00000000 00000000| .....-.\........ 00000020
|00000000 00000000 00000000 00000000| ................ 00000030
|00000000 00000d04 00000000 00000000| ................ 00000040
|00000000 00000000 00000000 00000000| ................ 00000050
|17409d72 31d05343 102f5361 746f7368| .@.r1.SC./Satosh 00000060
|693a302e 31382e30 2fdfcd08 0001|     i:0.18.0/.....   00000070
                                                       0000007e
➜  btc-cli git:(development)

"rpc" 子命令

此子命令允许用户通过 JSON RPC 与比特币节点通信(目前仅实现了密码认证)

➜  btc-cli git:(development) ✗ cargo run rpc --node http://localhost:8332 --username user --action get-best-block-hash
    Finished dev [unoptimized + debuginfo] target(s) in 0.14s
     Running `target/debug/main rpc --node 'http://localhost:8332' --username user --action get-best-block-hash`
Type in the RPC password:

best block hash: 000000000000000000141688aac2f0da13de43612e683666593b6e6a1afe7faf
➜  btc-cli git:(development)

"electrum" 子命令

此子命令允许用户与 Electrum 服务器通信。尚未实现

依赖项

~10MB
~216K SLoC