From 74b9d167242a2025e69aab3cc7f154198ed94ee2 Mon Sep 17 00:00:00 2001 From: Thibaut Boustany Date: Tue, 7 Aug 2018 16:40:15 +0200 Subject: [PATCH] eip55 validation for ethereum recepient addresses --- src/bridge/EthereumJSBridge.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bridge/EthereumJSBridge.js b/src/bridge/EthereumJSBridge.js index 003a180f..d07b3b62 100644 --- a/src/bridge/EthereumJSBridge.js +++ b/src/bridge/EthereumJSBridge.js @@ -9,6 +9,7 @@ import throttle from 'lodash/throttle' import flatMap from 'lodash/flatMap' import uniqBy from 'lodash/uniqBy' import type { Account, Operation } from '@ledgerhq/live-common/lib/types' +import eip55 from 'eip55' import { apiForCurrency } from 'api/Ethereum' import type { Tx } from 'api/Ethereum' import { getDerivations } from 'helpers/derivations' @@ -100,7 +101,11 @@ const txToOps = (account: Account) => (tx: Tx): Operation[] => { } function isRecipientValid(currency, recipient) { - return !!recipient.match(/^0x[0-9a-fA-F]{40}$/) + try { + return eip55.verify(recipient) + } catch (error) { + return false + } } function mergeOps(existing: Operation[], newFetched: Operation[]) {