Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/Send/Send.js
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | const { | ||||
wallet, | wallet, | ||||
fiatPrice, | fiatPrice, | ||||
apiError, | apiError, | ||||
cashtabSettings, | cashtabSettings, | ||||
changeCashtabSettings, | changeCashtabSettings, | ||||
chronik, | chronik, | ||||
} = ContextValue; | } = ContextValue; | ||||
const walletState = getWalletState(wallet); | const walletState = getWalletState(wallet); | ||||
const { balances, slpBalancesAndUtxos } = walletState; | const { balances, nonSlpUtxos } = walletState; | ||||
// Modal settings | // Modal settings | ||||
const [isOneToManyXECSend, setIsOneToManyXECSend] = useState(false); | const [isOneToManyXECSend, setIsOneToManyXECSend] = useState(false); | ||||
const [opReturnMsg, setOpReturnMsg] = useState(false); | const [opReturnMsg, setOpReturnMsg] = useState(false); | ||||
const [isEncryptedOptionalOpReturnMsg, setIsEncryptedOptionalOpReturnMsg] = | const [isEncryptedOptionalOpReturnMsg, setIsEncryptedOptionalOpReturnMsg] = | ||||
useState(false); | useState(false); | ||||
// Get device window width | // Get device window width | ||||
// If this is less than 769, the page will open with QR scanner open | // If this is less than 769, the page will open with QR scanner open | ||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | async function send() { | ||||
//convert each line from TextArea input | //convert each line from TextArea input | ||||
let addressAndValueArray = address.split('\n'); | let addressAndValueArray = address.split('\n'); | ||||
try { | try { | ||||
const link = await sendXec( | const link = await sendXec( | ||||
chronik, | chronik, | ||||
wallet, | wallet, | ||||
slpBalancesAndUtxos.nonSlpUtxos, | nonSlpUtxos, | ||||
currency.defaultFee, | currency.defaultFee, | ||||
opReturnMsg, | opReturnMsg, | ||||
true, // indicate send mode is one to many | true, // indicate send mode is one to many | ||||
addressAndValueArray, | addressAndValueArray, | ||||
null, | null, | ||||
null, | null, | ||||
false, // one to many tx msg can't be encrypted | false, // one to many tx msg can't be encrypted | ||||
airdropFlag, | airdropFlag, | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | async function send() { | ||||
} else { | } else { | ||||
optionalOpReturnMsg = opReturnMsg; | optionalOpReturnMsg = opReturnMsg; | ||||
} | } | ||||
try { | try { | ||||
const link = await sendXec( | const link = await sendXec( | ||||
chronik, | chronik, | ||||
wallet, | wallet, | ||||
slpBalancesAndUtxos.nonSlpUtxos, | nonSlpUtxos, | ||||
currency.defaultFee, | currency.defaultFee, | ||||
optionalOpReturnMsg, | optionalOpReturnMsg, | ||||
false, // sendToMany boolean flag | false, // sendToMany boolean flag | ||||
null, // address array not applicable for one to many tx | null, // address array not applicable for one to many tx | ||||
cleanAddress, | cleanAddress, | ||||
bchValue, | bchValue, | ||||
isEncryptedOptionalOpReturnMsg, | isEncryptedOptionalOpReturnMsg, | ||||
); | ); | ||||
▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | const SendBCH = ({ passLoadingStatus }) => { | ||||
}; | }; | ||||
const onMax = async () => { | const onMax = async () => { | ||||
// Clear amt error | // Clear amt error | ||||
setSendBchAmountError(false); | setSendBchAmountError(false); | ||||
// Set currency to BCH | // Set currency to BCH | ||||
setSelectedCurrency(currency.ticker); | setSelectedCurrency(currency.ticker); | ||||
try { | try { | ||||
const txFeeSats = calcFee(slpBalancesAndUtxos.nonSlpUtxos); | const txFeeSats = calcFee(nonSlpUtxos); | ||||
const txFeeBch = txFeeSats / 10 ** currency.cashDecimals; | const txFeeBch = txFeeSats / 10 ** currency.cashDecimals; | ||||
let value = | let value = | ||||
balances.totalBalance - txFeeBch >= 0 | balances.totalBalance - txFeeBch >= 0 | ||||
? (balances.totalBalance - txFeeBch).toFixed( | ? (balances.totalBalance - txFeeBch).toFixed( | ||||
currency.cashDecimals, | currency.cashDecimals, | ||||
) | ) | ||||
: 0; | : 0; | ||||
▲ Show 20 Lines • Show All 442 Lines • Show Last 20 Lines |