From a6bf8a5c36bd0bd740ebce177cca6e427a502e85 Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Sat, 1 Jan 2022 16:34:31 +0100 Subject: [PATCH 1/5] fix: correcly display qr code on receive page when navigating to the reiceve page with a specific account, the qr code has not been loaded. this fix will ensure the account type is an integer and hence the qrcode is loaded as expected. --- src/components/Receive.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Receive.jsx b/src/components/Receive.jsx index c969a0d81..6777f10cb 100644 --- a/src/components/Receive.jsx +++ b/src/components/Receive.jsx @@ -12,7 +12,7 @@ const Receive = ({ currentWallet }) => { const [isLoading, setIsLoading] = useState(false) const [address, setAddress] = useState('') const [amount, setAmount] = useState(0) - const [account, setAccount] = useState(location.state?.account || 0) + const [account, setAccount] = useState(parseInt(location.state?.account, 10) || 0) const [addressCount, setAddressCount] = useState(0) useEffect(() => { From 21453d8470b758e3419fa69093a072367923a044 Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Sat, 1 Jan 2022 16:54:39 +0100 Subject: [PATCH 2/5] fix: validate amount on payment page a value of zero will actually send the entire amount. this is probably not what the user expects. solving this by requiring the value to be greater than zero. --- src/components/Payment.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Payment.jsx b/src/components/Payment.jsx index 6567bdf09..5be52ac2c 100644 --- a/src/components/Payment.jsx +++ b/src/components/Payment.jsx @@ -120,8 +120,8 @@ export default function Payment({ currentWallet }) { Amount in Sats - - Please provide a receiving address. + + Please provide a valid amount. setIsCoinjoin(e.target.checked)} /> From 07d0f09bda68c50bf46c80dd329fa3a582c52ecb Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Sat, 1 Jan 2022 17:40:51 +0100 Subject: [PATCH 3/5] ui: select account via select box on payment page --- src/components/Payment.jsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/Payment.jsx b/src/components/Payment.jsx index 5be52ac2c..91b68a870 100644 --- a/src/components/Payment.jsx +++ b/src/components/Payment.jsx @@ -10,7 +10,7 @@ export default function Payment({ currentWallet }) { const [alert, setAlert] = useState(null) const [isSending, setIsSending] = useState(false) const [isCoinjoin, setIsCoinjoin] = useState(false) - const [account, setAccount] = useState(location.state?.account || 0) + const [account, setAccount] = useState(parseInt(location.state?.account, 10) || 0) const sendPayment = async (account, destination, amount_sats) => { const { name, token } = currentWallet @@ -18,7 +18,7 @@ export default function Payment({ currentWallet }) { method: 'POST', headers: { 'Authorization': `Bearer ${token}` }, body: JSON.stringify({ - mixdepth: account, + mixdepth: String(account), destination, amount_sats }) @@ -53,7 +53,7 @@ export default function Payment({ currentWallet }) { method: 'POST', headers: { 'Authorization': `Bearer ${token}` }, body: JSON.stringify({ - mixdepth: account, + mixdepth: String(account), destination, amount_sats, counterparties @@ -91,7 +91,7 @@ export default function Payment({ currentWallet }) { setValidated(true) if (isValid) { - const { account, amount, counterparties, destination } = serialize(form) + const { amount, counterparties, destination } = serialize(form) const success = isCoinjoin ? await startCoinjoin(account, destination, amount, counterparties) : await sendPayment(account, destination, amount) @@ -115,8 +115,9 @@ export default function Payment({ currentWallet }) { Account - setAccount(parseInt(e.target.value, 10))} style={{ width: '15ch' }} required /> - Please provide an account between {ACCOUNTS[0]} and {ACCOUNTS[4]}. + setAccount(parseInt(e.target.value, 10))} style={{ maxWidth: '15ch' }} required> + {ACCOUNTS.map(val => )} + Amount in Sats From c5d11e3457400bbdec5c874fee50dc11b88cee74 Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Sat, 1 Jan 2022 17:45:38 +0100 Subject: [PATCH 4/5] ui: select account via select box on receive page --- src/components/Receive.jsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/Receive.jsx b/src/components/Receive.jsx index 6777f10cb..aa80170f9 100644 --- a/src/components/Receive.jsx +++ b/src/components/Receive.jsx @@ -37,7 +37,10 @@ const Receive = ({ currentWallet }) => { .finally(() => setIsLoading(false)) } - if (ACCOUNTS.includes(account)) fetchAddress(account) + + if (ACCOUNTS.includes(account)) { + fetchAddress(account) + } return () => abortCtrl.abort() }, [account, currentWallet, addressCount]) @@ -69,13 +72,14 @@ const Receive = ({ currentWallet }) => { )} Account - setAccount(parseInt(e.target.value, 10))} style={{ width: '10ch' }} required /> - Please provide an account between {ACCOUNTS[0]} and {ACCOUNTS[4]}. + setAccount(parseInt(e.target.value, 10))} style={{ maxWidth: '15ch' }} required> + {ACCOUNTS.map(val => )} + Amount in Sats setAmount(e.target.value)} style={{ width: '21ch' }} /> - Please provide a receiving address. + Please provide a valid amount. Address From 20f003c8895f7f6d301a20ea39a5dee16c8e15ef Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Sat, 1 Jan 2022 17:46:41 +0100 Subject: [PATCH 5/5] ui: use same width for value/account form elements --- src/components/Payment.jsx | 4 ++-- src/components/Receive.jsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Payment.jsx b/src/components/Payment.jsx index 91b68a870..31fb113a0 100644 --- a/src/components/Payment.jsx +++ b/src/components/Payment.jsx @@ -115,13 +115,13 @@ export default function Payment({ currentWallet }) { Account - setAccount(parseInt(e.target.value, 10))} style={{ maxWidth: '15ch' }} required> + setAccount(parseInt(e.target.value, 10))} style={{ maxWidth: '21ch' }} required> {ACCOUNTS.map(val => )} Amount in Sats - + Please provide a valid amount. diff --git a/src/components/Receive.jsx b/src/components/Receive.jsx index aa80170f9..d76cebffc 100644 --- a/src/components/Receive.jsx +++ b/src/components/Receive.jsx @@ -72,7 +72,7 @@ const Receive = ({ currentWallet }) => { )} Account - setAccount(parseInt(e.target.value, 10))} style={{ maxWidth: '15ch' }} required> + setAccount(parseInt(e.target.value, 10))} style={{ maxWidth: '21ch' }} required> {ACCOUNTS.map(val => )}