Skip to content

Commit

Permalink
Merge pull request #8 from Fonta1n3/v0.0.2-beta
Browse files Browse the repository at this point in the history
v0.0.2 beta
  • Loading branch information
Fonta1n3 authored Dec 18, 2024
2 parents 7c375ee + 749a9c0 commit 48ba75f
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 50 deletions.
8 changes: 4 additions & 4 deletions FullyNoded-Server.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "FullyNoded-Server/Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = "FN Server - v0.0.1 Beta";
INFOPLIST_KEY_CFBundleDisplayName = "FN Server - v0.0.2 Beta";
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
Expand All @@ -695,7 +695,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 0.0.1;
MARKETING_VERSION = 0.0.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.dentonllc.FullyNoded-Server";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand Down Expand Up @@ -723,7 +723,7 @@
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "FullyNoded-Server/Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = "FN Server - v0.0.1 Beta";
INFOPLIST_KEY_CFBundleDisplayName = "FN Server - v0.0.2 Beta";
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
Expand All @@ -738,7 +738,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 0.0.1;
MARKETING_VERSION = 0.0.2;
PRODUCT_BUNDLE_IDENTIFIER = "com.dentonllc.FullyNoded-Server";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
Expand Down
2 changes: 1 addition & 1 deletion FullyNoded-Server/Scripts/CheckForLightning.command
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Created by Peter Denton on 9/5/24.
#

if command -v /opt/homebrew/Cellar/core-lightning/24.08.1/bin/lightningd &> /dev/null; then
if command -v /opt/homebrew/Cellar/core-lightning/24.11/bin/lightningd &> /dev/null; then
echo "Installed"
exit 1
else
Expand Down
2 changes: 1 addition & 1 deletion FullyNoded-Server/Scripts/GetRune.command
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
# Created by Peter Denton on 10/8/24.
#

sudo -u $(whoami) /opt/homebrew/Cellar/core-lightning/24.08.1/bin/lightning-cli commando-rune
sudo -u $(whoami) /opt/homebrew/Cellar/core-lightning/24.11/bin/lightning-cli commando-rune
exit 1
27 changes: 14 additions & 13 deletions FullyNoded-Server/Scripts/InstallLightning.command
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ export CELLAR_PATH=/opt/homebrew/Cellar

function configureLightning () {
CONFIG="alias=FullyNoded-Server\n\
plugin-dir=/opt/homebrew/Cellar/core-lightning/24.08.1/libexec/c-lightning/plugins\n\
subdaemon=channeld:/opt/homebrew/Cellar/core-lightning/24.08.1/libexec/c-lightning/lightning_channeld\n\
subdaemon=closingd:/opt/homebrew/Cellar/core-lightning/24.08.1/libexec/c-lightning/lightning_closingd\n\
subdaemon=connectd:/opt/homebrew/Cellar/core-lightning/24.08.1/libexec/c-lightning/lightning_connectd\n\
subdaemon=gossipd:/opt/homebrew/Cellar/core-lightning/24.08.1/libexec/c-lightning/lightning_gossipd\n\
subdaemon=hsmd:/opt/homebrew/Cellar/core-lightning/24.08.1/libexec/c-lightning/lightning_hsmd\n\
subdaemon=onchaind:/opt/homebrew/Cellar/core-lightning/24.08.1/libexec/c-lightning/lightning_onchaind\n\
subdaemon=openingd:/opt/homebrew/Cellar/core-lightning/24.08.1/libexec/c-lightning/lightning_openingd\n\
plugin-dir=/opt/homebrew/Cellar/core-lightning/24.11/libexec/c-lightning/plugins\n\
subdaemon=channeld:/opt/homebrew/Cellar/core-lightning/24.11/libexec/c-lightning/lightning_channeld\n\
subdaemon=closingd:/opt/homebrew/Cellar/core-lightning/24.11/libexec/c-lightning/lightning_closingd\n\
subdaemon=connectd:/opt/homebrew/Cellar/core-lightning/24.11/libexec/c-lightning/lightning_connectd\n\
subdaemon=gossipd:/opt/homebrew/Cellar/core-lightning/24.11/libexec/c-lightning/lightning_gossipd\n\
subdaemon=hsmd:/opt/homebrew/Cellar/core-lightning/24.11/libexec/c-lightning/lightning_hsmd\n\
subdaemon=onchaind:/opt/homebrew/Cellar/core-lightning/24.11/libexec/c-lightning/lightning_onchaind\n\
subdaemon=openingd:/opt/homebrew/Cellar/core-lightning/24.11/libexec/c-lightning/lightning_openingd\n\
bitcoin-rpcpassword="$RPC_PASSWORD"\n\
bitcoin-rpcuser="$RPC_USER"\n\
bitcoin-cli=/Users/$(whoami)/.fullynoded/BitcoinCore/"$PREFIX"/bin/bitcoin-cli\n\
Expand All @@ -37,7 +37,7 @@ log-level=debug:plugin\n\
experimental-offers\n\
fetchinvoice-noconnect\n\
disable-plugin=clnrest\n\
plugin=/opt/homebrew/Cellar/core-lightning/24.08.1/libexec/c-lightning/plugins/clnrest-rs/clnrest-rs\n\
plugin=/opt/homebrew/Cellar/core-lightning/24.11/libexec/c-lightning/plugins/clnrest-rs/clnrest-rs\n\
clnrest-port=18765\n\
clnrest-protocol=HTTP\n\
daemon"
Expand Down Expand Up @@ -70,14 +70,15 @@ daemon"
}

