lnlink-server 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/app.js +299 -299
  2. package/dist/build-info.json +1 -1
  3. package/dist/config.default.js +2 -2
  4. package/dist/index.js +5642 -5805
  5. package/dist/index.js.map +4 -4
  6. package/dist/package.json +1 -1
  7. package/dist/public/css/initOwner.css +61 -0
  8. package/dist/public/js/init.js +238 -15
  9. package/dist/setting.regtest.json +1 -2
  10. package/package.json +1 -1
  11. package/dist/node_modules/debug/.coveralls.yml +0 -1
  12. package/dist/node_modules/debug/.eslintrc +0 -11
  13. package/dist/node_modules/debug/.travis.yml +0 -14
  14. package/dist/node_modules/debug/CHANGELOG.md +0 -362
  15. package/dist/node_modules/debug/LICENSE +0 -19
  16. package/dist/node_modules/debug/Makefile +0 -50
  17. package/dist/node_modules/debug/README.md +0 -312
  18. package/dist/node_modules/debug/component.json +0 -19
  19. package/dist/node_modules/debug/karma.conf.js +0 -70
  20. package/dist/node_modules/debug/node.js +0 -1
  21. package/dist/node_modules/debug/package.json +0 -49
  22. package/dist/node_modules/debug/src/browser.js +0 -185
  23. package/dist/node_modules/debug/src/debug.js +0 -202
  24. package/dist/node_modules/debug/src/index.js +0 -10
  25. package/dist/node_modules/debug/src/inspector-log.js +0 -15
  26. package/dist/node_modules/debug/src/node.js +0 -248
  27. package/dist/node_modules/depd/History.md +0 -96
  28. package/dist/node_modules/depd/LICENSE +0 -22
  29. package/dist/node_modules/depd/Readme.md +0 -280
  30. package/dist/node_modules/depd/index.js +0 -522
  31. package/dist/node_modules/depd/lib/browser/index.js +0 -77
  32. package/dist/node_modules/depd/lib/compat/callsite-tostring.js +0 -103
  33. package/dist/node_modules/depd/lib/compat/event-listener-count.js +0 -22
  34. package/dist/node_modules/depd/lib/compat/index.js +0 -79
  35. package/dist/node_modules/depd/package.json +0 -41
  36. package/dist/node_modules/http-errors/HISTORY.md +0 -132
  37. package/dist/node_modules/http-errors/LICENSE +0 -23
  38. package/dist/node_modules/http-errors/README.md +0 -135
  39. package/dist/node_modules/http-errors/index.js +0 -260
  40. package/dist/node_modules/http-errors/package.json +0 -48
  41. package/dist/node_modules/inherits/LICENSE +0 -16
  42. package/dist/node_modules/inherits/README.md +0 -42
  43. package/dist/node_modules/inherits/inherits.js +0 -7
  44. package/dist/node_modules/inherits/inherits_browser.js +0 -23
  45. package/dist/node_modules/inherits/package.json +0 -29
  46. package/dist/node_modules/ms/index.js +0 -152
  47. package/dist/node_modules/ms/license.md +0 -21
  48. package/dist/node_modules/ms/package.json +0 -37
  49. package/dist/node_modules/ms/readme.md +0 -51
  50. package/dist/node_modules/setprototypeof/LICENSE +0 -13
  51. package/dist/node_modules/setprototypeof/README.md +0 -26
  52. package/dist/node_modules/setprototypeof/index.d.ts +0 -2
  53. package/dist/node_modules/setprototypeof/index.js +0 -15
  54. package/dist/node_modules/setprototypeof/package.json +0 -25
  55. package/dist/node_modules/statuses/HISTORY.md +0 -65
  56. package/dist/node_modules/statuses/LICENSE +0 -23
  57. package/dist/node_modules/statuses/README.md +0 -127
  58. package/dist/node_modules/statuses/codes.json +0 -66
  59. package/dist/node_modules/statuses/index.js +0 -113
  60. package/dist/node_modules/statuses/package.json +0 -48
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lnlink-server",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "electron": "lnlink.js",
@@ -703,3 +703,64 @@ input:-webkit-autofill:active {
703
703
  padding: 20px;
704
704
  }
705
705
  }
