Add parasite block template analysis #58

Merged
eztvdpqx5 merged 13 commits from parasite-stratum into master 2025-06-25 17:46:48 +00:00
eztvdpqx5 commented 2025-06-13 14:57:11 +00:00 (Migrated from github.com)

Implements live block template analysis from Parasite pool.

Key Features

  • Live TCP connection to parasite.wtf:42069 with auto-reconnection
  • Real-time /template page displaying latest mining notifications
  • Advanced coinbase analysis with Bitcoin transaction decoding
  • Database storage of stratum notifications with cleanup

Technical Changes

  • lib/stratum-collector.ts - TCP client with exponential backoff
  • app/template/page.tsx - Live block template viewer
  • app/api/stratum/route.ts - REST API for stratum data
  • Extended database schema with stratum_notifications table
  • Added bitcoinjs-lib for transaction parsing

Components Added

  • Block template analysis UI with merkle tree visualization
  • Coinbase transaction decoder with OP_RETURN parsing
  • Connection status indicator with real-time updates
  • Support for merged mining and auxiliary protocol detection

Database Schema

CREATE TABLE stratum_notifications (
  id TEXT PRIMARY KEY,
  timestamp INTEGER NOT NULL,
  pool TEXT NOT NULL,
  job_id TEXT NOT NULL,
  prev_block_hash TEXT NOT NULL,
  coinbase1 TEXT NOT NULL,
  coinbase2 TEXT NOT NULL,
  merkle_branches TEXT NOT NULL,
  version TEXT NOT NULL,
  n_bits TEXT NOT NULL,
  n_time TEXT NOT NULL,
  clean_jobs BOOLEAN NOT NULL,
  extranonce1 TEXT,
  extranonce2_size INTEGER,
  raw_message TEXT NOT NULL,
  created_at INTEGER NOT NULL
);
Implements live block template analysis from Parasite pool. ### Key Features - **Live TCP connection** to `parasite.wtf:42069` with auto-reconnection - **Real-time `/template` page** displaying latest mining notifications - **Advanced coinbase analysis** with Bitcoin transaction decoding - **Database storage** of stratum notifications with cleanup ### Technical Changes - `lib/stratum-collector.ts` - TCP client with exponential backoff - `app/template/page.tsx` - Live block template viewer - `app/api/stratum/route.ts` - REST API for stratum data - Extended database schema with `stratum_notifications` table - Added `bitcoinjs-lib` for transaction parsing ### Components Added - Block template analysis UI with merkle tree visualization - Coinbase transaction decoder with OP_RETURN parsing - Connection status indicator with real-time updates - Support for merged mining and auxiliary protocol detection ### Database Schema ```sql CREATE TABLE stratum_notifications ( id TEXT PRIMARY KEY, timestamp INTEGER NOT NULL, pool TEXT NOT NULL, job_id TEXT NOT NULL, prev_block_hash TEXT NOT NULL, coinbase1 TEXT NOT NULL, coinbase2 TEXT NOT NULL, merkle_branches TEXT NOT NULL, version TEXT NOT NULL, n_bits TEXT NOT NULL, n_time TEXT NOT NULL, clean_jobs BOOLEAN NOT NULL, extranonce1 TEXT, extranonce2_size INTEGER, raw_message TEXT NOT NULL, created_at INTEGER NOT NULL ); ```
eztvdpqx5 commented 2025-06-13 16:05:59 +00:00 (Migrated from github.com)

added the db directory to be able to use env variable to help with issue #57

