This is an example iOS application demonstrating how to use the Lightning Node Interface (LNI) Swift bindings with SwiftUI.
This example app provides a simple UI for testing various Lightning Network node implementations:
- Strike - Strike Lightning API
- Blink - Blink Lightning service
- NWC - Nostr Wallet Connect
- CLN - Core Lightning
- LND - Lightning Network Daemon
- Phoenixd - Phoenix daemon
- macOS with Xcode 15.0 or later
- Rust toolchain (stable)
- iOS Simulator or physical iOS device
From the bindings/swift directory:
./build.sh --release --iosThis will:
- Build the LNI library with UniFFI support
- Generate Swift bindings in
Sources/LNI/ - Build static libraries for iOS Simulator and Device
- Create an XCFramework
open ./example/LNIExample/LNIExample.xcodeproj- Drag the generated
LNI.xcframeworkfrombindings/swift/into your Xcode project - Add the Swift bindings from
bindings/swift/Sources/LNI/lni.swiftto your project - Ensure the framework is set to "Embed & Sign" in Target > General > Frameworks
- Select an iOS Simulator target (e.g., iPhone 15 Pro)
- Press Cmd+R or click the Run button
LNIExample/
├── LNIExample.xcodeproj/ # Xcode project
└── LNIExample/
├── LNIExampleApp.swift # App entry point
├── ContentView.swift # Main UI
└── Assets.xcassets/ # App assets
- Strike Balance: Enter your Strike API key and tap "Get Balance" to fetch your balance
- Node Tests: Tap on any node button (Strike, Blink, NWC, etc.) to see its configuration options
import LNI
let config = StrikeConfig(
apiKey: "your-api-key",
baseUrl: nil,
httpTimeout: nil,
socks5Proxy: nil,
acceptInvalidCerts: nil
)
// Create node using factory function (polymorphic)
let node: LightningNode = createStrikeNode(config: config)
// Get balance
Task {
do {
let info = try await node.getInfo()
print("Balance: \(info.sendBalanceMsat / 1000) sats")
} catch {
print("Error: \(error)")
}
}let invoiceParams = CreateInvoiceParams(
invoiceType: .bolt11,
amountMsats: 21000, // 21 sats
offer: nil,
description: "Test invoice",
descriptionHash: nil,
expiry: 3600,
rPreimage: nil,
isBlinded: false,
isKeysend: false,
isAmp: false,
isPrivate: false
)
let transaction = try await node.createInvoice(params: invoiceParams)
print("Invoice: \(transaction.invoice)")- This example uses placeholder implementations until the LNI library is built and linked
- The actual LNI library usage is commented out in ContentView.swift
- Once the library is linked, uncomment the implementation code
Same license as the main LNI project.