Skip to content

Commit 9886590

Browse files
committed
Merge #14451: Add BIP70 deprecation warning and allow building GUI without BIP70 support
48439b3 Don't link SSL_LIBS with GUI unless BIP70 is enabled (James Hilliard) fbb643d Add BIP70 deprecation warning (James Hilliard) 38b9850 qt: cleanup: Move BIP70 functions together in paymentserver (Wladimir J. van der Laan) 9dcf6c0 build: Add --disable-bip70 configure option (Wladimir J. van der Laan) Pull request description: This is based off of #11622 and adds a deprecation warning when a BIP70 URL is used. Rational: - BIP70 increases attack surface in multiple ways and is difficult for third party wallets to implement in a secure manner - Very few merchants use the standard BIP70 variant supported by Bitcoin Core - The one major payment processor that doesn't support BIP21 and currently uses a customized non-standard version of BIP70 has indicated that "Unfortunately the original BIP70 is not useful for us." Tree-SHA512: 1e16ee8d2cdac9499f751ee7b50d058278150f9e38a87a47ddb5105dd0353cdedabe462903f54ead6209b249b249fe5e6a10d29631531be27400f2f69c25b9b9
2 parents 2e15fa1 + 48439b3 commit 9886590

19 files changed

+329
-162
lines changed

configure.ac

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ AC_ARG_ENABLE([zmq],
209209
[disable ZMQ notifications])],
210210
[use_zmq=$enableval],
211211
[use_zmq=yes])
212+
AC_ARG_ENABLE([bip70],
213+
[AS_HELP_STRING([--disable-bip70],
214+
[disable BIP70 (payment protocol) support in GUI (enabled by default)])],
215+
[enable_bip70=$enableval],
216+
[enable_bip70=yes])
212217

213218
AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[specify protoc bin path])], [protoc_bin_path=$withval], [])
214219

@@ -1082,7 +1087,9 @@ if test x$use_pkgconfig = xyes; then
10821087
[
10831088
PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)])
10841089
PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)])
1085-
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([PROTOBUF], [protobuf], [have_protobuf=yes], [BITCOIN_QT_FAIL(libprotobuf not found)])])
1090+
if test x$enable_bip70 != xno; then
1091+
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([PROTOBUF], [protobuf], [have_protobuf=yes], [BITCOIN_QT_FAIL(libprotobuf not found)])])
1092+
fi
10861093
if test x$use_qr != xno; then
10871094
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])])
10881095
fi
@@ -1142,7 +1149,9 @@ else
11421149
esac
11431150
fi
11441151

1145-
BITCOIN_QT_CHECK(AC_CHECK_LIB([protobuf] ,[main],[PROTOBUF_LIBS=-lprotobuf], BITCOIN_QT_FAIL(libprotobuf not found)))
1152+
if test x$enable_bip70 != xno; then
1153+
BITCOIN_QT_CHECK(AC_CHECK_LIB([protobuf] ,[main],[PROTOBUF_LIBS=-lprotobuf], BITCOIN_QT_FAIL(libprotobuf not found)))
1154+
fi
11461155
if test x$use_qr != xno; then
11471156
BITCOIN_QT_CHECK([AC_CHECK_LIB([qrencode], [main],[QR_LIBS=-lqrencode], [have_qrencode=no])])
11481157
BITCOIN_QT_CHECK([AC_CHECK_HEADER([qrencode.h],, have_qrencode=no)])
@@ -1220,7 +1229,9 @@ AM_CONDITIONAL([EMBEDDED_UNIVALUE],[test x$need_bundled_univalue = xyes])
12201229
AC_SUBST(UNIVALUE_CFLAGS)
12211230
AC_SUBST(UNIVALUE_LIBS)
12221231

1232+
if test x$enable_bip70 != xno; then
12231233
BITCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path)
1234+
fi
12241235

12251236
AC_MSG_CHECKING([whether to build bitcoind])
12261237
AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes])
@@ -1338,6 +1349,15 @@ if test x$bitcoin_enable_qt != xno; then
13381349
else
13391350
AC_MSG_RESULT([no])
13401351
fi
1352+
1353+
AC_MSG_CHECKING([whether to build BIP70 support])
1354+
if test x$enable_bip70 != xno; then
1355+
AC_DEFINE([ENABLE_BIP70],[1],[Define if BIP70 support should be compiled in])
1356+
enable_bip70=yes
1357+
AC_MSG_RESULT([yes])
1358+
else
1359+
AC_MSG_RESULT([no])
1360+
fi
13411361
fi
13421362

