Skip to content

Instantly share code, notes, and snippets.

View gertjaap's full-sized avatar

Gert-Jaap Glasbergen gertjaap

View GitHub Profile
@gertjaap
gertjaap / dlcflow
Last active April 13, 2018 14:35
Message flow for DLC
// Structure for storing the contract data
type DlcContract struct {
Idx uint64 // Index of the contract for referencing in commands
ContractPubKey [33]byte // Unique key for the contract so we can reference it in messages (accept/decline) in case we have more than one contract between two peers
CoinType uint32 // Coin type
OracleA [33]byte // Pub keys of the oracle
OracleR [33]byte // Pub key of the data point we are using
OracleTimestamp uint64 // Expected timestamp (epoch) of publication
ValueAllOurs, ValueAllTheirs uint64 // The values of the data point based on which all money in the contract goes to either party
@gertjaap
gertjaap / lint.txt
Created June 20, 2019 18:31
Lint output
share/qt/extract_strings_qt.py:58: invalid syntax at "print('Cannot extract strings: xgettext utility is not installed or not configured.',file=sys.stderr)"
test/functional/combine_logs.py:53: invalid syntax at "print("Opening latest test directory: {}".format(testdir), file=sys.stderr)"
test/functional/feature_block.py:1281: invalid syntax at "def next_block(self, number, spend=None, additional_coinbase_value=0, script=CScript([OP_TRUE]), solve=True, *, version=1):"
test/functional/feature_help.py:19: invalid syntax at "def get_node_output(self, *, ret_code_expected):"
test/functional/mining_basic.py:191: invalid syntax at "def chain_tip(b_hash, *, status='headers-only', branchlen=1):"
test/functional/p2p_invalid_messages.py:20: invalid syntax at "def __init__(self, *, str_data):"
test/functional/p2p_invalid_tx.py:30: invalid syntax at "def bootstrap_p2p(self, *, num_connections=1):"
test/functional/test_framework/blocktools.py:52: invalid syntax at "def create_block(hashprev, coinbase, ntime=None, *, versio
@gertjaap
gertjaap / NHMON.md
Last active December 4, 2019 18:57
Nicehash monitor

Nicehash monitor

The idea is simple. We build a proxy that connects to Nicehash as one or more stratum clients (both EU and US endpoints preferably), and acts as a stratum server to miners.

The work that Nicehash sends contains the previousBlockHash. We run full nodes to all coins using Lyra2REv3, and index those blocks. We can then lookup the previousBlockHash that's part of the stratum work in our set of known blocks. If it is absent from there, there is most likely someone privately mining blocks.

We add a public frontend to this data that shows all work on blockhashes not matching any known public blocks. We keep the work given to the miner archived in a database, so that in case of an actual reorg we can prove Nicehash was used to conduct the attack.

The reason for actually mining versus just connecting to stratum and reading work, is that Nicehash will eventually kick you off their stratum server if you don't submit any work.