Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct channel id in listing channel monitors #229

Merged
merged 1 commit into from
Mar 27, 2024
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
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
Loading