diff --git a/src/omnicore/dex.cpp b/src/omnicore/dex.cpp index a5b07f482c224..cd87bf3930ed6 100644 --- a/src/omnicore/dex.cpp +++ b/src/omnicore/dex.cpp @@ -42,6 +42,20 @@ bool DEx_offerExists(const std::string& addressSeller, uint32_t propertyId) return !(my_offers.find(key) == my_offers.end()); } +/** + * Checks, if the seller has any open offer. + */ +bool DEx_hasOffer(const std::string& addressSeller) +{ + for (auto const& offer : my_offers) { + if (offer.first.find(addressSeller) == 0) { + return true; + } + } + + return false; +} + /** * Retrieves a sell offer. * diff --git a/src/omnicore/dex.h b/src/omnicore/dex.h index 2ce14e9a4ee0b..46d1bdc18b765 100644 --- a/src/omnicore/dex.h +++ b/src/omnicore/dex.h @@ -231,6 +231,7 @@ extern AcceptMap my_accepts; int64_t calculateDesiredBTC(const int64_t amountOffered, const int64_t amountDesired, const int64_t amountAvailable); bool DEx_offerExists(const std::string& addressSeller, uint32_t propertyId); +bool DEx_hasOffer(const std::string& addressSeller); CMPOffer* DEx_getOffer(const std::string& addressSeller, uint32_t propertyId); bool DEx_acceptExists(const std::string& addressSeller, uint32_t propertyId, const std::string& addressBuyer); CMPAccept* DEx_getAccept(const std::string& addressSeller, uint32_t propertyId, const std::string& addressBuyer); diff --git a/src/omnicore/rpcrequirements.cpp b/src/omnicore/rpcrequirements.cpp index c150b81a50305..27b6bf781432b 100644 --- a/src/omnicore/rpcrequirements.cpp +++ b/src/omnicore/rpcrequirements.cpp @@ -118,7 +118,7 @@ void RequireMatchingDExOffer(const std::string& address, uint32_t propertyId) void RequireNoOtherDExOffer(const std::string& address, uint32_t propertyId) { LOCK(cs_tally); - if (mastercore::DEx_offerExists(address, propertyId)) { + if (mastercore::DEx_hasOffer(address)) { throw JSONRPCError(RPC_TYPE_ERROR, "Another active sell offer from the given address already exists on the distributed exchange"); } }