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: Blocktank2 leftovers #1914

Merged
merged 1 commit into from
May 30, 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
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
Loading