diff --git a/react/lib/util/address.ts b/react/lib/util/address.ts index 7361c3dc..5569b639 100644 --- a/react/lib/util/address.ts +++ b/react/lib/util/address.ts @@ -49,7 +49,7 @@ const removeAddressPrefix = function (addressString: string): string { type NetworkSlugsType = 'ecash' | 'bitcoincash' -const getAddressPrefix = function (addressString: string): NetworkSlugsType { +export const getAddressPrefix = function (addressString: string): NetworkSlugsType { try { const format = xecaddr.detectAddressFormat(addressString) if (format === xecaddr.Format.Xecaddr) { diff --git a/react/lib/util/validate.ts b/react/lib/util/validate.ts index 874af6f9..2632f9ef 100644 --- a/react/lib/util/validate.ts +++ b/react/lib/util/validate.ts @@ -1,5 +1,5 @@ import BigNumber from "bignumber.js"; -import { getCurrencyTypeFromAddress } from "./address"; +import { getAddressPrefix, getCurrencyTypeFromAddress } from "./address"; import { resolveNumber } from "./number"; import { Currency, CurrencyObject, Transaction } from "./types"; import { DECIMALS } from "./constants"; @@ -19,9 +19,11 @@ export const shouldTriggerOnSuccess = ( paymentId, rawMessage:rawOpReturn, message, - amount, - address } = transaction; - + amount, + address } = transaction; + + const addressPrefix = getAddressPrefix(address); + const isBCH = addressPrefix === 'bitcoincash'; let isAmountValid = true; if(expectedAmount) { @@ -44,13 +46,16 @@ export const shouldTriggerOnSuccess = ( let isOpReturnValid = true if(!randomSatoshis || randomSatoshis === 0){ - const paymentIdsMatch = expectedPaymentId === paymentId; - isPaymentIdValid = disablePaymentId ? true : paymentIdsMatch; - + if(!isBCH){ + const paymentIdsMatch = expectedPaymentId === paymentId; + isPaymentIdValid = disablePaymentId ? true : paymentIdsMatch; + } + } + if(!isBCH){ const rawOpReturnIsEmptyOrUndefined = rawOpReturn === '' || rawOpReturn === undefined; const opReturn = rawOpReturnIsEmptyOrUndefined ? message : rawOpReturn const opReturnIsEmptyOrUndefined = opReturn === '' || opReturn === undefined; - + const opReturnsMatch = opReturn === expectedOpReturn; isOpReturnValid = expectedOpReturn ? opReturnsMatch : opReturnIsEmptyOrUndefined; }