bitcoin - 通过 https 访问比特币节点
问题描述
我通过 https 链接拥有自己的比特币测试网节点,当我想通过 curl 对其进行 ping 操作时
curl https://link_to node/ 我有这样的回应
JSONRPC server handles only POST requests
所以这意味着我可以连接到节点并向它发送请求,所以我想通过 nodejs 和比特币核心连接到它。我想初始化比特币对象
const bitcoin = require('bitcoin-core');
let client = new bitcoin({
network: 'testnet',
username: 'user',
password: 'password',
host: 'https://link_to_node/',
timeout: 30000,
port: 443
});
client.upTime((err, res) => {console.log(err, ' and ', res);})</i>
在这里,我连接到节点并发送有关其正常运行时间的请求并收到类似的响应
错误:getaddrinfo ENOTFOUND https:80 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26) 错误:'ENOTFOUND',代码:'ENOTFOUND',系统调用:'getaddrinfo',主机名:'https',主机:'https',端口:80},isOperational:true,errno:'ENOTFOUND',代码:'ENOTFOUND',系统调用:'getaddrinfo',主机名:'https',主机:'https',端口:80}
那么我如何通过 https 和 bitcoin-core 连接到比特币节点呢?
解决方案
Bitcoin Core 的 JSON RPC API 不支持 HTTPS。但是,您可以使其(在服务器上)只能通过 localhost ( rpcallowip=127.0.0.1
) 访问。您可以编写一个包装器(例如 PHP)并通过 HTTPS Web 服务器运行它。
推荐阅读
- c++ - MobileNet SSD V2 转换的 tflite 模型的错误输出
- php - php脚本找不到包含文件
- python - 在python中添加365天至今
- winapi - 如何在 win32 中使用 SetTextColor 更改文本 SetDlgItemText 的颜色?
- math - 我将使用“光线投射器”选择“对象”之一进行放大
- python - MNIST图像数据上的EM算法python
- java - 如何在不发送实体的完整 json 的情况下更新对象
- azure - Azure 事件网格出口限制
- python - 基于其他两个类/表自动填充由 sqlalchemy 类定义的表
- ios - UILabel 没有在 UIStackView 中使用 addArrangedView 呈现;使用 addSubView 渲染