Bitcoin Forum
June 14, 2024, 02:35:26 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Some programming questions  (Read 1256 times)
ATC777 (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10



View Profile WWW
January 09, 2013, 09:27:07 PM
 #1

I'm working on some Bitcoin-related software and had a few questions... FYI, I'm using C++ and C#...

1) Where can I find information/guidelines/tutorials for connecting to the Bitcoin network?
2) What's the easiest way to get the current mining difficulty from the network?
3) Is there a simple open-source BTC client written in C# I can have a look at and dissect?
4) Are their any "best practices" articles about programming for Bitcoin?

Thanks,

--ATC--

Epic Coinage -- Gold, Silver, Bitcoin, Exchange, Apparel, Electronics and more!

Check the official trade thread for full list of products and services!

Tips :: 13M9QLc5BDQe2iuB1N3Br58fYvJF5ixihT
ATC777 (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10



View Profile WWW
January 09, 2013, 09:31:14 PM
 #2

Also, where can I learn more about math behind Bitcoin mining, difficulty and SHA-256 in general? I would also like to know how I can fetch the "last" price from Mt Gox and/or BTC-E.

Epic Coinage -- Gold, Silver, Bitcoin, Exchange, Apparel, Electronics and more!

Check the official trade thread for full list of products and services!

Tips :: 13M9QLc5BDQe2iuB1N3Br58fYvJF5ixihT
weex
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
January 09, 2013, 09:51:59 PM
 #3

Your best bet is to search the wiki. Also check out pynode which is in python but simple enough to get into for Bitcoin software. On mobile or else I'd postlinks . Good luck and welcome to Bitcoin.
01BTC10
VIP
Hero Member
*
Offline Offline

Activity: 756
Merit: 503



View Profile
January 09, 2013, 09:56:20 PM
 #4

You can get difficulty and market price information via Blockchain.info API: http://blockchain.info/api

You can also query MtGox or BTC-E API directly:

https://en.bitcoin.it/wiki/MtGox/API
https://btc-e.com/api/documentation
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1025



View Profile
January 10, 2013, 01:08:21 AM
 #5

I'm working on some Bitcoin-related software and had a few questions... FYI, I'm using C++ and C#...

1) Where can I find information/guidelines/tutorials for connecting to the Bitcoin network?
2) What's the easiest way to get the current mining difficulty from the network?
3) Is there a simple open-source BTC client written in C# I can have a look at and dissect?
4) Are their any "best practices" articles about programming for Bitcoin?

More information would be very useful when answering you.  For example, in question 1, are you asking what it takes to make a program that talks to other bitcoin nodes using the p2p protocol?  If so, the network information can be found here.  Actually getting connected isn't too bad.  You connect the socket, go through the version/verack handshake, and you are on.  After that, it is just a matter of not doing anything that make the other side think it needs to disconnect you.

For #2, "the network" doesn't know the difficulty.  Each node knows it, but there is no point in communicating it over the p2p socket, so there is no message for it.  However, if you grab the latest block from a node, that block header will have a target field, which you can use to calculate the difficulty.  Being sure that a given block is the "latest block" is not trivial.  Vastly easier is to just run a node somewhere, and use the getmininginfo RPC call.

#3 Not that I'm aware of.  The good news is that the reference client is open source.  Even better, it is also Free Software (MIT license).  The bad news is that it is C++.

#4 changes dramatically depending on what you really mean by "programming for Bitcoin".  If you are writing wallet/node software, the best practice (or only practice, really) is to go through the reference client with a microscope and faithfully recreate every wart, wrinkle and bug that you find in it.  If you are just looking to hook some stuff up using RPC, best practices will be vastly different, since the node you are RPCing to already manages the burden of validation and correctness.  In that case, the best practice is to use strings to represent amounts.  Smiley

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
notme
Legendary
*
Offline Offline

Activity: 1904
Merit: 1002


View Profile
January 10, 2013, 01:13:42 AM
 #6

If you haven't read this, do it before you do anything else:
http://www.bitcoin.org/bitcoin.pdf

https://www.bitcoin.org/bitcoin.pdf
While no idea is perfect, some ideas are useful.
ATC777 (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10



View Profile WWW
January 10, 2013, 01:56:10 AM
 #7

If you haven't read this, do it before you do anything else:
http://www.bitcoin.org/bitcoin.pdf

That's the Satoshi whitepaper link, isn't it?

If so, I have indeed downloaded it and started reading it a few days ago. Just haven't gotten very deep yet.

Epic Coinage -- Gold, Silver, Bitcoin, Exchange, Apparel, Electronics and more!

Check the official trade thread for full list of products and services!

Tips :: 13M9QLc5BDQe2iuB1N3Br58fYvJF5ixihT
ATC777 (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10



View Profile WWW
January 10, 2013, 07:40:05 AM
 #8

Just for giggles I'm currently working on what will be a very accurate and detailed mining calculator... with some refinements in the future it might be good enough for professional use (maybe...if I take it seriously). Right now I'm just writing the UI code, wiring up events and designing the thing. Here's a screenie of what it looks like right now:



If you have any suggestions on how I should design it or technical/logical suggestions on making it more accurate I'm all ears!  Cheesy

--ATC--

Epic Coinage -- Gold, Silver, Bitcoin, Exchange, Apparel, Electronics and more!

Check the official trade thread for full list of products and services!

Tips :: 13M9QLc5BDQe2iuB1N3Br58fYvJF5ixihT
Atruk
Hero Member
*****
Offline Offline

Activity: 700
Merit: 500



View Profile
January 10, 2013, 06:00:10 PM
 #9

Just for giggles I'm currently working on what will be a very accurate and detailed mining calculator... with some refinements in the future it might be good enough for professional use (maybe...if I take it seriously). Right now I'm just writing the UI code, wiring up events and designing the thing. Here's a screenie of what it looks like right now:



If you have any suggestions on how I should design it or technical/logical suggestions on making it more accurate I'm all ears!  Cheesy

--ATC--

One useful thing a lot of mining calculators lack is a way to calculate returns relative to difficulty increases over time. The more ways you allow inputting this the better.

ATC777 (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10



View Profile WWW
January 10, 2013, 06:06:05 PM
 #10

One useful thing a lot of mining calculators lack is a way to calculate returns relative to difficulty increases over time. The more ways you allow inputting this the better.

That's one thing I'm putting a lot of thought into. I will of course provide some simple methods for calculating difficulty increase, like annual % increase, annual hash-power increase and perhaps even post-ASIC difficulty estimates (could use some help there).

But what I'd really like to do is create a difficulty curve on a graph that can be adjusted over a user-specified time scale by clicking and dragging or manually inserting control points. It would allow people considering a serious/professional mining operation to create customized difficulty profiles for the network and calculate the effectiveness of different equipment to fit it.

I think I might also add a feature where you can add different chip profiles. For instance, you might create a profile for the HD 7970 and one for the 5970 and adjust the number of each you have, and it will make calculations as a total of all your equipment. Furthermore, perhaps I should also add a field for something like "auxiliary power consumption" so people can also account for the power-sucking effect of other devices they need to run their rigs (e.g., CPU, mobo, etc).

Epic Coinage -- Gold, Silver, Bitcoin, Exchange, Apparel, Electronics and more!

Check the official trade thread for full list of products and services!

Tips :: 13M9QLc5BDQe2iuB1N3Br58fYvJF5ixihT
Atruk
Hero Member
*****
Offline Offline

Activity: 700
Merit: 500



View Profile
January 10, 2013, 06:18:55 PM
 #11

One useful thing a lot of mining calculators lack is a way to calculate returns relative to difficulty increases over time. The more ways you allow inputting this the better.

That's one thing I'm putting a lot of thought into. I will of course provide some simple methods for calculating difficulty increase, like annual % increase, annual hash-power increase and perhaps even post-ASIC difficulty estimates (could use some help there).

But what I'd really like to do is create a difficulty curve on a graph that can be adjusted over a user-specified time scale by clicking and dragging or manually inserting control points. It would allow people considering a serious/professional mining operation to create customized difficulty profiles for the network and calculate the effectiveness of different equipment to fit it.

That sounds great. The second one especially sounds interesting. I think it would be useful to be able to input an algebraic expression as well for an anticipated growth rate. It would be nice to have a quick GUI option as opposed to beating up my keyboard while I use Python as a calculator.

Chip profiles or rig profiles that can be saved is a cool idea as well.

There are a lot of really basic and not so basic mining calculators out there, but putting together a nice one with advanced functionality like you are thinking about is probably going to net you some positive attention if you can pull it off.

As far as general tips if you decide to develop a client go, it is hard to go wrong if you use bitcoind to handle the networking on a full client or an electrum server (it'd probably be polite to set up your own for testing your software on during development) if you go the light route.

ATC777 (OP)
Member
**
Offline Offline

Activity: 112
Merit: 10



View Profile WWW
January 10, 2013, 06:38:57 PM
 #12

That sounds great. The second one especially sounds interesting. I think it would be useful to be able to input an algebraic expression as well for an anticipated growth rate. It would be nice to have a quick GUI option as opposed to beating up my keyboard while I use Python as a calculator.

Chip profiles or rig profiles that can be saved is a cool idea as well.

I like those ideas too. Can't let myself get carried away with the infamous "feature creep", but keep the ideas rolling!  Cool

There are a lot of really basic and not so basic mining calculators out there, but putting together a nice one with advanced functionality like you are thinking about is probably going to net you some positive attention if you can pull it off.

Definitely. The question is will I do it... Hopefully. But I've got a lot of stuff going on (e.g., getting a start-up off the ground, primarily) and gotta put food on the table and keep the lights on, haha.

Perhaps I can put some financial incentive in it which would definitely make me work fast and furious. I'll make it freeware with the "pay what you want" concept and a suggested donation of around 0.70 BTC (close to $10). I have no moral problem with proprietary software (in fact, been developing it for years) but I think making this free to use would be "in the spirit of Bitcoin", and a great way for our new company (and me, personally) to contribute to Bitcoin and the community. But do you think it would actually work, or would people just download it and say "eff that ATC guy!"? lol...

As far as general tips if you decide to develop a client go, it is hard to go wrong if you use bitcoind to handle the networking on a full client or an electrum server (it'd probably be polite to set up your own for testing your software on during development) if you go the light route.

Thanks for the suggestions. I'll be looking into this more quite soon. But I can't let myself get too many simultaneous development projects going on! Believe me, I can really get carried away! Cheesy

Epic Coinage -- Gold, Silver, Bitcoin, Exchange, Apparel, Electronics and more!

Check the official trade thread for full list of products and services!

Tips :: 13M9QLc5BDQe2iuB1N3Br58fYvJF5ixihT
Atruk
Hero Member
*****
Offline Offline

Activity: 700
Merit: 500



View Profile
January 10, 2013, 07:02:42 PM
 #13

Perhaps I can put some financial incentive in it which would definitely make me work fast and furious. I'll make it freeware with the "pay what you want" concept and a suggested donation of around 0.70 BTC (close to $10). I have no moral problem with proprietary software (in fact, been developing it for years) but I think making this free to use would be "in the spirit of Bitcoin", and a great way for our new company (and me, personally) to contribute to Bitcoin and the community. But do you think it would actually work, or would people just download it and say "eff that ATC guy!"? lol...

As far as general tips if you decide to develop a client go, it is hard to go wrong if you use bitcoind to handle the networking on a full client or an electrum server (it'd probably be polite to set up your own for testing your software on during development) if you go the light route.

Thanks for the suggestions. I'll be looking into this more quite soon. But I can't let myself get too many simultaneous development projects going on! Believe me, I can really get carried away! Cheesy

Donations aren't something to count on, but if you could produce a web version either as your primary, or as a demonstration that could get whatever site you put it on quite a bit of traffic. Traffic brings its own problems though. A charge of a bitcent, bitnickle, or bitdime to unlock some of the advanced functionality though might bring in more revenue than a higher charge or suggested donation. If we've learned anything from mobile app land, lots of small purchases make more money than a few big ones in a lot of cases.

If you worry about getting carried away just remember that it is okay to let dead end projects die. It is alright to start a bunch of small projects to learn aspects of how bitcoin works and then kill the small ones to focus on a few you find interesting or potentially lucrative. Rather than trying to make a single big project at the outset instead make features that let you learn and practice, which might be useful incorporated into a project.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!