Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions LDKNodeMonday.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objectVersion = 60;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -33,6 +33,7 @@
AE186B8E2A1540B700338463 /* StartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE186B8D2A1540B700338463 /* StartView.swift */; };
AE1D9BEC2B2A1FFD00620748 /* BitcoinUI in Frameworks */ = {isa = PBXBuildFile; productRef = AE1D9BEB2B2A1FFD00620748 /* BitcoinUI */; };
AE1D9C0B2B2A251500620748 /* ChannelDetails+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE1D9C0A2B2A251500620748 /* ChannelDetails+Extensions.swift */; };
AE2DD9632BC45B3F00EE0696 /* LDKNode in Frameworks */ = {isa = PBXBuildFile; productRef = AE2DD9622BC45B3F00EE0696 /* LDKNode */; };
AE3815362B6A9705006B2952 /* LightningNodesService.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE3815352B6A9705006B2952 /* LightningNodesService.swift */; };
AE3815392B6A978A006B2952 /* LightningNodeServiceError.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE3815382B6A978A006B2952 /* LightningNodeServiceError.swift */; };
AE38153B2B6A979E006B2952 /* LightningNodeInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE38153A2B6A979E006B2952 /* LightningNodeInfo.swift */; };
Expand Down Expand Up @@ -86,7 +87,6 @@
AEE5B76A2A09C722001E5E59 /* Peer.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEE5B7692A09C722001E5E59 /* Peer.swift */; };
AEE8FDDD29F855E700406DD9 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEE8FDDC29F855E700406DD9 /* String+Extensions.swift */; };
AEE8FDDF29F8579600406DD9 /* Date+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEE8FDDE29F8579600406DD9 /* Date+Extensions.swift */; };
AEF66F502BA4A3E600FA15F9 /* LDKNode in Frameworks */ = {isa = PBXBuildFile; productRef = AEF66F4F2BA4A3E600FA15F9 /* LDKNode */; };
AEF66F522BA4B11A00FA15F9 /* PaymentKind+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEF66F512BA4B11A00FA15F9 /* PaymentKind+Extensions.swift */; };
AEFAF2922A433F6F001128DF /* LightningPaymentStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEFAF2912A433F6F001128DF /* LightningPaymentStatus.swift */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -181,7 +181,7 @@
AE51BEFD2B37A5DC00BAE452 /* SimpleToast in Frameworks */,
AE7C4A082B406D590061189D /* SimpleToast in Frameworks */,
AEBFD8AA2B8916A00024E3F7 /* LDKNode in Frameworks */,
AEF66F502BA4A3E600FA15F9 /* LDKNode in Frameworks */,
AE2DD9632BC45B3F00EE0696 /* LDKNode in Frameworks */,
AE01C5B02AB3BEED00F28C7E /* KeychainAccess in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -543,7 +543,7 @@
AE51BEFC2B37A5DC00BAE452 /* SimpleToast */,
AE7C4A072B406D590061189D /* SimpleToast */,
AEBFD8A92B8916A00024E3F7 /* LDKNode */,
AEF66F4F2BA4A3E600FA15F9 /* LDKNode */,
AE2DD9622BC45B3F00EE0696 /* LDKNode */,
);
productName = LDKNodeMonday;
productReference = AE17E8D629A402E30058C9C9 /* LDKNodeMonday.app */;
Expand Down Expand Up @@ -578,7 +578,7 @@
AE01C5AE2AB3BEED00F28C7E /* XCRemoteSwiftPackageReference "KeychainAccess" */,
AE1D9BEA2B2A1FFD00620748 /* XCRemoteSwiftPackageReference "BitcoinUI" */,
AE7C4A062B406D590061189D /* XCRemoteSwiftPackageReference "SimpleToast" */,
AEF66F4E2BA4A3E600FA15F9 /* XCRemoteSwiftPackageReference "ldk-node" */,
AE2DD9612BC45B3F00EE0696 /* XCLocalSwiftPackageReference "../ldk-node/bindings/swift" */,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The verification process confirms that the local ldk-node Swift bindings were not found at the specified path ../ldk-node/bindings/swift. This suggests that the path might be incorrect or the directory structure has changed. It's essential to ensure the correct path is used to reference the local ldk-node Swift bindings for the experimental integration efforts mentioned in the PR objectives.

