Skip to content

Commit

Permalink
Channel: display ID and SCID
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloudis committed Nov 23, 2024
1 parent f28aae3 commit d63eb64
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 36 deletions.
13 changes: 4 additions & 9 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ PODS:
- fmt (= 9.1.0)
- glog
- RCT-Folly/Default (= 2024.01.01.00)
- RCT-Folly/Default (2024.01.01.00):
- boost
- DoubleConversion
- fmt (= 9.1.0)
- glog
- RCT-Folly/Fabric (2024.01.01.00):
- boost
- DoubleConversion
Expand Down Expand Up @@ -1619,14 +1614,14 @@ SPEC CHECKSUMS:
boost: d3f49c53809116a5d38da093a8aa78bf551aed09
BVLinearGradient: 34a999fda29036898a09c6a6b728b0b4189e1a44
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: 76ab83afb40bddeeee456813d9c04f67f78771b5
DoubleConversion: f16ae600a246532c4020132d54af21d0ddb2a385
FBLazyVector: 4bc164e5b5e6cfc288d2b5ff28643ea15fa1a589
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
glog: fdfdfe5479092de0c4bdbebedd9056951f092c4f
fmt: 10c6e61f4be25dc963c36bd73fc7b1705fe975be
glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a
hermes-engine: 01d3e052018c2a13937aca1860fbedbccd4a41b7
lottie-ios: 8f97d3271e155c2d688875c29cd3c74908aef5f8
lottie-react-native: 8f9d4be452e23f6e5ca0fdc11669dc99ab52be81
RCT-Folly: 02617c592a293bd6d418e0a88ff4ee1f88329b47
RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648
RCTDeprecation: b03c35057846b685b3ccadc9bfe43e349989cdb2
RCTRequired: 194626909cfa8d39ca6663138c417bc6c431648c
RCTTypeSafety: 552aff5b8e8341660594db00e53ac889682bc120
Expand Down
8 changes: 8 additions & 0 deletions ios/zeus.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,7 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-zeus-zeusTests/Pods-zeus-zeusTests-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/RCT-Folly/RCT-Folly_privacy.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/RNCAsyncStorage/RNCAsyncStorage_resources.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/RNDeviceInfo/RNDeviceInfoPrivacyInfo.bundle",
"${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/AntDesign.ttf",
Expand All @@ -1513,9 +1514,11 @@
"${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Zocial.ttf",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/RCTI18nStrings.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/SwiftProtobuf/SwiftProtobuf.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/glog/glog_privacy.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RCT-Folly_privacy.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RNCAsyncStorage_resources.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RNDeviceInfoPrivacyInfo.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AntDesign.ttf",
Expand All @@ -1536,6 +1539,7 @@
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Zocial.ttf",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RCTI18nStrings.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SwiftProtobuf.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/glog_privacy.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -1566,6 +1570,7 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-zeus/Pods-zeus-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/RCT-Folly/RCT-Folly_privacy.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/RNCAsyncStorage/RNCAsyncStorage_resources.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/RNDeviceInfo/RNDeviceInfoPrivacyInfo.bundle",
"${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/AntDesign.ttf",
Expand All @@ -1586,9 +1591,11 @@
"${PODS_ROOT}/../../node_modules/react-native-vector-icons/Fonts/Zocial.ttf",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/RCTI18nStrings.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/SwiftProtobuf/SwiftProtobuf.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/glog/glog_privacy.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RCT-Folly_privacy.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RNCAsyncStorage_resources.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RNDeviceInfoPrivacyInfo.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AntDesign.ttf",
Expand All @@ -1609,6 +1616,7 @@
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Zocial.ttf",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RCTI18nStrings.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SwiftProtobuf.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/glog_privacy.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@
"views.Channel.SortButton.ascending": "ascending",
"views.Channel.SortButton.descending": "descending",
"views.Channel.channelId": "Channel ID",
"views.Channel.scid": "Short Channel ID (SCID)",
"views.Channel.channelIds": "Channel IDs",
"views.Channel.displayName": "Display name",
"views.Channel.Total.outbound": "Sending capacity (outbound)",
Expand Down
18 changes: 18 additions & 0 deletions models/Channel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import BigNumber from 'bignumber.js';
import { observable, computed } from 'mobx';
import BigInt from 'big-integer';

import BaseModel from './BaseModel';
import { lnrpc } from '../proto/lightning';

Expand Down Expand Up @@ -182,6 +184,22 @@ export default class Channel extends BaseModel {
return this.chan_id || this.channel_id;
}

