Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(draft) feat: onchain #161

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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,14 +3,13 @@
archiveVersion = 1;
classes = {
};
objectVersion = 56;
objectVersion = 60;
objects = {

/* Begin PBXBuildFile section */
655574802D398A750064F859 /* LoadingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6555747F2D398A750064F859 /* LoadingView.swift */; };
655574822D3994E10064F859 /* ErrorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 655574812D3994E10064F859 /* ErrorView.swift */; };
655C19042D42AB1500AC5F72 /* WalletClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 655C19032D42AB1500AC5F72 /* WalletClient.swift */; };
65875A932CCB9809000D3E70 /* LDKNode in Frameworks */ = {isa = PBXBuildFile; productRef = 65875A922CCB9809000D3E70 /* LDKNode */; };
659EE6952CF8D4990064ED78 /* ImportWalletView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 659EE6942CF8D4990064ED78 /* ImportWalletView.swift */; };
65A406632D070CBD00EA331E /* NetworkSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65A406622D070CBD00EA331E /* NetworkSettingsView.swift */; };
AE00550E2B479EF000100797 /* OnboardingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AE00550D2B479EF000100797 /* OnboardingView.swift */; };
Expand Down Expand Up @@ -81,6 +80,7 @@
AEBFD8B02B8A97DB0024E3F7 /* LightningServiceProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEBFD8AF2B8A97DB0024E3F7 /* LightningServiceProvider.swift */; };
AEBFD8B22B8ABF7C0024E3F7 /* AmountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEBFD8B12B8ABF7C0024E3F7 /* AmountView.swift */; };
AEBFD8B62B8BABC00024E3F7 /* ReceiveView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEBFD8B52B8BABC00024E3F7 /* ReceiveView.swift */; };
AED1DBF72D514609008CBD48 /* LDKNode in Frameworks */ = {isa = PBXBuildFile; productRef = AED1DBF62D514609008CBD48 /* LDKNode */; };
AEDF47F12B3FADF900145D64 /* EventService.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEDF47F02B3FADF900145D64 /* EventService.swift */; };
AEDF47F32B3FBAB900145D64 /* Notification+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEDF47F22B3FBAB900145D64 /* Notification+Extensions.swift */; };
AEDF76022B5C6863002DDEE1 /* Optional+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEDF76012B5C6863002DDEE1 /* Optional+Extensions.swift */; };
Expand Down Expand Up @@ -179,7 +179,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
65875A932CCB9809000D3E70 /* LDKNode in Frameworks */,
AED1DBF72D514609008CBD48 /* LDKNode in Frameworks */,
AE060C382C051B59006724F1 /* LDKNode in Frameworks */,
AE1D9BEC2B2A1FFD00620748 /* BitcoinUI in Frameworks */,
AEE5B7652A09B1FC001E5E59 /* CodeScanner in Frameworks */,
Expand Down Expand Up @@ -557,7 +557,7 @@
AE7C4A072B406D590061189D /* SimpleToast */,
AE060C372C051B59006724F1 /* LDKNode */,
AE80C2042C4AB5E4006E7193 /* LDKNode */,
65875A922CCB9809000D3E70 /* LDKNode */,
AED1DBF62D514609008CBD48 /* LDKNode */,
);
productName = LDKNodeMonday;
productReference = AE17E8D629A402E30058C9C9 /* LDKNodeMonday.app */;
Expand Down Expand Up @@ -592,7 +592,7 @@
AE01C5AE2AB3BEED00F28C7E /* XCRemoteSwiftPackageReference "KeychainAccess" */,
AE1D9BEA2B2A1FFD00620748 /* XCRemoteSwiftPackageReference "BitcoinUI" */,
AE7C4A062B406D590061189D /* XCRemoteSwiftPackageReference "SimpleToast" */,
65875A912CCB9809000D3E70 /* XCRemoteSwiftPackageReference "ldk-node" */,
AED1DBF52D514609008CBD48 /* XCLocalSwiftPackageReference "../ldk-node/bindings/swift" */,
);
productRefGroup = AE17E8D729A402E30058C9C9 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -907,15 +907,14 @@
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
65875A912CCB9809000D3E70 /* XCRemoteSwiftPackageReference "ldk-node" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/lightningdevkit/ldk-node.git";
requirement = {
kind = exactVersion;
version = 0.4.3;
};
/* Begin XCLocalSwiftPackageReference section */
AED1DBF52D514609008CBD48 /* XCLocalSwiftPackageReference "../ldk-node/bindings/swift" */ = {
isa = XCLocalSwiftPackageReference;
relativePath = "../ldk-node/bindings/swift";
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCRemoteSwiftPackageReference section */
AE01C5AE2AB3BEED00F28C7E /* XCRemoteSwiftPackageReference "KeychainAccess" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/kishikawakatsumi/KeychainAccess.git";
Expand Down Expand Up @@ -951,11 +950,6 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
65875A922CCB9809000D3E70 /* LDKNode */ = {
isa = XCSwiftPackageProductDependency;
package = 65875A912CCB9809000D3E70 /* XCRemoteSwiftPackageReference "ldk-node" */;
productName = LDKNode;
};
AE01C5AF2AB3BEED00F28C7E /* KeychainAccess */ = {
isa = XCSwiftPackageProductDependency;
package = AE01C5AE2AB3BEED00F28C7E /* XCRemoteSwiftPackageReference "KeychainAccess" */;
Expand Down Expand Up @@ -983,6 +977,10 @@
isa = XCSwiftPackageProductDependency;
productName = LDKNode;
};
AED1DBF62D514609008CBD48 /* LDKNode */ = {
isa = XCSwiftPackageProductDependency;
productName = LDKNode;
};
AEE5B7642A09B1FC001E5E59 /* CodeScanner */ = {
isa = XCSwiftPackageProductDependency;
package = AEE5B7632A09B1FC001E5E59 /* XCRemoteSwiftPackageReference "CodeScanner" */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "3c4f831e3e2d84e3d749572be35ef446cf04910008de67451a51af6ca58e22b3",
"originHash" : "2d457a0d145c5ec561d10ae3f13d805b262d5bfda9ebf0868311848416a25b6e",
"pins" : [
{
"identity" : "bitcoinui",
Expand Down Expand Up @@ -28,15 +28,6 @@
"version" : "4.2.2"
}
},
{
"identity" : "ldk-node",
"kind" : "remoteSourceControl",
"location" : "https://github.com/lightningdevkit/ldk-node.git",
"state" : {
"revision" : "a5c4a44dd44f098acec6c244a63d4ebb5d794132",
"version" : "0.4.3"
}
},
{
"identity" : "simpletoast",
"kind" : "remoteSourceControl",
Expand Down
21 changes: 18 additions & 3 deletions LDKNodeMonday/Extensions/Event+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ extension Event: CustomStringConvertible {

switch self {

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

case .paymentFailed(_, let paymentHash, let paymentFailureReason):
return
"Payment Failed \(paymentFailureReason.debugDescription) \(String(describing: paymentHash?.truncated(toLength: 10)))"

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

Expand All @@ -36,11 +36,26 @@ extension Event: CustomStringConvertible {
return
"Channel Closed \(debugReason) \(counterpartyNodeId?.truncated(toLength: 10) ?? "")"

case .paymentForwarded(
let prevChannelId,
let nextChannelId,
let prevUserChannelId,
let nextUserChannelId,
let prevNodeId,
let nextNodeId,
let totalFeeEarnedMsat,
let skimmedFeeMsat,
let claimFromOnchainTx,
let outboundAmountForwardedMsat
):
return "Payment Forwarded"

case .paymentClaimable(
let paymentId,
let paymentHash,
let claimableAmountMsat,
let claimDeadline
let claimDeadline,
let customRecords
):
return "Payment Claimable \(paymentHash.truncated(toLength: 10))"

Expand Down
21 changes: 17 additions & 4 deletions LDKNodeMonday/Service/Lightning Service/LightningNodeService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,26 @@ class LightningNodeService {
withIntermediateDirectories: true
)

// This is what `Config` looks like now, need to find out where `logDirPath` and `logLevel` are now

// public struct Config {
// public var storageDirPath: String
// public var network: Network
// public var listeningAddresses: [SocketAddress]?
// public var nodeAlias: NodeAlias?
// public var trustedPeers0conf: [PublicKey]
// public var probingLiquidityLimitMultiplier: UInt64
// public var anchorChannelsConfig: AnchorChannelsConfig?
// public var sendingParameters: SendingParameters?

var config = defaultConfig()
config.storageDirPath = networkPath
config.logDirPath = logPath
//config.logDirPath = logPath
config.network = self.network
config.trustedPeers0conf = [
Constants.Config.LiquiditySourceLsps2.Signet.lqwd.nodeId
]
config.logLevel = .trace
//config.logLevel = .trace

let nodeBuilder = Builder.fromConfig(config: config)
nodeBuilder.setChainSourceEsplora(serverUrl: self.server.url, config: nil)
Expand Down Expand Up @@ -253,7 +265,7 @@ class LightningNodeService {

func receiveViaJitChannel(
amountMsat: UInt64,
description: String,
description: Bolt11InvoiceDescription,
expirySecs: UInt32,
maxLspFeeLimitMsat: UInt64?
) async throws -> Bolt11Invoice {
Expand Down Expand Up @@ -349,7 +361,8 @@ public struct LightningNodeClient {
let closeChannel: (ChannelId, PublicKey) throws -> Void
let send: (String) async throws -> QrPaymentResult
let receive: (UInt64, String, UInt32) async throws -> String
let receiveViaJitChannel: (UInt64, String, UInt32, UInt64?) async throws -> Bolt11Invoice
let receiveViaJitChannel:
(UInt64, Bolt11InvoiceDescription, UInt32, UInt64?) async throws -> Bolt11Invoice
let listPeers: () -> [PeerDetails]
let listChannels: () -> [ChannelDetails]
let listPayments: () -> [PaymentDetails]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ func handleNodeError(_ error: NodeError) -> MondayError {
case .InvalidNodeAlias(let message):
return .init(title: "InvalidNodeAlias", detail: message)

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

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class JITInvoiceViewModel: ObservableObject {

func receivePaymentViaJitChannel(
amountMsat: UInt64,
description: String,
description: Bolt11InvoiceDescription,
expirySecs: UInt32,
maxLspFeeLimitMsat: UInt64?
) async {
Expand Down
2 changes: 1 addition & 1 deletion LDKNodeMonday/View/Home/Receive/JITInvoiceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct JITInvoiceView: View {
let amountMsat = (UInt64(viewModel.amountMsat) ?? 0) * 1000
await viewModel.receivePaymentViaJitChannel(
amountMsat: amountMsat,
description: "Monday Wallet",
description: .direct(description: "Monday Wallet"),
expirySecs: UInt32(3600),
maxLspFeeLimitMsat: nil
)
Expand Down
3 changes: 3 additions & 0 deletions LDKNodeMonday/View/Settings/Channel/ChannelDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ struct ChannelDetailView: View {
channelId: ChannelId(stringLiteral: "channelID"),
counterpartyNodeId: PublicKey(stringLiteral: "counterpartyNodeId"),
fundingTxo: nil,
shortChannelId: UInt64(1_000_000),
outboundScidAlias: UInt64(1_000_000),
inboundScidAlias: UInt64(1_000_000),
channelValueSats: UInt64(1_000_000),
unspendablePunishmentReserve: nil,
userChannelId: UserChannelId(stringLiteral: "userChannelId"),
Expand Down