Bitcoin Forum
May 10, 2024, 07:10:31 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: For educational purposes, I've created a bitcoin miner!  (Read 405 times)
Coding Enthusiast (OP)
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
June 24, 2019, 04:57:52 PM
Merited by NeuroticFish (5), Jet Cash (5), hugeblack (4), LoyceV (2), OgNasty (1), vapourminer (1), ABCbits (1), AverageGlabella (1), DaCryptoRaccoon (1), Farul (1)
 #1

I've started a new project: https://github.com/Autarkysoft/LearnMining
It serves 3 purposes:
1. Helps with learning how mining works
2. It works with the hash algorithm under the hood
3. Explores optimization of code written in C#

It is a work in progress and I have written everything from scratch purely based on documentations without any kind of "code translation" or "code copying" from other projects so it might contain some mistakes.
Currently it only has bitcoin mining (double SHA256). But I plan on adding other hash algorithms, possibly Scrypt (what LTC uses) be next. I am open to suggestions.
The code has tons of comment on it and I believe it is easy to understand what is going on, I can add more if something is unclear.
Since this is obviously not meant for actually mining anything, parallelization is avoided and it works only on CPU.

Please check it out and tell me what you think. Specially the part about Target here and here, not sure if I'm missing some endian swaps there.

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
1715368231
Hero Member
*
Offline Offline

Posts: 1715368231

View Profile Personal Message (Offline)

Ignore
1715368231
Reply with quote  #2

1715368231
Report to moderator
1715368231
Hero Member
*
Offline Offline

Posts: 1715368231

View Profile Personal Message (Offline)

Ignore
1715368231
Reply with quote  #2

1715368231
Report to moderator
Bitcoin mining is now a specialized and very risky industry, just like gold mining. Amateur miners are unlikely to make much money, and may even lose money. Bitcoin is much more than just mining, though!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715368231
Hero Member
*
Offline Offline

Posts: 1715368231

View Profile Personal Message (Offline)

Ignore
1715368231
Reply with quote  #2

1715368231
Report to moderator
1715368231
Hero Member
*
Offline Offline

Posts: 1715368231

View Profile Personal Message (Offline)

Ignore
1715368231
Reply with quote  #2

1715368231
Report to moderator
1715368231
Hero Member
*
Offline Offline

Posts: 1715368231

View Profile Personal Message (Offline)

Ignore
1715368231
Reply with quote  #2

1715368231
Report to moderator
Coding Enthusiast (OP)
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
July 07, 2019, 06:05:46 AM
 #2

Since this project has been getting some traffic on GitHub and some clones I decided to prioritize it for now.

Added scrypt-miner for litecoin to only work with the algorithm and see how LTC mining works, it is not optimized at all. Also since every code I post is written 100% by me from scratch sometimes I end up with much faster code (SHA256 and HMAC are 60% faster than .Net framework's) and sometimes I end up with much slower code (scrypt). These functions are from the library I'm working on so they are thoroughly tested and they are all generalized instead of being specific to mining the 80 byte array!

https://github.com/Autarkysoft/LearnMining/commit/0dd1c4121e0aa8b0654ac1fe07df79efae9df118

I haven't decided whether to focus on optimizing this or move to CryptoNight algorithm since it uses AES among other things and I've already been working on that for my AEZEED project.

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
AverageGlabella
Legendary
*
Offline Offline

Activity: 1232
Merit: 1080


View Profile
July 09, 2019, 08:07:30 PM
 #3

Appreciate the comments including in the miner. I think this could be a good thing combined with a mining introduction course where students could potentially take a look at the inner workings of the miner. Possibly a thought when theymos implements these courses he indicated he might be doing.
Coding Enthusiast (OP)
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
July 19, 2019, 08:48:43 AM
Merited by bones261 (2), ABCbits (1)
 #4

Since scrypt (used for Litecoin) is more complicated, I decided to start a visual demonstration of the algorithm and also did the same for Double_SHA256. Since the pictures are big here are the direct links:
SHA256: https://i.imgur.com/KhItpCG.jpg
scrypt: https://i.imgur.com/dfOwNyY.jpg
Hopefully they can help. I'll also publish the optimized version of scrypt algorithm soon.




Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
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!