@computed
public get shortChannelId(): string | undefined {
const chanId = BigInt(Number(this.channelId) || 0); // Use BigInt for large numbers

// Extract the components
// @ts-ignore:next-line
const blockHeight = chanId >> BigInt(40); // Shift right by 40 bits
// @ts-ignore:next-line
const txIndex = (chanId >> BigInt(16)) & BigInt(0xffffff); // Shift right by 16 bits and mask 24 bits
// @ts-ignore:next-line
const outputIndex = chanId & BigInt(0xffff); // Mask the lower 16 bits

// Combine components into the short channel ID
return `${blockHeight}x${txIndex}x${outputIndex}`;
}

@computed
public get remotePubkey(): string {
return this.remote_pubkey || this.remote_node_pub || '';
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"bbqr": "1.0.0",
"bc-ur": "0.1.6",
"bech32": "2.0.0",
"big-integer": "1.6.52",
"bignumber.js": "9.0.2",
"bip39": "3.1.0",
"bitcoinjs-lib": "6.1.5",
Expand Down
71 changes: 45 additions & 26 deletions views/Channels/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export default class ChannelView extends React.Component<
remotePubkey,
capacity,
channelId,
shortChannelId,
initiator,
alias_scids,
local_chan_reserve_sat,
Expand Down Expand Up @@ -360,18 +361,22 @@ export default class ChannelView extends React.Component<
)}
{remotePubkey && this.renderContactLink(remotePubkey)}
</View>
<BalanceSlider
sendingCapacity={lurkerMode ? 50 : sendingCapacity}
receivingCapacity={lurkerMode ? 50 : receivingCapacity}
localBalance={lurkerMode ? 50 : localBalance}
remoteBalance={lurkerMode ? 50 : remoteBalance}
localReserveBalance={
lurkerMode ? 50 : localReserveBalance
}
remoteReserveBalance={
lurkerMode ? 50 : remoteReserveBalance
}
/>
<View style={{ height: 40 }}>
<BalanceSlider
sendingCapacity={lurkerMode ? 50 : sendingCapacity}
receivingCapacity={
lurkerMode ? 50 : receivingCapacity
}
localBalance={lurkerMode ? 50 : localBalance}
remoteBalance={lurkerMode ? 50 : remoteBalance}
localReserveBalance={
lurkerMode ? 50 : localReserveBalance
}
remoteReserveBalance={
lurkerMode ? 50 : remoteReserveBalance
}
/>
</View>
<Text
style={{ ...styles.status, color: themeColor('text') }}
>
Expand All @@ -387,6 +392,30 @@ export default class ChannelView extends React.Component<
? localeString('views.Channel.active')
: localeString('views.Channel.inactive')}
</Text>
{channelId && (
<KeyValue
keyValue={localeString('views.Channel.channelId')}
value={channelId}
/>
)}
{channelId && (
<KeyValue
keyValue={localeString('views.Channel.scid')}
value={shortChannelId}
/>
)}
{!!alias_scids && alias_scids.length > 0 && (
<KeyValue
keyValue={
alias_scids.length > 1
? localeString('views.Channel.aliasScids')
: localeString('views.Channel.aliasScid')
}
value={PrivacyUtils.sensitiveValue(
alias_scids.join(', ')
)}
/>
)}
{zero_conf && (
<KeyValue
keyValue={localeString('views.Channel.zeroConf')}
Expand Down Expand Up @@ -547,18 +576,6 @@ export default class ChannelView extends React.Component<
/>
</ListItem>
)}
{!!alias_scids && alias_scids.length > 0 && (
<KeyValue
keyValue={
alias_scids.length > 1
? localeString('views.Channel.aliasScids')
: localeString('views.Channel.aliasScid')
}
value={PrivacyUtils.sensitiveValue(
alias_scids.join(', ')
)}
/>
)}
<KeyValue
keyValue={localeString('views.Channel.channelBalance')}
/>
Expand Down Expand Up @@ -883,8 +900,10 @@ const styles = StyleSheet.create({
},
status: {
fontFamily: 'PPNeueMontreal-Book',
alignSelf: 'center',
marginBottom: 10
margin: 18,
flex: 1,
flexDirection: 'row',
textAlign: 'center'
},
alias: {
fontSize: 28,
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3966,7 +3966,7 @@ bech32@^1.1.2, bech32@^1.1.4:
resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9"
integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==

big-integer@1.6.x:
big-integer@1.6.52, big-integer@1.6.x:
version "1.6.52"
resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.52.tgz#60a887f3047614a8e1bffe5d7173490a97dc8c85"
integrity sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==
Expand Down

0 comments on commit d63eb64

Please sign in to comment.