Skip to content

Commit

Permalink
Merge pull request #229 from synonymdev/channel-id-fix
Browse files Browse the repository at this point in the history
fix: correct channel id in listing channel monitors
  • Loading branch information
ovitrif authored Mar 27, 2024
2 parents 067f7b6 + 59a80e5 commit ffb7cfa
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/android/src/main/java/com/reactnativeldk/Helpers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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().reversedArray())
result.putHexString("counterparty_node_id", _counterparty_node_id)

val balances = Arguments.createArray()
Expand Down
2 changes: 1 addition & 1 deletion lib/android/src/main/java/com/reactnativeldk/LdkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/ios/Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()?.reversed() ?? []).hexEncodedString(),
"counterparty_node_id": Data(getCounterpartyNodeId() ?? []).hexEncodedString(),
"claimable_balances": getClaimableBalances().map({ $0.asJson })
]
Expand Down
4 changes: 2 additions & 2 deletions lib/ios/Ldk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion lib/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
};
Expand Down

0 comments on commit ffb7cfa

Please sign in to comment.