Skip to content

Commit bc6a25a

Browse files
committed
fix: check amount to update clientPayment
1 parent 119d356 commit bc6a25a

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

services/chronikService.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
getSimplifiedTransactions,
1313
getSimplifiedTrasaction,
1414
connectAllTransactionsToPrices,
15-
updatePaymentStatus
15+
updatePaymentStatus,
16+
getClientPayment
1617
} from './transactionService'
1718
import { Address, Prisma, ClientPaymentStatus } from '@prisma/client'
1819
import xecaddr from 'xecaddrjs'
@@ -470,8 +471,14 @@ export class ChronikBlockchainClient {
470471
const parsedOpReturn = parseOpReturnData(tx.opReturn)
471472
const paymentId = parsedOpReturn.paymentId
472473
const newClientPaymentStatus = 'ADDED_TO_MEMPOOL' as ClientPaymentStatus
473-
474-
await updatePaymentStatus(paymentId, newClientPaymentStatus)
474+
const clientPayment = await getClientPayment(paymentId)
475+
if (clientPayment.amount !== null) {
476+
if (clientPayment.amount === tx.amount) {
477+
await updatePaymentStatus(paymentId, newClientPaymentStatus)
478+
}
479+
} else {
480+
await updatePaymentStatus(paymentId, newClientPaymentStatus)
481+
}
475482
}
476483
}
477484
this.mempoolTxsBeingProcessed -= 1

services/transactionService.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,3 +1007,10 @@ export const updatePaymentStatus = async (paymentId: string, status: ClientPayme
10071007
data: { status }
10081008
})
10091009
}
1010+
1011+
export const getClientPayment = async (paymentId: string): Promise<Prisma.ClientPaymentGetPayload<{ include: { address: true } }>> => {
1012+
return await prisma.clientPayment.findUniqueOrThrow({
1013+
where: { paymentId },
1014+
include: { address: true }
1015+
})
1016+
}

0 commit comments

Comments
 (0)