简体   繁体   English

是否需要运行比特币节点才能与比特币区块链进行交互?

[英]Is it necessary to run a bitcoin node in order to interact with bitcoin blockchain?

Was looking at libraries for bitcoin node implementation like bitcoin-ruby and toshi . 正在寻找用于实现比特币节点的库,例如bitcoin-rubytoshi I guess my question is quite basic but I'm a newby here: Is it necessary to download the entire blockchain (and even set a node) in order interact with it as sending/receiving transactions, getting block data or create an address? 我想我的问题很基本,但是我是个新手:是否有必要下载整个区块链(甚至设置一个节点)以便在发送/接收交易,获取区块数据或创建地址时与之交互?

Things you can do offline, without syncing fully with the blockchain 您可以离线完成的事情,而无需与区块链完全同步

  • Create new bitcoin addresses 创建新的比特币地址
  • Create transactions to be sent if you already have funds in some of your addresses 如果您的某些地址已经有资金,请创建要发送的交易

Things you can do with a connected, without syncing fully with the blockchain - 您可以在不完全与区块链同步的情况下通过连接进行的操作-

  • Send a transaction (broadcast it) 发送交易(广播)

Check out implementations of SPV wallets such as breadwallet to know more. 查看SPV钱包(如面包钱包)的实现,以了解更多信息。

It is possible to interact with the bitcoin network without downloading the entire blockchain. 无需下载整个区块链即可与比特币网络进行交互。

You should check how to interact with the peers in the bitcoin developer guide p2p section . 您应该在bitcoin开发人员指南p2p部分中检查如何与对等方进行交互。

There are also a lot of libraries that allow you to interact with the bitcoin network, for example, with bitcore p2p you can interact with a pool of peers with: 还有很多库可让您与比特币网络进行交互,例如,通过bitcore p2p,您可以通过以下方式与对等池进行交互:

var Pool = require('bitcore-p2p').Pool;
var Networks = require('bitcore-lib').Networks;

var pool = new Pool({network: Networks.livenet});

// connect to the network
pool.connect();

// attach peer events
pool.on('peerinv', function(peer, message) {
  // a new peer message has arrived
});

// Send a message, as soon as the response arrives, the pool will emit the related event.
// If your request is a getheaders message https://en.bitcoin.it/wiki/Protocol_documentation#getheaders
// you should listen for 'peerheaders'
pool.sendMessage(message)

// will disconnect all peers
pool.disconnect()

For checking an address balance, if you don't download the entire blockchain, you should download the header chain . 为了检查地址余额,如果您不下载整个区块链,则应下载标题链 When you want to check if an address is or not in a block, you can request a merkleblock . 当您要检查某个地址是否在一个块中时,可以请求merkleblock

Here and here you can find more about the spv clients. 在这里这里,您可以找到有关spv客户端的更多信息。

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

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