WinoGarcia / CryptoPay

Cryptocurrency payment system based on @cryptobot in Telegram
MIT License
19 stars 8 forks source link

CheckSignature sometimes returns only false for some update objects #4

Closed Insadem closed 1 year ago

Insadem commented 1 year ago

As I stated in title, CheckSignature doesn't work correct. I don't know is it because of this library, or cryptopay in general has this issue. P.S: I respond with code 400, it retries, but still no luck. This only happens to random update objects

WinoGarcia commented 1 year ago

Unfortunately, I don't repeat your case. You may try to use this code:

[HttpPost("{token}")]
public async Task<IActionResult> PostAsync(
    [FromBody] Update update, 
    string token, 
    CancellationToken cancellationToken = default)
{
    if (update is not null &&
        this.HttpContext.Request.Headers.TryGetValue("crypto-pay-api-signature", out var signature) &&
        CryptoPayHelper.CheckSignature(signature, token, update) &&
        update.UpdateType == UpdateTypes.invoice_paid)
    {
        return this.Ok();
    }

    return this.BadRequest();
}

Pay attention, before call CheckSignature there are check update is not null and update.UpdateType == UpdateTypes.invoice_paid

Insadem commented 1 year ago

Triple checked everything, I'm 100% sure that it's either cryptopay issue, or this library. Try to make about 10 different purchases

WinoGarcia commented 1 year ago

I checked again. The error is not reproduced.