Analysis chain

Switching to a local Swift package for ldk-node by adding a XCLocalSwiftPackageReference is a significant change. It allows the project to directly reference a local copy of ldk-node, which is essential for the experimental integration efforts mentioned in the PR objectives. Ensure the path ../ldk-node/bindings/swift correctly points to the local ldk-node Swift bindings.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the existence of the local ldk-node Swift bindings.
if [ -d "../ldk-node/bindings/swift" ]; then
  echo "Local ldk-node Swift bindings found."
else
  echo "Local ldk-node Swift bindings not found. Check the path."
fi

Length of output: 162

);
productRefGroup = AE17E8D729A402E30058C9C9 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -890,6 +890,13 @@
};
/* End XCConfigurationList section */

/* Begin XCLocalSwiftPackageReference section */
AE2DD9612BC45B3F00EE0696 /* XCLocalSwiftPackageReference "../ldk-node/bindings/swift" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = "../ldk-node/bindings/swift";
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCRemoteSwiftPackageReference section */
AE01C5AE2AB3BEED00F28C7E /* XCRemoteSwiftPackageReference "KeychainAccess" */ = {
isa = XCRemoteSwiftPackageReference;
Expand Down Expand Up @@ -923,14 +930,6 @@
version = 2.0.0;
};
};
AEF66F4E2BA4A3E600FA15F9 /* XCRemoteSwiftPackageReference "ldk-node" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/tnull/ldk-node.git";
requirement = {
branch = "2024-01-0.3-pre-alpha";
kind = branch;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -944,6 +943,10 @@
package = AE1D9BEA2B2A1FFD00620748 /* XCRemoteSwiftPackageReference "BitcoinUI" */;
productName = BitcoinUI;
};
AE2DD9622BC45B3F00EE0696 /* LDKNode */ = {
isa = XCSwiftPackageProductDependency;
productName = LDKNode;
};
AE51BEFC2B37A5DC00BAE452 /* SimpleToast */ = {
isa = XCSwiftPackageProductDependency;
productName = SimpleToast;
Expand All @@ -962,11 +965,6 @@
package = AEE5B7632A09B1FC001E5E59 /* XCRemoteSwiftPackageReference "CodeScanner" */;
productName = CodeScanner;
};
AEF66F4F2BA4A3E600FA15F9 /* LDKNode */ = {
isa = XCSwiftPackageProductDependency;
package = AEF66F4E2BA4A3E600FA15F9 /* XCRemoteSwiftPackageReference "ldk-node" */;
productName = LDKNode;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = AE17E8CE29A402E30058C9C9 /* Project object */;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 8 additions & 10 deletions LDKNodeMonday/Extensions/Event+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ extension Event: CustomStringConvertible {

switch self {

case .paymentSuccessful(paymentId: _, let paymentHash, feePaidMsat: _):
let truncatedHash = paymentHash.truncated(toLength: 10)
return "Payment Successful \(truncatedHash)"
case .paymentSuccessful(let paymentId, let paymentHash, _):
return "Payment Successful \(paymentHash.truncated(toLength: 10))"

case .paymentFailed(paymentId: _, let paymentHash, let reason):
let truncatedHash = paymentHash.truncated(toLength: 10)
let debugReason = reason.debugDescription
return "Payment Failed \(debugReason) \(truncatedHash))"
case .paymentFailed(let paymentId, let paymentHash, let paymentFailureReason):
return
"Payment Failed \(paymentFailureReason.debugDescription) \(paymentHash.truncated(toLength: 10))"

case .paymentReceived(paymentId: _, paymentHash: _, let amountMsat):
let formattedAmount = amountMsat.formattedAmount()
return "Payment Received \(formattedAmount) sats"
case .paymentReceived(let paymentId, _, let amountMsat):
let formatted = amountMsat.formattedAmount()
return "Payment Received \(formatted) sats"

case .channelPending(_, _, _, let counterpartyNodeId, _):
return "Channel Pending \(counterpartyNodeId.truncated(toLength: 10))"
Expand Down
26 changes: 13 additions & 13 deletions LDKNodeMonday/Extensions/PaymentKind+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

import LDKNode

extension PaymentKind {
var preimageAsString: String? {
switch self {
case .bolt11(_, let preimage, _),
.bolt11Jit(_, let preimage, _, _),
.bolt12(_, let preimage, _),
.spontaneous(_, let preimage):
return preimage
case .onchain:
return nil
}
}
}
//extension PaymentKind {
// var preimageAsString: String? {
// switch self {
// case .bolt11(_, let preimage, _),
// .bolt11Jit(_, let preimage, _, _),
// .bolt12(_, let preimage, _),
// .spontaneous(_, let preimage):
// return preimage
// case .onchain:
// return nil
// }
// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import os

class LightningNodeService {
static var shared: LightningNodeService = LightningNodeService()
private let ldkNode: Node
private let ldkNode: Node //LdkNode
private let keyService: KeyClient
var networkColor = Color.black
var network: Network
Expand Down Expand Up @@ -42,8 +42,7 @@ class LightningNodeService {
Constants.Config.LiquiditySourceLsps2.Signet.mutiny.nodeId
],
probingLiquidityLimitMultiplier: UInt64(3),
logLevel: .trace,
anchorChannelsConfig: nil
logLevel: .trace
)

let nodeBuilder = Builder.fromConfig(config: config)
Expand Down Expand Up @@ -176,8 +175,7 @@ class LightningNodeService {
func closeChannel(userChannelId: ChannelId, counterpartyNodeId: PublicKey) throws {
try ldkNode.closeChannel(
userChannelId: userChannelId,
counterpartyNodeId: counterpartyNodeId,
force: false // TODO: double check
counterpartyNodeId: counterpartyNodeId
)
}

Expand Down Expand Up @@ -252,6 +250,11 @@ class LightningNodeService {
return payments
}

func status() -> NodeStatus {
let status = ldkNode.status()
return status
}

}

extension LightningNodeService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,8 @@ func handleNodeError(_ error: NodeError) -> MondayError {
case .LiquidityFeeTooHigh(let message):
return .init(title: "LiquidityFeeTooHigh", detail: message)

case .OfferCreationFailed(let message):
return .init(title: "OfferCreationFailed", detail: message)

case .InvalidPaymentId(let message):
return .init(title: "InvalidPaymentId", detail: message)

case .InvalidOffer(let message):
return .init(title: "InvalidOffer", detail: message)

case .UnsupportedCurrency(let message):
return .init(title: "UnsupportedCurrency", detail: message)

}

}
10 changes: 10 additions & 0 deletions LDKNodeMonday/View Model/Home/BitcoinViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ class BitcoinViewModel: ObservableObject {
@Published var totalBalance: UInt64 = 0
@Published var totalLightningBalance: UInt64 = 0
@Published var lightningBalances: [LightningBalance] = []
@Published var status: NodeStatus?
@Published var isSpendableBalanceFinished: Bool = false
@Published var isTotalBalanceFinished: Bool = false
@Published var isStatusFinished: Bool = false
@Published var isTotalLightningBalanceFinished: Bool = false
@Published var isPriceFinished: Bool = false
let priceClient: PriceClient
Expand Down Expand Up @@ -59,6 +61,14 @@ class BitcoinViewModel: ObservableObject {
}
}

func getStatus() async {
let status = LightningNodeService.shared.status()
DispatchQueue.main.async {
self.status = status
self.isStatusFinished = true
}
}
Comment on lines +64 to +70
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling for the getStatus asynchronous function to improve robustness.


func getPrices() async {
do {
let price = try await priceClient.fetchPrice()
Expand Down
10 changes: 10 additions & 0 deletions LDKNodeMonday/View Model/Profile/NodeIDViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class NodeIDViewModel: ObservableObject {
@Published var nodeID: String = ""
@Published var network: String?
@Published var esploraURL: String?
@Published var status: NodeStatus?
@Published var isStatusFinished: Bool = false
let keyClient: KeyClient

init(keyClient: KeyClient = .live) {
Expand Down Expand Up @@ -75,6 +77,14 @@ class NodeIDViewModel: ObservableObject {
}
}

func getStatus() async {
let status = LightningNodeService.shared.status()
DispatchQueue.main.async {
self.status = status
self.isStatusFinished = true
}
}
Comment on lines +80 to +86
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling for the getStatus asynchronous function to improve robustness.


func onboarding() {
do {
try LightningNodeService.shared.stop()
Expand Down
Loading