mirror of
https://github.com/Such-Software/xmrcheckout.git
synced 2026-12-01 12:14:11 +01:00
fix(payments): never reuse a subaddress or count older payments toward an invoice
Subaddress indices wrapped after 300 invoices per merchant, and the reconciler counted every transfer ever received on the subaddress. A later invoice could therefore show as paid by an earlier invoice's payment. Indices now only increase, and the reconciler counts only transfers whose timestamp is no more than two hours before the invoice was created. The slack covers Monero's block timestamp rules, so a genuine payment mined after creation always counts.
This commit is contained in:
@@ -12,6 +12,7 @@ from sqlalchemy.orm import Session
|
||||
from .btcpay_webhooks import dispatch_btcpay_webhooks
|
||||
from .config import INVOICE_RECONCILE_INTERVAL_SECONDS, LATE_PAYMENT_LOOKBACK_HOURS
|
||||
from .db import SessionLocal
|
||||
from .invoice_transfers import transfers_for_invoice
|
||||
from .models import Invoice, InvoiceTransfer, SystemStatus, User
|
||||
from .monero_service import MoneroWalletService, TransferDetail
|
||||
from .webhooks import dispatch_webhooks
|
||||
@@ -127,8 +128,9 @@ def _reconcile_invoices(service: MoneroWalletService) -> None:
|
||||
if not acquired:
|
||||
continue
|
||||
try:
|
||||
transfers = _get_transfers_with_retry(
|
||||
service, user, invoice.address,
|
||||
transfers = transfers_for_invoice(
|
||||
_get_transfers_with_retry(service, user, invoice.address),
|
||||
invoice.created_at,
|
||||
)
|
||||
|
||||
total_atomic = 0
|
||||
|
||||
Reference in New Issue
Block a user