Skip to content

Commit 13c8956

Browse files
authored
Merge pull request #279 from synonymdev/lkd-update-0.0.125
Lkd update 0.0.125
2 parents b102e82 + 83a9c82 commit 13c8956

File tree

62 files changed

+1373895
-79799
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1373895
-79799
lines changed

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ PODS:
316316
- React-jsinspector (0.72.4)
317317
- React-logger (0.72.4):
318318
- glog
319-
- react-native-ldk (0.0.154):
319+
- react-native-ldk (0.0.155):
320320
- React
321321
- react-native-randombytes (3.6.1):
322322
- React-Core
@@ -621,7 +621,7 @@ SPEC CHECKSUMS:
621621
React-jsiexecutor: c7f826e40fa9cab5d37cab6130b1af237332b594
622622
React-jsinspector: aaed4cf551c4a1c98092436518c2d267b13a673f
623623
React-logger: da1ebe05ae06eb6db4b162202faeafac4b435e77
624-
react-native-ldk: 6910154336e57be6702a33acad2191d39a3a214b
624+
react-native-ldk: 9ea2f29a6f96cc55f839ee180caf8dc9e58cd6eb
625625
react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846
626626
react-native-tcp-socket: c1b7297619616b4c9caae6889bcb0aba78086989
627627
React-NativeModulesApple: edb5ace14f73f4969df6e7b1f3e41bef0012740f

example/ldk/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,10 @@ export const setupLdk = async (
132132
channelCloseMinimum: 10,
133133
minAllowedAnchorChannelRemoteFee: 10,
134134
maxAllowedNonAnchorChannelRemoteFee: 10,
135-
onChainSweep: 10,
136135
minAllowedNonAnchorChannelRemoteFee: 10,
137136
outputSpendingFee: 10,
137+
maximumFeeEstimate: 10,
138+
urgentOnChainSweep: 10,
138139
}),
139140
getTransactionData,
140141
getTransactionPosition,

example/tests/eclair.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,15 @@ describe('Eclair', function () {
105105
...profile.getStartParams(),
106106
getFees: () => {
107107
return Promise.resolve({
108-
onChainSweep: 30,
109108
maxAllowedNonAnchorChannelRemoteFee: Math.max(25, 30 * 10),
110109
minAllowedAnchorChannelRemoteFee: 5,
111110
minAllowedNonAnchorChannelRemoteFee: Math.max(5 - 1, 0),
112111
anchorChannelFee: 10,
113112
nonAnchorChannelFee: 20,
114113
channelCloseMinimum: 5,
115114
outputSpendingFee: 10,
115+
urgentOnChainSweep: 30,
116+
maximumFeeEstimate: 30
116117
});
117118
},
118119
});

