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.117 #177

Merged
merged 2 commits into from
Oct 10, 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.111):
- react-native-ldk (0.0.113):
- 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: 20bafd3ad8ea69c33841d7b4895379b6eb8cf9f6
react-native-ldk: dd463969f46a47599bd622fc02a67d878f13abe5
react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846
react-native-tcp-socket: c1b7297619616b4c9caae6889bcb0aba78086989
React-perflogger: 8c79399b0500a30ee8152d0f9f11beae7fc36595
Expand Down
Binary file modified lib/android/libs/LDK-release.aar
Binary file not shown.
Binary file modified lib/android/libs/ldk-java-javadoc.jar
Binary file not shown.
15 changes: 6 additions & 9 deletions lib/android/src/main/java/com/reactnativeldk/LdkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ import org.ldk.batteries.NioPeerHandler
import org.ldk.enums.Currency
import org.ldk.enums.Network
import org.ldk.enums.Recipient
import org.ldk.impl.bindings.LDKDestination.Node
import org.ldk.impl.bindings.get_ldk_c_bindings_version
import org.ldk.impl.bindings.get_ldk_version
import org.ldk.structs.*
import org.ldk.structs.Result_Bolt11InvoiceParseOrSemanticErrorZ.Result_Bolt11InvoiceParseOrSemanticErrorZ_OK
import org.ldk.structs.Result_Bolt11InvoiceSignOrCreationErrorZ.Result_Bolt11InvoiceSignOrCreationErrorZ_OK
import org.ldk.structs.Result_PaymentIdPaymentErrorZ.Result_PaymentIdPaymentErrorZ_OK
import org.ldk.structs.Result_PublicKeyErrorZ.Result_PublicKeyErrorZ_OK
import org.ldk.structs.Result_PublicKeyNoneZ.Result_PublicKeyNoneZ_OK
import org.ldk.structs.Result_StringErrorZ.Result_StringErrorZ_OK
import org.ldk.structs.Result_StrSecp256k1ErrorZ.Result_StrSecp256k1ErrorZ_OK
import org.ldk.util.UInt128
import java.io.File
import java.net.InetSocketAddress
Expand Down Expand Up @@ -685,7 +682,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
ldkOutputs.toTypedArray(),
changeDestinationScript.hexa(),
feeRate.toInt(),
Option_PackedLockTimeZ.none()
Option_u32Z.none()
)

