Skip to content

Commit 5b5bd0c

Browse files
committed
Merge branch 'master' into ldk-123
2 parents de65c15 + b3718c7 commit 5b5bd0c

File tree

12 files changed

+132
-41
lines changed

12 files changed

+132
-41
lines changed

backup-server/src/server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const ldkLabels = [
3434
];
3535
const bitkitLabels = [
3636
'bitkit_settings',
37+
'bitkit_wallet',
3738
'bitkit_widgets',
3839
'bitkit_metadata',
3940
'bitkit_blocktank_orders',

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.147):
319+
- react-native-ldk (0.0.148):
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: 71275a0c18172fa1646bc2a38a62560ded090da5
624+
react-native-ldk: fda4d4381d40401bdc5c3a9965937d19b232ed08
625625
react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846
626626
react-native-tcp-socket: c1b7297619616b4c9caae6889bcb0aba78086989
627627
React-NativeModulesApple: edb5ace14f73f4969df6e7b1f3e41bef0012740f

example/ldk/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ export const setupLdk = async (
150150
},
151151
manually_accept_inbound_channels: true,
152152
},
153-
trustedZeroConfPeers: [peers.lnd.pubKey],
154153
skipRemoteBackups: !backupServerDetails,
155154
lspLogEvent: async (payload) => {
156155
console.log('Log event for LSP:', JSON.stringify(payload));
@@ -184,6 +183,15 @@ export const setupLdk = async (
184183
return err(e.toString());
185184
}
186185

186+
//Set trusted peers we should accept zero conf channels from
187+
const trustedPeers = Object.values(peers).map((peer) => peer.pubKey);
188+
const trustedPeersRes = await lm.setTrustedZeroConfPeerNodeIds(
189+
trustedPeers,
190+
);
191+
if (trustedPeersRes.isErr()) {
192+
return err(trustedPeersRes.error.message);
193+
}
194+
187195
const nodeIdRes = await ldk.nodeId();
188196
if (nodeIdRes.isErr()) {
189197
return err(nodeIdRes.error.message);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ val ChannelDetails.asJson: WritableMap
123123
result.putInt("balance_sat", (_balance_msat / 1000).toInt())
124124
result.putHexString("counterparty_node_id", _counterparty._node_id)
125125
result.putHexString("funding_txid", _funding_txo?._txid?.reversed()?.toByteArray())
126+
_funding_txo?._index?.toInt()?.let { result.putInt("funding_output_index", it) }
126127
result.putHexString("channel_type", _channel_type?.write())
127128
result.putString("user_channel_id", _user_channel_id.leBytes.hexEncodedString())
128129
result.putInt("confirmations_required", (_confirmations_required as Option_u32Z.Some).some)

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
12291229
}
12301230

12311231
@ReactMethod
1232-
fun spendRecoveredForceCloseOutputs(transaction: String, confirmationHeight: Double, changeDestinationScript: String, promise: Promise) {
1232+
fun spendRecoveredForceCloseOutputs(transaction: String, confirmationHeight: Double, changeDestinationScript: String, useInner: Boolean, promise: Promise) {
12331233
if (channelStoragePath == "") {
12341234
return handleReject(promise, LdkErrors.init_storage_path)
12351235
}
@@ -1271,13 +1271,23 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
12711271
continue
12721272
}
12731273

1274-
val res = keysManager!!.spend_spendable_outputs(
1275-
descriptors,
1276-
emptyArray(),
1277-
changeDestinationScript.hexa(),
1278-
feeEstimator.onChainSweep,
1279-
Option_u32Z.none()
1280-
)
1274+
val res = if (useInner) {
1275+
keysManager!!.inner.spend_spendable_outputs(
1276+
descriptors,
1277+
emptyArray(),
1278+
changeDestinationScript.hexa(),
1279+
feeEstimator.onChainSweep,
1280+
Option_u32Z.none()
1281+
)
1282+
} else {
1283+
keysManager!!.spend_spendable_outputs(
1284+
descriptors,
1285+
emptyArray(),
1286+
changeDestinationScript.hexa(),
1287+
feeEstimator.onChainSweep,
1288+
Option_u32Z.none()
1289+
)
1290+
}
12811291

12821292
if (res.is_ok) {
12831293
txs.pushHexString((res as Result_TransactionNoneZ.Result_TransactionNoneZ_OK).res)

lib/ios/Helpers.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ extension ChannelDetails {
122122
"balance_sat": getBalanceMsat() / 1000,
123123
"counterparty_node_id": Data(getCounterparty().getNodeId()).hexEncodedString(),
124124
"funding_txid": Data(getFundingTxo()?.getTxid()?.reversed() ?? []).hexEncodedString(),
125+
"funding_output_index": getFundingTxo()?.getIndex() as Any, // Optional number
125126
"channel_type": Data(getChannelType()?.write() ?? []).hexEncodedString(),
126127
"user_channel_id": Data(getUserChannelId()).hexEncodedString(), //String
127128
"confirmations_required": getConfirmationsRequired() as Any, // Optional number

lib/ios/Ldk.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ @interface RCT_EXTERN_MODULE(Ldk, NSObject)
176176
RCT_EXTERN_METHOD(spendRecoveredForceCloseOutputs:(NSString *)transaction
177177
confirmationHeight:(NSInteger *)confirmationHeight
178178
changeDestinationScript:(NSString *)changeDestinationScript
179+
useInner:(BOOL *)useInner
179180
resolve:(RCTPromiseResolveBlock)resolve
180181
reject:(RCTPromiseRejectBlock)reject)
181182
RCT_EXTERN_METHOD(nodeSign:(NSString *)message

lib/ios/Ldk.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ class Ldk: NSObject {
13931393
}
13941394

13951395
@objc
1396-
func spendRecoveredForceCloseOutputs(_ transaction: NSString, confirmationHeight: NSInteger, changeDestinationScript: NSString, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
1396+
func spendRecoveredForceCloseOutputs(_ transaction: NSString, confirmationHeight: NSInteger, changeDestinationScript: NSString, useInner: Bool, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
13971397

13981398
guard let channelStoragePath = Ldk.channelStoragePath, let keysManager, let channelManager else {
13991399
return handleReject(reject, .init_storage_path)
@@ -1439,7 +1439,14 @@ class Ldk: NSObject {
14391439
continue
14401440
}
14411441

1442-
let res = keysManager.spendSpendableOutputs(
1442+
let res = useInner ? keysManager.inner.spendSpendableOutputs(
1443+
descriptors: descriptors,
1444+
outputs: [],
1445+
changeDestinationScript: String(changeDestinationScript).hexaBytes,
1446+
feerateSatPer1000Weight: feeEstimator.getEstSatPer1000Weight(confirmationTarget: .OnChainSweep),
1447+
locktime: nil)
1448+
:
1449+
keysManager.spendSpendableOutputs(
14431450
descriptors: descriptors,
14441451
outputs: [],
14451452
changeDestinationScript: String(changeDestinationScript).hexaBytes,

lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@synonymdev/react-native-ldk",
33
"title": "React Native LDK",
4-
"version": "0.0.147",
4+
"version": "0.0.148",
55
"description": "React Native wrapper for LDK",
66
"main": "./dist/index.js",
77
"types": "./dist/index.d.ts",

lib/src/ldk.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,12 +1249,14 @@ class LDK {
12491249
transaction,
12501250
confirmationHeight,
12511251
changeDestinationScript,
1252+
useInner,
12521253
}: TSpendRecoveredForceCloseOutputsReq): Promise<Result<string[]>> {
12531254
try {
12541255
const res = await NativeLDK.spendRecoveredForceCloseOutputs(
12551256
transaction,
12561257
confirmationHeight,
12571258
changeDestinationScript,
1259+
useInner,
12581260
);
12591261
this.writeDebugToLog('spendRecoveredForceCloseOutputs', res);
12601262
return ok(res);

0 commit comments

Comments
 (0)