Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjoberg committed Dec 18, 2023
1 parent 9c11d8b commit dda37d5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 43 deletions.
69 changes: 26 additions & 43 deletions src/components/PendingChannelCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useMemo } from "react";
import { Body, Text, Left, Right, Card, CardItem, Row, Button } from "native-base";
import { Image, Linking } from "react-native";
import Long from "long";
Expand Down Expand Up @@ -39,6 +39,7 @@ export const PendingChannelCard = ({ channel, type, alias }: IPendingChannelCard
const bitcoinUnit = useStoreState((store) => store.settings.bitcoinUnit);
const fiatUnit = useStoreState((store) => store.settings.fiatUnit);
const currentRate = useStoreState((store) => store.fiat.currentRate);
const onchainTransactions = useStoreState((store) => store.onChain.transactions);

if (!channel.channel) {
return <Text>Error</Text>;
Expand Down Expand Up @@ -97,11 +98,7 @@ export const PendingChannelCard = ({ channel, type, alias }: IPendingChannelCard
);
};

const bumpChannelFee = async (
channel:
| lnrpc.PendingChannelsResponse.IPendingOpenChannel
| lnrpc.PendingChannelsResponse.IWaitingCloseChannel,
) => {
const bumpChannelFee = async (channel: lnrpc.PendingChannelsResponse.IPendingOpenChannel) => {
if (!channel.channel || !channel.channel.channelPoint) {
Alert.alert(t("channel.bumpFeeAlerts.missingChannelPoint"));
return;
Expand Down Expand Up @@ -168,6 +165,17 @@ export const PendingChannelCard = ({ channel, type, alias }: IPendingChannelCard
service = lightningServices[serviceKey];
}

let isFeeBumpable = useMemo(() => {
for (const onchainTransaction of onchainTransactions) {
if (onchainTransaction.txHash == channel?.channel?.channelPoint?.split(":")[0]) {
if (onchainTransaction.destAddresses && onchainTransaction.destAddresses.length > 1) {
return true;
}
}
}
return false;
}, [channel]);

return (
<Card style={style.channelCard}>
<CardItem style={style.channelDetail}>
Expand Down Expand Up @@ -279,17 +287,20 @@ export const PendingChannelCard = ({ channel, type, alias }: IPendingChannelCard
</Row>
<Row style={{ width: "100%" }}>
<Left style={{ flexDirection: "row" }}>
<Button
style={{ marginTop: 14 }}
danger={true}
small={true}
onPress={() => bumpChannelFee(channel)}
>
<Text style={{ fontSize: 8 }}>{t("channel.bumpFee")}</Text>
</Button>
{channel?.channel.initiator === lnrpc.Initiator["INITIATOR_LOCAL"] &&
isFeeBumpable === true && (
<Button
style={{ marginTop: 14 }}
danger={true}
small={true}
onPress={() => bumpChannelFee(channel)}
>
<Text style={{ fontSize: 8 }}>{t("channel.bumpFee")}</Text>
</Button>
)}

<Button
style={{ marginTop: 14, marginLeft: 10 }}
style={{ marginTop: 14, marginLeft: isFeeBumpable ? 10 : 0 }}
small={true}
onPress={() => {
const txId = channel.channel?.channelPoint?.split(":")[0];
Expand Down Expand Up @@ -380,34 +391,6 @@ export const PendingChannelCard = ({ channel, type, alias }: IPendingChannelCard
</Left>
</Row>
)}
{!!(channel as lnrpc.PendingChannelsResponse.IWaitingCloseChannel)?.closingTxid && (
<Row style={{ width: "100%" }}>
<Left style={{ flexDirection: "row" }}>
<Button
style={{ marginTop: 14 }}
danger={true}
small={true}
onPress={() => bumpChannelFee(channel)}
>
<Text style={{ fontSize: 8 }}>{t("channel.bumpFee")}</Text>
</Button>

<Button
style={{ marginTop: 14, marginLeft: 10 }}
small={true}
onPress={() =>
onPressViewInExplorer(
(channel as lnrpc.PendingChannelsResponse.ClosedChannel).closingTxid,
)
}
>
<Text style={{ fontSize: 8 }}>
{t("generic.viewInBlockExplorer", { ns: namespaces.common })}
</Text>
</Button>
</Left>
</Row>
)}
</>
)}
{type === "FORCE_CLOSING" && (
Expand Down
4 changes: 4 additions & 0 deletions src/state/OnChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ export const onChain: IOnChainModel = {
importance: "high",
});
actions.addToTransactionNotificationBlacklist(transaction.txHash);

actions.getTransactions();
}
} catch (error) {
toast(error.message, undefined, "danger");
Expand All @@ -143,6 +145,8 @@ export const onChain: IOnChainModel = {

actions.setTransactionSubscriptionStarted(true);
}

actions.getTransactions();
return true;
},
),
Expand Down

0 comments on commit dda37d5

Please sign in to comment.