diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -252,6 +252,12 @@ target_disable_clang_tidy(bitcoin-qt-protobuf) endif() + # Message::ByteSize() is deprecated and replaced by ByteSizeLong() since + # protobuf 3.1. + if(Protobuf_VERSION GREATER_EQUAL "3.1.0") + target_compile_definitions(bitcoin-qt-base PRIVATE USE_PROTOBUF_MESSAGE_BYTESIZELONG) + endif() + # OpenSSL functionality include(BrewHelper) find_brew_prefix(OPENSSL_ROOT_DIR openssl) diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -766,11 +766,16 @@ "key, refund_to not set"; } - int length = payment.ByteSize(); + QVariant length; +#ifdef USE_PROTOBUF_MESSAGE_BYTESIZELONG + length.setValue(payment.ByteSizeLong()); +#else + length.setValue(payment.ByteSize()); +#endif netRequest.setHeader(QNetworkRequest::ContentLengthHeader, length); - QByteArray serData(length, '\0'); - if (payment.SerializeToArray(serData.data(), length)) { + QByteArray serData(length.toInt(), '\0'); + if (payment.SerializeToArray(serData.data(), length.toInt())) { netManager->post(netRequest, serData); } else { // This should never happen, either.