if (!res.is_ok) {
Expand Down Expand Up @@ -735,7 +732,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
UtilMethods.pay_invoice(invoice, Retry.timeout(timeoutSeconds.toLong()), channelManager)
if (res.is_ok) {
channelManagerPersister.persistPaymentSent(hashMapOf(
"payment_id" to (res as Result_PaymentIdPaymentErrorZ_OK).res.hexEncodedString(),
"payment_id" to (res as Result_ThirtyTwoBytesPaymentErrorZ.Result_ThirtyTwoBytesPaymentErrorZ_OK).res.hexEncodedString(),
"payment_hash" to invoice.payment_hash().hexEncodedString(),
"amount_sat" to if (isZeroValueInvoice) amountSats.toLong() else ((invoice.amount_milli_satoshis() as Option_u64Z.Some).some.toInt() / 1000),
"unix_timestamp" to (System.currentTimeMillis() / 1000).toInt(),
Expand All @@ -745,7 +742,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
return handleResolve(promise, LdkCallbackResponses.invoice_payment_success)
}

val error = res as? Result_PaymentIdPaymentErrorZ.Result_PaymentIdPaymentErrorZ_Err
val error = res as? Result_ThirtyTwoBytesPaymentErrorZ.Result_ThirtyTwoBytesPaymentErrorZ_Err

val invoiceError = error?.err as? PaymentError.Invoice
if (invoiceError != null) {
Expand Down Expand Up @@ -1056,7 +1053,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
emptyArray(),
changeDestinationScript.hexa(),
feeRate.toInt(),
Option_PackedLockTimeZ.none()
Option_u32Z.none()
)

if (!res.is_ok) {
Expand All @@ -1076,7 +1073,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
return handleReject(promise, LdkErrors.failed_signing_request)
}

promise.resolve((res as Result_StringErrorZ_OK).res)
promise.resolve((res as Result_StrSecp256k1ErrorZ_OK).res)
}

@ReactMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.reactnativeldk.handleReject
import com.reactnativeldk.hexEncodedString
import com.reactnativeldk.hexa
import org.json.JSONObject
import org.ldk.structs.Result_StringErrorZ.Result_StringErrorZ_OK
import org.ldk.structs.Result_StrSecp256k1ErrorZ.Result_StrSecp256k1ErrorZ_OK
import org.ldk.structs.UtilMethods
import java.net.HttpURLConnection
import java.net.URL
Expand Down Expand Up @@ -370,7 +370,7 @@ class BackupClient {
throw BackupError.signingError
}

return (res as Result_StringErrorZ_OK).res
return (res as Result_StrSecp256k1ErrorZ_OK).res
}

private fun verifySignature(message: String, signature: String, pubKey: String): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import com.reactnativeldk.*
import org.json.JSONArray
import org.ldk.batteries.ChannelManagerConstructor
import org.ldk.structs.Event
import org.ldk.structs.Option_PaymentHashZ
import org.ldk.structs.Option_PaymentIdZ
import org.ldk.structs.Option_PaymentPreimageZ
import org.ldk.structs.Option_ThirtyTwoBytesZ
import org.ldk.structs.Option_u64Z
import org.ldk.structs.PaymentPurpose
import java.io.File
Expand All @@ -29,7 +27,7 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {
body.putHexString("payment_hash", paymentClaimable.payment_hash)
body.putInt("amount_sat", paymentClaimable.amount_msat.toInt() / 1000)
(paymentClaimable.purpose as? PaymentPurpose.InvoicePayment)?.let {
body.putHexString("payment_preimage", (it.payment_preimage as Option_PaymentPreimageZ.Some).some)
body.putHexString("payment_preimage", (it.payment_preimage as Option_ThirtyTwoBytesZ.Some).some)
body.putHexString("payment_secret", it.payment_secret)
}
(paymentClaimable.purpose as? PaymentPurpose.SpontaneousPayment)?.let {
Expand All @@ -44,7 +42,7 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {

(event as? Event.PaymentSent)?.let { paymentSent ->
val body = Arguments.createMap()
body.putHexString("payment_id", (paymentSent.payment_id as Option_PaymentIdZ.Some).some)
body.putHexString("payment_id", (paymentSent.payment_id as Option_ThirtyTwoBytesZ.Some).some)
body.putHexString("payment_preimage", paymentSent.payment_preimage)
body.putHexString("payment_hash", paymentSent.payment_hash)
body.putInt("fee_paid_sat", (paymentSent.fee_paid_msat as Option_u64Z.Some).some.toInt() / 1000)
Expand Down Expand Up @@ -73,7 +71,7 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {
val body = Arguments.createMap()

body.putHexString("payment_id", paymentPathSuccessful.payment_id)
body.putHexString("payment_hash", (paymentPathSuccessful.payment_hash as Option_PaymentHashZ.Some).some)
body.putHexString("payment_hash", (paymentPathSuccessful.payment_hash as Option_ThirtyTwoBytesZ.Some).some)

val pathHops = Arguments.createArray()
println(paymentPathSuccessful.path)
Expand All @@ -84,7 +82,7 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {

(event as? Event.PaymentPathFailed)?.let { paymentPathFailed ->
val body = Arguments.createMap()
body.putHexString("payment_id", (paymentPathFailed.payment_id as Option_PaymentIdZ.Some).some)
body.putHexString("payment_id", (paymentPathFailed.payment_id as Option_ThirtyTwoBytesZ.Some).some)
body.putHexString("payment_hash", paymentPathFailed.payment_hash)
body.putBoolean("payment_failed_permanently", paymentPathFailed.payment_failed_permanently)
body.putInt("short_channel_id", (paymentPathFailed.short_channel_id as Option_u64Z.Some).some.toInt())
Expand All @@ -94,7 +92,7 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {

if (paymentPathFailed.payment_id != null) {
persistPaymentSent(hashMapOf(
"payment_id" to (paymentPathFailed.payment_id!! as Option_PaymentIdZ.Some).some.hexEncodedString(),
"payment_id" to (paymentPathFailed.payment_id!! as Option_ThirtyTwoBytesZ.Some).some.hexEncodedString(),
"payment_hash" to paymentPathFailed.payment_hash.hexEncodedString(),
"unix_timestamp" to (System.currentTimeMillis() / 1000).toInt(),
"state" to if (paymentPathFailed.payment_failed_permanently) "failed" else "pending"
Expand Down Expand Up @@ -159,7 +157,7 @@ class LdkChannelManagerPersister: ChannelManagerConstructor.EventHandler {
body.putHexString("payment_hash", paymentClaimed.payment_hash)
body.putInt("amount_sat", paymentClaimed.amount_msat.toInt() / 1000)
(paymentClaimed.purpose as? PaymentPurpose.InvoicePayment)?.let {
body.putHexString("payment_preimage", (it.payment_preimage as Option_PaymentPreimageZ.Some).some)
body.putHexString("payment_preimage", (it.payment_preimage as Option_ThirtyTwoBytesZ.Some).some)
body.putHexString("payment_secret", it.payment_secret)
}
(paymentClaimed.purpose as? PaymentPurpose.SpontaneousPayment)?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.reactnativeldk.hexEncodedString
import com.reactnativeldk.putHexString
import org.ldk.structs.Filter
import org.ldk.structs.Filter.FilterInterface
import org.ldk.structs.Option_BlockHashZ
import org.ldk.structs.Option_ThirtyTwoBytesZ
import org.ldk.structs.WatchedOutput

class LdkFilter {
Expand All @@ -21,8 +21,8 @@ class LdkFilter {

override fun register_output(output: WatchedOutput) {
val body = Arguments.createMap()
if (output._block_hash is Option_BlockHashZ.Some) {
body.putHexString("block_hash", (output._block_hash as Option_BlockHashZ.Some).some)
if (output._block_hash is Option_ThirtyTwoBytesZ.Some) {
body.putHexString("block_hash", (output._block_hash as Option_ThirtyTwoBytesZ.Some).some)
}
body.putInt("index", output._outpoint._index.toInt())
body.putString("script_pubkey", output._script_pubkey.hexEncodedString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LdkPersister {
return ChannelMonitorUpdateStatus.LDKChannelMonitorUpdateStatus_Completed
} catch (e: Exception) {
LdkEventEmitter.send(EventTypes.emergency_force_close_channel, body)
return ChannelMonitorUpdateStatus.LDKChannelMonitorUpdateStatus_PermanentFailure
return ChannelMonitorUpdateStatus.LDKChannelMonitorUpdateStatus_UnrecoverableError
}
}

Expand Down
26 changes: 13 additions & 13 deletions lib/ios/Classes/LdkChannelManagerPersister.swift
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ class LdkChannelManagerPersister: Persister, ExtendedChannelManagerPersister {
}
}

override func persistManager(channelManager: ChannelManager) -> Result_NoneErrorZ {
override func persistManager(channelManager: Bindings.ChannelManager) -> Bindings.Result_NoneIOErrorZ {
guard let managerStorage = Ldk.accountStoragePath?.appendingPathComponent(LdkFileNames.channel_manager.rawValue) else {
return Result_NoneErrorZ.initWithErr(e: .Other)
return Result_NoneIOErrorZ.initWithErr(e: .Other)
}

do {
Expand All @@ -274,44 +274,44 @@ class LdkChannelManagerPersister: Persister, ExtendedChannelManagerPersister {

LdkEventEmitter.shared.send(withEvent: .backup, body: "")

return Result_NoneErrorZ.initWithOk()
return Result_NoneIOErrorZ.initWithOk()
} catch {
LdkEventEmitter.shared.send(withEvent: .native_log, body: "Error. Failed to persist channel manager to disk Error \(error.localizedDescription).")
return Result_NoneErrorZ.initWithErr(e: .Other)
return Result_NoneIOErrorZ.initWithErr(e: .Other)
}
}

override func persistGraph(networkGraph: NetworkGraph) -> Result_NoneErrorZ {
override func persistGraph(networkGraph: Bindings.NetworkGraph) -> Bindings.Result_NoneIOErrorZ {
guard let graphStorage = Ldk.accountStoragePath?.appendingPathComponent(LdkFileNames.network_graph.rawValue) else {
return Result_NoneErrorZ.initWithErr(e: .Other)
return Result_NoneIOErrorZ.initWithErr(e: .Other)
}

do {
try Data(networkGraph.write()).write(to: graphStorage)
LdkEventEmitter.shared.send(withEvent: .native_log, body: "Persisted network graph to disk")

return Result_NoneErrorZ.initWithOk()
return Result_NoneIOErrorZ.initWithOk()
} catch {
LdkEventEmitter.shared.send(withEvent: .native_log, body: "Error. Failed to persist network graph to disk Error \(error.localizedDescription).")
return Result_NoneErrorZ.initWithErr(e: .Other)
return Result_NoneIOErrorZ.initWithErr(e: .Other)
}
}

override func persistScorer(scorer: WriteableScore) -> Bindings.Result_NoneErrorZ {
override func persistScorer(scorer: Bindings.WriteableScore) -> Bindings.Result_NoneIOErrorZ {
guard let scorerStorage = Ldk.accountStoragePath?.appendingPathComponent(LdkFileNames.scorer.rawValue) else {
return Result_NoneErrorZ.initWithErr(e: .Other)
return Result_NoneIOErrorZ.initWithErr(e: .Other)
}

do {
try Data(scorer.write()).write(to: scorerStorage)

return Result_NoneErrorZ.initWithOk()
return Result_NoneIOErrorZ.initWithOk()
} catch {
LdkEventEmitter.shared.send(withEvent: .native_log, body: "Error. Failed to persist scorer to disk Error \(error.localizedDescription).")
return Result_NoneErrorZ.initWithErr(e: .Other)
return Result_NoneIOErrorZ.initWithErr(e: .Other)
}
}

/// Saves claiming/claimed payment to disk. If payment hash exists already then the payment values are merged into the existing entry as an update
/// - Parameter payment: payment obj
private func persistPaymentClaimed(_ payment: [String: Any]) {
Expand Down
2 changes: 1 addition & 1 deletion lib/ios/Classes/LdkPersist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class LdkPersister: Persist {
return ChannelMonitorUpdateStatus.Completed
} catch {
LdkEventEmitter.shared.send(withEvent: .native_log, body: "Error. Failed to persist channel (\(channelId)) to disk Error \(error.localizedDescription).")
return ChannelMonitorUpdateStatus.PermanentFailure
return ChannelMonitorUpdateStatus.UnrecoverableError
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ struct nativeRouteHintHopOpaque;
typedef struct nativeRouteHintHopOpaque LDKnativeRouteHintHop;
struct nativeMultiThreadedLockableScoreOpaque;
typedef struct nativeMultiThreadedLockableScoreOpaque LDKnativeMultiThreadedLockableScore;
struct nativeMultiThreadedScoreLockOpaque;
typedef struct nativeMultiThreadedScoreLockOpaque LDKnativeMultiThreadedScoreLock;
struct nativeMultiThreadedScoreLockReadOpaque;
typedef struct nativeMultiThreadedScoreLockReadOpaque LDKnativeMultiThreadedScoreLockRead;
struct nativeMultiThreadedScoreLockWriteOpaque;
typedef struct nativeMultiThreadedScoreLockWriteOpaque LDKnativeMultiThreadedScoreLockWrite;
struct nativeChannelUsageOpaque;
typedef struct nativeChannelUsageOpaque LDKnativeChannelUsage;
struct nativeFixedPenaltyScorerOpaque;
Expand Down Expand Up @@ -159,6 +161,8 @@ struct nativeChannelConfigUpdateOpaque;
typedef struct nativeChannelConfigUpdateOpaque LDKnativeChannelConfigUpdate;
struct nativeUserConfigOpaque;
typedef struct nativeUserConfigOpaque LDKnativeUserConfig;
struct nativeTaggedHashOpaque;
typedef struct nativeTaggedHashOpaque LDKnativeTaggedHash;
struct nativeChannelMonitorUpdateOpaque;
typedef struct nativeChannelMonitorUpdateOpaque LDKnativeChannelMonitorUpdate;
struct nativeHTLCUpdateOpaque;
Expand All @@ -179,10 +183,14 @@ struct nativePeerManagerOpaque;
typedef struct nativePeerManagerOpaque LDKnativePeerManager;
struct nativeRapidGossipSyncOpaque;
typedef struct nativeRapidGossipSyncOpaque LDKnativeRapidGossipSync;
struct nativeMonitorUpdatingPersisterOpaque;
typedef struct nativeMonitorUpdatingPersisterOpaque LDKnativeMonitorUpdatingPersister;
struct nativeUnsignedInvoiceRequestOpaque;
typedef struct nativeUnsignedInvoiceRequestOpaque LDKnativeUnsignedInvoiceRequest;
struct nativeInvoiceRequestOpaque;
typedef struct nativeInvoiceRequestOpaque LDKnativeInvoiceRequest;
struct nativeVerifiedInvoiceRequestOpaque;
typedef struct nativeVerifiedInvoiceRequestOpaque LDKnativeVerifiedInvoiceRequest;
struct nativeInitOpaque;
typedef struct nativeInitOpaque LDKnativeInit;
struct nativeErrorMessageOpaque;
Expand Down Expand Up @@ -315,8 +323,10 @@ struct nativeInvalidShutdownScriptOpaque;
typedef struct nativeInvalidShutdownScriptOpaque LDKnativeInvalidShutdownScript;
struct nativeBolt12ParseErrorOpaque;
typedef struct nativeBolt12ParseErrorOpaque LDKnativeBolt12ParseError;
struct nativeFilesystemPersisterOpaque;
typedef struct nativeFilesystemPersisterOpaque LDKnativeFilesystemPersister;
struct nativePacketOpaque;
typedef struct nativePacketOpaque LDKnativePacket;
struct nativeClaimedHTLCOpaque;
typedef struct nativeClaimedHTLCOpaque LDKnativeClaimedHTLC;
struct nativeBolt11InvoiceOpaque;
typedef struct nativeBolt11InvoiceOpaque LDKnativeBolt11Invoice;
struct nativeSignedRawBolt11InvoiceOpaque;
Expand Down Expand Up @@ -353,6 +363,16 @@ struct nativeUntrustedStringOpaque;
typedef struct nativeUntrustedStringOpaque LDKnativeUntrustedString;
struct nativePrintableStringOpaque;
typedef struct nativePrintableStringOpaque LDKnativePrintableString;
struct nativeForwardNodeOpaque;
typedef struct nativeForwardNodeOpaque LDKnativeForwardNode;
struct nativeForwardTlvsOpaque;
typedef struct nativeForwardTlvsOpaque LDKnativeForwardTlvs;
struct nativeReceiveTlvsOpaque;
typedef struct nativeReceiveTlvsOpaque LDKnativeReceiveTlvs;
struct nativePaymentRelayOpaque;
typedef struct nativePaymentRelayOpaque LDKnativePaymentRelay;
struct nativePaymentConstraintsOpaque;
typedef struct nativePaymentConstraintsOpaque LDKnativePaymentConstraints;
struct nativeUtxoFutureOpaque;
typedef struct nativeUtxoFutureOpaque LDKnativeUtxoFuture;
struct nativeOnionMessengerOpaque;
Expand All @@ -361,6 +381,8 @@ struct nativeDefaultMessageRouterOpaque;
typedef struct nativeDefaultMessageRouterOpaque LDKnativeDefaultMessageRouter;
struct nativeOnionMessagePathOpaque;
typedef struct nativeOnionMessagePathOpaque LDKnativeOnionMessagePath;
struct nativeFilesystemStoreOpaque;
typedef struct nativeFilesystemStoreOpaque LDKnativeFilesystemStore;
struct nativeBlindedPathOpaque;
typedef struct nativeBlindedPathOpaque LDKnativeBlindedPath;
struct nativeBlindedHopOpaque;
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.116-18-g42de5b818613b331"
#define _LDK_C_BINDINGS_HEADER_VER "v0.0.116.0"
#define _LDK_HEADER_VER "v0.0.117-rc1-44-g4b81eb2c308e657b"
#define _LDK_C_BINDINGS_HEADER_VER "v0.0.117.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