Skip to content

Commit

Permalink
feat: remove rpc creds from quickconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
Fonta1n3 committed Nov 29, 2024
1 parent e3bf63c commit 78d78b7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 44 deletions.
19 changes: 8 additions & 11 deletions FullyNoded-Server/Views/BitcoinCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,8 @@ struct BitcoinCore: View {

Label {
Text(logOutput)
//.foregroundStyle(.green)
} icon: {
Image(systemName: "info.circle")
//.foregroundStyle(.green)
}
.padding(.all)
.foregroundStyle(.tertiary)
Expand Down Expand Up @@ -404,7 +402,6 @@ struct BitcoinCore: View {
}

private func refreshRPCAuth() {
// First remove all "FullyNoded-Server" users from the bitcoin.conf
guard let newCreds = RPCAuth().generateCreds(username: "FullyNoded-Server", password: nil) else {
showMessage(message: "Unable to create rpc creds.")
return
Expand Down Expand Up @@ -539,15 +536,15 @@ struct BitcoinCore: View {
return
}

guard let decryptedPass = Crypto.decrypt(encryptedPass) else {
showMessage(message: "Unable to decrypt rpc password data.")
return
}
// guard let decryptedPass = Crypto.decrypt(encryptedPass) else {
// showMessage(message: "Unable to decrypt rpc password data.")
// return
// }

guard let rpcPass = String(data: decryptedPass, encoding: .utf8) else {
showMessage(message: "Unable to encode decrypted rpc data to utf8 string.")
return
}
// guard let rpcPass = String(data: decryptedPass, encoding: .utf8) else {
// showMessage(message: "Unable to encode decrypted rpc data to utf8 string.")
// return
// }

let url = "http://xxx:xxx@\(onionHost)"
qrImage = url.qrQode
Expand Down
3 changes: 2 additions & 1 deletion FullyNoded-Server/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,11 @@ struct ContentView: View {

}
}
}
}.padding()
Text("Select a service.")
.foregroundStyle(.secondary)
}
//.padding(.all)

.onAppear(perform: {
/// For testing fresh install.
Expand Down
33 changes: 8 additions & 25 deletions FullyNoded-Server/Views/CoreLightning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@ struct CoreLightning: View {
.padding([.leading, .trailing])
)
Spacer()
Label {
Text(logOutput)
} icon: {
Image(systemName: "info.circle")
}
.padding(.all)
.foregroundStyle(.tertiary)
// Label {
// Text(logOutput)
// } icon: {
// Image(systemName: "info.circle")
// }
// .padding(.all)
// .foregroundStyle(.tertiary)
.onAppear(perform: {
isLightningOn()
checkIfPlasmaExists()
Expand Down Expand Up @@ -299,7 +299,6 @@ struct CoreLightning: View {
} else if output.contains("Stopped") {
isRunning = false
}
showLog()
}

private func startLightning() {
Expand Down Expand Up @@ -364,22 +363,6 @@ struct CoreLightning: View {
isAnimating = false
if result.contains("Shutdown complete") {
isRunning = false
showLog()
}
}

private func showLog() {
let path = URL(fileURLWithPath: "/Users/\(NSUserName())/.lightning/lightning.log")
guard let log = try? String(contentsOf: path, encoding: .utf8) else {
print("can not get lightning.log")
return
}
let logItems = log.components(separatedBy: "\n")
DispatchQueue.main.async {
if logItems.count > 2 {
let lastLogItem = "\(logItems[logItems.count - 2])"
logOutput = lastLogItem
}
}
}

Expand Down Expand Up @@ -425,7 +408,7 @@ struct CoreLightning: View {
} else {
let path = URL(fileURLWithPath: "/Users/\(NSUserName())/.lightning/config")
guard let config = try? Data(contentsOf: path) else {
print("Unable to get ngrok.log.")
print("Unable to get config.")
return
}
guard let stringValue = String(data: config, encoding: .utf8) else {
Expand Down
10 changes: 3 additions & 7 deletions FullyNoded-Server/Views/JoinMarket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,8 @@ struct JoinMarket: View {
TextField("Enter the wallet name", text: $walletName)
Button("OK", action: increaseGapLimit)
}
.alert("The order book launches a terminal (see output if any issues and report) and opens the browser at http://localhost:62601 to display the current order book.",
isPresented: $orderBookOpened) {
Button("Open") {
openOrderBookNow()
}
.alert("The order book launches a terminal (see output if any issues and report) and opens the browser at http://localhost:62601 to display the current order book.", isPresented: $orderBookOpened) {
Button("Open", action: openOrderBookNow)
}
}

Expand Down Expand Up @@ -434,7 +431,6 @@ struct JoinMarket: View {

if let wallets = try? fm.contentsOfDirectory(atPath: path) {
for wallet in wallets {
print("Found \(wallet)")
if wallet.hasSuffix(".lock") {
// Delete the .lock file
try? fm.removeItem(atPath: path + "/" + wallet)
Expand Down Expand Up @@ -474,7 +470,7 @@ struct JoinMarket: View {
guard errorDesc == nil else {
if errorDesc!.contains("Could not connect to the server.") {
isRunning = false
} else if !errorDesc!.contains("The request timd out.") {
} else if !errorDesc!.contains("The request timed out.") {
showMessage(message: errorDesc!)
}
return
Expand Down

0 comments on commit 78d78b7

Please sign in to comment.