13431363
AM_CONDITIONAL([ENABLE_ZMQ], [test "x$use_zmq" = "xyes"])
@@ -1369,6 +1389,7 @@ AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet = xyes])
13691389
AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
13701390
AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt = xyes])
13711391
AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$BUILD_TEST_QT = xyes])
1392+
AM_CONDITIONAL([ENABLE_BIP70],[test x$enable_bip70 = xyes])
13721393
AM_CONDITIONAL([ENABLE_BENCH],[test x$use_bench = xyes])
13731394
AM_CONDITIONAL([USE_QRCODE], [test x$use_qr = xyes])
13741395
AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes])
@@ -1503,6 +1524,7 @@ echo "Options used to compile and link:"
15031524
echo " with wallet = $enable_wallet"
15041525
echo " with gui / qt = $bitcoin_enable_qt"
15051526
if test x$bitcoin_enable_qt != xno; then
1527+
echo " with bip70 = $enable_bip70"
15061528
echo " with qr = $use_qr"
15071529
fi
15081530
echo " with zmq = $use_zmq"

src/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,11 @@ if HARDEN
587587
$(AM_V_at) READELF=$(READELF) OBJDUMP=$(OBJDUMP) $(top_srcdir)/contrib/devtools/security-check.py < $(bin_PROGRAMS)
588588
endif
589589

590+
if ENABLE_BIP70
590591
%.pb.cc %.pb.h: %.proto
591592
@test -f $(PROTOC)
592593
$(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$(<D) $<
594+
endif
593595

594596
if EMBEDDED_LEVELDB
595597
include Makefile.leveldb.include

src/Makefile.qt.include

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,15 @@ QT_QRC = qt/bitcoin.qrc
176176
QT_QRC_LOCALE_CPP = qt/qrc_bitcoin_locale.cpp
177177
QT_QRC_LOCALE = qt/bitcoin_locale.qrc
178178

179+
if ENABLE_BIP70
179180
PROTOBUF_CC = qt/paymentrequest.pb.cc
180181
PROTOBUF_H = qt/paymentrequest.pb.h
181182
PROTOBUF_PROTO = qt/paymentrequest.proto
183+
else
184+
PROTOBUF_CC =
185+
PROTOBUF_H =
186+
PROTOBUF_PROTO =
187+
endif
182188

183189
BITCOIN_QT_H = \
184190
qt/addressbookpage.h \
@@ -327,7 +333,6 @@ BITCOIN_QT_WALLET_CPP = \
327333
qt/editaddressdialog.cpp \
328334
qt/openuridialog.cpp \
329335
qt/overviewpage.cpp \
330-
qt/paymentrequestplus.cpp \
331336
qt/paymentserver.cpp \
332337
qt/receivecoinsdialog.cpp \
333338
qt/receiverequestdialog.cpp \
@@ -346,13 +351,19 @@ BITCOIN_QT_WALLET_CPP = \
346351
qt/walletmodeltransaction.cpp \
347352
qt/walletview.cpp
348353

354+
BITCOIN_QT_WALLET_BIP70_CPP = \
355+
qt/paymentrequestplus.cpp
356+
349357
BITCOIN_QT_CPP = $(BITCOIN_QT_BASE_CPP)
350358
if TARGET_WINDOWS
351359
BITCOIN_QT_CPP += $(BITCOIN_QT_WINDOWS_CPP)
352360
endif
353361
if ENABLE_WALLET
354362
BITCOIN_QT_CPP += $(BITCOIN_QT_WALLET_CPP)
355-
endif
363+
if ENABLE_BIP70
364+
BITCOIN_QT_CPP += $(BITCOIN_QT_WALLET_BIP70_CPP)
365+
endif # ENABLE_BIP70
366+
endif # ENABLE_WALLET
356367

357368
RES_IMAGES =
358369

@@ -405,8 +416,11 @@ endif
405416
if ENABLE_ZMQ
406417
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
407418
endif
419+
if ENABLE_BIP70
420+
qt_bitcoin_qt_LDADD += $(SSL_LIBS)
421+
endif
408422
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBLEVELDB_SSE42) $(LIBMEMENV) \
409-
$(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
423+
$(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
410424
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
411425
qt_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
412426
qt_bitcoin_qt_LIBTOOLFLAGS = $(AM_LIBTOOLFLAGS) --tag CXX

src/Makefile.qttest.include

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ TEST_QT_MOC_CPP = \
1313
if ENABLE_WALLET
1414
TEST_QT_MOC_CPP += \
1515
qt/test/moc_addressbooktests.cpp \
16-
qt/test/moc_paymentservertests.cpp \
1716
qt/test/moc_wallettests.cpp
18-
endif
17+
if ENABLE_BIP70
18+
TEST_QT_MOC_CPP += \
19+
qt/test/moc_paymentservertests.cpp
20+
endif # ENABLE_BIP70
21+
endif # ENABLE_WALLET
1922

2023
TEST_QT_H = \
2124
qt/test/addressbooktests.h \
@@ -48,10 +51,13 @@ qt_test_test_bitcoin_qt_SOURCES = \
4851
if ENABLE_WALLET
4952
qt_test_test_bitcoin_qt_SOURCES += \
5053
qt/test/addressbooktests.cpp \
51-
qt/test/paymentservertests.cpp \
5254
qt/test/wallettests.cpp \
5355
wallet/test/wallet_test_fixture.cpp
54-
endif
56+
if ENABLE_BIP70
57+
qt_test_test_bitcoin_qt_SOURCES += \
58+
qt/test/paymentservertests.cpp
59+
endif # ENABLE_BIP70
60+
endif # ENABLE_WALLET
5561

5662
nodist_qt_test_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP)
5763

src/qt/bitcoin.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,10 @@ void BitcoinApplication::addWallet(WalletModel* walletModel)
439439
window->setCurrentWallet(walletModel->getWalletName());
440440
}
441441

