Invoice Payment Hash Inconsistency in CheckPendingInvoices #5
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
There's a critical bug in the
CheckPendingInvoices()
method that causes payment verification to fail due to inconsistent payment hash handling between invoice creation and payment status checking. This results in successfully paid invoices being treated as unpaid, causing players to lose their purchases.Root Cause Analysis
Inconsistent Hash Case Handling
The issue stems from redundant and inconsistent case conversion of payment hashes throughout the payment verification process:
1. Invoice Creation - Hash Stored as Lowercase (Lines ~580, ~630)
2. CheckPendingInvoices - Redundant Conversion (Lines ~450-470)
3. Retry Counter Logic - Mixed Hash Usage (Lines ~475-545)
The Core Problem
Since
invoice.RHash
is already lowercase from creation, calling.ToLower()
again creates no difference betweenlocalPaymentHash
andinvoice.RHash
. However, the inconsistent usage of these variables throughout the method creates potential for bugs and makes the code fragile.Specific Code Issues
Issue 1: Redundant Conversion
Issue 2: Inconsistent Variable Usage
Issue 3: Potential Dictionary Key Mismatch
If there were ever a case where the hash formats differed, the retry counter logic would break:
Impact
Steps to Reproduce
Potential Scenario (if hash formats ever differed):
/buyblood 10
commandRHash = paymentHash.ToLower()
CheckPendingInvoices()
createslocalPaymentHash = invoice.RHash.ToLower()
Proposed Fix
Solution: Consistent Hash Handling
Eliminate redundant conversions and use consistent variable names:
Additional Improvements
Ensure Consistent Hash Storage
Make sure all hash storage is consistently lowercase:
Add Hash Validation
Environment
Severity
🔴 Critical - Players lose real money when payments are incorrectly processed
Additional Notes
This bug represents a fundamental data consistency issue that could cause the plugin's core payment processing to fail unpredictably. The fix ensures that:
Fixed on 0.4.0