From f23dc8c333292820f0e1022da341976fc8159cb6 Mon Sep 17 00:00:00 2001 From: lissavxo Date: Tue, 15 Apr 2025 13:11:29 -0300 Subject: [PATCH 1/3] feat: ignore opReturn bch --- react/lib/util/address.ts | 2 +- react/lib/util/validate.ts | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) 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..b88afb8a 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) { @@ -51,6 +53,15 @@ export const shouldTriggerOnSuccess = ( const opReturn = rawOpReturnIsEmptyOrUndefined ? message : rawOpReturn const opReturnIsEmptyOrUndefined = opReturn === '' || opReturn === undefined; + 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; + } + const opReturnsMatch = opReturn === expectedOpReturn; isOpReturnValid = expectedOpReturn ? opReturnsMatch : opReturnIsEmptyOrUndefined; } From 3baa4387e017c8cc37f9255bfc0334243c4e19df Mon Sep 17 00:00:00 2001 From: lissavxo Date: Tue, 3 Jun 2025 15:44:53 -0300 Subject: [PATCH 2/3] fix: shouldTriggerOnSuccess logic --- react/lib/util/validate.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/react/lib/util/validate.ts b/react/lib/util/validate.ts index b88afb8a..cd4239ea 100644 --- a/react/lib/util/validate.ts +++ b/react/lib/util/validate.ts @@ -47,21 +47,13 @@ export const shouldTriggerOnSuccess = ( if(!randomSatoshis || randomSatoshis === 0){ const paymentIdsMatch = expectedPaymentId === paymentId; - isPaymentIdValid = disablePaymentId ? true : paymentIdsMatch; - - const rawOpReturnIsEmptyOrUndefined = rawOpReturn === '' || rawOpReturn === undefined; - const opReturn = rawOpReturnIsEmptyOrUndefined ? message : rawOpReturn - const opReturnIsEmptyOrUndefined = opReturn === '' || opReturn === undefined; - + 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; - } - + const opReturnsMatch = opReturn === expectedOpReturn; isOpReturnValid = expectedOpReturn ? opReturnsMatch : opReturnIsEmptyOrUndefined; } From 163c4bac98a4fae29a921affa83bca5e3f7c4a73 Mon Sep 17 00:00:00 2001 From: lissavxo Date: Wed, 4 Jun 2025 15:29:59 -0300 Subject: [PATCH 3/3] fix: shouldTriggerOnSuccess --- react/lib/util/validate.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/react/lib/util/validate.ts b/react/lib/util/validate.ts index cd4239ea..2632f9ef 100644 --- a/react/lib/util/validate.ts +++ b/react/lib/util/validate.ts @@ -46,8 +46,10 @@ 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;