442+
#ifdef ENABLE_BIP70
442443
connect(walletModel, &WalletModel::coinsSent,
443444
paymentServer, &PaymentServer::fetchPaymentACK);
445+
#endif
444446
connect(walletModel, &WalletModel::unload, this, &BitcoinApplication::removeWallet);
445447

446448
m_wallet_models.push_back(walletModel);
@@ -467,7 +469,9 @@ void BitcoinApplication::initializeResult(bool success)
467469
// Log this only after AppInitMain finishes, as then logging setup is guaranteed complete
468470
qWarning() << "Platform customization:" << platformStyle->getName();
469471
#ifdef ENABLE_WALLET
472+
#ifdef ENABLE_BIP70
470473
PaymentServer::LoadRootCAs();
474+
#endif
471475
paymentServer->setOptionsModel(optionsModel);
472476
#endif
473477

@@ -536,7 +540,7 @@ WId BitcoinApplication::getMainWinId() const
536540

537541
static void SetupUIArgs()
538542
{
539-
#ifdef ENABLE_WALLET
543+
#if defined(ENABLE_WALLET) && defined(ENABLE_BIP70)
540544
gArgs.AddArg("-allowselfsignedrootcertificates", strprintf("Allow self signed root certificates (default: %u)", DEFAULT_SELFSIGNED_ROOTCERTS), true, OptionsCategory::GUI);
541545
#endif
542546
gArgs.AddArg("-choosedatadir", strprintf("Choose data directory on startup (default: %u)", DEFAULT_CHOOSE_DATADIR), false, OptionsCategory::GUI);

src/qt/coincontroldialog.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

5+
#if defined(HAVE_CONFIG_H)
6+
#include <config/bitcoin-config.h>
7+
#endif
8+
59
#include <qt/coincontroldialog.h>
610
#include <qt/forms/ui_coincontroldialog.h>
711

812
#include <qt/addresstablemodel.h>
13+
#include <base58.h>
914
#include <qt/bitcoinunits.h>
1015
#include <qt/guiutil.h>
1116
#include <qt/optionsmodel.h>

0 commit comments

Comments
 (0)