bug fixing and deploy and build diagnostics

This commit is contained in:
Dorian
2026-03-22 03:30:21 +00:00
parent 01942cea95
commit 13e4a738be
198 changed files with 21703 additions and 19587 deletions
+492
View File
@@ -913,6 +913,10 @@ app.post('/rpc/v1', (req, res) => {
return res.json({ result: { signature: mockSig } })
}
case 'identity.verify': {
return res.json({ result: { valid: true } })
}
case 'node.createBackup': {
const { passphrase } = params || {}
if (!passphrase) {
@@ -1247,6 +1251,186 @@ app.post('/rpc/v1', (req, res) => {
return res.json({ result: { success: true } })
}
case 'identity.list': {
return res.json({
result: {
identities: [
{
id: 'id-primary',
name: 'Primary',
purpose: 'Main node identity',
pubkey: 'a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456',
did: 'did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH',
created_at: '2026-01-10T08:00:00Z',
is_default: true,
nostr_pubkey: 'a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456',
nostr_npub: 'npub1mockprimaryidentitypubkeyvalue0000000000000000000000000abc',
profile: {
display_name: 'Archipelago Node',
about: 'Self-sovereign Bitcoin node',
nip05: 'satoshi@archipelago.local',
lud16: 'satoshi@getalby.com',
},
},
{
id: 'id-anon',
name: 'Anonymous',
purpose: 'Privacy-focused browsing',
pubkey: 'f6e5d4c3b2a19876543210fedcba9876543210fedcba9876543210fedcba98',
did: 'did:key:z6MkvWkza1fMBWhKnYE3CgMgxHLKbN8NmbFRqHcECF4oGrwx',
created_at: '2026-02-14T12:30:00Z',
is_default: false,
nostr_pubkey: 'f6e5d4c3b2a19876543210fedcba9876543210fedcba9876543210fedcba98',
nostr_npub: 'npub1mockanonidentitypubkeyvalue000000000000000000000000000xyz',
profile: { display_name: 'Anon' },
},
{
id: 'id-merchant',
name: 'Merchant',
purpose: 'BTCPay & commerce',
pubkey: '1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
did: 'did:key:z6MknGc3ocHs3zdPiJbnaaqDi58NGb4pk1Sp9WNhSwaxN21V',
created_at: '2026-03-01T16:00:00Z',
is_default: false,
nostr_pubkey: '1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
nostr_npub: 'npub1mockmerchantidentitypubkeyvalue000000000000000000000000def',
profile: { display_name: 'My Shop', website: 'https://myshop.onion' },
},
],
},
})
}
case 'identity.get': {
const id = params?.id || 'id-primary'
return res.json({
result: {
id,
name: 'Primary',
purpose: 'Main node identity',
pubkey: 'a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456',
did: 'did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH',
created_at: '2026-01-10T08:00:00Z',
is_default: true,
nostr_pubkey: 'a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456',
nostr_npub: 'npub1mockprimaryidentitypubkeyvalue0000000000000000000000000abc',
profile: {
display_name: 'Archipelago Node',
about: 'Self-sovereign Bitcoin node',
},
},
})
}
case 'identity.export-keys': {
return res.json({
result: {
ed25519_secret_hex: 'deadbeef'.repeat(8),
nostr_secret_hex: 'cafebabe'.repeat(8),
nostr_nsec: 'nsec1mockexportedkeyvalue00000000000000000000000000000000000abc',
},
})
}
case 'identity.update-profile': {
return res.json({ result: { success: true } })
}
case 'identity.publish-profile': {
return res.json({ result: { event_id: `evt-${Date.now().toString(36)}` } })
}
case 'identity.list': {
return res.json({
result: {
identities: [
{
id: 'id-primary',
name: 'Primary',
purpose: 'personal',
pubkey: 'a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456',
did: 'did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH',
created_at: '2026-01-10T08:00:00Z',
is_default: true,
nostr_pubkey: 'a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456',
nostr_npub: 'npub1598eg0y7m08htfzjfmzv6zjvf5u7p00dr9w0yfamaxqhkwlryckq5dh9ee',
profile: {
display_name: 'Satoshi',
about: 'Running a sovereign Bitcoin node',
nip05: 'satoshi@archipelago.local',
lud16: 'satoshi@getalby.com',
},
},
{
id: 'id-business',
name: 'Business',
purpose: 'business',
pubkey: 'f6e5d4c3b2a10987654321fedcba0987654321fedcba0987654321fedcba0987',
did: 'did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2ReMkBe4bR6XBIDNq9',
created_at: '2026-02-05T12:30:00Z',
is_default: false,
nostr_pubkey: 'f6e5d4c3b2a10987654321fedcba0987654321fedcba0987654321fedcba0987',
nostr_npub: 'npub17m9mx9kk2ry8p3xfkq0070fjlph9r9l0dj0y8fn0zrlj80ekjph7jxmxfg',
profile: {
display_name: 'Archy Consulting',
about: 'Bitcoin infrastructure services',
},
},
{
id: 'id-anon',
name: 'Anonymous',
purpose: 'anonymous',
pubkey: 'deadbeef00112233445566778899aabbccddeeff00112233445566778899aabb',
did: 'did:key:z6MknGc3ocHs3zdPiJbnaaqDi5hjrZo4HzmQnwzaxWhAbWAs',
created_at: '2026-03-01T18:00:00Z',
is_default: false,
profile: {},
},
],
},
})
}
case 'identity.get': {
const id = params?.id || 'id-primary'
const identities = {
'id-primary': {
id: 'id-primary', name: 'Primary', purpose: 'personal',
pubkey: 'a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456',
did: 'did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH',
nostr_pubkey: 'a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456',
nostr_npub: 'npub1598eg0y7m08htfzjfmzv6zjvf5u7p00dr9w0yfamaxqhkwlryckq5dh9ee',
is_default: true, created_at: '2026-01-10T08:00:00Z',
profile: { display_name: 'Satoshi', about: 'Running a sovereign Bitcoin node' },
},
}
return res.json({ result: identities[id] || identities['id-primary'] })
}
case 'identity.export-keys': {
const { password } = params || {}
if (password !== MOCK_PASSWORD) {
return res.json({ error: { code: -32603, message: 'Incorrect password' } })
}
return res.json({
result: {
ed25519_secret_hex: 'mock_ed25519_secret_' + '0'.repeat(40),
nostr_secret_hex: 'mock_nostr_secret_' + '0'.repeat(44),
nostr_nsec: 'nsec1mockkeymockkeymockkeymockkeymockkeymockkeymockkeymockkeymo',
},
})
}
case 'identity.update-profile': {
console.log(`[Identity] Updated profile for: ${params?.id}`)
return res.json({ result: { success: true } })
}
case 'identity.publish-profile': {
console.log(`[Identity] Published profile for: ${params?.id}`)
return res.json({ result: { event_id: `nostr-event-${Date.now().toString(36)}` } })
}
// =========================================================================
// Nostr
// =========================================================================
@@ -1267,6 +1451,19 @@ app.post('/rpc/v1', (req, res) => {
// =========================================================================
// Content & Network
// =========================================================================
case 'content.browse-peer': {
const onion = params?.onion || ''
return res.json({
result: {
items: [
{ id: 'peer-doc-1', filename: 'Bitcoin Whitepaper.pdf', mime_type: 'application/pdf', size_bytes: 184292, description: 'The original Bitcoin whitepaper by Satoshi Nakamoto', access: 'free' },
{ id: 'peer-img-1', filename: 'node-setup-guide.png', mime_type: 'image/png', size_bytes: 524800, description: 'Visual guide for setting up a Bitcoin node', access: 'free' },
{ id: 'peer-vid-1', filename: 'Lightning Demo.mp4', mime_type: 'video/mp4', size_bytes: 15728640, description: 'Lightning Network payment channel demo', access: { paid: { price_sats: 500 } } },
],
},
})
}
case 'content.remove': {
return res.json({ result: { success: true } })
}
@@ -1275,6 +1472,66 @@ app.post('/rpc/v1', (req, res) => {
return res.json({ result: { success: true } })
}
case 'network.diagnostics': {
return res.json({
result: {
wan_ip: '82.14.203.47',
nat_type: 'Full Cone',
upnp_available: true,
tor_connected: true,
wifi_count: 3,
},
})
}
case 'network.list-interfaces': {
return res.json({
result: {
interfaces: [
{ name: 'eth0', type: 'ethernet', state: 'up', mac: 'a8:a1:59:3c:f2:10', ipv4: ['192.168.1.228/24'] },
{ name: 'wlan0', type: 'wifi', state: 'up', mac: 'dc:a6:32:12:ab:cd', ipv4: ['192.168.1.230/24'] },
{ name: 'lo', type: 'loopback', state: 'up', mac: '00:00:00:00:00:00', ipv4: ['127.0.0.1/8'] },
{ name: 'podman0', type: 'bridge', state: 'up', mac: '2e:f4:8a:11:22:33', ipv4: ['10.89.0.1/16'] },
{ name: 'tailscale0', type: 'tunnel', state: 'up', mac: '', ipv4: ['100.82.97.63/32'] },
],
},
})
}
case 'network.scan-wifi': {
return res.json({
result: {
networks: [
{ ssid: 'HomeNetwork', signal: 92, security: 'WPA2' },
{ ssid: 'Neighbor-5G', signal: 45, security: 'WPA3' },
{ ssid: 'CoffeeShop', signal: 30, security: 'Open' },
],
},
})
}
case 'network.configure-wifi': {
console.log(`[Network] Connecting to WiFi: ${params?.ssid}`)
return res.json({ result: { success: true } })
}
case 'network.dns-status': {
return res.json({
result: {
provider: 'system',
servers: ['1.1.1.1', '9.9.9.9'],
doh_enabled: false,
doh_url: null,
resolv_conf_servers: ['1.1.1.1', '9.9.9.9'],
},
})
}
case 'network.configure-dns': {
console.log(`[Network] DNS configured: ${params?.provider}`)
return res.json({ result: { success: true } })
}
case 'network.accept-request': {
return res.json({ result: { success: true } })
}
@@ -1323,9 +1580,35 @@ app.post('/rpc/v1', (req, res) => {
return res.json({ result: { success: true } })
}
case 'router.list-forwards': {
return res.json({
result: {
forwards: [
{ id: 'fwd-1', name: 'Bitcoin P2P', external_port: 8333, internal_port: 8333, protocol: 'tcp', enabled: true },
{ id: 'fwd-2', name: 'LND gRPC', external_port: 10009, internal_port: 10009, protocol: 'tcp', enabled: true },
],
},
})
}
// =========================================================================
// Tor & Peer Networking
// =========================================================================
case 'tor.list-services': {
return res.json({
result: {
tor_running: true,
services: [
{ name: 'archipelago', local_port: 5678, onion_address: 'archydemox7k3pnw4hv5qz2jcbr6dwefys3ockqzf4mzjlvxot2ioad.onion', enabled: true, unauthenticated: false, protocol: false },
{ name: 'bitcoin', local_port: 8333, onion_address: 'btcmockxj4k5pnw7hv8qz9jcbr2dwefys6ockqzf1mzjlvxot5ioad.onion', enabled: true, unauthenticated: false, protocol: false },
{ name: 'lnd', local_port: 9735, onion_address: 'lndmockab3c4def5ghi6jkl7mno8pqr9stu0vwx1yz2ab3c4def5ghi.onion', enabled: true, unauthenticated: false, protocol: false },
{ name: 'electrs', local_port: 50001, onion_address: 'elecmockyz9wvu8tsr7qpo6nml5kji4hgf3edc2ba1xyz9wvu8tsr7q.onion', enabled: true, unauthenticated: true, protocol: false },
{ name: 'nostr-relay', local_port: 7777, onion_address: null, enabled: false, unauthenticated: true, protocol: false },
],
},
})
}
case 'node.tor-address': {
return res.json({
result: {
@@ -1815,6 +2098,88 @@ app.post('/rpc/v1', (req, res) => {
})
}
case 'mesh.deadman-status': {
return res.json({
result: {
dead_man_enabled: false,
dead_man_interval_secs: 21600,
time_remaining_secs: 21600,
triggered: false,
has_gps: false,
emergency_contacts: 2,
},
})
}
case 'mesh.deadman-configure': {
const { enabled, interval_secs } = params || {}
console.log(`[Mesh] Deadman configured: enabled=${enabled}, interval=${interval_secs}`)
return res.json({
result: {
dead_man_enabled: enabled ?? false,
dead_man_interval_secs: interval_secs ?? 21600,
time_remaining_secs: interval_secs ?? 21600,
triggered: false,
has_gps: false,
emergency_contacts: 2,
},
})
}
case 'mesh.deadman-checkin': {
return res.json({
result: {
checked_in: true,
time_remaining_secs: 21600,
},
})
}
case 'mesh.block-headers': {
return res.json({
result: {
headers: [
{ height: 893421, hash: '0000000000000000000234a6b12dc03e5c4f7e891d2f34b5a678cd9012345678', timestamp: new Date(Date.now() - 600000).toISOString() },
{ height: 893420, hash: '00000000000000000001bc7d89ef01234567890abcdef1234567890abcdef12', timestamp: new Date(Date.now() - 1200000).toISOString() },
{ height: 893419, hash: '00000000000000000003ef4a56789012bcdef34567890abcdef1234567890ab', timestamp: new Date(Date.now() - 1800000).toISOString() },
],
latest_height: 893421,
count: 3,
},
})
}
case 'mesh.relay-tx': {
return res.json({
result: {
request_id: Math.floor(Math.random() * 10000),
queued: true,
tx_hex_len: (params?.tx_hex || '').length,
},
})
}
case 'mesh.relay-status': {
return res.json({
result: {
relayed: true,
pending_count: 0,
status: 'confirmed',
txid: 'a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456',
},
})
}
case 'mesh.relay-lightning': {
return res.json({
result: {
request_id: Math.floor(Math.random() * 10000),
queued: true,
amount_sats: params?.amount_sats || 0,
},
})
}
// =====================================================================
// Transport Layer (unified routing: mesh > lan > tor)
// =====================================================================
@@ -2205,6 +2570,133 @@ app.post('/rpc/v1', (req, res) => {
mockState.analyticsEnabled = false
return res.json({ result: { enabled: false } })
}
case 'telemetry.fleet-status': {
return res.json({
result: {
nodes: [
{
node_id: 'archy-228',
version: '0.1.0',
uptime_secs: 604800,
cpu_cores: 4,
cpu_pct: +(15 + Math.random() * 20).toFixed(1),
mem_pct: +(38 + Math.random() * 10).toFixed(1),
disk_pct: 34.2,
container_count: 12,
running_count: 10,
federation_peers: 4,
recent_alerts: [],
containers: [
{ id: 'bitcoin', state: 'running', version: '27.0' },
{ id: 'lnd', state: 'running', version: '0.18.0' },
{ id: 'electrs', state: 'running', version: '0.10.6' },
{ id: 'mempool', state: 'running', version: '3.0.0' },
],
reported_at: new Date().toISOString(),
},
{
node_id: 'archy-198',
version: '0.1.0',
uptime_secs: 259200,
cpu_cores: 4,
cpu_pct: +(8 + Math.random() * 12).toFixed(1),
mem_pct: +(25 + Math.random() * 8).toFixed(1),
disk_pct: 22.7,
container_count: 8,
running_count: 7,
federation_peers: 4,
recent_alerts: [{ rule: 'container_crash', message: 'electrs restarted 2x in 1h', timestamp: new Date(Date.now() - 7200000).toISOString() }],
containers: [
{ id: 'bitcoin', state: 'running', version: '27.0' },
{ id: 'lnd', state: 'running', version: '0.18.0' },
{ id: 'electrs', state: 'running', version: '0.10.6' },
],
reported_at: new Date(Date.now() - 60000).toISOString(),
},
{
node_id: 'arch-1',
version: '0.1.0',
uptime_secs: 172800,
cpu_cores: 2,
cpu_pct: +(5 + Math.random() * 10).toFixed(1),
mem_pct: +(45 + Math.random() * 15).toFixed(1),
disk_pct: 61.3,
container_count: 6,
running_count: 6,
federation_peers: 4,
recent_alerts: [],
containers: [
{ id: 'bitcoin', state: 'running', version: '27.0' },
{ id: 'lnd', state: 'running', version: '0.18.0' },
],
reported_at: new Date(Date.now() - 120000).toISOString(),
},
{
node_id: 'arch-2',
version: '0.1.0',
uptime_secs: 86400,
cpu_cores: 2,
cpu_pct: +(3 + Math.random() * 8).toFixed(1),
mem_pct: +(30 + Math.random() * 10).toFixed(1),
disk_pct: 18.9,
container_count: 5,
running_count: 5,
federation_peers: 4,
recent_alerts: [],
containers: [
{ id: 'bitcoin', state: 'running', version: '27.0' },
],
reported_at: new Date(Date.now() - 300000).toISOString(),
},
{
node_id: 'arch-3',
version: '0.1.0',
uptime_secs: 43200,
cpu_cores: 4,
cpu_pct: +(20 + Math.random() * 15).toFixed(1),
mem_pct: +(55 + Math.random() * 10).toFixed(1),
disk_pct: 47.5,
container_count: 10,
running_count: 9,
federation_peers: 4,
recent_alerts: [{ rule: 'disk_warning', message: 'Disk usage approaching 50%', timestamp: new Date(Date.now() - 3600000).toISOString() }],
containers: [
{ id: 'bitcoin', state: 'running', version: '27.0' },
{ id: 'lnd', state: 'running', version: '0.18.0' },
{ id: 'electrs', state: 'running', version: '0.10.6' },
{ id: 'mempool', state: 'running', version: '3.0.0' },
],
reported_at: new Date(Date.now() - 30000).toISOString(),
},
],
},
})
}
case 'telemetry.fleet-alerts': {
return res.json({
result: {
alerts: [
{ node_id: 'archy-198', rule: 'container_crash', message: 'electrs restarted 2x in 1h', timestamp: new Date(Date.now() - 7200000).toISOString() },
{ node_id: 'arch-3', rule: 'disk_warning', message: 'Disk usage approaching 50%', timestamp: new Date(Date.now() - 3600000).toISOString() },
{ node_id: 'arch-1', rule: 'mem_high', message: 'Memory usage above 60%', timestamp: new Date(Date.now() - 86400000).toISOString() },
],
},
})
}
case 'telemetry.fleet-node-history': {
const nodeId = params?.node_id || 'archy-228'
const now = Date.now()
const history = Array.from({ length: 24 }, (_, i) => ({
timestamp: new Date(now - (23 - i) * 3600000).toISOString(),
cpu_pct: +(10 + Math.random() * 30).toFixed(1),
mem_pct: +(30 + Math.random() * 20).toFixed(1),
disk_pct: +(30 + Math.random() * 5).toFixed(1),
}))
return res.json({ result: { history } })
}
case 'analytics.get-snapshot':
case 'telemetry.report': {
return res.json({ result: {