706
+
707
+ /* Tor Toggle Styles */
708
+ .tor-toggle-wrapper {
709
+ display: flex;
710
+ align-items: center;
711
+ gap: 12px;
712
+ }
713
+
714
+ .toggle-switch {
715
+ position: relative;
716
+ display: inline-block;
717
+ width: 50px;
718
+ height: 28px;
719
+ margin: 0;
720
+ }
721
+
722
+ .toggle-switch input {
723
+ opacity: 0;
724
+ width: 0;
725
+ height: 0;
726
+ }
727
+
728
+ .toggle-slider {
729
+ position: absolute;
730
+ cursor: pointer;
731
+ top: 0;
732
+ left: 0;
733
+ right: 0;
734
+ bottom: 0;
735
+ background-color: var(--input-bg);
736
+ border: 1px solid var(--border-color);
737
+ border-radius: 28px;
738
+ transition: 0.3s;
739
+ }
740
+
741
+ .toggle-slider:before {
742
+ position: absolute;
743
+ content: "";
744
+ height: 20px;
745
+ width: 20px;
746
+ left: 4px;
747
+ bottom: 3px;
748
+ background-color: white;
749
+ border-radius: 50%;
750
+ transition: 0.3s;
751
+ }
752
+
753
+ .toggle-switch input:checked + .toggle-slider {
754
+ background-color: var(--lime-primary);
755
+ border-color: var(--lime-primary);
756
+ }
757
+
758
+ .toggle-switch input:checked + .toggle-slider:before {
759
+ transform: translateX(22px);
760
+ background-color: var(--bg-dark);
761
+ }
762
+
763
+ .toggle-label {
764
+ color: var(--text-secondary);
765
+ font-size: 0.9rem;
766
+ }
@@ -65,7 +65,8 @@ async function fetchNetworkConfigs() {
65
65
  bitcoindZmqBlock: item.bitcoindZmqBlock,
66
66
  bitcoindZmqRawTx: item.bitcoindZmqRawTx,
67
67
  network: networkKey,
68
- nostrRelays: item.nostrRelays ? [item.nostrRelays] : [],
68
+ // nostrRelays: item.nostrRelays ? [item.nostrRelays] : [],
69
+ nostrRelays: ["wss://relay.snort.social"],
69
70
  officialLndPeer: item.lndPeerId,
70
71
  officialLndPeerHost: item.lndPeerHost,
71
72
  officialNostrPubKey: item.nostrPubkey,
@@ -204,17 +205,6 @@ async function getInfo(showLoading = true) {
204
205
  // Fetch network configs only when needed for configuration
205
206
  await fetchNetworkConfigs()
206
207
 
207
- fetch("https://api.example.com/login", {
208
- method: "POST",
209
- headers: {
210
- "Content-Type": "application/json",
211
- "Authorization": "Bearer your-token-here", // 可选
212
- },
213
- body: JSON.stringify({
214
- username: "test",
215
- password: "123456",
216
- }),
217
- })
218
208
  renderConfigurationForm(res.data)
219
209
  }
220
210
  }
