cpu-bitcoin-miner

command module
v0.0.0-...-94b93b3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2020 License: MIT Imports: 5 Imported by: 0

README

CPU Bitcoin Miner in Go

Disclaimer: my first Go project :) and only a prototype. Deprecated now (July 2019).

Synopsis

Implementation of a Bitcoin mining client in Go to take advantage of the built-in concurrency primitives of the language. This implementation integrates getblocktemplate used for pool mining instead of getwork as it is getting the standard with BIP 0023.

Motivation

This project is for educational purpose at start for a deep and better understanding of Bitcoin under the hood as well as the discovery of Go (a LOT of things can be improved ;)

Install & Run

After cloning this repo, get the information that you need from your BitCoin Core Client and set your own configuration in config.json:

{
    "user" : "user_name",
    "password" : "Pa$$w0rd",
    "host" : "127.0.0.1:8332",
    "account" : "MyBTCAccount",
    "log": {
        "Activated": true,
        "Level": "info",
        "File": ""
    }
}

Just start the program to begin minning:

go run src/main.go

Implementation

The interactions with the Bitcoin Core client are currently done with curl calls, that have to be re-written with net/http or with a websocket implementation to maintain long-help connections.

The mining side is implemented with a Job/Worker/Dispatcher pattern (see reference).

A first step is to send the raw data from bitcoin client to the dispatcher which is formating and spliting it into 'Chunks'. Those Chunks are sent to the miners. When a successful block is found, it is sent back to the Dispatcher for verification and back to the WebSocket for submitting to the network (last part to be done).

The overall Bitcoin implementation, but especially the Block Header, tries to stay as close as possible to the reference.

Performance

The current version is able to perform around 350.000 operations (double sha256 hashs) per second on a 2.4 GHz Intel Core i5.

Dependencies

None, beside your Bitcoin client. The btcsuite/btcrpcclient library was used for the JSON-RPC call at the beginning but was recently removed due to its deprecated mining implementation (BIP 0023 again).

Contributors

  • Mathieu Mailhos (@mathieumailhos)

References

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
gobtcminer
client
Package client for interacting with bitcoin client Author: Mathieu Mailhos Filename: client_curl.go
Package client for interacting with bitcoin client Author: Mathieu Mailhos Filename: client_curl.go
config
Package config for reading configuration file Author: Mathieu Mailhos Filename: config.go Description: Read and parse configuration file to enable a proper connection with the Bitcoin client.
Package config for reading configuration file Author: Mathieu Mailhos Filename: config.go Description: Read and parse configuration file to enable a proper connection with the Bitcoin client.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL