Skip to content
This repository was archived by the owner on Feb 9, 2026. It is now read-only.

Commit d125f01

Browse files
committed
fix: int overflow for short channel IDs
1 parent 8645003 commit d125f01

4 files changed

Lines changed: 22 additions & 14 deletions

File tree

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,21 @@ val ChannelDetails.asJson: WritableMap
123123
result.putHexString("channel_type", _channel_type?.write())
124124
result.putString("user_channel_id", _user_channel_id.leBytes.hexEncodedString())
125125
result.putInt("confirmations_required", (_confirmations_required as Option_u32Z.Some).some)
126-
(_short_channel_id as? Option_u64Z.Some)?.some?.toInt()
127-
?.let { result.putString("short_channel_id", it.toString()) } //Optional number
128-
(_inbound_scid_alias as? Option_u64Z.Some)?.some?.toInt()
129-
?.let { result.putInt("inbound_scid_alias", it) }
130-
(_inbound_scid_alias as? Option_u64Z.Some)?.some?.toInt()
131-
?.let { result.putInt("inbound_payment_scid", it) }
126+
if (_short_channel_id is Option_u64Z.Some) {
127+
result.putString("short_channel_id", (_short_channel_id as Option_u64Z.Some).some.toULong().toString())
128+
} else {
129+
result.putString("short_channel_id", "")
130+
}
131+
if (_inbound_scid_alias is Option_u64Z.Some) {
132+
result.putString("inbound_scid_alias", (_inbound_scid_alias as Option_u64Z.Some).some.toULong().toString())
133+
} else {
134+
result.putString("inbound_scid_alias", "")
135+
}
136+
if (_inbound_payment_scid is Option_u64Z.Some) {
137+
result.putString("inbound_payment_scid", (_inbound_payment_scid as Option_u64Z.Some).some.toULong().toString())
138+
} else {
139+
result.putString("inbound_payment_scid", "")
140+
}
132141
result.putInt("inbound_capacity_sat", (_inbound_capacity_msat / 1000).toInt())
133142
result.putInt("outbound_capacity_sat", (_outbound_capacity_msat / 1000).toInt())
134143
result.putInt("channel_value_satoshis", _channel_value_satoshis.toInt())

lib/ios/Helpers.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ extension RouteHintHop {
112112
//Our own channels
113113
extension ChannelDetails {
114114
var asJson: [String: Any] {
115-
let shortChannelId = getShortChannelId()
116115
return [
117116
"channel_id": Data(getChannelId() ?? []).hexEncodedString(),
118117
"is_public": getIsPublic(),
@@ -123,11 +122,11 @@ extension ChannelDetails {
123122
"counterparty_node_id": Data(getCounterparty().getNodeId()).hexEncodedString(),
124123
"funding_txid": Data(getFundingTxo()?.getTxid()?.reversed() ?? []).hexEncodedString(),
125124
"channel_type": Data(getChannelType()?.write() ?? []).hexEncodedString(),
126-
"user_channel_id": Data(getUserChannelId()).hexEncodedString(), //Sting
125+
"user_channel_id": Data(getUserChannelId()).hexEncodedString(), //String
127126
"confirmations_required": getConfirmationsRequired() as Any, // Optional number
128-
"short_channel_id": shortChannelId != nil ? String(shortChannelId!) : "",
129-
"inbound_scid_alias": getInboundScidAlias() as Any, //Optional number
130-
"inbound_payment_scid": getInboundPaymentScid() as Any, //Optional number,
127+
"short_channel_id": getShortChannelId() != nil ? String(getShortChannelId()!) : "", //String
128+
"inbound_scid_alias": getInboundScidAlias() != nil ? String(getInboundScidAlias()!) : "", //String
129+
"inbound_payment_scid": getInboundPaymentScid() != nil ? String(getInboundPaymentScid()!) : "", //String
131130
"inbound_capacity_sat": getInboundCapacityMsat() / 1000,
132131
"outbound_capacity_sat": getOutboundCapacityMsat() / 1000,
133132
"channel_value_satoshis": getChannelValueSatoshis(),

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.114",
4+
"version": "0.0.118",
55
"description": "React Native wrapper for LDK",
66
"main": "./dist/index.js",
77
"types": "./dist/index.d.ts",

lib/src/utils/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ export type TChannel = {
151151
user_channel_id: string;
152152
confirmations_required?: number;
153153
short_channel_id: string;
154-
inbound_scid_alias?: number;
155-
inbound_payment_scid?: number;
154+
inbound_scid_alias: string;
155+
inbound_payment_scid: string;
156156
inbound_capacity_sat: number;
157157
outbound_capacity_sat: number;
158158
channel_value_satoshis: number;

0 commit comments

Comments
 (0)