ntonnelier
ntonnelier

Reputation: 1549

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. 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?

Upvotes: 2

Views: 449

Answers (2)

Fi3
Fi3

Reputation: 439

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.

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:

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.

Here and here you can find more about the spv clients.

Upvotes: 1

Manan
Manan

Reputation: 93

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.

Upvotes: 2

Related Questions