example/tests/unit.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ describe('Unit', function () {
7070
channelCloseMinimum: 5,
7171
minAllowedAnchorChannelRemoteFee: 5,
7272
minAllowedNonAnchorChannelRemoteFee: 5,
73-
onChainSweep: 5,
7473
outputSpendingFee: 5,
74+
urgentOnChainSweep: 5,
75+
maximumFeeEstimate: 5,
7576
});
7677
},
7778
getTransactionData: async () => ({
@@ -214,8 +215,9 @@ describe('Unit', function () {
214215
channelCloseMinimum: 5,
215216
minAllowedAnchorChannelRemoteFee: 5,
216217
minAllowedNonAnchorChannelRemoteFee: 5,
217-
onChainSweep: 5,
218218
outputSpendingFee: 5,
219+
urgentOnChainSweep: 5,
220+
maximumFeeEstimate: 5,
219221
});
220222
},
221223
getTransactionData: async () => ({

example/tests/utils/test-profile.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,15 @@ export default class TestProfile {
7575
getScriptPubKeyHistory: this.getScriptPubKeyHistory,
7676
getFees: () =>
7777
Promise.resolve({
78-
onChainSweep: 4,
7978
maxAllowedNonAnchorChannelRemoteFee: Math.max(25, 4 * 10),
8079
minAllowedAnchorChannelRemoteFee: 1,
8180
minAllowedNonAnchorChannelRemoteFee: Math.max(1 - 1, 0),
8281
anchorChannelFee: 2,
8382
nonAnchorChannelFee: 3,
8483
channelCloseMinimum: 1,
8584
outputSpendingFee: 5,
85+
urgentOnChainSweep: 5,
86+
maximumFeeEstimate: 5,
8687
}),
8788
getTransactionData: this.getTransactionData,
8889
getTransactionPosition: this.getTransactionPosition,

lib/android/libs/LDK-release.aar

1.95 MB
Binary file not shown.
56.2 KB
Binary file not shown.

lib/android/src/main/java/com/reactnativeldk/Helpers.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ val ChannelDetails.asJson: WritableMap
116116
val result = Arguments.createMap()
117117

118118
result.putHexString("channel_id", _channel_id._a)
119-
result.putBoolean("is_public", _is_public)
119+
result.putBoolean("is_public", _is_announced)
120120
result.putBoolean("is_usable", _is_usable)
121121
result.putBoolean("is_channel_ready", _is_channel_ready)
122122
result.putBoolean("is_outbound", _is_outbound)
@@ -188,7 +188,7 @@ val NodeInfo.asJson: WritableMap
188188
val shortChannelIds = Arguments.createArray()
189189
_channels.iterator().forEach { shortChannelIds.pushString(it.toString()) }
190190
result.putArray("shortChannelIds", shortChannelIds)
191-
result.putDouble("announcement_info_last_update", (_announcement_info?._last_update ?: 0).toDouble() * 1000)
191+
result.putDouble("announcement_info_last_update", ((_announcement_info as Option_NodeAnnouncementInfoZ.Some).some.last_update()).toDouble() * 1000)
192192
return result
193193
}
194194

@@ -335,7 +335,7 @@ fun ChannelHandshakeConfig.mergeWithMap(map: ReadableMap?): ChannelHandshakeConf
335335
_negotiate_scid_privacy = map.getBoolean("negotiate_scid_privacy")
336336
} catch (_: Exception) {}
337337
try {
338-
_announced_channel = map.getBoolean("announced_channel")
338+
_announce_for_forwarding = map.getBoolean("announced_channel")
339339
} catch (_: Exception) {}
340340
try {
341341
_commit_upfront_shutdown_pubkey = map.getBoolean("commit_upfront_shutdown_pubkey")

lib/android/src/main/java/com/reactnativeldk/LdkModule.kt

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import org.ldk.structs.Result_ChannelIdAPIErrorZ.Result_ChannelIdAPIErrorZ_OK
2121
import org.ldk.structs.Result_NoneAPIErrorZ.Result_NoneAPIErrorZ_OK
2222
import org.ldk.structs.Result_NoneRetryableSendFailureZ.Result_NoneRetryableSendFailureZ_Err
2323
import org.ldk.structs.Result_PublicKeyNoneZ.Result_PublicKeyNoneZ_OK
24-
import org.ldk.structs.Result_StrSecp256k1ErrorZ.Result_StrSecp256k1ErrorZ_OK
24+
//import org.ldk.structs.Result_StrSecp256k1ErrorZ.Result_StrSecp256k1ErrorZ_OK
2525
import org.ldk.util.UInt128
2626
import java.io.File
2727
import java.net.InetSocketAddress
@@ -592,8 +592,27 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
592592
//MARK: Update methods
593593

594594
@ReactMethod
595-
fun updateFees(anchorChannelFee: Double, nonAnchorChannelFee: Double, channelCloseMinimum: Double, minAllowedAnchorChannelRemoteFee: Double, onChainSweep: Double, minAllowedNonAnchorChannelRemoteFee: Double, outputSpendingFee: Double, promise: Promise) {
596-
feeEstimator.update(anchorChannelFee.toInt(), nonAnchorChannelFee.toInt(), channelCloseMinimum.toInt(), minAllowedAnchorChannelRemoteFee.toInt(), onChainSweep.toInt(), minAllowedNonAnchorChannelRemoteFee.toInt(), outputSpendingFee.toInt())
595+
fun updateFees(
596+
anchorChannelFee: Double,
597+
nonAnchorChannelFee: Double,
598+
channelCloseMinimum: Double,
599+
minAllowedAnchorChannelRemoteFee: Double,
600+
minAllowedNonAnchorChannelRemoteFee: Double,
601+
outputSpendingFee: Double,
602+
maximumFeeEstimate: Double,
603+
urgentOnChainSweep: Double,
604+
promise: Promise
605+
) {
606+
feeEstimator.update(
607+
anchorChannelFee.toInt(),
608+
nonAnchorChannelFee.toInt(),
609+
channelCloseMinimum.toInt(),
610+
minAllowedAnchorChannelRemoteFee.toInt(),
611+
minAllowedNonAnchorChannelRemoteFee.toInt(),
612+
outputSpendingFee.toInt(),
613+
maximumFeeEstimate.toInt(),
614+
urgentOnChainSweep.toInt(),
615+
)
597616
handleResolve(promise, LdkCallbackResponses.fees_updated)
598617
}
599618

@@ -761,7 +780,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
761780
channelManager ?: return handleReject(promise, LdkErrors.init_channel_manager)
762781

763782
val channelIdObj = ChannelId.of(channelId.hexa())
764-
val res = if (force) channelManager!!.force_close_broadcasting_latest_txn(channelIdObj, counterpartyNodeId.hexa()) else channelManager!!.close_channel(channelIdObj, counterpartyNodeId.hexa())
783+
val res = if (force) channelManager!!.force_close_broadcasting_latest_txn(channelIdObj, counterpartyNodeId.hexa(), "Force close") else channelManager!!.close_channel(channelIdObj, counterpartyNodeId.hexa())
765784
if (!res.is_ok) {
766785
return handleReject(promise, LdkErrors.channel_close_fail)
767786
}
@@ -846,9 +865,9 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
846865
channelManager ?: return handleReject(promise, LdkErrors.init_channel_manager)
847866

848867
if (broadcastLatestTx) {
849-
channelManager!!.force_close_all_channels_broadcasting_latest_txn()
868+
channelManager!!.force_close_all_channels_broadcasting_latest_txn("Force close broadcasting latest tx")
850869
} else {
851-
channelManager!!.force_close_all_channels_without_broadcasting_txn()
870+
channelManager!!.force_close_all_channels_without_broadcasting_txn("Force close without broadcasting latest tx")
852871
}
853872

854873
handleResolve(promise, LdkCallbackResponses.close_channel_success)
@@ -1353,15 +1372,15 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
13531372
descriptors,
13541373
emptyArray(),
13551374
changeDestinationScript.hexa(),
1356-
feeEstimator.onChainSweep,
1375+
feeEstimator.urgentOnChainSweep,
13571376
Option_u32Z.none()
13581377
)
13591378
} else {
13601379
keysManager!!.spend_spendable_outputs(
13611380
descriptors,
13621381
emptyArray(),
13631382
changeDestinationScript.hexa(),
1364-
feeEstimator.onChainSweep,
1383+
feeEstimator.urgentOnChainSweep,
13651384
Option_u32Z.none()
13661385
)
13671386
}
@@ -1381,13 +1400,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
13811400
fun nodeSign(message: String, promise: Promise) {
13821401
keysManager ?: return handleReject(promise, LdkErrors.init_keys_manager)
13831402

1384-
val res = UtilMethods.sign(message.toByteArray(Charsets.UTF_8), keysManager!!.inner._node_secret_key)
1385-
1386-
if (!res.is_ok) {
1387-
return handleReject(promise, LdkErrors.failed_signing_request)
1388-
}
1389-
1390-
promise.resolve((res as Result_StrSecp256k1ErrorZ_OK).res)
1403+
promise.resolve(UtilMethods.sign(message.toByteArray(Charsets.UTF_8), keysManager!!.inner._node_secret_key))
13911404
}
13921405

13931406
@ReactMethod

lib/android/src/main/java/com/reactnativeldk/classes/BackupClient.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import com.reactnativeldk.hexEncodedString
99
import com.reactnativeldk.hexa
1010
import com.reactnativeldk.putDateOrNull
1111
import org.json.JSONObject
12-
import org.ldk.structs.Result_StrSecp256k1ErrorZ.Result_StrSecp256k1ErrorZ_OK
1312
import org.ldk.structs.UtilMethods
1413
import java.net.HttpURLConnection
1514
import java.net.URL
@@ -458,12 +457,7 @@ class BackupClient {
458457
throw BackupError.requiresSetup
459458
}
460459

461-
val res = UtilMethods.sign("$signedMessagePrefix$message".toByteArray(Charsets.UTF_8), secretKey)
462-
if (!res.is_ok) {
463-
throw BackupError.signingError
464-
}
465-
466-
return (res as Result_StrSecp256k1ErrorZ_OK).res
460+
return UtilMethods.sign("$signedMessagePrefix$message".toByteArray(Charsets.UTF_8), secretKey)
467461
}
468462

469463
private fun verifySignature(message: String, signature: String, pubKey: String): Boolean {

0 commit comments

Comments
 (0)