A "Hello World" of bitcoin?

1

1

I would like to write a very simple program in bitcoin. I thought a simple C program that accepts the mined blocks would be appropriate. So I assume, the program would open a socket connection to some fixed relay node and start accepting the blocks. Could someone show how it could be done. Thank you.

[Edit:] I have since discovered what is probably best suited for the purpose. There is a minimal bitcoin networking stack implemented in python by Dr Christian Decker of ETH Zurich. It was used to gather results for some highly cited research papers on the bitcoin network but at the same time it is extremely readable too.

user2277550

Posted 2015-09-12T04:22:07.300

Reputation: 691

Answers

4

The easiest way if you come from web development and or you want to put a system in production is to use the most stable and updated implementation/API of Bitcoin Core

note: after downloading it it's best practice to check the md5/sha of the file you downloaded on bitcoin.org to be sure your installer is genuine


1) Install Bitcoin Core

2) Use it's CLI or JSON rpc APIs: https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list

there's no step 3!


This in the case your target is to run an app connected to most of the updated nodes, have the latest code with security fixes to at least sign and broadcast transactions, and obviously, query the blockchain!

glhf

makevoid

Posted 2015-09-12T04:22:07.300

Reputation: 305

1

You should looks at the existing C implementations (SPV node, incomplete):

Jonas Schnelli

Posted 2015-09-12T04:22:07.300

Reputation: 5 465

Thank you for that information. Something even better would be just 40-50 lines of code doing some basic thing, like accepting blocks or smthn like that.user2277550 2015-09-12T09:57:03.030

1Accepting blocks means validating them, which is a huge amount of work and must be bit-for-bit identical with Bitcoin Core. It's not possible with a small codebase, or at least not for now until libbitcoinconcensus is stable.Anonymous 2015-09-12T10:23:20.000

0

Whilst not C, libbitcoin is written in C++ and is a full implementation. It should let you do everything.

If you're not limited to C, bitpay has a very straightforward p2p library here: https://github.com/bitpay/bitcore-p2p

I do not accept the answer of using the RPC, since you have to use a whole other 30mb application just to get your data, and it's not a great start for a scalable application or learning the inner workings of the network.

karimkorun

Posted 2015-09-12T04:22:07.300

Reputation: 763

0

Depends on the area. In any case i suggest you to only use test network to avoid losing funds.

If you are interested about the crypto stuff, study how to turn random number into wallet address, or how signatures are made.

https://github.com/keeshux/basic-blockchain-programming

Anlhord Smithson

Posted 2015-09-12T04:22:07.300

Reputation: 129