From 12b809d702f6744e75c1db6a7613e3a224ed3733 Mon Sep 17 00:00:00 2001 From: Stephane Janel Date: Tue, 19 Nov 2024 12:24:33 +0100 Subject: [PATCH] [Binance private] - Fix recomputation of signature in case of error --- src/api/exchanges/src/binanceprivateapi.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/exchanges/src/binanceprivateapi.cpp b/src/api/exchanges/src/binanceprivateapi.cpp index 4b5613f0..05cc3bda 100644 --- a/src/api/exchanges/src/binanceprivateapi.cpp +++ b/src/api/exchanges/src/binanceprivateapi.cpp @@ -105,9 +105,11 @@ void SetNonceAndSignature(const APIKey& apiKey, CurlPostData& postData, Duration static constexpr std::string_view kSignatureKey = "signature"; + if (postData.back().key() == kSignatureKey) { + postData.pop_back(); + } auto sha256Hex = ssl::Sha256Hex(postData.str(), apiKey.privateKey()); - - postData.set_back(kSignatureKey, std::string_view(sha256Hex)); + postData.emplace_back(kSignatureKey, std::string_view(sha256Hex)); } bool CheckErrorDoRetry(int statusCode, const json::container& ret, QueryDelayDir& queryDelayDir, Duration& sleepingTime,