@@ -243,12 +233,16 @@ async function getInfo(showLoading = true) {
243
233
 
244
234
  // Render configured view
245
235
  function renderConfiguredView(basicData, settings) {
236
+ console.log("renderConfiguredView called with:", { basicData, settings })
246
237
  const mainContent = document.getElementById("main-content")
247
238
 
248
239
  // Extract Node ID (Nostr PubKey)
249
240
  const nodeId
250
241
  = settings.officialNostrPubKey || basicData.officialNostrPubKey || "Unknown"
251
242
 
243
+ // Get Tor status from basicData
244
+ const enableTor = basicData.enableTor !== undefined ? basicData.enableTor : true
245
+
252
246
  // Determine Service Status
253
247
  // We check basicData for status indicators or default to design mocks if not present
254
248
  // Assuming keys might exist, otherwise using placeholders for the design requirement
@@ -305,6 +299,18 @@ function renderConfiguredView(basicData, settings) {
305
299
  </div>
306
300
  </div>
307
301
 
302
+ <!-- Tor Network Toggle -->
303
+ <div class="read-only-input-group" style="margin-top: 1rem;">
304
+ <label class="card-label">Tor Network</label>
305
+ <div class="tor-toggle-wrapper">
306
+ <label class="toggle-switch">
307
+ <input type="checkbox" id="torToggle" ${enableTor ? "checked" : ""} onchange="handleTorToggle(this)">
308
+ <span class="toggle-slider"></span>
309
+ </label>
310
+ <span class="toggle-label" id="torToggleLabel">${enableTor ? "Enabled" : "Disabled"} - Enhanced privacy</span>
311
+ </div>
312
+ </div>
313
+
308
314
  <!-- Service Status -->
309
315
  <div class="service-status-section">
310
316
  <label class="card-label">Service Status</label>
@@ -347,6 +353,118 @@ function renderConfiguredView(basicData, settings) {
347
353
  // Store data globally for modal use
348
354
  window.currentSettings = settings
349
355
  window.currentBasicData = basicData
356
+
357
+ // Update button state based on service status
358
+ updateManageButtonState(isRgbRunning || isLitdRunning, isRgbRunning && isLitdRunning)
359
+ }
360
+
361
+ // Update Manage My Node button state
362
+ function updateManageButtonState(anyRunning, allRunning) {
363
+ const manageBtn = document.querySelector(".manage-btn")
364
+ if (!manageBtn)
365
+ return
366
+
367
+ if (allRunning) {
368
+ // All services running - enable button
369
+ manageBtn.disabled = false
370
+ manageBtn.classList.remove("loading-state")
371
+ manageBtn.innerHTML = "Manage My Node <i class=\"fas fa-arrow-right\"></i>"
372
+ }
373
+ else if (anyRunning) {
374
+ // Some services starting - show loading
375
+ manageBtn.disabled = true
376
+ manageBtn.classList.add("loading-state")
377
+ manageBtn.innerHTML = "<span class=\"loading\"></span> Starting Services..."
378
+ }
379
+ else {
380
+ // No services running - show normal but disabled
381
+ manageBtn.disabled = true
382
+ manageBtn.classList.remove("loading-state")
383
+ manageBtn.innerHTML = "Services Stopped"
384
+ }
385
+ }
386
+
387
+ // Poll service status until both services are running
388
+ async function pollServiceStatus() {
389
+ console.log("pollServiceStatus started")
390
+ const maxAttempts = 30 // Poll for up to 30 seconds
391
+ let attempts = 0
392
+
393
+ // Immediately update button to loading state
394
+ updateManageButtonState(true, false)
395
+
396
+ const checkStatus = async () => {
397
+ console.log(`Polling attempt ${attempts + 1}/${maxAttempts}`)
398
+ try {
399
+ const response = await fetch("/api/lnd/info")
400
+ const result = await response.json()
401
+
402
+ if (result.code === 200 && result.data) {
403
+ const rgbRunning = result.data.rgb === "Running"
404
+ const litdRunning = result.data.litd === "Running"
405
+
406
+ // Update UI - find status boxes by iterating
407
+ const statusBoxes = document.querySelectorAll(".status-box")
408
+ let rgbStatusEl, litdStatusEl, rgbDotEl, litdDotEl
409
+
410
+ statusBoxes.forEach((box) => {
411
+ const nameEl = box.querySelector(".status-name")
412
+ if (nameEl && nameEl.textContent.includes("RGB")) {
413
+ rgbStatusEl = box.querySelector(".status-value")
414
+ rgbDotEl = box.querySelector(".status-dot")
415
+ }
416
+ else if (nameEl && nameEl.textContent.includes("LITD")) {
417
+ litdStatusEl = box.querySelector(".status-value")
418
+ litdDotEl = box.querySelector(".status-dot")
419
+ }
420
+ })
421
+
422
+ if (rgbStatusEl) {
423
+ rgbStatusEl.textContent = result.data.rgb || "Stopped"
424
+ rgbStatusEl.className = `status-value ${rgbRunning ? "running" : "stopped"}`
425
+ }
426
+ if (litdStatusEl) {
427
+ litdStatusEl.textContent = result.data.litd || "Stopped"
428
+ litdStatusEl.className = `status-value ${litdRunning ? "running" : "stopped"}`
429
+ }
430
+ if (rgbDotEl) {
431
+ rgbDotEl.className = `status-dot ${rgbRunning ? "running" : "stopped"}`
432
+ }
433
+ if (litdDotEl) {
434
+ litdDotEl.className = `status-dot ${litdRunning ? "running" : "stopped"}`
435
+ }
436
+
437
+ // Update button state
438
+ updateManageButtonState(rgbRunning || litdRunning, rgbRunning && litdRunning)
439
+
440
+ // If both services are running, stop polling
441
+ if (rgbRunning && litdRunning) {
442
+ console.log("All services running, polling stopped")
443
+ return
444
+ }
445
+ }
446
+
447
+ // Continue polling if not all services are running and within max attempts
448
+ attempts++
449
+ if (attempts < maxAttempts) {
450
+ setTimeout(checkStatus, 1000)
451
+ }
452
+ else {
453
+ console.log("Service status polling timed out")
454
+ // Re-enable button even if services didn't start
455
+ updateManageButtonState(false, false)
456
+ }
457
+ }
458
+ catch (error) {
459
+ console.error("Error polling service status:", error)
460
+ attempts++
461
+ if (attempts < maxAttempts) {
462
+ setTimeout(checkStatus, 2000)
463
+ }
464
+ }
465
+ }
466
+
467
+ checkStatus()
350
468
  }
351
469
 
352
470
  // Navigate to manage URL with loading state
@@ -563,6 +681,18 @@ function renderConfigurationForm(basicData) {
563
681
  <input type="hidden" id="network" name="network" value="regtest">
564
682
  </div>
565
683
 
684
+ <!-- Tor Configuration -->
685
+ <div class="config-group mt-4">
686
+ <label class="form-label text-muted">Tor Network</label>
687
+ <div class="tor-toggle-wrapper">
688
+ <label class="toggle-switch">
689
+ <input type="checkbox" id="enableTor" name="enableTor">
690
+ <span class="toggle-slider"></span>
691
+ </label>
692
+ <span class="toggle-label">Enable Tor for enhanced privacy</span>
693
+ </div>
694
+ </div>
695
+
566
696
  <!-- Advanced Toggle -->
567
697
  <div class="mt-3 mb-3 d-flex align-items-center justify-content-between">
568
698
  <a href="javascript:void(0)" class="advanced-toggle text-decoration-none text-lime" onclick="toggleAdvanced()">
@@ -828,10 +958,10 @@ async function handleConfigFormSubmit(event) {
828
958
  // Extract owner
829
959
  const owner = formData.get("owner")
830
960
 
831
- // Build settings object (exclude owner)
961
+ // Build settings object (exclude owner and enableTor)
832
962
  const settings = {}
833
963
  for (const [key, value] of formData.entries()) {
834
- if (key === "owner")
964
+ if (key === "owner" || key === "enableTor")
835
965
  continue
836
966
 
837
967
  if (key === "nostrRelays") {
@@ -846,9 +976,14 @@ async function handleConfigFormSubmit(event) {
846
976
  }
847
977
  }
848
978
 
979
+ // Get enableTor checkbox value (default to true if checkbox not found)
980
+ const enableTorCheckbox = document.getElementById("enableTor")
981
+ const enableTor = enableTorCheckbox ? enableTorCheckbox.checked : false
982
+
849
983
  const raw = JSON.stringify({
850
984
  owner,
851
985
  settings,
986
+ enableTor,
852
987
  })
853
988
 
854
989
  const requestOptions = {
@@ -863,8 +998,11 @@ async function handleConfigFormSubmit(event) {
863
998
  const result = await response.json()
864
999
 
865
1000
  if (result.code === 200) {
866
- await getInfo(false)
1001
+ // Backend has already waited for services to start
867
1002
  showSuccessModal("Complete configuration saved successfully!")
1003
+
1004
+ // Refresh page data to show running services
1005
+ await getInfo(false)
868
1006
  }
869
1007
  else {
870
1008
  showErrorModal(result.message || "Configuration failed")
@@ -881,6 +1019,91 @@ async function handleConfigFormSubmit(event) {
881
1019
  }
882
1020
  }
883
1021
 
1022
+ // Handle Tor toggle
1023
+ async function handleTorToggle(checkbox) {
1024
+ const enable = checkbox.checked
1025
+ const label = document.getElementById("torToggleLabel")
1026
+ const originalText = label.textContent
1027
+
1028
+ try {
1029
+ // Disable checkbox during request
1030
+ checkbox.disabled = true
1031
+ label.textContent = enable ? "Enabling..." : "Disabling..."
1032
+
1033
+ const response = await fetch("/api/lnd/tor/toggle", {
1034
+ method: "POST",
1035
+ headers: {
1036
+ "Content-Type": "application/json",
1037
+ },
1038
+ body: JSON.stringify({ enable }),
1039
+ })
1040
+
1041
+ const result = await response.json()
1042
+
1043
+ if (result.code === 200) {
1044
+ label.textContent = `${enable ? "Enabled" : "Disabled"} - Enhanced privacy`
1045
+
1046
+ // Show success message
1047
+ showToast(`Tor ${enable ? "enabled" : "disabled"} successfully. Litd is restarting...`, "success")
1048
+
1049
+ // Poll service status to update UI
1050
+ await pollServiceStatus()
1051
+ }
1052
+ else {
1053
+ throw new Error(result.message || "Failed to toggle Tor")
1054
+ }
1055
+ }
1056
+ catch (error) {
1057
+ console.error("Error toggling Tor:", error)
1058
+ // Revert checkbox state on error
1059
+ checkbox.checked = !enable
1060
+ label.textContent = originalText
1061
+ showToast(`Failed to toggle Tor: ${error.message}`, "error")
1062
+ }
1063
+ finally {
1064
+ checkbox.disabled = false
1065
+ }
1066
+ }
1067
+
1068
+ // Show toast notification
1069
+ function showToast(message, type = "info") {
1070
+ // Create toast element if it doesn't exist
1071
+ let toast = document.getElementById("toast-notification")
1072
+ if (!toast) {
1073
+ toast = document.createElement("div")
1074
+ toast.id = "toast-notification"
1075
+ toast.style.cssText = `
1076
+ position: fixed;
1077
+ top: 20px;
1078
+ right: 20px;
1079
+ padding: 15px 20px;
1080
+ border-radius: 8px;
1081
+ color: white;
1082
+ font-size: 14px;
1083
+ z-index: 10000;
1084
+ box-shadow: 0 4px 12px rgba(0,0,0,0.3);
1085
+ transition: opacity 0.3s;
1086
+ `
1087
+ document.body.appendChild(toast)
1088
+ }
1089
+
1090
+ // Set background color based on type
1091
+ const colors = {
1092
+ success: "#10b981",
1093
+ error: "#ef4444",
1094
+ info: "#3b82f6",
1095
+ }
1096
+ toast.style.backgroundColor = colors[type] || colors.info
1097
+ toast.textContent = message
1098
+ toast.style.opacity = "1"
1099
+
1100
+ // Auto hide after 3 seconds
1101
+ setTimeout(() => {
1102
+ toast.style.opacity = "0"
1103
+ setTimeout(() => toast.remove(), 300)
1104
+ }, 3000)
1105
+ }
1106
+
884
1107
  // Page initialization
885
1108
  document.addEventListener("DOMContentLoaded", async () => {
886
1109
  // Get information
@@ -8,8 +8,7 @@
8
8
  "bitcoindZmqRawTx": "tcp://regtest.lnfi.network:28335",
9
9
  "network": "regtest",
10
10
  "nostrRelays": [
11
- "wss://relay01.lnfi.network",
12
- "wss://relay02.lnfi.network"
11
+ "wss://relay.snort.social"
13
12
  ],
14
13
  "officialLndPeer": "03b24a4bf911ffd26ac1d5e5f2440a3c2f6974e4cc85d2ef54e17ee6d3717433d3",
15
14
  "officialLndPeerHost": "34.84.66.29:7739",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lnlink-server",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -1 +0,0 @@
1
- repo_token: SIAeZjKYlHK74rbcFvNHMUzjRiMpflxve
@@ -1,11 +0,0 @@
1
- {
2
- "env": {
3
- "browser": true,
4
- "node": true
5
- },
6
- "rules": {
7
- "no-console": 0,
8
- "no-empty": [1, { "allowEmptyCatch": true }]
9
- },
10
- "extends": "eslint:recommended"
11
- }
@@ -1,14 +0,0 @@
1
-
2
- language: node_js
3
- node_js:
4
- - "6"
5
- - "5"
6
- - "4"
7
-
8
- install:
9
- - make node_modules
10
-
11
- script:
12
- - make lint
13
- - make test
14
- - make coveralls