ldk-swift's People
Forkers
ramshandilya gpazo jurvis 22388o jkczyz cypherpoet hebertialmeida sparrowtek arik-so tnull saambaby arealayer reezldk-swift's Issues
Make RpcBlockchainObserver a protocol
Currently we implement RegtestBlockchainManager
, but it will be nice to define a common interface that chain observers need.
Guide in Docs folder is not updated
The "Result_NoneChannelMonitorUpdateErrZ" type does not exist for the version of ldk-swift that is currently in use for swift developers
Pointer being freed was not allocated
Getting a crash on this line in react-native-ldk. Seems to only happen when accidentally cooperatively closing a channel with a disconnected peer instead of force closing. Reproducible almost every time so let me know if there are any other details you need.
Adding a check in react-native-ldk to patch this so not too urgent.
example(14018,0x70000eebe000) malloc: *** error for object 0x60000012b300: pointer being freed was not allocated
example(14018,0x70000eebe000) malloc: *** set a breakpoint in malloc_error_break to debug
2022-10-05 12:19:07.023119+0200 example[14018:1418996] [javascript] [Error: Cannot begin shutdown while peer is disconnected or we're waiting on a monitor update, maybe force-close instead?]
example(14018,0x70000eebe000) malloc: *** error for object 0x60000012b300: pointer being freed was not allocated
CoreSimulator 857.7 - Device: iPhone 14 (C8BBB7A1-CC93-456D-A600-9CD38012F9FB) - Runtime: iOS 16.0 (20A360) - DeviceType: iPhone 14
Check whether None/Some(zero-sized struct) issue is hit
Add JavaScript mocha tests to Github Actions
Compilation issues
Hello,
Demo Project is not working. So I created new project and added LDK Framework using SPM. Then I added project files for Polar connection. However I am getting compilation errors. Any suggestions @danielnordh ?
Add basic readme.md with installation instructions
I'm looking to start using LDKin a new SwiftUI app and would really appreciate a brief installation and setup guide.
I found some documentation linked from the LDK website to SwiftLightning, but not sure if that is fully applicable here, and it doesn't mention the installation.
The rn-ldk repo is a good example of a basic guide (so I can probably grok the overview from there, but a dedicated one for idk-swift would save me and others time).
Fix comment parser to better document the Swift API objects and methods.
Look into using system lipo instead of cargo lipo
I believe cargo-lipo
is now deprecated, and its maintainer strongly recommends using Apple's system lipo
instead: https://github.com/TimNN/cargo-lipo
On top of that, it will not be supporting Mac Catalyst, and makes it impossible for us to build libraries for Mac Catalyst targets that support x86_64
and arm64
architectures.
Add anchors for objects if they're pointer arguments in an initializer
Example: ProbabilisticScorer::init(params: ProbabilisticScoringParameters, networkGraph: NetworkGraph, logger: Logger)
Clarify if we need to apply `Info.plist` fixes for Xcode 15.3
Apple is fun. See here: bitcoindevkit/bdk-ffi#466
(cc @arik-so)
Persisting ChannelManager and ChannelMonitors with Codable
My first attempt at persisting the channel manager and monitors was to try to convert it to Data:
let data = try! JSONEncoder().encode(self.channelManager)
swift
But since ChannelManager does not conform to Codable, that doesn't work.
Any chance we could make that class (and ChannelMonitor) Codable?
Make CI linker settings conditional (if possible)
The linker settings in the CI SPM package are always set: https://github.com/lightningdevkit/ldk-swift/blob/main/ci/LDKSwift/Package.swift#L48
However, on some environments, there is no available address sanitizer library. If there's a way to make linker flags be added conditionally, it would be extremely helpful.
package: error adding ldk-swift to xcode project
Describe the bug
User cannot add ldk-swift to Xcode project.
This is happening for ldk-swift 0.0.117
and main
, but not 0.0.116
.
![Screenshot 2023-10-16 at 1 09 13 PM](https://private-user-images.githubusercontent.com/6657488/275613756-fb1e3197-e92c-4fbf-a7eb-62d6d7a003bb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk3MzE5NDQsIm5iZiI6MTcxOTczMTY0NCwicGF0aCI6Ii82NjU3NDg4LzI3NTYxMzc1Ni1mYjFlMzE5Ny1lOTJjLTRmYmYtYTdlYi02MmQ2ZDdhMDAzYmIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYzMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MzBUMDcxNDA0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NTNmYThhZjE3MGVmYTFjNTQzMWQwNDdiYmU1MjZhMDY1YzljNTY3NTNiZGNiNDMyMjhkOTkzN2Y0ZmZjNGUxYSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.kX6wWweyMth2SqgJWsxQUODDvjZikg4lyvM4SPKFySw)
To Reproduce
Steps to reproduce the behavior in Xcode:
- File -> Add Swift Package Dependencies
- Enter Package URL
https://github.com/lightningdevkit/ldk-swift.git
- Dependency Rule -> Exact Version ->
0.0.117
or Dependency Rule -> Branch ->main
- Add Package
- See error "Invalid Manifest"
- Add Anyway
- See more specific errors in Navigator/IssueNavigator
Expected behavior
User can add ldk-swift to Xcode project when using version 0.0.117
or main
.
Screenshots
main
error
![Screenshot 2023-10-16 at 1 06 39 PM](https://private-user-images.githubusercontent.com/6657488/275615630-4c613114-bbe6-49ac-8758-d73f8a8305a1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk3MzE5NDQsIm5iZiI6MTcxOTczMTY0NCwicGF0aCI6Ii82NjU3NDg4LzI3NTYxNTYzMC00YzYxMzExNC1iYmU2LTQ5YWMtODc1OC1kNzNmOGE4MzA1YTEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYzMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MzBUMDcxNDA0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Nzg2MjU3NGRmZTM1YzU4NTVjZjk4NjFhZDczZTZkNjNkZGQ1OGU1OWFhMDkzZGNjNjYxNWE3ZWVkNzc5NWNmZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.j7VshjbDBUp5-UZaAaf-cXWF_KF4YiM6O_lB9P0hq4A)
![Screenshot 2023-10-16 at 1 07 10 PM](https://private-user-images.githubusercontent.com/6657488/275615632-7e16793a-afda-400b-9662-3f6544d26d3e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk3MzE5NDQsIm5iZiI6MTcxOTczMTY0NCwicGF0aCI6Ii82NjU3NDg4LzI3NTYxNTYzMi03ZTE2NzkzYS1hZmRhLTQwMGItOTY2Mi0zZjY1NDRkMjZkM2UucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYzMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MzBUMDcxNDA0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZDEzMTY0MDM1NTE2ZGMxMjVlODQ3YjU4NjZlNGM1M2UzNzUzMDdjZDcwM2U0ZGI1NTM3ZmRmN2Q2NDNlMmQxNSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.V094I8pIwfyq9837-y7_gXtaFnCCUStgnSrB1ZmRftg)
0.0.116
success
![Screenshot 2023-10-16 at 1 11 25 PM](https://private-user-images.githubusercontent.com/6657488/275615901-dfb16374-2b38-4e46-84b8-0e4910b50c35.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk3MzE5NDQsIm5iZiI6MTcxOTczMTY0NCwicGF0aCI6Ii82NjU3NDg4LzI3NTYxNTkwMS1kZmIxNjM3NC0yYjM4LTRlNDYtODRiOC0wZTQ5MTBiNTBjMzUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYzMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MzBUMDcxNDA0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9N2M5MTk5YTcxOGI2Y2QzOGRmM2EwMThkZjg4NTg2MjhlOGJjOTZlM2I2ZWNlNWExNjcyZTJjOGIyMDk1MTEwZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.OwovOtZfad0eSD-2UkGz9jC3TBFJ-tX9i-1QRCRKKUU)
0.0.117
error
![Screenshot 2023-10-16 at 1 09 13 PM](https://private-user-images.githubusercontent.com/6657488/275615770-01300eb1-3971-4fae-b8a6-a57e0a71c585.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTk3MzE5NDQsIm5iZiI6MTcxOTczMTY0NCwicGF0aCI6Ii82NjU3NDg4LzI3NTYxNTc3MC0wMTMwMGViMS0zOTcxLTRmYWUtYjhhNi1hNTdlMGE3MWM1ODUucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDYzMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA2MzBUMDcxNDA0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NmQwYzU1MWM0MmIwYWNiNDk1MDUwZWQ5YzQ0N2YxYjJiYmI5ZjNmNWNmN2E0NGE1MjE5NDRhZmU0MmVhMzVjNiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.2APbkw6QFHjlNBM_URREVYlBWyJtuBkD3bHi3kpbXB8)
Desktop (please complete the following information):
I did all of my testing (main, 0.0.117, 0.0.116) with two separate OS and Xcode for additional sanity checking.
macOS 15
- Xcode 15.0 with iOS 17.0 minimum support
macOS 13
- Xcode 14.3.1 with iOS 16.4 minimum support
Additional context
On 10/12/23 a user ran into a similar problem and posted about it in the LDK Discord. I followed up with him in the channel that I had run into this sort of error super recently and gave him the short term fix I used to get things working.
Improve `RGS` consideration in `ChannelManagerConstructor`
As with Java, CMC doesn't offer the option to initialize a BackgroundProcessor if a user wishes to use RGS. This issue is already known in Java: lightningdevkit/ldk-garbagecollected#122
Make available via Swift Package Manager
Would be great to have the repo easily available in the standard ways for swift developers.
Top of my list would be Swift package manager, Cocoa Pods and Carthage less important for me personally but others might like that.
If I figure out how this repo is linked to the LDK source I might try and submit a PR for this, but at the moment I haven't wrapped my head around the code to see how easy or hard this would be.
Issues when using example setup code
While attempting to set up LDK with the setup instructions in Xcode 13.2.1, I run into a bunch of errors and warnings.
Some easy to understand and fix, but some less so:
Errors:
override func log(record: String?)
- does not override any function in super
override func persist_new_channel(id: OutPoint, data: ChannelMonitor) -> Result_NoneChannelMonitorUpdateErrZ
- does not override any function in super
override func update_persisted_channel(id: OutPoint, update: ChannelMonitorUpdate, data: ChannelMonitor) -> Result_NoneChannelMonitorUpdateErrZ
- does not override any function in super
let txid = outpoint.get_txid()
- needs ? optional flag
let outputIndex = outpoint.get_index()
- needs ? optional flag
let monitorBytes: [UInt8] = data.write(obj: data)
- Argument passed to call that takes no arguments
chainMonitor = ChainMonitor.init(chain_source: filter, broadcaster: broadcaster, logger: logger, feeest: feeEstimator, persister: persister)
- Cannot convert value of type 'MyFilter' to expected argument type 'Option_FilterZ'
let router = NetGraphMsgHandler(chain_access: nil, logger: logger, network_graph: networkGraph)
- 'nil' is not compatible with expected argument type 'Option_AccessZ', Argument 'network_graph' must precede argument 'chain_access'
let peerManager = PeerManager(message_handler: messageHandler, our_node_secret: nodeSecret, ephemeral_random_data: peerManagerSeed, logger: logger)
- Missing argument for parameter 'custom_message_handler' in call
Warnings:
print("record: \(record)")
- need to account for optional
keyData.withUnsafeMutableBytes {SecRandomCopyBytes(kSecRandomDefault, 32, $0.baseAddress!)}
- Result of call to 'withUnsafeMutableBytes' is unused
let chainParameters = ChainParameters(network_arg: LDKNetwork_Bitcoin, best_block_arg: bestBlock)
- 'init(network_arg:best_block_arg:)' is deprecated: This method passes non-cloneable objects by owned value. Here be dragons.
keyData2.withUnsafeMutableBytes {SecRandomCopyBytes(kSecRandomDefault, 32, $0.baseAddress!)}
- Result of call to 'withUnsafeMutableBytes' is unused
I found myself writing a wrapper 'LDKManager' class for all this boilerplate and it would be nice if something like that was included in the library. Requiring only a LDKManager.init() call with any relevant variables to get started.
Improve ldk-swift build tools
Purpose
The current steps required to build an xcframework
for use is less than ideal, for there are many manual steps involved that also means things going wrong.
The end goal is to get building ldk-swift
into just a three-step process:
- Install rust targets and necessary cargo installs
- Init
rust-lightning
andldk-c-bindings
as submodules (I know @arik-so opposes to this, another approach is to have users manually git clone, but that will mean we will be very strict about where they clone to for succeeding automations to work) - Build the framework.
Proposed Steps
- Scrap the current LDKFramework projects and start a new one from ground-up. We should only need one project and one target.
- Configure the target to only build for architectures you need by reading off
$PLATFORM
,$ARCHS
,$CONFIGURATION
, envvars provided by Xcode. An example of something similar can be seen here. The goal will also be to enable "Cleaning" to actually clean intermediary files. This essentially replaces./compile_dependency_binaries.sh
. - Call
./genbindings.sh
and swift generation scripts from Build Phases in Xcode - Put Swift files in a package to remove the need to manually drag-and-drop the LDK folder to the project (since Swift packages capture all files within a given directory; so if we add/remove files, it will not break references)
- Figure out how to export package symbols and move to framework for export to
xcframework
Intended Outcomes
- Reduce friction for developers to start contributing to
ldk-swift
- Reduce build times by not necessitating building a fat framework for all possible architectures we want to support
- Open up the opportunity to improve CI to ensure builds work for iOS Simulator, macOS, and iOS, and also to run tests for greater developer confidence.
- The README should be written against CI steps. Project should treat releases as: if it doesn't build in CI, it won't build for anyone else who clones this project according to the README!
Developer Story
Pain Points
- too many steps for developers to need to care about when wanting to build their own xcframework
- hard to get release updates without relying on git submodules and custom scripts to manage cloning the three different code bases (rust-lightning, ldk-swift, and ldk-c-bindings)
- xcframework releases has missing architectural targets (Darwin OS X, simulator arm64)
- partially due to limitations of
cargo lipo
that has since been deprecated
- partially due to limitations of
- build tools upstream causes complexity downstream for building CI tooling, or building for use
Goals
- simplify framework builds and unit tests
- achieved through a single xcworkspace that CI can just call to build schemes of
- deprecate use of
cargo lipo
-- it does not currently support same architecture (arm64) for different plaforms (iOS Sim/iOS/Mac Catalyst) - expose a single script that a package manager like Cocoapods can call via
prepare_command
to build an xcframework that gets exposed using thevendored_frameworks
property- enables further improvements through CI to build xcframework for release to be served up with SwiftPM via
binaryTarget
- enables further improvements through CI to build xcframework for release to be served up with SwiftPM via
Open Questions
- how to manage versioning of dependent libraries (specifically,
rust-lightning
andldk-c-bindings
?)- i like git submodules via tags
--
s/o to @conradev for helping with this!
Convert complicated build scripts to Python
ci/build_libldk.sh
ci/build_frameworks.sh
xcode/LDK/build_libldk.sh
xcode/build_xcode_frameworks.sh
Plus whatever the path to the script containing commonalities is gonna be.
Combine Github workflows into single file
No other reason than internal maintenance convenience, i. e. the ability to cancel action runs with a single button press instead of four.
Create description of the bindings compilation workflow and architecture.
Summarize the flow of how the bindings compilation process works, perhaps adding a section to the Readme.
README images for release framework PR
Create wrapper types for arrays
Currently, arrays passed into native context aren't freed properly.
released xcframeworks doesn't contain macOS version
First of all thanks for the awesome library!
I've added universal xcframework from release page into my iOS/MacOS app but Xcode fails to build macOS target with the message:
While building for macOS, no library for this platform was found in '/User/lightningDevKit/LDK-Universal-Test/Frameworks/LDKFramework.xcframework'
If you inspect LDKFramework.xcframework there are only iOS versions
- ios-arm64
- ios-x86_64-maccatalyst
- ios-x86_64-simulator
Missed versions are (?)
- ios-arm64-simulator
- ios-amr64-maccatalist
- macos-arm64
- macos-x86_64
LDKFramework-only-macOS.xcframework has only iOS version as well
- ios-x86_64-maccatalyst
It seems like static lib wasn't build for x86_64-apple-darwin
and arm-apple-darwin
targets
Detect and properly handle types with nullable `inner` values.
Particularly to avoid the liability arising from lightningdevkit/ldk-c-bindings#55
Deduplicate Xcode (DirectBindingsApp) and CI tests
The unit tests in https://github.com/lightningdevkit/ldk-swift/tree/main/ci/LDKSwift/Tests/LDKSwiftTests and https://github.com/lightningdevkit/ldk-swift/tree/main/xcode/DirectBindingsApp/DirectBindingsAppTests are virtually the same. There are some very minor changes in the first couple lines of the files, but the remainder is pretty much identical.
If there is a way to somehow link the CI tests into the Xcode tests and automatically sub the file beginnings, it would be really helpful here.
BestBlock_from_genesis has Network type mismatch
When attempting
let genesisBlock = BestBlock_from_genesis(Network.testnet)
I get
Cannot convert value of type 'Bindings.Network' to expected argument type 'LDKNetwork'
Check bindings only on pull request, not push
any thoughts on this @arik-so?
Update `setup.md` to use `KVStore`
We should update our example to use KVStore::read
for deserialization, possibly FilesystemStore
directly so users are not mislead into thinking they have to implement persistence from scratch.
Introduce formatter in generation and CI
We may want to introduce running swiftformat
/https://github.com/apple/swift-format as a final step of code generation, as well as enforcing it for all (generated and non-generated) files in CI.
borrowing this issue for hosting
Make LDKSwift package header reference dynamic
Currently, ci/LDKSwift contains an LDKHeaders directory with header files. That directory is referenced by the Package.swift explicitly. It would be nice to rely on environment-variable-defined paths the way the Xcode projects do.
ProbabilisticScorer.read() - parameters not named correctly
The parameter names are not very helpful here.
I presume they should reflect the expected types as on other platforms.
let scoreResult = ProbabilisticScorer.read(ser: <#T##[UInt8]#>, argA: <#T##Bindings.ProbabilisticScoringParameters#>, argB: <#T##Bindings.NetworkGraph#>, argC: <#T##Bindings.Logger#>)
ser - ?
argA - ProbabilisticScoringParameters
argB - NetworkGraph
argC - Logger
Use common script for overlap between ci/build_libldk.sh and xcode/LDK/build_libldk.sh
Update README to clone with HTTPS instead of SSH
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.