Skip to content
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 @@ -316,7 +316,7 @@ PODS:
- React-jsinspector (0.72.4)
- React-logger (0.72.4):
- glog
- react-native-ldk (0.0.154):
- react-native-ldk (0.0.155):
- React
- react-native-randombytes (3.6.1):
- React-Core
Expand Down Expand Up @@ -621,7 +621,7 @@ SPEC CHECKSUMS:
React-jsiexecutor: c7f826e40fa9cab5d37cab6130b1af237332b594
React-jsinspector: aaed4cf551c4a1c98092436518c2d267b13a673f
React-logger: da1ebe05ae06eb6db4b162202faeafac4b435e77
react-native-ldk: 6910154336e57be6702a33acad2191d39a3a214b
react-native-ldk: 9ea2f29a6f96cc55f839ee180caf8dc9e58cd6eb
react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846
react-native-tcp-socket: c1b7297619616b4c9caae6889bcb0aba78086989
React-NativeModulesApple: edb5ace14f73f4969df6e7b1f3e41bef0012740f
Expand Down
3 changes: 2 additions & 1 deletion example/ldk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ export const setupLdk = async (
channelCloseMinimum: 10,
minAllowedAnchorChannelRemoteFee: 10,
maxAllowedNonAnchorChannelRemoteFee: 10,
onChainSweep: 10,
minAllowedNonAnchorChannelRemoteFee: 10,
outputSpendingFee: 10,
maximumFeeEstimate: 10,
urgentOnChainSweep: 10,
}),
getTransactionData,
getTransactionPosition,
Expand Down
3 changes: 2 additions & 1 deletion example/tests/eclair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,15 @@
...profile.getStartParams(),
getFees: () => {
return Promise.resolve({
onChainSweep: 30,
maxAllowedNonAnchorChannelRemoteFee: Math.max(25, 30 * 10),
minAllowedAnchorChannelRemoteFee: 5,
minAllowedNonAnchorChannelRemoteFee: Math.max(5 - 1, 0),
anchorChannelFee: 10,
nonAnchorChannelFee: 20,
channelCloseMinimum: 5,
outputSpendingFee: 10,
urgentOnChainSweep: 30,
maximumFeeEstimate: 30

Check failure on line 116 in example/tests/eclair.ts

View workflow job for this annotation

GitHub Actions / Run lint check

Insert `,`

Check warning on line 116 in example/tests/eclair.ts

View workflow job for this annotation

GitHub Actions / Run lint check

Missing trailing comma
});
},
});
Expand Down
6 changes: 4 additions & 2 deletions example/tests/unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@
channelCloseMinimum: 5,
minAllowedAnchorChannelRemoteFee: 5,
minAllowedNonAnchorChannelRemoteFee: 5,
onChainSweep: 5,
outputSpendingFee: 5,
urgentOnChainSweep: 5,
maximumFeeEstimate: 5,
});
},
getTransactionData: async () => ({
Expand Down Expand Up @@ -194,19 +195,19 @@
}

const startParams = {
getBestBlock: async () => ({

Check warning on line 198 in example/tests/unit.ts

View workflow job for this annotation

GitHub Actions / Run lint check

Missing return type on function
hash: '6993d7c36204c9f369a7d9d80590c4e2a86b9641c327fbc276a534797ca50a2f',
height: 1,
hex: '000000205d1f3ece3bcb0a3530adaae2e4aa47f8aad434db95c6cb6d09d5ac99e3f6df4f0a19fe968830a06dcc49c9cca4acc532226e4c30b741802420e0fdd2b092eccdbf95cb64ffff7f2000000000',
}),
account,
getAddress: async () => ({

Check warning on line 204 in example/tests/unit.ts

View workflow job for this annotation

GitHub Actions / Run lint check

Missing return type on function
address: 'bcrt1qtk89me2ae95dmlp3yfl4q9ynpux8mxjus4s872',
publicKey:
'0298720ece754e377af1b2716256e63c2e2427ff6ebdc66c2071c43ae80132ca32',
}),
getScriptPubKeyHistory: async () => [],

Check warning on line 209 in example/tests/unit.ts

View workflow job for this annotation

GitHub Actions / Run lint check

Missing return type on function
getFees: () => {

Check warning on line 210 in example/tests/unit.ts

View workflow job for this annotation

GitHub Actions / Run lint check

Missing return type on function
return Promise.resolve({
nonAnchorChannelFee: 5,
anchorChannelFee: 5,
Expand All @@ -214,18 +215,19 @@
channelCloseMinimum: 5,
minAllowedAnchorChannelRemoteFee: 5,
minAllowedNonAnchorChannelRemoteFee: 5,
onChainSweep: 5,
outputSpendingFee: 5,
urgentOnChainSweep: 5,
maximumFeeEstimate: 5,
});
},
getTransactionData: async () => ({

Check warning on line 223 in example/tests/unit.ts

View workflow job for this annotation

GitHub Actions / Run lint check

Missing return type on function
header: '',
height: 0,
transaction: '',
vout: [],
}),
getTransactionPosition: async () => -1,

Check warning on line 229 in example/tests/unit.ts

View workflow job for this annotation

GitHub Actions / Run lint check

Missing return type on function
broadcastTransaction: async () => '',

Check warning on line 230 in example/tests/unit.ts

View workflow job for this annotation

GitHub Actions / Run lint check

Missing return type on function
network: ENetworks.regtest,
skipRemoteBackups: true,
};
Expand Down
3 changes: 2 additions & 1 deletion example/tests/utils/test-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,15 @@ export default class TestProfile {
getScriptPubKeyHistory: this.getScriptPubKeyHistory,
getFees: () =>
Promise.resolve({
onChainSweep: 4,
maxAllowedNonAnchorChannelRemoteFee: Math.max(25, 4 * 10),
minAllowedAnchorChannelRemoteFee: 1,
minAllowedNonAnchorChannelRemoteFee: Math.max(1 - 1, 0),
anchorChannelFee: 2,
nonAnchorChannelFee: 3,
channelCloseMinimum: 1,
outputSpendingFee: 5,
urgentOnChainSweep: 5,
maximumFeeEstimate: 5,
}),
getTransactionData: this.getTransactionData,
getTransactionPosition: this.getTransactionPosition,
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.
6 changes: 3 additions & 3 deletions lib/android/src/main/java/com/reactnativeldk/Helpers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ val ChannelDetails.asJson: WritableMap
val result = Arguments.createMap()

result.putHexString("channel_id", _channel_id._a)
result.putBoolean("is_public", _is_public)
result.putBoolean("is_public", _is_announced)
result.putBoolean("is_usable", _is_usable)
result.putBoolean("is_channel_ready", _is_channel_ready)
result.putBoolean("is_outbound", _is_outbound)
Expand Down Expand Up @@ -188,7 +188,7 @@ val NodeInfo.asJson: WritableMap
val shortChannelIds = Arguments.createArray()
_channels.iterator().forEach { shortChannelIds.pushString(it.toString()) }
result.putArray("shortChannelIds", shortChannelIds)
result.putDouble("announcement_info_last_update", (_announcement_info?._last_update ?: 0).toDouble() * 1000)
result.putDouble("announcement_info_last_update", ((_announcement_info as Option_NodeAnnouncementInfoZ.Some).some.last_update()).toDouble() * 1000)
return result
}

Expand Down Expand Up @@ -335,7 +335,7 @@ fun ChannelHandshakeConfig.mergeWithMap(map: ReadableMap?): ChannelHandshakeConf
_negotiate_scid_privacy = map.getBoolean("negotiate_scid_privacy")
} catch (_: Exception) {}
try {
_announced_channel = map.getBoolean("announced_channel")
_announce_for_forwarding = map.getBoolean("announced_channel")
} catch (_: Exception) {}
try {
_commit_upfront_shutdown_pubkey = map.getBoolean("commit_upfront_shutdown_pubkey")
Expand Down
43 changes: 28 additions & 15 deletions lib/android/src/main/java/com/reactnativeldk/LdkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import org.ldk.structs.Result_ChannelIdAPIErrorZ.Result_ChannelIdAPIErrorZ_OK
import org.ldk.structs.Result_NoneAPIErrorZ.Result_NoneAPIErrorZ_OK
import org.ldk.structs.Result_NoneRetryableSendFailureZ.Result_NoneRetryableSendFailureZ_Err
import org.ldk.structs.Result_PublicKeyNoneZ.Result_PublicKeyNoneZ_OK
import org.ldk.structs.Result_StrSecp256k1ErrorZ.Result_StrSecp256k1ErrorZ_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 @@ -592,8 +592,27 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
//MARK: Update methods

@ReactMethod
fun updateFees(anchorChannelFee: Double, nonAnchorChannelFee: Double, channelCloseMinimum: Double, minAllowedAnchorChannelRemoteFee: Double, onChainSweep: Double, minAllowedNonAnchorChannelRemoteFee: Double, outputSpendingFee: Double, promise: Promise) {
feeEstimator.update(anchorChannelFee.toInt(), nonAnchorChannelFee.toInt(), channelCloseMinimum.toInt(), minAllowedAnchorChannelRemoteFee.toInt(), onChainSweep.toInt(), minAllowedNonAnchorChannelRemoteFee.toInt(), outputSpendingFee.toInt())
fun updateFees(
anchorChannelFee: Double,
nonAnchorChannelFee: Double,
channelCloseMinimum: Double,
minAllowedAnchorChannelRemoteFee: Double,
minAllowedNonAnchorChannelRemoteFee: Double,
outputSpendingFee: Double,
maximumFeeEstimate: Double,
urgentOnChainSweep: Double,
promise: Promise
) {
feeEstimator.update(
anchorChannelFee.toInt(),
nonAnchorChannelFee.toInt(),
channelCloseMinimum.toInt(),
minAllowedAnchorChannelRemoteFee.toInt(),
minAllowedNonAnchorChannelRemoteFee.toInt(),
outputSpendingFee.toInt(),
maximumFeeEstimate.toInt(),
urgentOnChainSweep.toInt(),
)
handleResolve(promise, LdkCallbackResponses.fees_updated)
}

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

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

if (broadcastLatestTx) {
channelManager!!.force_close_all_channels_broadcasting_latest_txn()
channelManager!!.force_close_all_channels_broadcasting_latest_txn("Force close broadcasting latest tx")
} else {
channelManager!!.force_close_all_channels_without_broadcasting_txn()
channelManager!!.force_close_all_channels_without_broadcasting_txn("Force close without broadcasting latest tx")
}

handleResolve(promise, LdkCallbackResponses.close_channel_success)
Expand Down Expand Up @@ -1353,15 +1372,15 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
descriptors,
emptyArray(),
changeDestinationScript.hexa(),
feeEstimator.onChainSweep,
feeEstimator.urgentOnChainSweep,
Option_u32Z.none()
)
} else {
keysManager!!.spend_spendable_outputs(
descriptors,
emptyArray(),
changeDestinationScript.hexa(),
feeEstimator.onChainSweep,
feeEstimator.urgentOnChainSweep,
Option_u32Z.none()
)
}
Expand All @@ -1381,13 +1400,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
fun nodeSign(message: String, promise: Promise) {
keysManager ?: return handleReject(promise, LdkErrors.init_keys_manager)

val res = UtilMethods.sign(message.toByteArray(Charsets.UTF_8), keysManager!!.inner._node_secret_key)

if (!res.is_ok) {
return handleReject(promise, LdkErrors.failed_signing_request)
}

promise.resolve((res as Result_StrSecp256k1ErrorZ_OK).res)
promise.resolve(UtilMethods.sign(message.toByteArray(Charsets.UTF_8), keysManager!!.inner._node_secret_key))
}

@ReactMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.reactnativeldk.hexEncodedString
import com.reactnativeldk.hexa
import com.reactnativeldk.putDateOrNull
import org.json.JSONObject
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 @@ -458,12 +457,7 @@ class BackupClient {
throw BackupError.requiresSetup
}

val res = UtilMethods.sign("$signedMessagePrefix$message".toByteArray(Charsets.UTF_8), secretKey)
if (!res.is_ok) {
throw BackupError.signingError
}

return (res as Result_StrSecp256k1ErrorZ_OK).res
return UtilMethods.sign("$signedMessagePrefix$message".toByteArray(Charsets.UTF_8), secretKey)
}

private fun verifySignature(message: String, signature: String, pubKey: String): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ package com.reactnativeldk.classes

import com.reactnativeldk.EventTypes
import com.reactnativeldk.LdkEventEmitter
import org.ldk.structs.EcdsaChannelSigner
import org.ldk.structs.KeysManager
import org.ldk.structs.Option_u32Z
import org.ldk.structs.Result_CVec_u8ZNoneZ
import org.ldk.structs.Result_EcdsaChannelSignerDecodeErrorZ
import org.ldk.structs.Result_ShutdownScriptInvalidShutdownScriptZ
import org.ldk.structs.Result_ShutdownScriptNoneZ
import org.ldk.structs.Result_TransactionNoneZ
import org.ldk.structs.Result_WriteableEcdsaChannelSignerDecodeErrorZ
import org.ldk.structs.ShutdownScript
import org.ldk.structs.SignerProvider.SignerProviderInterface
import org.ldk.structs.SpendableOutputDescriptor
import org.ldk.structs.TxOut
import org.ldk.structs.WitnessProgram
import org.ldk.structs.WriteableEcdsaChannelSigner
import org.ldk.util.UInt128
import org.ldk.util.WitnessVersion

Expand Down Expand Up @@ -79,15 +79,15 @@ class CustomSignerProvider : SignerProviderInterface {
override fun derive_channel_signer(
channel_value_satoshis: Long,
channel_keys_id: ByteArray?
): WriteableEcdsaChannelSigner {
): EcdsaChannelSigner {
return customKeysManager.inner.as_SignerProvider().derive_channel_signer(channel_value_satoshis, channel_keys_id)
}

override fun generate_channel_keys_id(p0: Boolean, p1: Long, p2: UInt128?): ByteArray {
return customKeysManager.inner.as_SignerProvider().generate_channel_keys_id(p0, p1, p2)
}

override fun read_chan_signer(p0: ByteArray?): Result_WriteableEcdsaChannelSignerDecodeErrorZ {
override fun read_chan_signer(p0: ByteArray?): Result_EcdsaChannelSignerDecodeErrorZ? {
return customKeysManager.inner.as_SignerProvider().read_chan_signer(p0!!)
}
}
Loading
Loading