Skip to content

Commit

Permalink
Reject legacy channels by default
Browse files Browse the repository at this point in the history
  • Loading branch information
niteshbalusu11 committed Nov 24, 2023
1 parent 30b206e commit 8fbd833
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 29 deletions.
17 changes: 17 additions & 0 deletions src/state/ChannelAcceptanceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { bytesToHexString } from "../utils";
import logger from "./../utils/log";
import { IStoreModel } from "./index";
import { checkLndStreamErrorResponse } from "../utils/lndmobile";
import { lnrpc } from "../../proto/lightning";

const log = logger("ChannelAcceptanceManager");

Expand Down Expand Up @@ -34,6 +35,22 @@ export const channelAcceptanceManager: IChannelAcceptanceManagerModel = {

log.i("Channel accept request", [channelAcceptRequest]);

// Reject unknown, legacy and static remote key channels

if (
channelAcceptRequest.commitmentType === lnrpc.CommitmentType.LEGACY ||
channelAcceptRequest.commitmentType === lnrpc.CommitmentType.STATIC_REMOTE_KEY ||
channelAcceptRequest.commitmentType === lnrpc.CommitmentType.UNKNOWN_COMMITMENT_TYPE
) {
await injections.lndMobile.channel.channelAcceptorResponse(
channelAcceptRequest.pendingChanId,
false,
);

log.i("Channel request rejected due to commitment type: ", [channelAcceptRequest.commitmentType]);
return;
}

if (!!channelAcceptRequest.wantsZeroConf) {
const zeroConfPeers = getStoreState().settings.zeroConfPeers;

Expand Down
54 changes: 25 additions & 29 deletions src/windows/LightningInfo/OpenChannel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ export default function OpenChannel({ navigation, route }: IOpenChannelProps) {
await connectAndOpenChannelAll({
peer,
feeRateSat: feeRate !== 0 ? feeRate : undefined,
type: taprootChan ? lnrpc.CommitmentType["SIMPLE_TAPROOT"] : undefined,
type: taprootChan ? lnrpc.CommitmentType["SIMPLE_TAPROOT"] : lnrpc.CommitmentType.ANCHORS,
});
} else {
await connectAndOpenChannel({
peer,
amount: satoshiValue,
feeRateSat: feeRate !== 0 ? feeRate : undefined,
type: taprootChan ? lnrpc.CommitmentType["SIMPLE_TAPROOT"] : undefined,
type: taprootChan ? lnrpc.CommitmentType["SIMPLE_TAPROOT"] : lnrpc.CommitmentType.ANCHORS,
});
}
await getChannels(undefined);
Expand All @@ -88,35 +88,31 @@ export default function OpenChannel({ navigation, route }: IOpenChannelProps) {
(torEnabled && error.message?.includes(".onion: no such host")) ||
error.message?.includes(".onion: No address associated with hostname")
) {
await Alert.alert(
t("torPrompt.title"),
t("torPrompt.text1") + "\n\n" + t("torPrompt.text2"),
[
{
text: "Cancel",
},
{
text: "Activate Tor",
async onPress(value?) {
await changeTorEnabled(!torEnabled);
if (PLATFORM === "android") {
try {
await NativeModules.LndMobile.stopLnd();
await NativeModules.LndMobileTools.killLnd();
} catch (e) {
console.log(e);
}
NativeModules.LndMobileTools.restartApp();
} else {
Alert.alert(
t("bitcoinNetwork.restartDialog.title", { ns: namespaces.settings.settings }),
t("bitcoinNetwork.restartDialog.msg", { ns: namespaces.settings.settings }),
);
Alert.alert(t("torPrompt.title"), t("torPrompt.text1") + "\n\n" + t("torPrompt.text2"), [
{
text: "Cancel",
},
{
text: "Activate Tor",
async onPress(value?) {
await changeTorEnabled(!torEnabled);
if (PLATFORM === "android") {
try {
await NativeModules.LndMobile.stopLnd();
await NativeModules.LndMobileTools.killLnd();
} catch (e) {
console.log(e);
}
},
NativeModules.LndMobileTools.restartApp();
} else {
Alert.alert(
t("bitcoinNetwork.restartDialog.title", { ns: namespaces.settings.settings }),
t("bitcoinNetwork.restartDialog.msg", { ns: namespaces.settings.settings }),
);
}
},
],
);
},
]);
}
}
};
Expand Down

1 comment on commit 8fbd833

@vercel
Copy link

@vercel vercel bot commented on 8fbd833 Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

blixt-wallet – ./

blixt-wallet-hsjoberg.vercel.app
blixt-wallet-git-master-hsjoberg.vercel.app

Please sign in to comment.