Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
554 changes: 277 additions & 277 deletions docs/DEVELOPER_TRACTION_Q1_2026.md

Large diffs are not rendered by default.

412 changes: 206 additions & 206 deletions docs/RIP-305-cross-chain-airdrop.md

Large diffs are not rendered by default.

1,158 changes: 579 additions & 579 deletions ergo-anchor/rustchain_ergo_anchor.py

Large diffs are not rendered by default.

1,238 changes: 619 additions & 619 deletions miners/clawrtc/pow_miners.py

Large diffs are not rendered by default.

1,000 changes: 500 additions & 500 deletions miners/linux/rustchain_living_museum.py

Large diffs are not rendered by default.

714 changes: 357 additions & 357 deletions miners/linux/warthog_sidecar.py

Large diffs are not rendered by default.

1,008 changes: 504 additions & 504 deletions miners/macos/intel/rustchain_mac_miner_v2.4.py

Large diffs are not rendered by default.

1,076 changes: 538 additions & 538 deletions miners/macos/rustchain_mac_miner_v2.4.py

Large diffs are not rendered by default.

1,360 changes: 680 additions & 680 deletions miners/macos/rustchain_mac_miner_v2.5.py

Large diffs are not rendered by default.

998 changes: 499 additions & 499 deletions miners/power8/fingerprint_checks_power8.py

Large diffs are not rendered by default.

818 changes: 409 additions & 409 deletions miners/power8/rustchain_power8_miner.py

Large diffs are not rendered by default.

571 changes: 571 additions & 0 deletions node/arch_cross_validation.py

Large diffs are not rendered by default.

728 changes: 364 additions & 364 deletions node/beacon_x402.py

Large diffs are not rendered by default.

852 changes: 426 additions & 426 deletions node/rip_200_round_robin_1cpu1vote_v2.py

Large diffs are not rendered by default.

816 changes: 408 additions & 408 deletions node/rom_clustering_server.py

Large diffs are not rendered by default.

880 changes: 440 additions & 440 deletions node/rom_fingerprint_db.py

Large diffs are not rendered by default.

1,884 changes: 942 additions & 942 deletions node/rustchain_bft_consensus.py

Large diffs are not rendered by default.

1,494 changes: 747 additions & 747 deletions node/rustchain_block_producer.py

Large diffs are not rendered by default.

1,158 changes: 579 additions & 579 deletions node/rustchain_ergo_anchor.py

Large diffs are not rendered by default.

1,880 changes: 940 additions & 940 deletions node/rustchain_hardware_database.py

Large diffs are not rendered by default.

1,294 changes: 647 additions & 647 deletions node/rustchain_migration.py

Large diffs are not rendered by default.

1,638 changes: 819 additions & 819 deletions node/rustchain_p2p_gossip.py

Large diffs are not rendered by default.

1,550 changes: 775 additions & 775 deletions node/rustchain_tx_handler.py

Large diffs are not rendered by default.

97 changes: 97 additions & 0 deletions node/rustchain_v2_integrated_v2.2.1_rip200.py
Original file line number Diff line number Diff line change
Expand Up @@ -6341,3 +6341,100 @@ def check_hardware_wallet_consistency(hardware_id, miner_wallet, conn):
return False, f'hardware_bound_to_different_wallet:{bound_wallet[:20]}'

return True, 'ok'



# === WALLET HISTORY ENDPOINT (Bounty #908) ===
@app.route('/wallet/history', methods=['GET'])
def get_wallet_history():
'''
Get transaction history for a given wallet/miner ID.

Query params:
- miner_id: Wallet/miner ID to query
- limit: Number of transactions to return (default: 50)
- offset: Offset for pagination (default: 0)

Returns:
JSON with transaction history including rewards and transfers
'''
miner_id = request.args.get('miner_id')
limit = int(request.args.get('limit', 50))
offset = int(request.args.get('offset', 0))

if not miner_id:
return jsonify({'ok': False, 'error': 'miner_id is required'}), 400

try:
transactions = []

# Query epoch_rewards for mining rewards
c = conn.cursor()
c.execute('''
SELECT 'reward' as type, amount, epoch, timestamp, tx_hash
FROM epoch_rewards
WHERE miner_id = ?
ORDER BY epoch DESC
LIMIT ? OFFSET ?
''', (miner_id, limit, offset))

for row in c.fetchall():
transactions.append({
'type': 'reward',
'amount': row[0],
'epoch': row[1],
'timestamp': row[2],
'tx_hash': row[3]
})

# Query ledger for transfers
c.execute('''
SELECT 'transfer_in' as type, from_wallet, amount, timestamp, tx_hash
FROM ledger
WHERE to_wallet = ?
ORDER BY timestamp DESC
LIMIT ? OFFSET ?
''', (miner_id, limit, offset))

