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

LDK 0.0.118 #189

Merged
merged 2 commits into from
Nov 9, 2023
Merged
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
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ PODS:
- React-jsinspector (0.70.6)
- React-logger (0.70.6):
- glog
- react-native-ldk (0.0.113):
- react-native-ldk (0.0.120):
- React
- react-native-randombytes (3.6.1):
- React-Core
Expand Down Expand Up @@ -593,7 +593,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: b4a65947391c658450151275aa406f2b8263178f
React-jsinspector: 60769e5a0a6d4b32294a2456077f59d0266f9a8b
React-logger: 1623c216abaa88974afce404dc8f479406bbc3a0
react-native-ldk: dd463969f46a47599bd622fc02a67d878f13abe5
react-native-ldk: fc83520c891e58888c8f975a02ed394a4c4e1c36
react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846
react-native-tcp-socket: c1b7297619616b4c9caae6889bcb0aba78086989
React-perflogger: 8c79399b0500a30ee8152d0f9f11beae7fc36595
Expand Down
11 changes: 7 additions & 4 deletions example/ldk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,13 @@ export const setupLdk = async (
getScriptPubKeyHistory,
getFees: () =>
Promise.resolve({
highPriority: 10,
normal: 5,
background: 1,
mempoolMinimum: 1,
anchorChannelFee: 10,
nonAnchorChannelFee: 10,
channelCloseMinimum: 10,
minAllowedAnchorChannelRemoteFee: 10,
maxAllowedNonAnchorChannelRemoteFee: 10,
onChainSweep: 10,
minAllowedNonAnchorChannelRemoteFee: 10,
}),
getTransactionData,
getTransactionPosition,
Expand Down
Binary file modified lib/android/libs/LDK-release.aar
Binary file not shown.
4 changes: 2 additions & 2 deletions lib/android/src/main/java/com/reactnativeldk/LdkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
//MARK: Update methods

@ReactMethod
fun updateFees(high: Double, normal: Double, low: Double, mempoolMinimum: Double, promise: Promise) {
feeEstimator.update(high.toInt(), normal.toInt(), low.toInt(), mempoolMinimum.toInt())
fun updateFees(anchorChannelFee: Double, nonAnchorChannelFee: Double, channelCloseMinimum: Double, minAllowedAnchorChannelRemoteFee: Double, maxAllowedNonAnchorChannelRemoteFee: Double, onChainSweep: Double, minAllowedNonAnchorChannelRemoteFee: Double, promise: Promise) {
feeEstimator.update(anchorChannelFee.toInt(), nonAnchorChannelFee.toInt(), channelCloseMinimum.toInt(), minAllowedAnchorChannelRemoteFee.toInt(), maxAllowedNonAnchorChannelRemoteFee.toInt(), onChainSweep.toInt(), minAllowedNonAnchorChannelRemoteFee.toInt())
handleResolve(promise, LdkCallbackResponses.fees_updated)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,40 @@ import org.ldk.enums.ConfirmationTarget
import org.ldk.structs.FeeEstimator

class LdkFeeEstimator {
var high: Int = 0
var normal: Int = 0
var low: Int = 0
var mempoolMinimum: Int = 0
var feeEstimator = FeeEstimator.new_impl { target: ConfirmationTarget ->
if (target.equals(ConfirmationTarget.LDKConfirmationTarget_HighPriority)) {
return@new_impl high
}

if (target.equals(ConfirmationTarget.LDKConfirmationTarget_Normal)) {
return@new_impl normal
}

if (target.equals(ConfirmationTarget.LDKConfirmationTarget_Background)) {
return@new_impl low
}

if (target.equals(ConfirmationTarget.LDKConfirmationTarget_MempoolMinimum)) {
return@new_impl mempoolMinimum
}

LdkEventEmitter.send(EventTypes.native_log, "WARNING: New ConfirmationTarget added. Update LdkFeeEstimator.")
var anchorChannelFee: Int = 0
var nonAnchorChannelFee: Int = 0
var channelCloseMinimum: Int = 0
var minAllowedAnchorChannelRemoteFee: Int = 0
var maxAllowedNonAnchorChannelRemoteFee: Int = 0
var onChainSweep: Int = 0
var minAllowedNonAnchorChannelRemoteFee: Int = 0

fun update(anchorChannelFee: Int, nonAnchorChannelFee: Int, channelCloseMinimum: Int, minAllowedAnchorChannelRemoteFee: Int, maxAllowedNonAnchorChannelRemoteFee: Int, onChainSweep: Int, minAllowedNonAnchorChannelRemoteFee: Int) {
this.anchorChannelFee = anchorChannelFee
this.nonAnchorChannelFee = nonAnchorChannelFee
this.channelCloseMinimum = channelCloseMinimum
this.minAllowedAnchorChannelRemoteFee = minAllowedAnchorChannelRemoteFee
this.maxAllowedNonAnchorChannelRemoteFee = maxAllowedNonAnchorChannelRemoteFee
this.onChainSweep = onChainSweep
this.minAllowedNonAnchorChannelRemoteFee = minAllowedNonAnchorChannelRemoteFee

return@new_impl normal
LdkEventEmitter.send(EventTypes.native_log, "Fee estimator updated")
}

fun update(high: Int, normal: Int, low: Int, mempoolMinimum: Int) {
this.high = high
this.normal = normal
this.low = low
this.mempoolMinimum = mempoolMinimum

LdkEventEmitter.send(EventTypes.native_log, "Fee estimator updated")
var feeEstimator = FeeEstimator.new_impl { target: ConfirmationTarget ->
return@new_impl when (target) {
ConfirmationTarget.LDKConfirmationTarget_AnchorChannelFee -> anchorChannelFee
ConfirmationTarget.LDKConfirmationTarget_NonAnchorChannelFee -> nonAnchorChannelFee
ConfirmationTarget.LDKConfirmationTarget_ChannelCloseMinimum -> channelCloseMinimum
ConfirmationTarget.LDKConfirmationTarget_MinAllowedAnchorChannelRemoteFee -> minAllowedAnchorChannelRemoteFee
ConfirmationTarget.LDKConfirmationTarget_MaxAllowedNonAnchorChannelRemoteFee -> maxAllowedNonAnchorChannelRemoteFee
ConfirmationTarget.LDKConfirmationTarget_OnChainSweep -> onChainSweep
ConfirmationTarget.LDKConfirmationTarget_MinAllowedNonAnchorChannelRemoteFee -> minAllowedNonAnchorChannelRemoteFee
else -> {
LdkEventEmitter.send(EventTypes.native_log, "ERROR: New ConfirmationTarget added. Update LdkFeeEstimator.")
return@new_impl 0
}
}
}
}

60 changes: 33 additions & 27 deletions lib/ios/Classes/LdkFeeEstimator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,47 @@ import Foundation
import LightningDevKit

class LdkFeeEstimator: FeeEstimator {
private var high: UInt32 = 0
private var normal: UInt32 = 0
private var low: UInt32 = 0
private var mempoolMinimum: UInt32 = 0
private var anchorChannelFee: UInt32 = 0
private var nonAnchorChannelFee: UInt32 = 0
private var channelCloseMinimum: UInt32 = 0
private var minAllowedAnchorChannelRemoteFee: UInt32 = 0
private var maxAllowedNonAnchorChannelRemoteFee: UInt32 = 0
private var onChainSweep: UInt32 = 0
private var minAllowedNonAnchorChannelRemoteFee: UInt32 = 0

func update(high: UInt32, normal: UInt32, low: UInt32, mempoolMinimum: UInt32) {
self.high = high
self.normal = normal
self.low = low
self.mempoolMinimum = mempoolMinimum
func update(anchorChannelFee: UInt32, nonAnchorChannelFee: UInt32, channelCloseMinimum: UInt32, minAllowedAnchorChannelRemoteFee: UInt32, maxAllowedNonAnchorChannelRemoteFee: UInt32, onChainSweep: UInt32, minAllowedNonAnchorChannelRemoteFee: UInt32) {
self.anchorChannelFee = anchorChannelFee
self.nonAnchorChannelFee = nonAnchorChannelFee
self.channelCloseMinimum = channelCloseMinimum
self.minAllowedAnchorChannelRemoteFee = minAllowedAnchorChannelRemoteFee
self.maxAllowedNonAnchorChannelRemoteFee = maxAllowedNonAnchorChannelRemoteFee
self.onChainSweep = onChainSweep
self.minAllowedNonAnchorChannelRemoteFee = minAllowedNonAnchorChannelRemoteFee

LdkEventEmitter.shared.send(withEvent: .native_log, body: "Fee estimator updated")
}

override func getEstSatPer1000Weight(confirmationTarget: Bindings.ConfirmationTarget) -> UInt32 {
let target = confirmationTarget

if case ConfirmationTarget.HighPriority = target {
return high
switch target {
case .AnchorChannelFee:
return anchorChannelFee
case .NonAnchorChannelFee:
return nonAnchorChannelFee
case .ChannelCloseMinimum:
return channelCloseMinimum
case .MinAllowedAnchorChannelRemoteFee:
return minAllowedAnchorChannelRemoteFee
case .MaxAllowedNonAnchorChannelRemoteFee:
return maxAllowedNonAnchorChannelRemoteFee
case .OnChainSweep:
return onChainSweep
case .MinAllowedNonAnchorChannelRemoteFee:
return minAllowedNonAnchorChannelRemoteFee
@unknown default:
LdkEventEmitter.shared.send(withEvent: .native_log, body: "ERROR: New ConfirmationTarget added. Update LdkFeeEstimator.")
return 0
}

if case ConfirmationTarget.Normal = target {
return normal
}

if case ConfirmationTarget.Background = target {
return low
}

if case ConfirmationTarget.MempoolMinimum = target {
return mempoolMinimum
}

LdkEventEmitter.shared.send(withEvent: .native_log, body: "WARNING: New ConfirmationTarget added. Update LdkFeeEstimator.")

return normal
}
}
11 changes: 7 additions & 4 deletions lib/ios/Ldk.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ @interface RCT_EXTERN_MODULE(Ldk, NSObject)
reject:(RCTPromiseRejectBlock)reject)

//MARK: Update methods
RCT_EXTERN_METHOD(updateFees:(NSInteger *)high
normal:(NSInteger *)normal
low:(NSInteger *)low
mempoolMinimum:(NSInteger *)mempoolMinimum
RCT_EXTERN_METHOD(updateFees:(NSInteger *)anchorChannelFee
nonAnchorChannelFee:(NSInteger *)nonAnchorChannelFee
channelCloseMinimum:(NSInteger *)channelCloseMinimum
minAllowedAnchorChannelRemoteFee:(NSInteger *)minAllowedAnchorChannelRemoteFee
maxAllowedNonAnchorChannelRemoteFee:(NSInteger *)maxAllowedNonAnchorChannelRemoteFee
onChainSweep:(NSInteger *)onChainSweep
minAllowedNonAnchorChannelRemoteFee:(NSInteger *)minAllowedNonAnchorChannelRemoteFee
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(setLogLevel:(NSString *)level
Expand Down
12 changes: 10 additions & 2 deletions lib/ios/Ldk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,16 @@ class Ldk: NSObject {
//MARK: Update methods

@objc
func updateFees(_ high: NSInteger, normal: NSInteger, low: NSInteger, mempoolMinimum: NSInteger, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
feeEstimator.update(high: UInt32(high), normal: UInt32(normal), low: UInt32(low), mempoolMinimum: UInt32(mempoolMinimum))
func updateFees(_ anchorChannelFee: NSInteger, nonAnchorChannelFee: NSInteger, channelCloseMinimum: NSInteger, minAllowedAnchorChannelRemoteFee: NSInteger, maxAllowedNonAnchorChannelRemoteFee: NSInteger, onChainSweep: NSInteger, minAllowedNonAnchorChannelRemoteFee: NSInteger, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
feeEstimator.update(
anchorChannelFee: UInt32(anchorChannelFee),
nonAnchorChannelFee: UInt32(nonAnchorChannelFee),
channelCloseMinimum: UInt32(channelCloseMinimum),
minAllowedAnchorChannelRemoteFee: UInt32(minAllowedAnchorChannelRemoteFee),
maxAllowedNonAnchorChannelRemoteFee: UInt32(maxAllowedNonAnchorChannelRemoteFee),
onChainSweep: UInt32(onChainSweep),
minAllowedNonAnchorChannelRemoteFee: UInt32(minAllowedNonAnchorChannelRemoteFee)
)
return handleResolve(resolve, .fees_updated)
}

Expand Down
10 changes: 5 additions & 5 deletions lib/ios/LightningDevKit.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-arm64_x86_64-simulator</string>
<key>LibraryPath</key>
<string>LightningDevKit.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-arm64_x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>LightningDevKit.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ struct nativeDelayedPaymentOutputDescriptorOpaque;
typedef struct nativeDelayedPaymentOutputDescriptorOpaque LDKnativeDelayedPaymentOutputDescriptor;
struct nativeStaticPaymentOutputDescriptorOpaque;
typedef struct nativeStaticPaymentOutputDescriptorOpaque LDKnativeStaticPaymentOutputDescriptor;
struct nativeChannelDerivationParametersOpaque;
typedef struct nativeChannelDerivationParametersOpaque LDKnativeChannelDerivationParameters;
struct nativeHTLCDescriptorOpaque;
typedef struct nativeHTLCDescriptorOpaque LDKnativeHTLCDescriptor;
struct LDKChannelSigner;
struct nativeInMemorySignerOpaque;
typedef struct nativeInMemorySignerOpaque LDKnativeInMemorySigner;
Expand Down Expand Up @@ -121,12 +125,8 @@ struct nativeNodeAliasOpaque;
typedef struct nativeNodeAliasOpaque LDKnativeNodeAlias;
struct nativeNodeInfoOpaque;
typedef struct nativeNodeInfoOpaque LDKnativeNodeInfo;
struct nativeChannelDerivationParametersOpaque;
typedef struct nativeChannelDerivationParametersOpaque LDKnativeChannelDerivationParameters;
struct nativeAnchorDescriptorOpaque;
typedef struct nativeAnchorDescriptorOpaque LDKnativeAnchorDescriptor;
struct nativeHTLCDescriptorOpaque;
typedef struct nativeHTLCDescriptorOpaque LDKnativeHTLCDescriptor;
struct nativeInputOpaque;
typedef struct nativeInputOpaque LDKnativeInput;
struct nativeUtxoOpaque;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ static inline int _ldk_strncmp(const char *s1, const char *s2, uint64_t n) {
return 0;
}

#define _LDK_HEADER_VER "v0.0.117-rc1-44-g4b81eb2c308e657b"
#define _LDK_C_BINDINGS_HEADER_VER "v0.0.117.1"
#define _LDK_HEADER_VER "v0.0.118-15-g5df414c25b1b710b"
#define _LDK_C_BINDINGS_HEADER_VER "v0.0.118.0"
static inline const char* check_get_ldk_version() {
LDKStr bin_ver = _ldk_get_compiled_version();
if (_ldk_strncmp(_LDK_HEADER_VER, (const char*)bin_ver.chars, bin_ver.len) != 0) {
Expand Down
Loading
Loading