Giter Club home page Giter Club logo

hashhunt.josh.com's Introduction

hashhunt.josh.com

First one to find the hash wins a bitcoin!

Static web site (called docs)

here

The html/css/js that is served to the client. It locally generates the keys and gets other info to generate a block template from the server over a websocket.

Can be served from anywhere since the websocket host URLs are hard coded in.

Why is it called docs? Because that is the only folder name you can use with github pages. :/

Test mode

There is a parallel set of servers and nodes set up on a regtest blockchain for testing. The puzzles on this system are much easier to solve, but the prizes are possibly less valuable.

To tell the client to use the test mode infrastructure, add "?testmode=1" to the end of the URL.

Server

here Node.js websocket server. Responsible for...

  • sending live info about the block currently being mined to new clients
  • sending notifications to all clients whenever a new best block is mined
  • accepting mined blocks from clients and submitting them to the network

The server listens on port 81 for (1) /blocknotify as either a GET or PUT with info on a new block (thePUT takes the JSON that bitcoin-core getblock outputs), or (2) /status which shows a list of currently connected websocket clients.

Note that the server does check incoming mined blocks to make sure that they come from hash hunt before submitting them to bitcoin-core.

Connections to bitcoin-core

here

The websocket server interacts with an existing bitcoin-core node via RPC using a couple of scripts.

New best block on the network

Whenever the bitcoin-core node gets a new block, it calls our blocknotify script which retrieves the header for the new block and then sends it to the websocket server as JSON over an http connection (the websocket server has an internal HTTP server that listens for these updates as POST or GET requests).

Hash Hunt win

Whenever a player finds a valid block, it is submitted to the server over the websocket connection using the submitblock script. The server does some cursory validity checks before submitting to avoid DOS attacks.. The player can independently check if the block was accepted by the node and the network using any wallet or blockchain explorer.

Installation

  1. Install bitcoin-core and let it catch up. Run on testnet or regtest if you want a better chance of winning at the cost of the winning being worth much less.
  2. Clone this repo.
  3. Edit the bitcoin-core config file so the block-notify is equal to the path to the blocknotifyscript (.bat or .sh depending on which way you swing) in this repo. Example here.
  4. If you are running on a test net, Edit the bitcoin-core config file so rpcport=8332. Example here.
  5. Edit the blocknotify and submitblock scripts in this repo and set correct paths for datadir depending on how/where bitcoin-core is set up. The bitcoin-cli shouldn't but needs this.
  6. Add the path to the bitcoin-cli.exe executable to the path environment variable.
  7. Install node.js.
  8. Goto the node-server folder in this repo and do npm install to install the needed modules.
  9. Start the server with the command node index.js inside the node-server directory.
  10. Serve the static website from somewhere (I use github pages so that folder is called docs).

Copying

All of this is (c) 2021 Josh Levine so please do not use it without asking me first. I will hashhunt down anyone who tries to use this code in ways that dilute the message or who try to fool players.

If you see something like hashhunt running anywhere except hashhunt.josh.com please let me know!

hashhunt.josh.com's People

Contributors

bigjosh avatar bigjoshlevine-aws avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.