Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/Send/Send.js
Show First 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | async function submit() { | ||||
const { address, value } = formData; | const { address, value } = formData; | ||||
// Get the param-free address | // Get the param-free address | ||||
let cleanAddress = address.split('?')[0]; | let cleanAddress = address.split('?')[0]; | ||||
// Ensure address has bitcoincash: prefix and checksum | // Ensure address has bitcoincash: prefix and checksum | ||||
cleanAddress = toLegacy(cleanAddress); | cleanAddress = toLegacy(cleanAddress); | ||||
// If there was an error converting the address | let hasValidCashPrefix; | ||||
if (!cleanAddress.startsWith('bitcoincash:')) { | try { | ||||
// return as above with other errors | hasValidCashPrefix = cleanAddress.startsWith('bitcoincash:'); | ||||
} catch (err) { | |||||
hasValidCashPrefix = false; | |||||
console.log(`toLegacy() returned an error:`, cleanAddress); | console.log(`toLegacy() returned an error:`, cleanAddress); | ||||
// Note: the address must be valid to get to this point, so unsure if this can be produced | } | ||||
if (!hasValidCashPrefix) { | |||||
// set loading to false and set address validation to false | |||||
// Now that the no-prefix case is handled, this happens when user tries to send | |||||
// BCHA to an SLPA address | |||||
setLoading(false); | |||||
setSendBchAddressError( | |||||
`Destination is not a valid ${currency.ticker} address`, | |||||
); | |||||
return; | return; | ||||
} | } | ||||
// Calculate the amount in BCH | // Calculate the amount in BCH | ||||
let bchValue = value; | let bchValue = value; | ||||
if (selectedCurrency === 'USD') { | if (selectedCurrency === 'USD') { | ||||
bchValue = (value / fiatPrice).toFixed(8); | bchValue = (value / fiatPrice).toFixed(8); | ||||
▲ Show 20 Lines • Show All 331 Lines • Show Last 20 Lines |