function installLightning () {
sudo -u $(whoami) $BREW_PATH install core-lightning
cd /opt/homebrew/Cellar/core-lightning/24.08.1/libexec/c-lightning/plugins
sudo -u $(whoami) $BREW_PATH reinstall core-lightning
chmod -R +x /opt/homebrew/Cellar/core-lightning/24.11/libexec/c-lightning/plugins
cd /opt/homebrew/Cellar/core-lightning/24.11/libexec/c-lightning/plugins
git clone https://github.com/daywalker90/clnrest-rs.git
cd clnrest-rs
$BREW_PATH install rust
cargo build --release
mv target/release/clnrest-rs /opt/homebrew/Cellar/core-lightning/24.08.1/libexec/c-lightning/plugins/clnrest-rs
chmod +x /opt/homebrew/Cellar/core-lightning/24.08.1/libexec/c-lightning/plugins/clnrest-rs/clnrest-rs
mv target/release/clnrest-rs /opt/homebrew/Cellar/core-lightning/24.11/libexec/c-lightning/plugins/clnrest-rs
chmod +x /opt/homebrew/Cellar/core-lightning/24.11/libexec/c-lightning/plugins/clnrest-rs/clnrest-rs
echo "Core Lightning installation complete, you can close this terminal window."
exit 1
}
Expand Down
2 changes: 1 addition & 1 deletion FullyNoded-Server/Scripts/LightningNodeId.command
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
# Created by Peter Denton on 10/7/24.
#

sudo -u $(whoami) /opt/homebrew/Cellar/core-lightning/24.08.1/bin/lightning-cli getinfo
sudo -u $(whoami) /opt/homebrew/Cellar/core-lightning/24.11/bin/lightning-cli getinfo
exit 1
2 changes: 1 addition & 1 deletion FullyNoded-Server/Scripts/StartLightning.command
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
# Created by Peter Denton on 9/11/24.
#

sudo -u $(whoami) /opt/homebrew/Cellar/core-lightning/24.08.1/bin/lightningd
sudo -u $(whoami) /opt/homebrew/Cellar/core-lightning/24.11/bin/lightningd
exit 1

2 changes: 1 addition & 1 deletion FullyNoded-Server/Scripts/StopLightning.command
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
#
# Created by Peter Denton on 9/11/24.
#
sudo -u $(whoami) /opt/homebrew/Cellar/core-lightning/24.08.1/bin/lightning-cli stop
sudo -u $(whoami) /opt/homebrew/Cellar/core-lightning/24.11/bin/lightning-cli stop
exit 1
10 changes: 8 additions & 2 deletions FullyNoded-Server/Views/BitcoinCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SwiftUI

