From 21e1b6299fe57c6361e64ef189a1ba87a3a01e08 Mon Sep 17 00:00:00 2001 From: Jason Date: Mon, 25 Mar 2024 17:12:25 +0200 Subject: [PATCH] fix: correct channel_id, funding txid and index in listing channel monitors --- lib/android/src/main/java/com/reactnativeldk/Helpers.kt | 3 ++- lib/android/src/main/java/com/reactnativeldk/LdkModule.kt | 2 +- lib/ios/Helpers.swift | 3 ++- lib/ios/Ldk.swift | 4 ++-- lib/src/utils/types.ts | 3 ++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/android/src/main/java/com/reactnativeldk/Helpers.kt b/lib/android/src/main/java/com/reactnativeldk/Helpers.kt index ffd4df7e..c62596d1 100644 --- a/lib/android/src/main/java/com/reactnativeldk/Helpers.kt +++ b/lib/android/src/main/java/com/reactnativeldk/Helpers.kt @@ -203,7 +203,8 @@ val RouteHop.asJson: WritableMap fun ChannelMonitor.asJson(channelId: String): WritableMap { val result = Arguments.createMap() result.putString("channel_id", channelId) - result.putHexString("funding_txo", _funding_txo._b) + result.putInt("funding_txo_index", _funding_txo._a._index.toInt()) + result.putHexString("funding_txo_txid", _funding_txo._a.to_channel_id()) result.putHexString("counterparty_node_id", _counterparty_node_id) val balances = Arguments.createArray() diff --git a/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt b/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt index 8506215f..1ca81338 100644 --- a/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt +++ b/lib/android/src/main/java/com/reactnativeldk/LdkModule.kt @@ -967,7 +967,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod if (channelMonitor.is_ok) { val channelMonitorResult = (channelMonitor as Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_OK) - result.pushMap(channelMonitorResult.res._b.asJson(channelMonitorResult.res._a.hexEncodedString())) + result.pushMap(channelMonitorResult.res._b.asJson(channelId)) } } diff --git a/lib/ios/Helpers.swift b/lib/ios/Helpers.swift index d49f8681..6b4fba8b 100644 --- a/lib/ios/Helpers.swift +++ b/lib/ios/Helpers.swift @@ -191,7 +191,8 @@ extension ChannelMonitor { func asJson(channelId: String) -> [String: Any?] { return [ "channel_id": channelId, - "funding_txo": Data(getFundingTxo().1).hexEncodedString(), + "funding_txo_index": getFundingTxo().0.getIndex(), + "funding_txo_txid": Data(getFundingTxo().0.getTxid() ?? []).hexEncodedString(), "counterparty_node_id": Data(getCounterpartyNodeId() ?? []).hexEncodedString(), "claimable_balances": getClaimableBalances().map({ $0.asJson }) ] diff --git a/lib/ios/Ldk.swift b/lib/ios/Ldk.swift index a61a09c1..62b4e02a 100644 --- a/lib/ios/Ldk.swift +++ b/lib/ios/Ldk.swift @@ -1040,12 +1040,12 @@ class Ldk: NSObject { argB: keysManager.signerProvider ) - guard let (channelId, channelMonitor) = channelMonitorResult.getValue() else { + guard let (_, channelMonitor) = channelMonitorResult.getValue() else { LdkEventEmitter.shared.send(withEvent: .native_log, body: "Loading channel error. No channel value.") continue } - result.append(channelMonitor.asJson(channelId: Data(channelId).hexEncodedString())) + result.append(channelMonitor.asJson(channelId: channelId)) } return resolve(result) diff --git a/lib/src/utils/types.ts b/lib/src/utils/types.ts index 455f14ff..8d8f2e24 100644 --- a/lib/src/utils/types.ts +++ b/lib/src/utils/types.ts @@ -166,7 +166,8 @@ export type TChannel = { export type TChannelMonitor = { channel_id: string; - funding_txo: string; + funding_txo_index: number; + funding_txo_txid: string; counterparty_node_id: string; claimable_balances: [TClaimableBalance]; };