for row in c.fetchall():
transactions.append({
'type': 'transfer_in',
'from': row[1],
'amount': row[2],
'timestamp': row[3],
'tx_hash': row[4]
})

c.execute('''
SELECT 'transfer_out' as type, to_wallet, amount, timestamp, tx_hash
FROM ledger
WHERE from_wallet = ?
ORDER BY timestamp DESC
LIMIT ? OFFSET ?
''', (miner_id, limit, offset))

for row in c.fetchall():
transactions.append({
'type': 'transfer_out',
'to': row[1],
'amount': row[2],
'timestamp': row[3],
'tx_hash': row[4]
})

# Sort by timestamp descending
transactions.sort(key=lambda x: x.get('timestamp', ''), reverse=True)

# Get total count
c.execute('SELECT COUNT(*) FROM epoch_rewards WHERE miner_id = ?', (miner_id,))
total = c.fetchone()[0]

return jsonify({
'ok': True,
'miner_id': miner_id,
'transactions': transactions[:limit],
'total': total
})

except Exception as e:
return jsonify({'ok': False, 'error': str(e)}), 500
228 changes: 114 additions & 114 deletions node/rustchain_x402.py
Original file line number Diff line number Diff line change
@@ -1,114 +1,114 @@
"""
RustChain x402 Integration — Swap Info + Coinbase Wallet Linking
Adds /wallet/swap-info and /wallet/link-coinbase endpoints.
Usage in rustchain server:
import rustchain_x402
rustchain_x402.init_app(app, DB_PATH)
"""
import logging
import os
import sqlite3
import time
from flask import jsonify, request
log = logging.getLogger("rustchain.x402")
# Import shared config
try:
import sys
sys.path.insert(0, "/root/shared")
from x402_config import SWAP_INFO, WRTC_BASE, USDC_BASE, AERODROME_POOL
X402_CONFIG_OK = True
except ImportError:
log.warning("x402_config not found — using inline swap info")
X402_CONFIG_OK = False
SWAP_INFO = {
"wrtc_contract": "0x5683C10596AaA09AD7F4eF13CAB94b9b74A669c6",
"usdc_contract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"aerodrome_pool": "0x4C2A0b915279f0C22EA766D58F9B815Ded2d2A3F",
"swap_url": "https://aerodrome.finance/swap?from=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&to=0x5683C10596AaA09AD7F4eF13CAB94b9b74A669c6",
"network": "Base (eip155:8453)",
"reference_price_usd": 0.10,
}
COINBASE_MIGRATION = "ALTER TABLE balances ADD COLUMN coinbase_address TEXT DEFAULT NULL"
def _run_migration(db_path):
"""Add coinbase_address column to balances if missing."""
conn = sqlite3.connect(db_path)
cursor = conn.execute("PRAGMA table_info(balances)")
existing = {row[1] for row in cursor.fetchall()}
if "coinbase_address" not in existing:
try:
conn.execute(COINBASE_MIGRATION)
conn.commit()
log.info("Added coinbase_address column to balances")
except sqlite3.OperationalError:
pass
conn.close()
def init_app(app, db_path):
"""Register x402 routes on the RustChain Flask app."""
try:
_run_migration(db_path)
except Exception as e:
log.error(f"RustChain x402 migration failed: {e}")
@app.route("/wallet/swap-info", methods=["GET"])
def wallet_swap_info():
"""Returns Aerodrome pool info for USDC→wRTC swap guidance."""
return jsonify(SWAP_INFO)
@app.route("/wallet/link-coinbase", methods=["PATCH", "POST"])
def wallet_link_coinbase():
"""Link a Coinbase Base address to a miner_id. Requires admin key."""
admin_key = request.headers.get("X-Admin-Key", "") or request.headers.get("X-API-Key", "")
expected = os.environ.get("RC_ADMIN_KEY", "rustchain_admin_key_2025_secure64")
if admin_key != expected:
return jsonify({"error": "Unauthorized — admin key required"}), 401
data = request.get_json(silent=True) or {}
miner_id = data.get("miner_id", "").strip()
coinbase_address = data.get("coinbase_address", "").strip()
if not miner_id:
return jsonify({"error": "miner_id is required"}), 400
if not coinbase_address or not coinbase_address.startswith("0x") or len(coinbase_address) != 42:
return jsonify({"error": "Invalid Base address (must be 0x + 40 hex chars)"}), 400
conn = sqlite3.connect(db_path)
row = conn.execute(
"SELECT miner_id FROM balances WHERE miner_id = ?", (miner_id,)
).fetchone()
if not row:
# Try miner_pk
row = conn.execute(
"SELECT miner_id FROM balances WHERE miner_pk = ?", (miner_id,)
).fetchone()
if not row:
conn.close()
return jsonify({"error": f"Miner '{miner_id}' not found in balances"}), 404
actual_id = row[0]
conn.execute(
"UPDATE balances SET coinbase_address = ? WHERE miner_id = ?",
(coinbase_address, actual_id),
)
conn.commit()
conn.close()
return jsonify({
"ok": True,
"miner_id": actual_id,
"coinbase_address": coinbase_address,
"network": "Base (eip155:8453)",
})
log.info("RustChain x402 module initialized")
"""
RustChain x402 Integration — Swap Info + Coinbase Wallet Linking
Adds /wallet/swap-info and /wallet/link-coinbase endpoints.

Usage in rustchain server:
import rustchain_x402
rustchain_x402.init_app(app, DB_PATH)
"""

