Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Nicolas Dorier on June 10, 2014, 03:13:15 PM



Title: NBitcoin : How to scan the Blockchain
Post by: Nicolas Dorier on June 10, 2014, 03:13:15 PM
I just published an article on NBitcoin http://www.codeproject.com/Articles/784519/NBitcoin-How-to-scan-the-Blockchain (http://www.codeproject.com/Articles/784519/NBitcoin-How-to-scan-the-Blockchain)
I introduce a design of blockchain scanner that is easily extensible for tracking colored coins, multi sig, stealth address and more.

It actually works with the full blockchain dump of Bitcoin QT (BlkXXX.dat), but will very soon be extended to support SPV.

Waiting for your feedback !

Preview :
Quote
The previous article I wrote about bitcoin (Introduction article and one about stealth address and two factor), I did not invent anything special, I just wanted to explain in simpler term how things work.

On the other hand, this article propose a simple and scalable design to scan a blockchain, that work for full Bitcoin node and (soon) SPV.
I entirely made up this design, and it is experimental for now, and expect some bugs lurking around despite the 100+ unit tests I wrote. I expect you will use it and give me feedback about it.

Being experimental, the code of this article might have changed since I wrote it. But the general principle stays the same.

For people that knows how bitcoin works, you can skip the “Bitcoin Basics” part.


Title: Re: NBitcoin : How to scan the Blockchain
Post by: johnatan32 on June 12, 2014, 05:24:00 PM
I liked it


Title: Re: NBitcoin : How to scan the Blockchain
Post by: Nicolas Dorier on June 14, 2014, 09:04:39 PM
Thanks, added a part "manual scanning" if it interest you. :)


Title: Re: NBitcoin : How to scan the Blockchain
Post by: mcaizgk2 on June 15, 2014, 01:07:43 AM
Good job, Nicolas.


Title: Re: NBitcoin : How to scan the Blockchain
Post by: Justin00 on June 15, 2014, 02:24:59 AM
reading so far, looks like you did a nice job... i'm abit slow lol so i have to read a few setanes a couple of times.
I have some questions thoigh.. should I PM you or ask in thread ?


Title: Re: NBitcoin : How to scan the Blockchain
Post by: Nicolas Dorier on June 15, 2014, 10:00:02 AM
reading so far, looks like you did a nice job... i'm abit slow lol so i have to read a few setanes a couple of times.
I have some questions thoigh.. should I PM you or ask in thread ?
Ask in this thread if you have some question, other will also have and maybe I missed to explain something in the article.


Title: Re: NBitcoin : How to scan the Blockchain
Post by: newIndia on June 15, 2014, 10:16:03 AM
Hey... nice development. Can I run my own block explorer using https://github.com/NicolasDorier/NBitcoin ? Will send/receive API be supported ?


Title: Re: NBitcoin : How to scan the Blockchain
Post by: Nicolas Dorier on June 15, 2014, 11:59:04 AM
Hey... nice development. Can I run my own block explorer using https://github.com/NicolasDorier/NBitcoin ? Will send/receive API be supported ?

Yes, you can code your own blockexplorer using it.
Actually I index only Blocks with the IndexedBlockStore, but nothing prevent you to index other data structure like transactions.

The class you will need for that is BlockStore, which permit you to enumerate the blocks in the blocks folder of bitcoind.
And SqlLiteNoSqlRepository, which permit you to have a persistent key-value store, to create your index.

You can send/receive with the NodeServer class, which permit to connect to bitcoin network send transactions, and receive transactions, with raw protocol messages.
You can also use RPCClient which would connect in RPC to bitcoind, that would send transaction on your behalf, this is recommended because NBitcoin can't verify that inputs are not already spent.

NBitcoin is not a full node implementation, that means that it is unable to verify validity of a transaction. (precisely, it can't verify that inputs of your transaction are not already spent)

This is why I recommend to have a running bitcoind that verify transactions, but using the tracking abilities of NBitcoin (Scanners) from NBitcoin.


Title: Re: NBitcoin : How to scan the Blockchain
Post by: Altoidnerd on June 16, 2014, 07:07:53 AM
Can any badasses confirm this repo is safe?