本文转自:https://laravel-china.org/index.php/articles/8919/bitcoin-requests-node-data-through-rpc

文章来自本人的 简书

俺滴围脖 https://weibo.com/liuningtw

配置文件

放在 /mnt/bitcoin 目录下

#  /mnt/bitcoin/bitcoin.conf
server=1
daemon=1
rpcthreads=10
txindex=1
rpcuser=bitcoin
rpcpassword=12345

运行节点

bitcoind -datadir=/mnt/bitcoin # 确保有/mnt/bitcoin/bitcoin.conf

curl

curl --user bitcoin:12345 -H 'content-type:text/plain;' http://127.0.0.1:8332/
--data-binary '{"jsonrpc":"1.0","id":"1","method":"getblockhash","params":[1]}' {
"result": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
"error": null,
"id": "1"
}

python script

import json
import requests url = "http://127.0.0.1:8332/"
auth=("bitcoin", "12345")
payload = json.dumps({"method": 'getblockhash', "params": [1] }) response = requests.request("POST", url, data=payload, auth=auth)
print(response.text)

参考:

https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)
https://bitcoin.stackexchange.com/questions/19665/json-rpc-via-curl

最新文章

  1. 使用CallableStatement的用法
  2. 蚁群算法简介(part3: 蚁群算法之更新信息素)
  3. GitHub 上一份很受欢迎的前端代码优化指南-强烈推荐收藏
  4. Mongo DB Study: first face with mongo DB
  5. Java笔试题解答和部分面试题
  6. html5 canvas 笔记三(绘制文本和图片)
  7. 【Python学习笔记】字典操作
  8. SmallDateTime时间范围检查
  9. html 学习笔记--基础篇
  10. JAVA中子类会不会继承父类的构造方法
  11. Java通配符解惑
  12. http无状态协议,cookie和session详解(一)
  13. focus()无效问题
  14. Python 中关于 round 函数的小坑
  15. Java io概述
  16. 教你用Windows自带工具给优盘/移动硬盘添加密码
  17. 容器平台选型的十大模式:Docker、DC/OS、K8S 谁与当先?【转】
  18. SAS DATA ENCODING 解决odbc乱码问题
  19. 关于解决java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoader问题
  20. 5. 集成学习(Ensemble Learning)GBDT

热门文章

  1. redis在linux云服务器上完整的搭建步骤
  2. jquery向Django后台发送数组
  3. 安装virtualbox出现2503、2502的错误提示解决方法
  4. Python之配置日志的几种方式(logging模块)
  5. Java记事本编写第一个程序“你好,世界”
  6. spring 排除指定的类或者包扫描
  7. 深入分析.NET应用程序SQL注入【危害】
  8. 干了这碗鸡汤:从理发店小弟到阿里P10技术大牛
  9. Javascript高级编程学习笔记(48)—— HTML5
  10. springboot打jar包,调用webservice出错