简体   繁体   English

如何从区块链获取给定地址的详细信息?

[英]How to get detail of given address from blockchain?

I am building blockchain explorer. 我正在构建区块链资源管理器。 I have my own blockchain. 我有自己的区块链。 In that, i want to search details of a given address from blockchain. 在此,我想从区块链中搜索给定地址的详细信息。 There is no direct API to get detail of an address, could anybody help how to this ? 没有直接的API可以获取地址的详细信息,有人可以帮忙吗? Thanks in Advance. 提前致谢。

Two options: 两种选择:

option 1: 选项1:

blockchain.info has an open API (REST + JSON) blockchain.info具有开放的API(REST + JSON)

https://blockchain.info/it/api/blockchain_api https://blockchain.info/it/api/blockchain_api

here how: 这里如何:

https://blockchain.info/it/rawaddr/$bitcoin_address

bear in mind that you can only acquire info from an address that actually moved at least once some bitcoin on the network. 请记住,您只能从实际在网络上至少移动过一次比特币的地址获取信息。 If you just create a new wallet and do not transact then the public address is non existent on the blockchain (ie there's no difference between a newly generated address and a non existent address). 如果您只是创建一个新钱包而不进行交易,那么公共地址在区块链上就不存在(即,新生成的地址与不存在的地址之间没有区别)。 That's the "shameful" approach as you are building a blockchain explorer using another blockchain explorer, see option 2 for the correct approach: 在使用另一个区块链浏览器构建区块链浏览器时,这是“可耻的”方法,有关正确方法,请参见选项2:

option 2: 选项2:

Run a bitcoin node on your own and query your stuff on it. 自己运行一个比特币节点,并查询其中的内容。 You may not be able to run a node on a normal hosting, probably you need something more like an Amazon AWS instance or host on your own server 您可能无法在普通主机上运行节点,可能需要更多类似Amazon AWS实例或您自己服务器上的主机的东西

I see from comments you are using peercoin ( https://github.com/peercoin/peercoin ). 我从评论中看到您正在使用peercoin( https://github.com/peercoin/peercoin )。 If it's a fork of Bitcoin, then the following holds: 如果它是比特币的叉子,那么以下内容成立:

In basic Bitcoin full-node setup, it's impossible to query random address. 在基本的比特币全节点设置中,不可能查询随机地址。 You can add some addresses to track, but think of it as of "yours". 您可以添加一些要跟踪的地址,但可以将其视为“您的”。

There are modifications to the bitcoin-core, that have a addressindex option. 比特币核心有一些修改,其中有一个addressindex选项。 The one I am aware of is bitcore : https://github.com/bitpay/bitcore-node . 我知道的是bitcorehttps : //github.com/bitpay/bitcore-node

Here's how to run your own blockchain explorer for Bitcoin using bitcore's insight : https://github.com/bitpay/insight-api 这是使用bitcore的insight运行自己的比特币区块链资源管理器的方法: https : //github.com/bitpay/insight-api

npm install -g bitcore@latest
bitcore create mynode
cd mynode
bitcore install insight-api
bitcore install insight-ui
bitcore start

This will launch full node in the needed mode ( addressindex=1 enabled, etc) and a webservice with API and UI, similar to: https://insight.bitpay.com/ . 这将以所需的模式(启用addressindex=1等)启动完整节点,并启动具有API和UI的Web服务,类似于: https : //insight.bitpay.com/

Config file will be located at mynode/bitcore-node.json 配置文件将位于mynode/bitcore-node.json

Bitcore's docs and not well maintained, some are outdated. Bitcore的文档并没有得到很好的维护,有些已经过时。 Try the code, but don't give up if it fails. 尝试代码,但是如果失败,不要放弃。 For more information, refer to the source code. 有关更多信息,请参阅源代码。

PS I am not sure how to convert this to run with your blockchain, but if it's similar to bitcoin, it should be possible. PS:我不确定如何将其转换为与您的区块链一起运行,但是如果它类似于比特币,那应该是可能的。 I think it's closest you can get without writing your own explorer. 我认为您无需编写自己的资源管理器就可以得到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM