diff --git a/CHANGELOG.md b/CHANGELOG.md
index 63f592cf8..ccf414423 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -30,6 +30,7 @@ Web UI version numbers should always match the corresponding version of LBRY App
* Fixed pagination styling for pages > 5 (#416)
* Fixed sizing on squat videos (#419)
* Support claims no longer show up on Published page (#384)
+ * Check for valid address when sending credits (#445)
### Deprecated
*
diff --git a/ui/js/actions/wallet.js b/ui/js/actions/wallet.js
index e97675d18..4ae22bf49 100644
--- a/ui/js/actions/wallet.js
+++ b/ui/js/actions/wallet.js
@@ -2,6 +2,7 @@ import * as types from "constants/action_types";
import lbry from "lbry";
import {
selectDraftTransaction,
+ selectDraftTransactionAddress,
selectDraftTransactionAmount,
selectBalance,
} from "selectors/wallet";
@@ -69,6 +70,7 @@ export function doSendDraftTransaction() {
return function(dispatch, getState) {
const state = getState();
const draftTx = selectDraftTransaction(state);
+ const address = selectDraftTransactionAddress(state);
const balance = selectBalance(state);
const amount = selectDraftTransactionAmount(state);
@@ -76,39 +78,49 @@ export function doSendDraftTransaction() {
return dispatch(doOpenModal("insufficientBalance"));
}
- dispatch({
- type: types.SEND_TRANSACTION_STARTED,
- });
-
- const successCallback = results => {
- if (results === true) {
- dispatch({
- type: types.SEND_TRANSACTION_COMPLETED,
- });
- dispatch(doOpenModal("transactionSuccessful"));
- } else {
- dispatch({
- type: types.SEND_TRANSACTION_FAILED,
- data: { error: results },
- });
- dispatch(doOpenModal("transactionFailed"));
- }
- };
-
- const errorCallback = error => {
- dispatch({
- type: types.SEND_TRANSACTION_FAILED,
- data: { error: error.message },
- });
- dispatch(doOpenModal("transactionFailed"));
- };
-
lbry
- .wallet_send({
- amount: draftTx.amount,
- address: draftTx.address,
+ .is_address({ address })
+ .then(addressIsValid => {
+ if (!addressIsValid) {
+ dispatch(doOpenModal("invalidAddress"));
+ reject();
+ }
})
- .then(successCallback, errorCallback);
+ .then(() => {
+ dispatch({
+ type: types.SEND_TRANSACTION_STARTED,
+ });
+
+ const successCallback = results => {
+ if (results === true) {
+ dispatch({
+ type: types.SEND_TRANSACTION_COMPLETED,
+ });
+ dispatch(doOpenModal("transactionSuccessful"));
+ } else {
+ dispatch({
+ type: types.SEND_TRANSACTION_FAILED,
+ data: { error: results },
+ });
+ dispatch(doOpenModal("transactionFailed"));
+ }
+ };
+
+ const errorCallback = error => {
+ dispatch({
+ type: types.SEND_TRANSACTION_FAILED,
+ data: { error: error.message },
+ });
+ dispatch(doOpenModal("transactionFailed"));
+ };
+
+ lbry
+ .wallet_send({
+ amount: draftTx.amount,
+ address: draftTx.address,
+ })
+ .then(successCallback, errorCallback);
+ });
};
}
diff --git a/ui/js/component/walletSend/view.jsx b/ui/js/component/walletSend/view.jsx
index 444acca4a..99561a42c 100644
--- a/ui/js/component/walletSend/view.jsx
+++ b/ui/js/component/walletSend/view.jsx
@@ -53,6 +53,14 @@ const WalletSend = props => {
+ {modal == "invalidAddress" &&
+
+ {__("You have entered an invalid LBRY address.")}
+ }
{modal == "insufficientBalance" &&