Skip to content

Commit ffb7cfa

Browse files
authored
Merge pull request #229 from synonymdev/channel-id-fix
fix: correct channel id in listing channel monitors
2 parents 067f7b6 + 59a80e5 commit ffb7cfa

File tree

5 files changed

+9
-6
lines changed

5 files changed

+9
-6
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ val RouteHop.asJson: WritableMap
203203
fun ChannelMonitor.asJson(channelId: String): WritableMap {
204204
val result = Arguments.createMap()
205205
result.putString("channel_id", channelId)
206-
result.putHexString("funding_txo", _funding_txo._b)
206+
result.putInt("funding_txo_index", _funding_txo._a._index.toInt())
207+
result.putHexString("funding_txo_txid", _funding_txo._a.to_channel_id().reversedArray())
207208
result.putHexString("counterparty_node_id", _counterparty_node_id)
208209

209210
val balances = Arguments.createArray()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
967967

968968
if (channelMonitor.is_ok) {
969969
val channelMonitorResult = (channelMonitor as Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ_OK)
970-
result.pushMap(channelMonitorResult.res._b.asJson(channelMonitorResult.res._a.hexEncodedString()))
970+
result.pushMap(channelMonitorResult.res._b.asJson(channelId))
971971
}
972972
}
973973

lib/ios/Helpers.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ extension ChannelMonitor {
191191
func asJson(channelId: String) -> [String: Any?] {
192192
return [
193193
"channel_id": channelId,
194-
"funding_txo": Data(getFundingTxo().1).hexEncodedString(),
194+
"funding_txo_index": getFundingTxo().0.getIndex(),
195+
"funding_txo_txid": Data(getFundingTxo().0.getTxid()?.reversed() ?? []).hexEncodedString(),
195196
"counterparty_node_id": Data(getCounterpartyNodeId() ?? []).hexEncodedString(),
196197
"claimable_balances": getClaimableBalances().map({ $0.asJson })
197198
]

lib/ios/Ldk.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,12 +1040,12 @@ class Ldk: NSObject {
10401040
argB: keysManager.signerProvider
10411041
)
10421042

1043-
guard let (channelId, channelMonitor) = channelMonitorResult.getValue() else {
1043+
guard let (_, channelMonitor) = channelMonitorResult.getValue() else {
10441044
LdkEventEmitter.shared.send(withEvent: .native_log, body: "Loading channel error. No channel value.")
10451045
continue
10461046
}
10471047

1048-
result.append(channelMonitor.asJson(channelId: Data(channelId).hexEncodedString()))
1048+
result.append(channelMonitor.asJson(channelId: channelId))
10491049
}
10501050

10511051
return resolve(result)

lib/src/utils/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ export type TChannel = {
166166

167167
export type TChannelMonitor = {
168168
channel_id: string;
169-
funding_txo: string;
169+
funding_txo_index: number;
170+
funding_txo_txid: string;
170171
counterparty_node_id: string;
171172
claimable_balances: [TClaimableBalance];
172173
};

0 commit comments

Comments
 (0)