struct BitcoinCore: View {

@State private var statusText = ""
@State private var promptToRefreshRpcAuth = false
@State private var rpcAuth = ""
@State private var qrImage: NSImage? = nil
Expand Down Expand Up @@ -72,7 +73,7 @@ struct BitcoinCore: View {
Image(systemName: "circle.fill")
.foregroundStyle(.orange)
.padding([.leading])
Text("Stopping...")
Text(statusText)
} else {
Image(systemName: "circle.fill")
.foregroundStyle(.green)
Expand All @@ -85,7 +86,7 @@ struct BitcoinCore: View {
Image(systemName: "circle.fill")
.foregroundStyle(.orange)
.padding([.leading])
Text("Starting...")
Text(statusText)
} else {
Image(systemName: "circle.fill")
.foregroundStyle(.red)
Expand Down Expand Up @@ -339,7 +340,9 @@ struct BitcoinCore: View {
private func reindex() {
if !isRunning {
isAnimating = true
statusText = "Reindexing..."
ScriptUtil.runScript(script: .reindex, env: env, args: nil) { (_, _, errorMessage) in
statusText = ""
guard errorMessage == nil else {
if errorMessage != "" {
showMessage(message: errorMessage!)
Expand Down Expand Up @@ -669,6 +672,7 @@ struct BitcoinCore: View {

private func startBitcoinCore() {
isAnimating = true
statusText = "Starting.."
ScriptUtil.runScript(script: .startBitcoin, env: env, args: nil) { (output, rawData, errorMessage) in
guard errorMessage == nil else {
if errorMessage != "" {
Expand Down Expand Up @@ -709,6 +713,7 @@ struct BitcoinCore: View {

private func stopBitcoinCore() {
isAnimating = true
statusText = "Stopping..."
BitcoinRPC.shared.command(method: "stop", params: [:]) { (result, error) in
guard let result = result as? String else {
isAnimating = false
Expand Down Expand Up @@ -775,6 +780,7 @@ struct BitcoinCore: View {

private func isBitcoinCoreRunning() {
isAnimating = true
statusText = "Refreshing..."
BitcoinRPC.shared.command(method: "getblockchaininfo", params: [:]) { (result, error) in
isAnimating = false
guard error == nil, let result = result as? [String: Any] else {
Expand Down
45 changes: 24 additions & 21 deletions FullyNoded-Server/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public struct Service: Identifiable {

struct ContentView: View {

@State private var isInitialLoad = true
@State private var isInstallingLightning = false
@State private var torProgress = 0.0
@State private var showError = false
Expand Down Expand Up @@ -54,7 +55,7 @@ struct ContentView: View {
private let timerForJMInstall = Timer.publish(every: 3, on: .main, in: .common).autoconnect()
private let timerForTor = Timer.publish(every: 3, on: .main, in: .common).autoconnect()
private let bitcoinCore = Service(name: "Bitcoin Core", id: UUID())
private let coreLightning = Service(name: "Core Lightning", id: UUID())
//private let coreLightning = Service(name: "Core Lightning", id: UUID())
private let joinMarket = Service(name: "Join Market", id: UUID())
private let tor = Service(name: "Tor", id: UUID())
private let help = Service(name: "Help", id: UUID())
Expand Down Expand Up @@ -140,6 +141,8 @@ struct ContentView: View {
.onChange(of: torRunning) {
if !torRunning {
TorClient.sharedInstance.resign()
} else if !isInitialLoad && TorClient.sharedInstance.state != .connected {
TorClient.sharedInstance.start(delegate: nil)
}
}
}
Expand Down Expand Up @@ -183,7 +186,7 @@ struct ContentView: View {
.foregroundStyle(.gray)
EmptyView()
.onReceive(timerForLightningInstall) { _ in
if FileManager.default.fileExists(atPath: "/opt/homebrew/Cellar/core-lightning/24.08.1/bin/lightningd") {
if FileManager.default.fileExists(atPath: "/opt/homebrew/Cellar/core-lightning/24.11/bin/lightningd") {
lightningInstalled = true
isInstallingLightning = false
self.timerForLightningInstall.upstream.connect().cancel()
Expand Down Expand Up @@ -253,16 +256,11 @@ struct ContentView: View {
Text("Select a service.")
.foregroundStyle(.secondary)
}
//.padding(.all)

.onAppear(perform: {
/// For testing fresh install.
// DataManager.deleteAllData(entityName: "BitcoinRPCCreds") { deleted in
// print("deleted: \(deleted)")
// let domain = Bundle.main.bundleIdentifier!
// UserDefaults.standard.removePersistentDomain(forName: domain)
// UserDefaults.standard.synchronize()
// }
if isInitialLoad {
bootTor()
}
checkForXcode()
})
.alert("Install Core Lightning?", isPresented: $promptToInstallLightning) {
Expand Down Expand Up @@ -309,21 +307,24 @@ struct ContentView: View {
}
}

private func bootTor() {
if TorClient.sharedInstance.state == .connected {
torProgress = 100.0
} else {
TorClient.sharedInstance.start(delegate: nil)
}
TorClient.sharedInstance.showProgress = { progress in
torProgress = Double(progress)
}
isInitialLoad = false
}

private func checkForBrew() {
ScriptUtil.runScript(script: .checkForBrew, env: nil, args: nil) { (output, data, errorMess) in
guard let output = output, output != "" else {
promptToInstallBrew = true
return
}

if TorClient.sharedInstance.state == .connected {
torProgress = 100.0
} else {
TorClient.sharedInstance.start(delegate: nil)
}
TorClient.sharedInstance.showProgress = { progress in
torProgress = Double(progress)
}
getSavedValues()
}
}
Expand Down Expand Up @@ -403,7 +404,8 @@ struct ContentView: View {
"CHAIN": self.bitcoinEnvValues.chain
]

services = [bitcoinCore, coreLightning, joinMarket, tor, help]
//services = [bitcoinCore, coreLightning, joinMarket, tor, help]
services = [bitcoinCore, joinMarket, tor, help]
checkForBitcoin()
}

Expand All @@ -421,7 +423,8 @@ struct ContentView: View {
"CHAIN": self.bitcoinEnvValues.chain
]

services = [bitcoinCore, coreLightning, joinMarket, tor, help]
//services = [bitcoinCore, coreLightning, joinMarket, tor, help]
services = [bitcoinCore, joinMarket, tor, help]
checkForBitcoin()
}
}
Expand Down
2 changes: 1 addition & 1 deletion FullyNoded-Server/Views/CoreLightning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct CoreLightning: View {
Image(systemName: "server.rack")
.padding(.leading)

Text("Core Lightning Server v24.08.1")
Text("Core Lightning Server v24.11")
Spacer()
Button {
isLightningOn()
Expand Down
11 changes: 7 additions & 4 deletions FullyNoded-Server/Views/JoinMarket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SwiftUI

struct JoinMarket: View {
@Environment(\.openURL) var openURL
@State private var statusText = "Refreshing..."
@State private var walletName = ""
@State private var gapLimit = ""
@State private var promptToIncreaseGapLimit = false
Expand Down Expand Up @@ -61,7 +62,7 @@ struct JoinMarket: View {
.foregroundStyle(.orange)
.padding([.leading])

Text("Starting...")
Text(statusText)
.onAppear {
isAutoRefreshing = true
}
Expand All @@ -83,7 +84,7 @@ struct JoinMarket: View {
.foregroundStyle(.orange)
.padding([.leading])

Text("Starting...")
Text(statusText)

} else {
Image(systemName: "circle.fill")
Expand Down Expand Up @@ -164,7 +165,7 @@ struct JoinMarket: View {
Text("Data Dir")
}
Button {
increaseGapLimit()
promptToIncreaseGapLimit = true
} label: {
Text("Increase gap limit")
}
Expand Down Expand Up @@ -427,9 +428,10 @@ struct JoinMarket: View {

private func startJoinMarket() {
isAnimating = true
statusText = "Starting..."
// Ensure Bitcoin Core is running before starting JM.
BitcoinRPC.shared.command(method: "getblockchaininfo", params: [:]) { (result, error) in
guard error == nil, let result = result as? [String: Any] else {
guard error == nil, let _ = result as? [String: Any] else {
if let error = error {
if error.contains("Could not connect to the server") {
isAnimating = false
Expand Down Expand Up @@ -497,6 +499,7 @@ struct JoinMarket: View {
if !isAutoRefreshing {
isAnimating = true
isAutoRefreshing = true
statusText = "Refreshing..."
}
JMRPC.sharedInstance.command(method: .session, param: nil) { (response, errorDesc) in
isAnimating = false
Expand Down

0 comments on commit 48ba75f

Please sign in to comment.