Skip to content

spm: ldk-node local main#88

Closed
reez wants to merge 3 commits intomainfrom
node-stats
Closed

spm: ldk-node local main#88
reez wants to merge 3 commits intomainfrom
node-stats

Conversation

@reez
Copy link
Owner

@reez reez commented Apr 8, 2024

Description

Playing around with Expose Node status and statistics.

Notes to the reviewers

Using local build of ldk-node at commit 71b1d3c of main.

Kind of undoes all of the things I did in spm: ldk-node version (I'm assuming all of those make their way back into ldk-node main eventually?) but for now I wanted to play around with Expose Node status and statistics which was only available on main.

Changelog notice

Checklists

All Submissions:

  • I've signed all my commits
  • I have formatted my code with swift-format per .swift-format file

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

Summary by CodeRabbit

  • New Features

    • Introduced a new method func status() -> NodeStatus in LightningNodeService to fetch node status.
    • Updated the Bitcoin view to display balances and status updates more effectively.
    • Simplified the display of payments in PaymentsListView by organizing them based on status.
  • Refactor

    • Renamed Node type to LdkNode in LightningNodeService.
  • Style

    • Enhanced UI layout, spacing, and styling in BitcoinView and NodeIDView.
  • Chores

    • Removed unused code and functionalities related to error handling and PaymentKind string conversion.
  • Documentation

    • Commented out specific functionalities and error cases for future reference.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 8, 2024

Walkthrough

The project underwent significant changes to optimize Lightning Network operations. Updates include refining error handling, simplifying payment processes, and enhancing UI components for better data visualization. The adjustments aim to streamline operations and improve user experience within the Lightning Network ecosystem.

Changes

Files Changes
LightningNodeService.swift - Renamed Node to LdkNode
- Updated method calls
- Added status() method
LightningServiceError.swift - Modified error handling function, removed specific error cases
PaymentsListView.swift - Removed sections
- Modified groupedPayments property
- Updated logic for grouping payments by status
.../project.pbxproj, .../project.xcworkspace/.../Package.resolved - Updated project configuration, removed ldk-node source control entry
Event+Extensions.swift - Refactored event handling in Event extension

"In the realm of code, where the bits align,
A rabbit hopped through, making changes so fine.
🌟 From node to node, it leapt with ease,
🛠 Tweaking and tuning the digital breeze.
Now Lightning strikes, both swift and bright,
With Bitcoin's glow, guiding us through the night.
🐰 So here's to progress, in bytes and bits,
A rabbit's touch, the future it knits."


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 83d2381 and e5de567.
Files selected for processing (12)
  • LDKNodeMonday.xcodeproj/project.pbxproj (10 hunks)
  • LDKNodeMonday.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved (1 hunks)
  • LDKNodeMonday/Extensions/Event+Extensions.swift (1 hunks)
  • LDKNodeMonday/Extensions/PaymentKind+Extensions.swift (1 hunks)
  • LDKNodeMonday/Service/Lightning Service/LightningNodeService.swift (9 hunks)
  • LDKNodeMonday/Service/Lightning Service/LightningServiceError.swift (1 hunks)
  • LDKNodeMonday/View Model/Home/BitcoinViewModel.swift (2 hunks)
  • LDKNodeMonday/View Model/Profile/NodeIDViewModel.swift (2 hunks)
  • LDKNodeMonday/View/Home/BitcoinView.swift (10 hunks)
  • LDKNodeMonday/View/Home/Payments/PaymentsListView.swift (2 hunks)
  • LDKNodeMonday/View/Profile/Channel/ChannelDetailView.swift (1 hunks)
  • LDKNodeMonday/View/Profile/NodeIDView.swift (3 hunks)
Files skipped from review due to trivial changes (1)
  • LDKNodeMonday.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
Additional comments not posted (18)
LDKNodeMonday/Extensions/PaymentKind+Extensions.swift (1)

10-22: Consider removing commented-out code if it's no longer needed or clarify its future use.

LDKNodeMonday/Extensions/Event+Extensions.swift (1)

17-26: LGTM! The simplification enhances readability without altering the logic.

LDKNodeMonday/View Model/Home/BitcoinViewModel.swift (1)

18-21: Ensure proper initialization of new properties to maintain state consistency.

LDKNodeMonday/View Model/Profile/NodeIDViewModel.swift (1)

19-20: Ensure proper initialization of new properties to maintain state consistency.

LDKNodeMonday/Service/Lightning Service/LightningServiceError.swift (1)

119-129: Commenting out error handling cases could lead to unhandled errors. Ensure this is a deliberate decision and consider re-enabling or handling these errors differently.

LDKNodeMonday/View/Profile/Channel/ChannelDetailView.swift (1)

Line range hint 32-78: LGTM! The removal of the channelType parameter simplifies the code without negatively impacting functionality.

LDKNodeMonday/View/Profile/NodeIDView.swift (1)

29-52: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [32-78]

The UI adjustments enhance the user interface and align with the PR's objectives. Ensure consistency across different device sizes and orientations.

LDKNodeMonday/Service/Lightning Service/LightningNodeService.swift (1)

175-193: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [15-257]

Renaming Node to LdkNode and updating method calls align with the PR's objectives. Ensure this renaming does not introduce breaking changes or inconsistencies in the rest of the codebase.

Verification successful

The search results indicate that LdkNode is only referenced in the LightningNodeService.swift file. To ensure consistency and avoid potential issues, it's necessary to verify if the old Node type is still being used elsewhere in the codebase or if the renaming to LdkNode has been fully applied.


The search results indicate that the renaming to LdkNode is specific to the LightningNodeService.swift file, while references to "Node" appear in various other contexts throughout the codebase. This suggests that the renaming does not introduce inconsistencies within the LightningNodeService.swift file itself. However, to ensure overall consistency and clarity across the codebase, it may be beneficial to further clarify the distinction between LdkNode and other "Node" references or to complete the renaming process where applicable.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that `LdkNode` renaming does not introduce inconsistencies
rg --type swift "LdkNode"

Length of output: 125



Script:

#!/bin/bash
# Search for occurrences of both "LdkNode" and the old "Node" type across all Swift files to assess the renaming's impact.
rg --type swift "LdkNode"
rg --type swift " Node"

Length of output: 5177

LDKNodeMonday/View/Home/Payments/PaymentsListView.swift (3)

13-14: Consider adding a brief comment explaining the purpose of groupedPayments.


39-90: Ensure that the UI elements properly handle dynamic content, especially for long payment hashes or large amounts.


106-193: In the PaymentsListItemView_Previews, ensure that the placeholders used (localizedName(of: .ascii)) accurately represent typical data to provide meaningful previews.

LDKNodeMonday/View/Home/BitcoinView.swift (3)

38-120: Ensure that the new layout and asynchronous calls do not introduce any race conditions or UI inconsistencies, especially with the redacted placeholders based on status completion.


134-140: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [137-158]

Verify that the refreshable block's asynchronous calls are executed in the intended order and consider handling potential errors to improve resilience.


252-258: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [235-343]

Repeatedly calling asynchronous methods in multiple lifecycle events (onAppear, onReceive, sheet onDismiss) might lead to unnecessary network requests. Consider optimizing this to reduce network load and improve performance.

LDKNodeMonday.xcodeproj/project.pbxproj (4)

6-6: Update of objectVersion to 60 aligns with newer Xcode versions, ensuring compatibility.


36-36: Addition of LDKNode to the project's frameworks indicates the integration of a local build of ldk-node. This change is crucial for the project's objective to experiment with node status and statistics functionalities.


184-184: The inclusion of LDKNode in the Frameworks build phase ensures that the app links against the newly added local ldk-node package, facilitating the use of its functionalities within the app.


946-949: The explicit declaration of LDKNode as a XCSwiftPackageProductDependency underlines the project's dependency on the ldk-node package. This change is aligned with the PR's goal to leverage ldk-node for node status and statistics functionalities. It's important to ensure that the project's Swift package configuration correctly resolves this dependency.

Comment on lines +201 to +396
//import LDKNode
//import SwiftUI
//
//struct PaymentSection {
// let status: PaymentStatus
// var payments: [PaymentDetails]
//}
//
//struct PaymentsListView: View {
// let payments: [PaymentDetails]
// var sections: [PaymentSection] {
// orderedStatuses.compactMap { status -> PaymentSection? in
// guard let paymentsForStatus = groupedPayments[status] else { return nil }
// return PaymentSection(status: status, payments: paymentsForStatus)
// }
// }
// let orderedStatuses: [PaymentStatus] = [
// .succeeded,
// .pending,
// .failed,
// ]
// var statusDescriptions: [PaymentStatus: String] {
// [
// .succeeded: "Success",
// .pending: "Pending",
// .failed: "Failure",
// ]
// }
// var statusColors: [PaymentStatus: Color] {
// [
// .succeeded: .green,
// .pending: .yellow,
// .failed: .red,
// ]
// }
// var groupedPayments: [PaymentStatus: [PaymentDetails]] {
// Dictionary(grouping: payments, by: { $0.status })
// }
//
// var body: some View {
// List {
// ForEach(sections, id: \.status) { section in
// Section(header: Text(statusDescriptions[section.status] ?? "")) {
// ForEach(section.payments, id: \.id) { payment in
// VStack {
// HStack(alignment: .center, spacing: 15) {
// VStack(alignment: .leading, spacing: 5.0) {
// PaymentDetailView(payment: payment)
// }
// Spacer()
// }
// .padding(.all, 10.0)
// }
// }
// }
// }
// }
// }
//}
//
//struct PaymentDetailView: View {
// let payment: PaymentDetails
//
// var body: some View {
// VStack {
// HStack(alignment: .center, spacing: 15) {
// VStack(alignment: .leading, spacing: 5.0) {
// HStack {
// Image(systemName: payment.direction == .inbound ? "arrow.down" : "arrow.up")
// .font(.subheadline)
// .bold()
// let paymentAmount = payment.amountMsat ?? 0
// let amount = paymentAmount.formattedAmount()
// Text("\(amount) sats")
// .font(.body)
// .bold()
// }
// HStack {
// Text("Payment Hash")
// .lineLimit(1)
// .minimumScaleFactor(0.75)
// Text(payment.id)
// .truncationMode(.middle)
// .lineLimit(1)
// .foregroundColor(.secondary)
// }
// .font(.caption)
//
// if let preimage = payment.kind.preimageAsString {
// //if let preimage = payment.preimage {
// HStack {
// Text("Preimage")
// .lineLimit(1)
// .minimumScaleFactor(0.75)
// Text(preimage)
// .truncationMode(.middle)
// .lineLimit(1)
// .foregroundColor(.secondary)
// }
// .font(.caption)
// }
//
// }
// Spacer()
// }
// .padding(.all, 10.0)
// }
// }
//
//}
//
//struct PaymentsListItemView_Previews: PreviewProvider {
// static var previews: some View {
//
// PaymentsListView(
// payments: [
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .succeeded
// ),
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .pending
// ),
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .failed
// ),
// ]
// )
//
// PaymentsListView(
// payments: [
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .succeeded
// ),
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .pending
// ),
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .failed
// ),
// ]
// )
// .environment(\.sizeCategory, .accessibilityLarge)
//
// PaymentsListView(
// payments: [
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .succeeded
// ),
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .pending
// ),
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .failed
// ),
// ]
// )
// .environment(\.colorScheme, .dark)
//
// }
//}
Copy link
Contributor

Choose a reason for hiding this comment

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

The commented-out code, including the PaymentSection struct and related logic, should be removed if it's no longer needed to keep the codebase clean.

- //import LDKNode
- //import SwiftUI
- //
- //struct PaymentSection {
- //    let status: PaymentStatus
- //    var payments: [PaymentDetails]
- //}
- //
- //struct PaymentsListView: View {
- //    let payments: [PaymentDetails]
- //    var sections: [PaymentSection] {
- //        orderedStatuses.compactMap { status -> PaymentSection? in
- //            guard let paymentsForStatus = groupedPayments[status] else { return nil }
- //            return PaymentSection(status: status, payments: paymentsForStatus)
- //        }
- //    }
- //    ...
- //}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
//import LDKNode
//import SwiftUI
//
//struct PaymentSection {
// let status: PaymentStatus
// var payments: [PaymentDetails]
//}
//
//struct PaymentsListView: View {
// let payments: [PaymentDetails]
// var sections: [PaymentSection] {
// orderedStatuses.compactMap { status -> PaymentSection? in
// guard let paymentsForStatus = groupedPayments[status] else { return nil }
// return PaymentSection(status: status, payments: paymentsForStatus)
// }
// }
// let orderedStatuses: [PaymentStatus] = [
// .succeeded,
// .pending,
// .failed,
// ]
// var statusDescriptions: [PaymentStatus: String] {
// [
// .succeeded: "Success",
// .pending: "Pending",
// .failed: "Failure",
// ]
// }
// var statusColors: [PaymentStatus: Color] {
// [
// .succeeded: .green,
// .pending: .yellow,
// .failed: .red,
// ]
// }
// var groupedPayments: [PaymentStatus: [PaymentDetails]] {
// Dictionary(grouping: payments, by: { $0.status })
// }
//
// var body: some View {
// List {
// ForEach(sections, id: \.status) { section in
// Section(header: Text(statusDescriptions[section.status] ?? "")) {
// ForEach(section.payments, id: \.id) { payment in
// VStack {
// HStack(alignment: .center, spacing: 15) {
// VStack(alignment: .leading, spacing: 5.0) {
// PaymentDetailView(payment: payment)
// }
// Spacer()
// }
// .padding(.all, 10.0)
// }
// }
// }
// }
// }
// }
//}
//
//struct PaymentDetailView: View {
// let payment: PaymentDetails
//
// var body: some View {
// VStack {
// HStack(alignment: .center, spacing: 15) {
// VStack(alignment: .leading, spacing: 5.0) {
// HStack {
// Image(systemName: payment.direction == .inbound ? "arrow.down" : "arrow.up")
// .font(.subheadline)
// .bold()
// let paymentAmount = payment.amountMsat ?? 0
// let amount = paymentAmount.formattedAmount()
// Text("\(amount) sats")
// .font(.body)
// .bold()
// }
// HStack {
// Text("Payment Hash")
// .lineLimit(1)
// .minimumScaleFactor(0.75)
// Text(payment.id)
// .truncationMode(.middle)
// .lineLimit(1)
// .foregroundColor(.secondary)
// }
// .font(.caption)
//
// if let preimage = payment.kind.preimageAsString {
// //if let preimage = payment.preimage {
// HStack {
// Text("Preimage")
// .lineLimit(1)
// .minimumScaleFactor(0.75)
// Text(preimage)
// .truncationMode(.middle)
// .lineLimit(1)
// .foregroundColor(.secondary)
// }
// .font(.caption)
// }
//
// }
// Spacer()
// }
// .padding(.all, 10.0)
// }
// }
//
//}
//
//struct PaymentsListItemView_Previews: PreviewProvider {
// static var previews: some View {
//
// PaymentsListView(
// payments: [
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .succeeded
// ),
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .pending
// ),
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .failed
// ),
// ]
// )
//
// PaymentsListView(
// payments: [
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .succeeded
// ),
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .pending
// ),
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .failed
// ),
// ]
// )
// .environment(\.sizeCategory, .accessibilityLarge)
//
// PaymentsListView(
// payments: [
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .succeeded
// ),
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .pending
// ),
// .init(
// id: .localizedName(of: .ascii),
// kind: .bolt11(hash: .localizedName(of: .ascii), preimage: nil, secret: nil),
// amountMsat: nil,
// direction: .inbound,
// status: .failed
// ),
// ]
// )
// .environment(\.colorScheme, .dark)
//
// }
//}

</details>
<!-- suggestion_end -->

<!-- This is an auto-generated comment by CodeRabbit -->

Image(systemName: "person.circle.fill")
.font(.title)
.foregroundColor(.secondary)
.foregroundColor(.primary)
Copy link
Contributor

Choose a reason for hiding this comment

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

The .foregroundColor(.primary) modifier is redundant if it's the default color for Image(systemName:). Consider removing it for clarity.

- .foregroundColor(.primary)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
.foregroundColor(.primary)

await viewModel.getTotalOnchainBalanceSats()
await viewModel.getTotalLightningBalanceSats()
await viewModel.getPrices()
await viewModel.getStatus()
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment about needing to refresh the view again should be addressed or removed if no longer relevant.

- // TODO: when i come back to this i need to refresh the view again

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
await viewModel.getStatus()
await viewModel.getStatus()

AE1D9BEA2B2A1FFD00620748 /* XCRemoteSwiftPackageReference "BitcoinUI" */,
AE7C4A062B406D590061189D /* XCRemoteSwiftPackageReference "SimpleToast" */,
AEF66F4E2BA4A3E600FA15F9 /* XCRemoteSwiftPackageReference "ldk-node" */,
AE2DD9612BC45B3F00EE0696 /* XCLocalSwiftPackageReference "../ldk-node/bindings/swift" */,
Copy link
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

Comment on lines +64 to +70
func getStatus() async {
let status = LightningNodeService.shared.status()
DispatchQueue.main.async {
self.status = status
self.isStatusFinished = true
}
}
Copy link
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.

Comment on lines +80 to +86
func getStatus() async {
let status = LightningNodeService.shared.status()
DispatchQueue.main.async {
self.status = status
self.isStatusFinished = true
}
}
Copy link
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.

viewModel.getNetwork()
viewModel.getEsploraUrl()
viewModel.getColor()
await viewModel.getStatus()
Copy link
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 await viewModel.getStatus() call to improve robustness.

@reez reez changed the title spm: ldk-node local main 71b1d3c spm: ldk-node local main May 17, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between e5de567 and 81581bd.
Files selected for processing (4)
  • LDKNodeMonday/Extensions/Event+Extensions.swift (1 hunks)
  • LDKNodeMonday/Service/Lightning Service/LightningNodeService.swift (5 hunks)
  • LDKNodeMonday/Service/Lightning Service/LightningServiceError.swift (1 hunks)
  • LDKNodeMonday/View/Home/Payments/PaymentsListView.swift (4 hunks)
Additional comments not posted (27)
LDKNodeMonday/Extensions/Event+Extensions.swift (3)

17-17: LGTM! The updated paymentSuccessful case improves readability.


20-22: LGTM! The updated paymentFailed case improves readability.


24-26: LGTM! The updated paymentReceived case improves readability.

LDKNodeMonday/Service/Lightning Service/LightningServiceError.swift (1)

119-119: LGTM! The updated InvalidPaymentId case improves readability.

LDKNodeMonday/Service/Lightning Service/LightningNodeService.swift (3)

178-179: LGTM! The removal of the force argument simplifies the function call.


190-191: LGTM! The combination of parameters in the sendUsingAmount call simplifies the function call.


250-253: LGTM! The new status() method adds useful functionality.

LDKNodeMonday/View/Home/Payments/PaymentsListView.swift (20)

13-14: LGTM! The new groupedPayments computed property improves readability.


37-37: LGTM! The new body property improves readability.


39-39: LGTM! The ForEach loop to iterate over orderedStatuses improves readability.


40-40: LGTM! The if let statement to check for groupedPayments improves readability.


41-41: LGTM! The Section header for each payment status improves readability.


42-42: LGTM! The ForEach loop to iterate over payments improves readability.


43-43: LGTM! The VStack to display payment details improves readability.


44-44: LGTM! The HStack to display payment direction and amount improves readability.


45-45: LGTM! The nested VStack to display payment details improves readability.


46-46: LGTM! The HStack to display payment direction improves readability.


47-47: LGTM! The switch statement to determine payment direction improves readability.


48-48: LGTM! The case for inbound payment direction improves readability.


49-52: LGTM! The Image for inbound payment direction improves readability.


53-56: LGTM! The case for outbound payment direction improves readability.


57-57: LGTM! The nested HStack to display payment amount improves readability.


58-58: LGTM! The let statement to format payment amount improves readability.


59-63: LGTM! The Text view to display payment amount improves readability.


88-88: LGTM! The Spacer in the HStack improves readability.


90-90: LGTM! The padding in the HStack improves readability.


106-120: LGTM! The PaymentsListView preview with sample data improves readability.

class LightningNodeService {
static var shared: LightningNodeService = LightningNodeService()
private let ldkNode: Node
private let ldkNode: Node//LdkNode
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the comment //LdkNode as it seems to be a leftover from debugging or development.

-    private let ldkNode: Node//LdkNode
+    private let ldkNode: Node

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
private let ldkNode: Node//LdkNode
private let ldkNode: Node

Comment on lines +65 to +73
// HStack {
// Text("Payment Hash")
// .lineLimit(1)
// .minimumScaleFactor(0.75)
// Text(payment.kind.bolt11.hash)
// .truncationMode(.middle)
// .lineLimit(1)
// .foregroundColor(.secondary)
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the commented-out code for payment hash if it's no longer needed.

-//                                        HStack {
-//                                            Text("Payment Hash")
-//                                                .lineLimit(1)
-//                                                .minimumScaleFactor(0.75)
-//                                            Text(payment.kind.bolt11.hash)
-//                                                .truncationMode(.middle)
-//                                                .lineLimit(1)
-//                                                .foregroundColor(.secondary)
-//                                        }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
// HStack {
// Text("Payment Hash")
// .lineLimit(1)
// .minimumScaleFactor(0.75)
// Text(payment.kind.bolt11.hash)
// .truncationMode(.middle)
// .lineLimit(1)
// .foregroundColor(.secondary)
// }

Comment on lines +75 to +86
// if let preimage = payment.preimage {
// HStack {
// Text("Preimage")
// .lineLimit(1)
// .minimumScaleFactor(0.75)
// Text(preimage)
// .truncationMode(.middle)
// .lineLimit(1)
// .foregroundColor(.secondary)
// }
// .font(.caption)
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the commented-out code for payment preimage if it's no longer needed.

-//                                        if let preimage = payment.preimage {
-//                                            HStack {
-//                                                Text("Preimage")
-//                                                    .lineLimit(1)
-//                                                    .minimumScaleFactor(0.75)
-//                                                Text(preimage)
-//                                                    .truncationMode(.middle)
-//                                                    .lineLimit(1)
-//                                                    .foregroundColor(.secondary)
-//                                            }
-//                                            .font(.caption)
-//                                        }

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
// if let preimage = payment.preimage {
// HStack {
// Text("Preimage")
// .lineLimit(1)
// .minimumScaleFactor(0.75)
// Text(preimage)
// .truncationMode(.middle)
// .lineLimit(1)
// .foregroundColor(.secondary)
// }
// .font(.caption)
// }

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 81581bd and 337ae3c.
Files selected for processing (3)
  • LDKNodeMonday/Service/Lightning Service/LightningNodeService.swift (4 hunks)
  • LDKNodeMonday/Service/Lightning Service/LightningServiceError.swift (1 hunks)
  • LDKNodeMonday/View/Home/Payments/PaymentsListView.swift (4 hunks)
Files not reviewed due to errors (1)
  • LDKNodeMonday/View/Home/Payments/PaymentsListView.swift (no review received)
Files skipped from review as they are similar to previous changes (2)
  • LDKNodeMonday/Service/Lightning Service/LightningNodeService.swift
  • LDKNodeMonday/Service/Lightning Service/LightningServiceError.swift

@reez reez changed the base branch from main to ohtwoplace May 27, 2024 20:07
@reez reez changed the base branch from ohtwoplace to main May 27, 2024 20:07
@reez reez closed this May 28, 2024
@reez reez deleted the node-stats branch June 1, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant