Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjoberg committed Jan 21, 2024
1 parent 7fcc5f4 commit b106abc
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 14 deletions.
10 changes: 6 additions & 4 deletions src/migration/app-migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,12 @@ export const appMigration: IAppMigration[] = [
// Version 39
{
async beforeLnd(db, i) {
if (Chain === "testnet" || Chain === "mainnet") {
const neutrinoPeers = DEFAULT_NEUTRINO_NODE?.split(",");

await setItemObject<string[]>(StorageItem.neutrinoPeers, neutrinoPeers || []);
if (Chain === "mainnet") {
// Change the peers if the user hasn't manually changed it
const peers = await getItemObject<string[]>(StorageItem.neutrinoPeers);
if (peers.length === 1 && peers[0] === "node.blixtwallet.com") {
await setItemObject<string[]>(StorageItem.neutrinoPeers, DEFAULT_NEUTRINO_NODE);
}
}
},
},
Expand Down
12 changes: 11 additions & 1 deletion src/state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,16 @@ export const model: IStoreModel = {

const nodeBackend = lndChainBackend === "neutrino" ? "neutrino" : "bitcoind";

let neutrinoPeerConfig = "";
if (nodeBackend === "neutrino") {
// If there is only 1 peer, use `neutrino.connect`, otherwise `neutrino.addpeer`
if (neutrinoPeers.length === 1) {
neutrinoPeerConfig = `neutrino.connect=${neutrinoPeers[0]}`;
} else {
neutrinoPeerConfig = neutrinoPeers.map((peer) => `neutrino.addpeer=${peer}`).join("\n");
}
}

const config = `
[Application Options]
debuglevel=${lndLogLevel}
Expand Down Expand Up @@ -563,13 +573,13 @@ ${
lndChainBackend === "neutrino"
? `
[Neutrino]
${neutrinoPeerConfig}
neutrino.feeurl=${neutrinoFeeUrl}
neutrino.broadcasttimeout=11s
neutrino.persistfilters=true
`
: ""
}
${`${neutrinoPeers.map((peer) => `neutrino.addpeer=${peer}`).join("\n")}`}
${
lndChainBackend === "bitcoindWithZmq"
Expand Down
3 changes: 1 addition & 2 deletions src/storage/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ export const setupApp = async () => {
let neutrinoFeeUrl = "";
if (Chain === "mainnet" || Chain === "testnet") {
lndChainBackend = "neutrino";
neutrinoPeers = DEFAULT_NEUTRINO_NODE?.split(",").map((peer) => peer.trim()) || [];

neutrinoPeers = DEFAULT_NEUTRINO_NODE;
neutrinoFeeUrl = "https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json";
}

Expand Down
15 changes: 10 additions & 5 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ export const PLATFORM = Platform.OS;
export const MATH_PAD_NATIVE_ID = "MATH_PAD";

export const DEFAULT_NEUTRINO_NODE = chainSelect({
mainnet:
"node.blixtwallet.com,btcd.lnolymp.us,neutrino.noderunner.wtf,node.eldamar.icu,btcd-mainnet.lightning.computer",
testnet: "testnet.blixtwallet.com",
regtest: "",
signet: "",
mainnet: [
"node.blixtwallet.com",
"btcd.lnolymp.us",
"neutrino.noderunner.wtf",
"node.eldamar.icu",
"btcd-mainnet.lightning.computer",
],
testnet: ["testnet.blixtwallet.com"],
regtest: [],
signet: [],
});
export const DEFAULT_INVOICE_EXPIRY = 3600;
export const DEFAULT_MAX_LN_FEE_PERCENTAGE = 2;
Expand Down
3 changes: 3 additions & 0 deletions src/windows/InitProcess/DEV_Commands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,9 @@ export default function DEV_Commands({ navigation, continueCallback }: IProps) {
<Button small onPress={async () => await setItemObject(StorageItem.appVersion, 28)}>
<Text style={styles.buttonText}>appVersion = 28</Text>
</Button>
<Button small onPress={async () => await setItemObject(StorageItem.appVersion, 38)}>
<Text style={styles.buttonText}>appVersion = 38</Text>
</Button>
<Button
small
onPress={async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/windows/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ ${t("LN.inbound.dialog.msg3")}`;
},
],
"plain-text",
neutrinoPeers[0] ?? "",
neutrinoPeers.join(",") ?? "",
);
};
const onSetBitcoinNodeLongPress = async () => {
Expand All @@ -763,7 +763,7 @@ ${t("LN.inbound.dialog.msg3")}`;
style: "default",
text: t("buttons.yes", { ns: namespaces.common }),
onPress: async () => {
await changeNeutrinoPeers([DEFAULT_NEUTRINO_NODE]);
await changeNeutrinoPeers(DEFAULT_NEUTRINO_NODE);
await writeConfig();
restartNeeded();
},
Expand Down

0 comments on commit b106abc

Please sign in to comment.