Skip to content

Commit

Permalink
fix: Blocktank2 leftovers
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed May 30, 2024
1 parent 8de4fa7 commit b220360
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
8 changes: 1 addition & 7 deletions src/screens/Settings/Lightning/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -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: '',
Expand Down Expand Up @@ -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];

Expand Down
9 changes: 5 additions & 4 deletions src/utils/lightning/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit b220360

Please sign in to comment.