From b220360a56457274d643564b1b0f02cd551a2b1f Mon Sep 17 00:00:00 2001 From: Ivan Vershigora Date: Thu, 30 May 2024 11:26:06 +0100 Subject: [PATCH] fix: Blocktank2 leftovers --- src/screens/Settings/Lightning/Channels.tsx | 8 +------- src/utils/lightning/index.ts | 9 +++++---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/screens/Settings/Lightning/Channels.tsx b/src/screens/Settings/Lightning/Channels.tsx index f927f6ceb..af776a36f 100644 --- a/src/screens/Settings/Lightning/Channels.tsx +++ b/src/screens/Settings/Lightning/Channels.tsx @@ -80,12 +80,10 @@ import useBreakpoints from '../../../styles/breakpoints'; * Convert pending (non-channel) blocktank orders to (fake) channels. * @param {IBtOrder[]} orders * @param {TPaidBlocktankOrders} paidOrders - * @param {string} nodeKey */ const getPendingBlocktankChannels = ( orders: IBtOrder[], paidOrders: TPaidBlocktankOrders, - nodeKey: string, ): { pendingOrders: TChannel[]; failedOrders: TChannel[]; @@ -112,7 +110,7 @@ const getPendingBlocktankChannels = ( is_channel_ready: false, is_outbound: false, balance_sat: order.lspBalanceSat, - counterparty_node_id: nodeKey, + counterparty_node_id: '', funding_txid: order.channel?.fundingTx.id, user_channel_id: '0', inbound_scid_alias: '', @@ -239,14 +237,10 @@ const Channels = ({ const openChannels = useAppSelector(openChannelsSelector); const pendingChannels = useAppSelector(pendingChannelsSelector); const closedChannels = useAppSelector(closedChannelsSelector); - const blocktankNodeKey = useAppSelector((state) => { - return state.blocktank.info.nodes[0]?.pubkey; - }); const { pendingOrders, failedOrders } = getPendingBlocktankChannels( blocktankOrders, paidOrders, - blocktankNodeKey, ); const pendingConnections = [...pendingOrders, ...pendingChannels]; diff --git a/src/utils/lightning/index.ts b/src/utils/lightning/index.ts index 7fdc61988..aed19c376 100644 --- a/src/utils/lightning/index.ts +++ b/src/utils/lightning/index.ts @@ -1163,8 +1163,9 @@ export const getLightningNodePeers = async ({ // No need to add Blocktank peer if geo-blocked. if (!geoBlocked) { // Set Blocktank node uri array if able. - blocktankNodeUris = - getBlocktankStore()?.info?.nodes[0].connectionStrings ?? []; + for (const node of getBlocktankStore().info.nodes) { + blocktankNodeUris.push(...node.connectionStrings); + } if (!blocktankNodeUris.length) { // Fall back to hardcoded Blocktank peer if the blocktankNodeUris array is empty. blocktankNodeUris = FALLBACK_BLOCKTANK_PEERS[selectedNetwork]; @@ -1534,14 +1535,14 @@ export const removeUnusedPeers = async ({ (channel) => channel.counterparty_node_id, ); const blocktankInfo = await getBlocktankInfo(true); - const blocktankPubKey = blocktankInfo.nodes[0].pubkey; + const blocktankPubKeys = blocktankInfo.nodes.map((n) => n.pubkey); const peers = await lm.getPeers(); await Promise.all( peers.map((peer) => { if ( !channelNodeIds.includes(peer.pubKey) && // If no channels exist for a given peer, remove them. - peer.pubKey !== blocktankPubKey // Ensure we don't disconnect from Blocktank if it was previously added as a peer. + !blocktankPubKeys.includes(peer.pubKey) // Ensure we don't disconnect from Blocktank if it was previously added as a peer. ) { const peerStr = `${peer.pubKey}@${peer.address}:${peer.port}`; // Remove peer from local storage.