简体   繁体   English

直接从区块链中检索交易中的“至”和“来自”地址

[英]Retrieving 'to' and 'from' addresses in transaction directly from blockchain

I'm trying to get a list of addresses that have made transactions with a given bitcoin address for a project that examines how people use bitcoin for non-nefarious purposes. 我正在尝试获取一个项目的地址列表,该地址使用一个给定的比特币地址进行了交易,该项目检查了人们如何将比特币用于非恶意目的。 I've got a lot of addresses so a web based blockchain explorer like blockchain.info isn't practical. 我有很多地址,因此像blockchain.info这样的基于Web的区块链资源管理器不切实际。

I've downloaded the blockchain and used bitcoin-abe to dump it into a sqlite database. 我已经下载了区块链,并使用了比特币安倍将其转储到sqlite数据库中。 However I'm not finding addresses anywhere. 但是我在任何地方都找不到地址。 Are the actual addresses called something different in the blockchain? 区块链中的实际地址是否有所不同?

The spending conditions, ie, who is able to spend a given output, are encoded as scripts in the output . 消费条件,即谁能够度过一个给定的输出,被编码为脚本输出 What is commonly referred to as a Bitcoin address is little more than a default script format (either pay-to-pubkey or pay-to-pubkey-hash ) which require a signature from a private key matching the pubkey in the script. 通常称为比特币地址,仅是默认脚本格式(pay-to-pubkey或pay-to-pubkey-hash ),后者需要来自与脚本中的公钥匹配的私钥签名。 For example P2PKH scripts look like this: 例如,P2PKH脚本如下所示:

OP_DUP OP_HASH160 <PubkeyHash> OP_EQUALVERIFY OP_CHECKSIG

This checks that the pubkey on the stack matches the hash, and then checks that the signature and pubkey are valid for the transaction. 这将检查堆栈上的pubkey是否与哈希匹配,然后检查签名和pubkey是否对事务有效。

ABE stores the output scripts, but appears not to create an index for the addresses. ABE存储输出脚本,但似乎不为地址创建索引。 So you probably want to convert the addresses that you're looking for into the script version (see the wiki for details on how to extract the pubkey hash or pubkey from the address). 因此,您可能希望将所需的地址转换为脚本版本(有关如何从该地址提取pubkey哈希或pubkey的详细信息,请参见Wiki )。 Once you have the pubkey hash or pubkey you construct a binary script similar to this (hexencoded): 一旦有了pubkey哈希或pubkey,就可以构造一个与此类似的二进制脚本(十六进制编码):

76a914<pubkey-hash>88ac

You should then be able to search for these in the database ABE gives you. 然后,您应该能够在ABE给您的数据库中进行搜索。

You need to write a cron job using the BTC address of the user and check whether the transaction is made or not. 您需要使用用户的BTC地址编写cron作业,并检查是否进行了交易。

https://www.blockchain.com/explorer https://www.blockchain.com/explorer

Ex. 例如 https://github.com/bitpay/insight https://github.com/bitpay/insight

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

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