Skip to content
Draft
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
2 changes: 2 additions & 0 deletions .agents/commands/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ Print the path to the local draft. Store it for the summary. Slack posting is de

### 7. Build & Upload to TestFlight (optional)

Before archiving, `Secrets.xcconfig` must exist at the repo root with `BREEZ_API_KEY` set (copy `Secrets.xcconfig.template`). Release builds fail without it. Check with `grep -q '^BREEZ_API_KEY = .\+' Secrets.xcconfig`; if it fails, stop and ask the releaser for the key. Never print the key.

Use `AskUserQuestion`:

**Question:** `"Archive and upload to TestFlight?"`
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ buildServer.json

# XcodeBuildMCP
.xcodebuildmcp/config.yaml

# Local build secrets (see Secrets.xcconfig.template)
Secrets.xcconfig
4 changes: 4 additions & 0 deletions Bitkit.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Base settings for the Bitkit app target.
// Local secrets stay out of git: copy Secrets.xcconfig.template to Secrets.xcconfig and fill it in.
// Without it the app builds with Spark (Lightning without channels) off on mainnet.
#include? "Secrets.xcconfig"
42 changes: 42 additions & 0 deletions Bitkit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
4AAB08CA2E1FE77600BA63DF /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = 4AAB08C92E1FE77600BA63DF /* Lottie */; };
961058E32C355B5500E1F1D8 /* BitkitNotification.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 961058DC2C355B5500E1F1D8 /* BitkitNotification.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
968FDF162DFAFE230053CD7F /* LDKNode in Frameworks */ = {isa = PBXBuildFile; productRef = 9613018B2C5022D700878183 /* LDKNode */; };
72B5EE0000000000000000A3 /* BreezSdkSpark in Frameworks */ = {isa = PBXBuildFile; productRef = 72B5EE0000000000000000A2 /* BreezSdkSpark */; };
968FE1402DFB016B0053CD7F /* LDKNode in Frameworks */ = {isa = PBXBuildFile; productRef = 968FE13F2DFB016B0053CD7F /* LDKNode */; };
96DEA03A2DE8BBA1009932BF /* BitkitCore in Frameworks */ = {isa = PBXBuildFile; productRef = 96DEA0392DE8BBA1009932BF /* BitkitCore */; };
96DEA03C2DE8BBAB009932BF /* BitkitCore in Frameworks */ = {isa = PBXBuildFile; productRef = 96DEA03B2DE8BBAB009932BF /* BitkitCore */; };
Expand Down Expand Up @@ -74,6 +75,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
B17C0F1A2EAE000000000001 /* Bitkit.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Bitkit.xcconfig; sourceTree = "<group>"; };
3D76260E4C9C4A53B1E4A001 /* CoreBluetooth.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreBluetooth.framework; path = System/Library/Frameworks/CoreBluetooth.framework; sourceTree = SDKROOT; };
4A319B4F2E8F24F2002B9AC9 /* BitkitWidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = BitkitWidgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
4A319B502E8F24F2002B9AC9 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -262,6 +264,7 @@
buildActionMask = 2147483647;
files = (
182817C12F59A7F10055A441 /* Paykit in Frameworks */,
72B5EE0000000000000000A3 /* BreezSdkSpark in Frameworks */,
3D76260F4C9C4A53B1E4A001 /* CoreBluetooth.framework in Frameworks */,
968FDF162DFAFE230053CD7F /* LDKNode in Frameworks */,
18D65E002EB964B500252335 /* VssRustClientFfi in Frameworks */,
Expand Down Expand Up @@ -302,6 +305,7 @@
96FE1F582C2DE6AA006D0C8B = {
isa = PBXGroup;
children = (
B17C0F1A2EAE000000000001 /* Bitkit.xcconfig */,
4A319B6E2E8F25F6002B9AC9 /* BitkitWidgetExtension.entitlements */,
96A44E912CEF5EA700FBACFF /* Bitkit */,
96A44F4A2CEF5F4B00FBACFF /* BitkitTests */,
Expand Down Expand Up @@ -378,6 +382,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 96FE1F862C2DE6AC006D0C8B /* Build configuration list for PBXNativeTarget "Bitkit" */;
buildPhases = (
B17C0F1A2EAE000000000002 /* Check Breez API Key */,
96FE1F5D2C2DE6AA006D0C8B /* Sources */,
96FE1F5E2C2DE6AA006D0C8B /* Frameworks */,
96FE1F5F2C2DE6AA006D0C8B /* Resources */,
Expand All @@ -402,6 +407,7 @@
4AAB08C92E1FE77600BA63DF /* Lottie */,
18D65DFF2EB964B500252335 /* VssRustClientFfi */,
182817C02F59A7F10055A441 /* Paykit */,
72B5EE0000000000000000A2 /* BreezSdkSpark */,
);
productName = Bitkit;
productReference = 96FE1F612C2DE6AA006D0C8B /* Bitkit.app */;
Expand Down Expand Up @@ -511,6 +517,7 @@
4AAB08C82E1FE77600BA63DF /* XCRemoteSwiftPackageReference "lottie-ios" */,
18D65DFE2EB9649F00252335 /* XCRemoteSwiftPackageReference "vss-rust-client-ffi" */,
182817BF2F59A7F10055A441 /* XCRemoteSwiftPackageReference "paykit-rs" */,
72B5EE0000000000000000A1 /* XCRemoteSwiftPackageReference "breez-sdk-spark-swift" */,
);
productRefGroup = 96FE1F622C2DE6AA006D0C8B /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -565,6 +572,26 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
B17C0F1A2EAE000000000002 /* Check Breez API Key */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Check Breez API Key";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ \"$CONFIGURATION\" = \"Release\" ] && [ -z \"$(echo \"${BREEZ_API_KEY}\" | tr -d ' ')\" ]; then\n echo \"error: BREEZ_API_KEY is empty. Copy Secrets.xcconfig.template to Secrets.xcconfig and set the key before a Release build or archive (Docs/RELEASE.md).\"\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
751000000000000000000001 /* Generate Plural Localizations */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
Expand Down Expand Up @@ -944,6 +971,7 @@
};
96FE1F872C2DE6AC006D0C8B /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = B17C0F1A2EAE000000000001 /* Bitkit.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
Expand Down Expand Up @@ -997,6 +1025,7 @@
};
96FE1F882C2DE6AC006D0C8B /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = B17C0F1A2EAE000000000001 /* Bitkit.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
Expand Down Expand Up @@ -1219,6 +1248,14 @@
version = 4.6.1;
};
};
72B5EE0000000000000000A1 /* XCRemoteSwiftPackageReference "breez-sdk-spark-swift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/breez/breez-sdk-spark-swift";
requirement = {
kind = exactVersion;
version = 0.27.2;
};
};
968FE13E2DFB016B0053CD7F /* XCRemoteSwiftPackageReference "ldk-node" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/synonymdev/ldk-node";
Expand Down Expand Up @@ -1266,6 +1303,11 @@
package = 4AAB08C82E1FE77600BA63DF /* XCRemoteSwiftPackageReference "lottie-ios" */;
productName = Lottie;
};
72B5EE0000000000000000A2 /* BreezSdkSpark */ = {
isa = XCSwiftPackageProductDependency;
package = 72B5EE0000000000000000A1 /* XCRemoteSwiftPackageReference "breez-sdk-spark-swift" */;
productName = BreezSdkSpark;
};
9613018B2C5022D700878183 /* LDKNode */ = {
isa = XCSwiftPackageProductDependency;
package = 968FE13E2DFB016B0053CD7F /* XCRemoteSwiftPackageReference "ldk-node" */;
Expand Down

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

31 changes: 31 additions & 0 deletions Bitkit/AppScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,16 @@ enum IncomingPaykitPaymentRequestPresentationDispatcher {
return IncomingPaykitPaymentRequestPresentationFeedback(paymentDetailsPendingWasRequested: wasRequested)
}

/// Ends a presentation the user asked for once its payment details fail to resolve, so the send sheet stops loading
/// and the user sees why; the request stays in Payment Requests to try again. Automatic presentations keep retrying.
static func finishRequestedPresentationAfterResolutionFailure(
for request: PaykitPaymentRequest,
with manager: PaykitPaymentRequestManager
) -> IncomingPaykitPaymentRequestPresentationFeedback? {
guard manager.requestedPresentationId == request.id else { return nil }
return finishPendingPrivateLink(for: request, with: manager)
}

static func handleStateChange(
from previous: IncomingPaykitPaymentRequestPresentationState,
to current: IncomingPaykitPaymentRequestPresentationState,
Expand Down Expand Up @@ -1723,6 +1733,20 @@ struct AppScene: View {
return
}
guard case let .opened(paymentTarget, privatePaymentContext, endpoints) = result else {
let isWaitingForUpdatedList = if case .waitingForUpdatedPaymentList = result {
true
} else {
false
}
if !isWaitingForUpdatedList,
let feedback = IncomingPaykitPaymentRequestPresentationDispatcher.finishRequestedPresentationAfterResolutionFailure(
for: request,
with: paykitPaymentRequestManager
)
{
presentIncomingPaykitPaymentRequestFeedback(feedback, for: request)
return
}
deferIncomingPaykitPaymentRequestPresentation(
request,
reason: result.incomingPaymentRequestFailureReason ?? .resolutionFailed
Expand Down Expand Up @@ -1848,6 +1872,13 @@ struct AppScene: View {
return
} catch {
guard isCurrentIncomingPaymentRequestPreparation(preparation) else { return }
if let feedback = IncomingPaykitPaymentRequestPresentationDispatcher.finishRequestedPresentationAfterResolutionFailure(
for: request,
with: paykitPaymentRequestManager
) {
presentIncomingPaykitPaymentRequestFeedback(feedback, for: request)
return
}
deferIncomingPaykitPaymentRequestPresentation(request, reason: .resolutionFailed)
return
}
Expand Down
106 changes: 69 additions & 37 deletions Bitkit/Components/LightningChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ struct LightningChannel: View {
let remoteBalance: UInt64
let status: ChannelStatus
let showLabels: Bool
/// False for a balance whose receiving isn't capped by a channel, such as Spark: only the spending side is drawn.
let showReceiving: Bool

init(
capacity: UInt64,
localBalance: UInt64,
remoteBalance: UInt64,
status: ChannelStatus = .open,
showLabels: Bool = false
showLabels: Bool = false,
showReceiving: Bool = true
) {
self.capacity = capacity
self.localBalance = localBalance
self.remoteBalance = remoteBalance
self.status = status
self.showLabels = showLabels
self.showReceiving = showReceiving
}

private var spendingColor: Color {
Expand Down Expand Up @@ -90,7 +94,9 @@ struct LightningChannel: View {

Spacer()

CaptionMText(t("lightning__receiving_label"))
if showReceiving {
CaptionMText(t("lightning__receiving_label"))
}
}
}

Expand All @@ -106,49 +112,75 @@ struct LightningChannel: View {

Spacer()

HStack(spacing: 4) {
Image("arrow-down")
.resizable()
.frame(width: 14, height: 14)
.foregroundColor(receivingAvailableColor)
if showReceiving {
HStack(spacing: 4) {
Image("arrow-down")
.resizable()
.frame(width: 14, height: 14)
.foregroundColor(receivingAvailableColor)

BodySSBText(formatNumber(remoteBalance), textColor: receivingAvailableColor)
BodySSBText(formatNumber(remoteBalance), textColor: receivingAvailableColor)
}
}
}

HStack(spacing: 4) {
// Spending bar (left)
ZStack(alignment: .trailing) {
// Background
Rectangle()
.fill(spendingColor)
.cornerRadius(8, corners: [.topLeft, .bottomLeft])

// Available
Rectangle()
.fill(spendingAvailableColor)
.frame(width: spendingPercentage * 100.0)
.cornerRadius(8, corners: [.topLeft, .bottomLeft])
}

// Receiving bar (right)
ZStack(alignment: .leading) {
// Background
Rectangle()
.fill(receivingColor)
.cornerRadius(8, corners: [.topRight, .bottomRight])

// Available
Rectangle()
.fill(receivingAvailableColor)
.frame(width: receivingPercentage * 100.0)
.cornerRadius(8, corners: [.topRight, .bottomRight])
}
if showReceiving {
channelBars
} else {
spendingBar
}
.frame(height: 16)
}
.opacity(status == .pending ? 0.5 : 1.0)
}

private var spendingBar: some View {
GeometryReader { geometry in
ZStack(alignment: .leading) {
Rectangle()
.fill(localBalance == 0 ? Color.gray6 : spendingColor)
.cornerRadius(8)

Rectangle()
.fill(spendingAvailableColor)
.frame(width: spendingPercentage * geometry.size.width)
.cornerRadius(8)
}
}
.frame(height: 16)
}

private var channelBars: some View {
HStack(spacing: 4) {
// Spending bar (left)
ZStack(alignment: .trailing) {
// Background
Rectangle()
.fill(spendingColor)
.cornerRadius(8, corners: [.topLeft, .bottomLeft])

// Available
Rectangle()
.fill(spendingAvailableColor)
.frame(width: spendingPercentage * 100.0)
.cornerRadius(8, corners: [.topLeft, .bottomLeft])
}

// Receiving bar (right)
ZStack(alignment: .leading) {
// Background
Rectangle()
.fill(receivingColor)
.cornerRadius(8, corners: [.topRight, .bottomRight])

// Available
Rectangle()
.fill(receivingAvailableColor)
.frame(width: receivingPercentage * 100.0)
.cornerRadius(8, corners: [.topRight, .bottomRight])
}
}
.frame(height: 16)
}
}

/// Extension to apply rounded corners to specific corners
Expand Down
Loading
Loading