added the db directory to be able to use env variable to help with issue #57
parabitdev (Migrated from github.com) reviewed 2025-06-16 18:00:59 +00:00
@ -0,0 +13,4 @@
```typescript
const authorizeMsg = {
method: "mining.authorize",
params: ["1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa", "x"] // Bitcoin address + "x"
parabitdev (Migrated from github.com) commented 2025-06-16 18:00:59 +00:00

x is 'password' not concatenated with username. No change required, just documenting for future reference.

x is 'password' not concatenated with username. No change required, just documenting for future reference.
parabitdev (Migrated from github.com) reviewed 2025-06-16 18:04:43 +00:00
@ -0,0 +1,408 @@
import net from 'net';
parabitdev (Migrated from github.com) commented 2025-06-16 18:04:43 +00:00

If you move the notification.id to a field other than id you could use a SERIAL type for id and forgo needing an index on created_at. Also, aren't notifications a bit spammy, how much traffic and deletion records were you seeing with this, does it impact performance since it is only working in-memory?

If you move the notification.id to a field other than id you could use a SERIAL type for id and forgo needing an index on created_at. Also, aren't notifications a bit spammy, how much traffic and deletion records were you seeing with this, does it impact performance since it is only working in-memory?
eztvdpqx5 (Migrated from github.com) reviewed 2025-06-17 03:52:52 +00:00
@ -0,0 +1,408 @@
import net from 'net';
eztvdpqx5 (Migrated from github.com) commented 2025-06-17 03:52:52 +00:00

okay, that makes sense. I pushed some changes, but don't have time to test right now. Will try to do so tomorrow

okay, that makes sense. I pushed some changes, but don't have time to test right now. Will try to do so tomorrow
parabitdev (Migrated from github.com) requested changes 2025-06-23 19:12:57 +00:00
@ -0,0 +1,410 @@
"use client";
parabitdev (Migrated from github.com) commented 2025-06-23 19:12:19 +00:00

If this is our testing placeholder address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa we should replace it with some indicator that this will be the users address. Currently it isn't intuitive that their output is being paid directly to the user.

Same for our lightning deposit address bc1qkgef7pl8vdrtuc4wk8fssycz366xp5ukzsm8gp which should be appended with (lightning deposit address)

If this is our testing placeholder address `1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa` we should replace it with some indicator that this will be the users address. Currently it isn't intuitive that their output is being paid directly to the user. Same for our lightning deposit address `bc1qkgef7pl8vdrtuc4wk8fssycz366xp5ukzsm8gp` which should be appended with `(lightning deposit address)`
eztvdpqx5 (Migrated from github.com) reviewed 2025-06-24 03:05:35 +00:00
@ -0,0 +1,410 @@
"use client";
eztvdpqx5 (Migrated from github.com) commented 2025-06-24 03:05:35 +00:00

Took me awhile to figure out what is going on here, but I see now. So that address is actually whatever address is used to connect to the stratum server. I am using 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa or satoshi's address just to connect, while it looks like like stratum.work uses 1FfmbHfnpaZjKFvyi1okTjJJusN455paPH which is silk road...what its really saying is the address that is connected would get the 1btc reward if it found it, so I will update that and actually not show the address. I understand now

Took me awhile to figure out what is going on here, but I see now. So that address is actually whatever address is used to connect to the stratum server. I am using 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa or satoshi's address just to connect, while it looks like like stratum.work uses 1FfmbHfnpaZjKFvyi1okTjJJusN455paPH which is silk road...what its really saying is the address that is connected would get the 1btc reward if it found it, so I will update that and actually not show the address. I understand now
eztvdpqx5 commented 2025-06-24 03:33:10 +00:00 (Migrated from github.com)

okay, i think i have those changes in there now

okay, i think i have those changes in there now
parabitdev (Migrated from github.com) reviewed 2025-06-24 23:42:19 +00:00
@ -0,0 +1,410 @@
"use client";
parabitdev (Migrated from github.com) commented 2025-06-24 23:42:19 +00:00

Exactly! It can be a bit disorienting at first as you have to remember that the template you receive is based on your username that you send us. :D

Exactly! It can be a bit disorienting at first as you have to remember that the template you receive is based on your username that you send us. :D
parabitdev (Migrated from github.com) approved these changes 2025-06-25 17:19:43 +00:00
parabitdev (Migrated from github.com) left a comment

lgtm, may have a few nits for another time, but it appears to be rtm

lgtm, may have a few nits for another time, but it appears to be rtm
Sign in to join this conversation.
No description provided.