import logging
import os
import sqlite3
import time

from flask import jsonify, request

log = logging.getLogger("rustchain.x402")

# Import shared config
try:
import sys
sys.path.insert(0, "/root/shared")
from x402_config import SWAP_INFO, WRTC_BASE, USDC_BASE, AERODROME_POOL
X402_CONFIG_OK = True
except ImportError:
log.warning("x402_config not found — using inline swap info")
X402_CONFIG_OK = False
SWAP_INFO = {
"wrtc_contract": "0x5683C10596AaA09AD7F4eF13CAB94b9b74A669c6",
"usdc_contract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"aerodrome_pool": "0x4C2A0b915279f0C22EA766D58F9B815Ded2d2A3F",
"swap_url": "https://aerodrome.finance/swap?from=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&to=0x5683C10596AaA09AD7F4eF13CAB94b9b74A669c6",
"network": "Base (eip155:8453)",
"reference_price_usd": 0.10,
}


COINBASE_MIGRATION = "ALTER TABLE balances ADD COLUMN coinbase_address TEXT DEFAULT NULL"


def _run_migration(db_path):
"""Add coinbase_address column to balances if missing."""
conn = sqlite3.connect(db_path)
cursor = conn.execute("PRAGMA table_info(balances)")
existing = {row[1] for row in cursor.fetchall()}
if "coinbase_address" not in existing:
try:
conn.execute(COINBASE_MIGRATION)
conn.commit()
log.info("Added coinbase_address column to balances")
except sqlite3.OperationalError:
pass
conn.close()


def init_app(app, db_path):
"""Register x402 routes on the RustChain Flask app."""

try:
_run_migration(db_path)
except Exception as e:
log.error(f"RustChain x402 migration failed: {e}")

@app.route("/wallet/swap-info", methods=["GET"])
def wallet_swap_info():
"""Returns Aerodrome pool info for USDC→wRTC swap guidance."""
return jsonify(SWAP_INFO)

@app.route("/wallet/link-coinbase", methods=["PATCH", "POST"])
def wallet_link_coinbase():
"""Link a Coinbase Base address to a miner_id. Requires admin key."""
admin_key = request.headers.get("X-Admin-Key", "") or request.headers.get("X-API-Key", "")
expected = os.environ.get("RC_ADMIN_KEY", "rustchain_admin_key_2025_secure64")
if admin_key != expected:
return jsonify({"error": "Unauthorized — admin key required"}), 401

data = request.get_json(silent=True) or {}
miner_id = data.get("miner_id", "").strip()
coinbase_address = data.get("coinbase_address", "").strip()

if not miner_id:
return jsonify({"error": "miner_id is required"}), 400
if not coinbase_address or not coinbase_address.startswith("0x") or len(coinbase_address) != 42:
return jsonify({"error": "Invalid Base address (must be 0x + 40 hex chars)"}), 400

conn = sqlite3.connect(db_path)
row = conn.execute(
"SELECT miner_id FROM balances WHERE miner_id = ?", (miner_id,)
).fetchone()
if not row:
# Try miner_pk
row = conn.execute(
"SELECT miner_id FROM balances WHERE miner_pk = ?", (miner_id,)
).fetchone()
if not row:
conn.close()
return jsonify({"error": f"Miner '{miner_id}' not found in balances"}), 404

actual_id = row[0]
conn.execute(
"UPDATE balances SET coinbase_address = ? WHERE miner_id = ?",
(coinbase_address, actual_id),
)
conn.commit()
conn.close()

return jsonify({
"ok": True,
"miner_id": actual_id,
"coinbase_address": coinbase_address,
"network": "Base (eip155:8453)",
})

log.info("RustChain x402 module initialized")
Loading