标签:hang res 导入 core cti 客户 html gnu []
#环境 ubuntu 16.4
#下载页面
#https://bitcoin.org/zh_CN/download
cd /opt/
wget https://bitcoin.org/bin/bitcoin-core-0.17.0.1/bitcoin-0.17.0.1-x86_64-linux-gnu.tar.gz
#解压,软连接
tar zxf bitcoin-0.17.0.1-x86_64-linux-gnu.tar.gz
ln -fs /opt/bitcoin-0.17.0 /opt/bitcoin
ln -fs /opt/bitcoin-0.17.0/bin/bitcoind /usr/local/bin/bitcoind
ln -fs /opt/bitcoin-0.17.0/bin/bitcoin-cli /usr/local/bin/bitcoin-cli
mkdir ~/.bitcoin
vim ~/.bitcoin/bitcoin.conf
# ~/.bitcoin/bitcoin.conf
dbcache=10240
txindex=1
rpcuser=btc
rpcpassword=btc2018
daemon=1
server=1
rest=1
rpcallowip=0.0.0.0/0
deprecatedrpc=accounts
#local testnet
regtest=1
bitcoind -daemon
bitcoin-cli stop
#查看钱包信息
bitcoin-cli -regtest getwalletinfo
#挖101个block,挖矿奖励在100个block后才能使用
bitcoin-cli -regtest generate 101
#查看挖矿奖励
bitcoin-cli -regtest getbalance
#查看默认hash地址
bitcoin-cli -regtest getaccountaddress ""
# 2MueCwwme7SZzuXpe2NYvHGUxx7KaaoCbpj
#生成新的地址
bitcoin-cli -regtest getnewaddress "test"
2Myr43NbpxMM3W2iTq5ifec66wFwNVWyMeM
#查看私钥
bitcoin-cli dumpprivkey 2Myr43NbpxMM3W2iTq5ifec66wFwNVWyMeM
#账户列表
bitcoin-cli listaccounts
#在test账户新建地址
bitcoin-cli -regtest getnewaddress "test"
# 2NAq5QXCPCQcosCxdYMrPxZoXAjU9h2misi
#查看账户test下的地址
bitcoin-cli getaddressesbyaccount "test"
#查地址所属账户
bitcoin-cli getaccount 2NAq5QXCPCQcosCxdYMrPxZoXAjU9h2misi
#查看账户余额
bitcoin-cli getbalance "test"
#查看地址收到币的数量
bitcoin-cli getreceivedbyaddress 2NAq5QXCPCQcosCxdYMrPxZoXAjU9h2misi
#从默认账户给目标地址转账
bitcoin-cli sendtoaddress "2NAq5QXCPCQcosCxdYMrPxZoXAjU9h2misi" 0.1
#从指定账户转账
bitcoin-cli sendfrom "test" "n3BMgZMA26TcHnVa5iNJeB3PMqkF3cEWBE" 0.01
#生成一个区块,使得交易得到确认(测试网络使用)
bitcoin-cli -regtest generate 1
#再次查看账户余额
bitcoin-cli getbalance "test"
#查看收到的比特币
bitcoin-cli -regtest listreceivedbyaddress
#查看交易详情
bitcoin-cli gettransaction 550d0bab60193a5edfd2636b6187bbdd557eb167a800b8f8d88edb1a037f19bd
#查看raw交易
bitcoin-cli getrawtransaction d0bab60193a5edfd2636b6187bbdd557eb167a800b8f8d88edb1a037f19bd
# rpc api访问测试,查询getwalletinfo
curl -s -X POST --user btc:btc2018 -H ‘content-type: text/plain;‘ http://127.0.0.1:18443/ --data-binary ‘{"jsonrpc": "1.0", "id":"curltest", "method": "getwalletinfo", "params": [] }‘
#命令列表
bitcoin-cli help
#某个命令的详细帮助信息
bitcoin-cli help sendtoaddress
#regtest 启动regtest网络,适合自己测试玩
#参考
# https://www.felix021.com/blog/read.php?2183
# https://www.jianshu.com/p/1891a083e4fe
#加密钱包:bitcoin-cli encryptwallet 密码
#解密钱包:bitcoin-cli walletpassphrase 密码 360(指多少秒后加密)
#改变解锁钱包的密码短语(test 改 test1)
bitcoin-cli -testnet walletpassphrasechange test test1
#删除内存中的加密密匙
bitcoin-cli -testnet walletlock
#备份钱包:
bitcoin-cli importwallet wallet.backup
#导入备份的钱包
bitcoin-cli importwallet wallet.backup
#导出明文私钥
bitcoin-cli dumpwallet wallet.txt
#bitcoin-cli importwallet 导入钱包的文件名
#参考
# http://8btc.com/thread-84788-1-3.html
标签:hang res 导入 core cti 客户 html gnu []
原文地址:https://www.cnblogs.com/elvi/p/10203922.html