diff --git a/public/locales/en.json b/public/locales/en.json index 17ea9ab..fd493b8 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -365,7 +365,8 @@ "11": "The date format can be changed in the [advanced settings](/settings).", "12": "You can see the [lowest mined block hashes](/network/blocks/lowest).", "13": "The most recently purchased names can be seen on the [Network Names page](/network/names/new).", - "14": "The block value increases when [names](/network/names) are purchased." + "14": "The block value increases when [names](/network/names) are purchased.", + "15": "If you're worried about accidental transactions, you can enable a confirmation prompt in the [advanced settings](/settings)." } }, @@ -417,6 +418,7 @@ "transactionsHighlightOwn": "Highlight own transactions in the transactions table", "transactionsHighlightVerified": "Highlight verified addresses in the transactions table", "transactionDefaultRaw": "Default to the 'Raw' tab instead of 'CommonMeta' on the transaction page", + "confirmTransactions": "Prompt for confirmation for all transactions", "clearTransactionForm": "Clear the Send Transaction form after clicking 'Send'", "sendTransactionDelay": "Time to wait, in milliseconds, before allowing another transaction to be sent", "defaultPageSize": "Default page size for table listings", @@ -932,8 +934,10 @@ "errorUnknown": "Unknown error sending transaction. See console for details.", + "payLargeConfirm": "Are you sure you want to send <1 />?", "payLargeConfirmHalf": "Are you sure you want to send <1 />? This is over half your balance!", "payLargeConfirmAll": "Are you sure you want to send <1 />? This is your entire balance!", + "payLargeConfirmDefault": "You are about to send your wallet private key and password to an unofficial Krist server, which will give them access to your Krist on the official server. Are you sure you want to do this?", "errorNotificationTitle": "Transaction failed", "successNotificationTitle": "Transaction successful", diff --git a/src/global/ws/SyncMOTD.tsx b/src/global/ws/SyncMOTD.tsx index 8dd7ca0..a7c492b 100644 --- a/src/global/ws/SyncMOTD.tsx +++ b/src/global/ws/SyncMOTD.tsx @@ -37,6 +37,7 @@ const motdBase: KristMOTDBase = { motd: data.motd, motdSet: new Date(data.motd_set), + endpoint: data.public_url, debugMode: data.debug_mode, miningEnabled: data.mining_enabled }; diff --git a/src/krist/api/types.ts b/src/krist/api/types.ts index bc86c73..5192459 100644 --- a/src/krist/api/types.ts +++ b/src/krist/api/types.ts @@ -96,6 +96,7 @@ miningEnabled: boolean; debugMode: boolean; + endpoint?: string; } export const DEFAULT_MOTD_BASE: KristMOTDBase = { motd: "", diff --git a/src/pages/dashboard/MOTDCard.tsx b/src/pages/dashboard/MOTDCard.tsx index 2a795ec..5cd41f2 100644 --- a/src/pages/dashboard/MOTDCard.tsx +++ b/src/pages/dashboard/MOTDCard.tsx @@ -14,7 +14,7 @@ export function MOTDCard(): JSX.Element { const { t } = useTranslation(); - const { motd, motdSet, debugMode } + const { motd, motdSet, endpoint, debugMode } = useSelector((s: RootState) => s.node.motd); // Make relative links start with the sync node, and override all links to @@ -22,7 +22,7 @@ const MarkdownLink = useMarkdownLink(); return - {debugMode && } + {(debugMode || (endpoint ? btoa([...endpoint] as any) !== atob("YXl4eUxHa3NjeXgwTEM0c1l5eGxMSElzYVN4aExIUXNMaXh1TEdVc2RBPT0=") : false)) && }

= ({ amount, balance, key2 }) => { + const { t, tKey } = useTFns("sendTransaction."); + + // Show the appropriate message, if this is just over half the + // balance, or if it is the entire balance. + return = balance + ? "payLargeConfirmAll" + : "payLargeConfirmHalf"))} + > + Are you sure you want to send ? + This is over half your balance! + ; +}; diff --git a/src/pages/transactions/send/SendTransactionForm.tsx b/src/pages/transactions/send/SendTransactionForm.tsx index ac21700..a769c58 100644 --- a/src/pages/transactions/send/SendTransactionForm.tsx +++ b/src/pages/transactions/send/SendTransactionForm.tsx @@ -5,7 +5,7 @@ import { Row, Col, Form, FormInstance, Input, Modal } from "antd"; import { RefSelectProps } from "antd/lib/select"; -import { useTranslation, Trans } from "react-i18next"; +import { useTranslation } from "react-i18next"; import { TranslatedError } from "@utils/i18n"; import { useSelector, useDispatch } from "react-redux"; @@ -15,16 +15,17 @@ import { useWallets, Wallet } from "@wallets"; import { useMountEffect } from "@utils"; +import { sha256 } from "@utils/crypto"; import { useBooleanSetting, useIntegerSetting } from "@utils/settings"; -import { APIError } from "@api"; +import { APIError, useSyncNode } from "@api"; import { KristTransaction } from "@api/types"; import { makeTransaction } from "@api/transactions"; import { useAuthFailedModal } from "@api/AuthFailed"; import { AddressPicker } from "@comp/addresses/picker/AddressPicker"; import { AmountInput } from "./AmountInput"; -import { KristValue } from "@comp/krist/KristValue"; +import { SendTransactionConfirmModalContents } from "./SendTransactionConfirmModal"; import awaitTo from "await-to-js"; @@ -220,6 +221,7 @@ // Used to check for warning on large transactions const { walletAddressMap } = useWallets(); + const url = useSyncNode(); // Confirmation modal used for when the transaction amount is very large. // This is created here to provide a translation context for the modal. @@ -229,6 +231,7 @@ // If the form allows it, and the setting is enabled, clear the form when // sending a transaction. + const confirmOnSend = useBooleanSetting("confirmTransactions"); const clearOnSend = useBooleanSetting("clearTransactionForm"); const sendDelay = useIntegerSetting("sendTransactionDelay"); @@ -334,24 +337,20 @@ // If the transaction is large (over half the balance), prompt for // confirmation before sending const { amount } = values; + const confirmable = await sha256(url) !== "cadc9145658308ead9ade59730063772f9a4d682650842981d3c075c5240cfee"; + const showConfirm = confirmOnSend || confirmable; const isLarge = amount >= currentWallet.balance / 2; - if (isLarge) { + if (showConfirm || isLarge) { // It's large, prompt for confirmation confirmModal.confirm({ title: t("sendTransaction.modalTitle"), - content: ( - // Show the appropriate message, if this is just over half the - // balance, or if it is the entire balance. - = currentWallet.balance - ? "sendTransaction.payLargeConfirmAll" - : "sendTransaction.payLargeConfirmHalf"} - > - Are you sure you want to send ? - This is over half your balance! - - ), + content: , // Transaction looks OK, submit it okText: t("sendTransaction.buttonSubmit"), diff --git a/src/utils/settings.ts b/src/utils/settings.ts index 1489755..7dd362a 100644 --- a/src/utils/settings.ts +++ b/src/utils/settings.ts @@ -52,6 +52,8 @@ readonly transactionsHighlightVerified: boolean; /** Default to the 'Raw' tab instead of 'CommonMeta' on the transaction page. */ readonly transactionDefaultRaw: boolean; + /** Prompt for confirmation for all transactions. */ + readonly confirmTransactions: boolean; /** Clear the Send Transaction form after clicking 'Send'. */ readonly clearTransactionForm: boolean; /** Time to wait, in milliseconds, before allowing another transaction to be sent. */ @@ -85,6 +87,7 @@ transactionsHighlightOwn: true, transactionsHighlightVerified: false, transactionDefaultRaw: false, + confirmTransactions: false, clearTransactionForm: false, sendTransactionDelay: 300, defaultPageSize: 15,