Skip to content

Commit

Permalink
Embedded LND: remove unused copyLndLog func
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Mar 9, 2025
1 parent f83b68c commit 3efceb2
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 85 deletions.
14 changes: 0 additions & 14 deletions android/app/src/main/java/com/zeus/LndMobileTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,6 @@ private boolean killLndProcess() {
return false;
}

@ReactMethod
public void copyLndLog(String network, Promise promise) {
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TITLE, "lnd.log");
if (network == "testnet") {
getReactApplicationContext().getCurrentActivity().startActivityForResult(intent, MainActivity.Companion.getINTENT_COPYLNDLOGTESTNET());
} else {
getReactApplicationContext().getCurrentActivity().startActivityForResult(intent, MainActivity.Companion.getINTENT_COPYLNDLOG());
}
promise.resolve(true);
}

@ReactMethod
public void tailLog(Integer numberOfLines, String lndDir, String network, Promise promise) {
File file;
Expand Down
20 changes: 1 addition & 19 deletions android/app/src/main/java/com/zeus/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,7 @@ class MainActivity : ReactActivity() {

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == INTENT_COPYLNDLOG && resultCode == RESULT_OK) {
val destUri = data!!.data
val sourceLocation = File("$filesDir/logs/bitcoin/mainnet/lnd.log")
try {
val `in`: InputStream = FileInputStream(sourceLocation)
val out = contentResolver.openOutputStream(destUri!!)
val buf = ByteArray(1024)
var len: Int
while (`in`.read(buf).also { len = it } > 0) {
out!!.write(buf, 0, len)
}
`in`.close()
out!!.close()
} catch (e: IOException) {
Toast.makeText(this, "Error " + e.message, Toast.LENGTH_LONG).show()
}
} else if (requestCode == INTENT_EXPORTCHANBACKUP && resultCode == RESULT_OK) {
if (requestCode == INTENT_EXPORTCHANBACKUP && resultCode == RESULT_OK) {
val destUri = data!!.data
try {
val `in` = ByteArrayInputStream(tmpChanBackup)
Expand Down Expand Up @@ -122,10 +106,8 @@ class MainActivity : ReactActivity() {
companion object {
var TAG = "MainActivity"
var started = false
var INTENT_COPYLNDLOG = 100
var INTENT_EXPORTCHANBACKUP = 101
var INTENT_EXPORTCHANBACKUPFILE = 102
var INTENT_COPYLNDLOGTESTNET = 200
var INTENT_EXPORTCHANBACKUPFILETESTNET = 202
var tmpChanBackup: ByteArray = ByteArray(0)
var currentActivity: WeakReference<MainActivity>? = null
Expand Down
6 changes: 0 additions & 6 deletions ios/LndMobile/LndMobileTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ @interface RCT_EXTERN_MODULE(LndMobileTools, RCTEventEmitter)
rejecter: (RCTPromiseRejectBlock)reject
)

RCT_EXTERN_METHOD(
copyLndLog: (NSString)network
resolver: (RCTPromiseResolveBlock)resolve
rejecter: (RCTPromiseRejectBlock)reject
)

RCT_EXTERN_METHOD(
macosOpenFileDialog: (RCTPromiseResolveBlock)resolve
rejecter: (RCTPromiseRejectBlock)reject
Expand Down
45 changes: 0 additions & 45 deletions ios/LndMobile/LndMobileTools.swift
Original file line number Diff line number Diff line change
Expand Up @@ -405,51 +405,6 @@ class LndMobileTools: RCTEventEmitter {
resolve(true)
}

@objc(copyLndLog:resolver:rejecter:)
func copyLndLog(network: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
DispatchQueue.main.async {
let paths = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)
let url = paths[0].appendingPathComponent("lnd", isDirectory: true)
.appendingPathComponent("logs", isDirectory: true)
.appendingPathComponent("bitcoin", isDirectory: true)
.appendingPathComponent(network ?? "mainnet", isDirectory: true)
.appendingPathComponent("lnd.log", isDirectory: false)
#if os(iOS)
do {
let data = try String(contentsOf: url)
let activityController = UIActivityViewController(activityItems: [data], applicationActivities: nil)
RCTSharedApplication()?.delegate?.window??.rootViewController?.present(activityController, animated: true, completion: {
resolve(true)
})
} catch {
reject("error", error.localizedDescription, error)
}
#else
do {
let data = try Data(contentsOf: url)
let savePanel = NSSavePanel()
savePanel.nameFieldStringValue = "lnd.log"
if (savePanel.runModal() == NSApplication.ModalResponse.OK) {
let saveUrl = savePanel.url
NSLog(saveUrl?.path ?? "")
NSLog(saveUrl?.absoluteString ?? "")
NSLog(saveUrl?.relativeString ?? "")

if let saveUrlUnwrapped = saveUrl {
try data.write(to: saveUrlUnwrapped)
}
resolve(true)
} else {
resolve(false)
}
} catch {
print("Error saving backup")
reject("error", error.localizedDescription, error)
}
#endif
}
}

@objc(macosOpenFileDialog:rejecter:)
func macosOpenFileDialog(resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
#if os(iOS)
Expand Down
1 change: 0 additions & 1 deletion lndmobile/LndMobile.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export interface ILndMobile {
export interface ILndMobileTools {
writeConfig(lndDir: string, config: string): Promise<string>;
killLnd(): Promise<boolean>;
copyLndLog(network: string): Promise<boolean>;
tailLog(
numberOfLines: number,
lndDir: string,
Expand Down

0 comments on commit 3efceb2

Please sign in to comment.