build: Add --disable-bip70 configure option
This patch adds a --disable-bip70 configure option that disables BIP70 payment request support. When disabled, this removes the dependency of the GUI on OpenSSL and Protobuf.
This commit is contained in:
parent
1d1417430c
commit
9dcf6c0dfe
19 changed files with 185 additions and 13 deletions
22
configure.ac
22
configure.ac
|
@ -209,6 +209,11 @@ AC_ARG_ENABLE([zmq],
|
||||||
[disable ZMQ notifications])],
|
[disable ZMQ notifications])],
|
||||||
[use_zmq=$enableval],
|
[use_zmq=$enableval],
|
||||||
[use_zmq=yes])
|
[use_zmq=yes])
|
||||||
|
AC_ARG_ENABLE([bip70],
|
||||||
|
[AS_HELP_STRING([--disable-bip70],
|
||||||
|
[disable BIP70 (payment protocol) support in GUI (enabled by default)])],
|
||||||
|
[enable_bip70=$enableval],
|
||||||
|
[enable_bip70=yes])
|
||||||
|
|
||||||
AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[specify protoc bin path])], [protoc_bin_path=$withval], [])
|
AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[specify protoc bin path])], [protoc_bin_path=$withval], [])
|
||||||
|
|
||||||
|
@ -1082,7 +1087,9 @@ if test x$use_pkgconfig = xyes; then
|
||||||
[
|
[
|
||||||
PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)])
|
PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)])
|
||||||
PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)])
|
PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)])
|
||||||
|
if test x$enable_bip70 != xno; then
|
||||||
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([PROTOBUF], [protobuf], [have_protobuf=yes], [BITCOIN_QT_FAIL(libprotobuf not found)])])
|
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([PROTOBUF], [protobuf], [have_protobuf=yes], [BITCOIN_QT_FAIL(libprotobuf not found)])])
|
||||||
|
fi
|
||||||
if test x$use_qr != xno; then
|
if test x$use_qr != xno; then
|
||||||
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])])
|
BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])])
|
||||||
fi
|
fi
|
||||||
|
@ -1142,7 +1149,9 @@ else
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test x$enable_bip70 != xno; then
|
||||||
BITCOIN_QT_CHECK(AC_CHECK_LIB([protobuf] ,[main],[PROTOBUF_LIBS=-lprotobuf], BITCOIN_QT_FAIL(libprotobuf not found)))
|
BITCOIN_QT_CHECK(AC_CHECK_LIB([protobuf] ,[main],[PROTOBUF_LIBS=-lprotobuf], BITCOIN_QT_FAIL(libprotobuf not found)))
|
||||||
|
fi
|
||||||
if test x$use_qr != xno; then
|
if test x$use_qr != xno; then
|
||||||
BITCOIN_QT_CHECK([AC_CHECK_LIB([qrencode], [main],[QR_LIBS=-lqrencode], [have_qrencode=no])])
|
BITCOIN_QT_CHECK([AC_CHECK_LIB([qrencode], [main],[QR_LIBS=-lqrencode], [have_qrencode=no])])
|
||||||
BITCOIN_QT_CHECK([AC_CHECK_HEADER([qrencode.h],, have_qrencode=no)])
|
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])
|
||||||
AC_SUBST(UNIVALUE_CFLAGS)
|
AC_SUBST(UNIVALUE_CFLAGS)
|
||||||
AC_SUBST(UNIVALUE_LIBS)
|
AC_SUBST(UNIVALUE_LIBS)
|
||||||
|
|
||||||
|
if test x$enable_bip70 != xno; then
|
||||||
BITCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path)
|
BITCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path)
|
||||||
|
fi
|
||||||
|
|
||||||
AC_MSG_CHECKING([whether to build bitcoind])
|
AC_MSG_CHECKING([whether to build bitcoind])
|
||||||
AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes])
|
AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes])
|
||||||
|
@ -1338,6 +1349,15 @@ if test x$bitcoin_enable_qt != xno; then
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT([no])
|
AC_MSG_RESULT([no])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([whether to build BIP70 support])
|
||||||
|
if test x$enable_bip70 != xno; then
|
||||||
|
AC_DEFINE([ENABLE_BIP70],[1],[Define if BIP70 support should be compiled in])
|
||||||
|
enable_bip70=yes
|
||||||
|
AC_MSG_RESULT([yes])
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT([no])
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AM_CONDITIONAL([ENABLE_ZMQ], [test "x$use_zmq" = "xyes"])
|
AM_CONDITIONAL([ENABLE_ZMQ], [test "x$use_zmq" = "xyes"])
|
||||||
|
@ -1369,6 +1389,7 @@ AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet = xyes])
|
||||||
AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
|
AM_CONDITIONAL([ENABLE_TESTS],[test x$BUILD_TEST = xyes])
|
||||||
AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt = xyes])
|
AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt = xyes])
|
||||||
AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$BUILD_TEST_QT = xyes])
|
AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$BUILD_TEST_QT = xyes])
|
||||||
|
AM_CONDITIONAL([ENABLE_BIP70],[test x$enable_bip70 = xyes])
|
||||||
AM_CONDITIONAL([ENABLE_BENCH],[test x$use_bench = xyes])
|
AM_CONDITIONAL([ENABLE_BENCH],[test x$use_bench = xyes])
|
||||||
AM_CONDITIONAL([USE_QRCODE], [test x$use_qr = xyes])
|
AM_CONDITIONAL([USE_QRCODE], [test x$use_qr = xyes])
|
||||||
AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes])
|
AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes])
|
||||||
|
@ -1503,6 +1524,7 @@ echo "Options used to compile and link:"
|
||||||
echo " with wallet = $enable_wallet"
|
echo " with wallet = $enable_wallet"
|
||||||
echo " with gui / qt = $bitcoin_enable_qt"
|
echo " with gui / qt = $bitcoin_enable_qt"
|
||||||
if test x$bitcoin_enable_qt != xno; then
|
if test x$bitcoin_enable_qt != xno; then
|
||||||
|
echo " with bip70 = $enable_bip70"
|
||||||
echo " with qr = $use_qr"
|
echo " with qr = $use_qr"
|
||||||
fi
|
fi
|
||||||
echo " with zmq = $use_zmq"
|
echo " with zmq = $use_zmq"
|
||||||
|
|
|
@ -587,9 +587,11 @@ if HARDEN
|
||||||
$(AM_V_at) READELF=$(READELF) OBJDUMP=$(OBJDUMP) $(top_srcdir)/contrib/devtools/security-check.py < $(bin_PROGRAMS)
|
$(AM_V_at) READELF=$(READELF) OBJDUMP=$(OBJDUMP) $(top_srcdir)/contrib/devtools/security-check.py < $(bin_PROGRAMS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if ENABLE_BIP70
|
||||||
%.pb.cc %.pb.h: %.proto
|
%.pb.cc %.pb.h: %.proto
|
||||||
@test -f $(PROTOC)
|
@test -f $(PROTOC)
|
||||||
$(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$(<D) $<
|
$(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$(<D) $<
|
||||||
|
endif
|
||||||
|
|
||||||
if EMBEDDED_LEVELDB
|
if EMBEDDED_LEVELDB
|
||||||
include Makefile.leveldb.include
|
include Makefile.leveldb.include
|
||||||
|
|
|
@ -178,9 +178,15 @@ QT_QRC = qt/bitcoin.qrc
|
||||||
QT_QRC_LOCALE_CPP = qt/qrc_bitcoin_locale.cpp
|
QT_QRC_LOCALE_CPP = qt/qrc_bitcoin_locale.cpp
|
||||||
QT_QRC_LOCALE = qt/bitcoin_locale.qrc
|
QT_QRC_LOCALE = qt/bitcoin_locale.qrc
|
||||||
|
|
||||||
|
if ENABLE_BIP70
|
||||||
PROTOBUF_CC = qt/paymentrequest.pb.cc
|
PROTOBUF_CC = qt/paymentrequest.pb.cc
|
||||||
PROTOBUF_H = qt/paymentrequest.pb.h
|
PROTOBUF_H = qt/paymentrequest.pb.h
|
||||||
PROTOBUF_PROTO = qt/paymentrequest.proto
|
PROTOBUF_PROTO = qt/paymentrequest.proto
|
||||||
|
else
|
||||||
|
PROTOBUF_CC =
|
||||||
|
PROTOBUF_H =
|
||||||
|
PROTOBUF_PROTO =
|
||||||
|
endif
|
||||||
|
|
||||||
BITCOIN_QT_H = \
|
BITCOIN_QT_H = \
|
||||||
qt/addressbookpage.h \
|
qt/addressbookpage.h \
|
||||||
|
@ -330,7 +336,6 @@ BITCOIN_QT_WALLET_CPP = \
|
||||||
qt/editaddressdialog.cpp \
|
qt/editaddressdialog.cpp \
|
||||||
qt/openuridialog.cpp \
|
qt/openuridialog.cpp \
|
||||||
qt/overviewpage.cpp \
|
qt/overviewpage.cpp \
|
||||||
qt/paymentrequestplus.cpp \
|
|
||||||
qt/paymentserver.cpp \
|
qt/paymentserver.cpp \
|
||||||
qt/receivecoinsdialog.cpp \
|
qt/receivecoinsdialog.cpp \
|
||||||
qt/receiverequestdialog.cpp \
|
qt/receiverequestdialog.cpp \
|
||||||
|
@ -349,13 +354,19 @@ BITCOIN_QT_WALLET_CPP = \
|
||||||
qt/walletmodeltransaction.cpp \
|
qt/walletmodeltransaction.cpp \
|
||||||
qt/walletview.cpp
|
qt/walletview.cpp
|
||||||
|
|
||||||
|
BITCOIN_QT_WALLET_BIP70_CPP = \
|
||||||
|
qt/paymentrequestplus.cpp
|
||||||
|
|
||||||
BITCOIN_QT_CPP = $(BITCOIN_QT_BASE_CPP)
|
BITCOIN_QT_CPP = $(BITCOIN_QT_BASE_CPP)
|
||||||
if TARGET_WINDOWS
|
if TARGET_WINDOWS
|
||||||
BITCOIN_QT_CPP += $(BITCOIN_QT_WINDOWS_CPP)
|
BITCOIN_QT_CPP += $(BITCOIN_QT_WINDOWS_CPP)
|
||||||
endif
|
endif
|
||||||
if ENABLE_WALLET
|
if ENABLE_WALLET
|
||||||
BITCOIN_QT_CPP += $(BITCOIN_QT_WALLET_CPP)
|
BITCOIN_QT_CPP += $(BITCOIN_QT_WALLET_CPP)
|
||||||
endif
|
if ENABLE_BIP70
|
||||||
|
BITCOIN_QT_CPP += $(BITCOIN_QT_WALLET_BIP70_CPP)
|
||||||
|
endif # ENABLE_BIP70
|
||||||
|
endif # ENABLE_WALLET
|
||||||
|
|
||||||
RES_IMAGES =
|
RES_IMAGES =
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,12 @@ TEST_QT_MOC_CPP = \
|
||||||
if ENABLE_WALLET
|
if ENABLE_WALLET
|
||||||
TEST_QT_MOC_CPP += \
|
TEST_QT_MOC_CPP += \
|
||||||
qt/test/moc_addressbooktests.cpp \
|
qt/test/moc_addressbooktests.cpp \
|
||||||
qt/test/moc_paymentservertests.cpp \
|
|
||||||
qt/test/moc_wallettests.cpp
|
qt/test/moc_wallettests.cpp
|
||||||
endif
|
if ENABLE_BIP70
|
||||||
|
TEST_QT_MOC_CPP += \
|
||||||
|
qt/test/moc_paymentservertests.cpp
|
||||||
|
endif # ENABLE_BIP70
|
||||||
|
endif # ENABLE_WALLET
|
||||||
|
|
||||||
TEST_QT_H = \
|
TEST_QT_H = \
|
||||||
qt/test/addressbooktests.h \
|
qt/test/addressbooktests.h \
|
||||||
|
@ -48,10 +51,13 @@ qt_test_test_bitcoin_qt_SOURCES = \
|
||||||
if ENABLE_WALLET
|
if ENABLE_WALLET
|
||||||
qt_test_test_bitcoin_qt_SOURCES += \
|
qt_test_test_bitcoin_qt_SOURCES += \
|
||||||
qt/test/addressbooktests.cpp \
|
qt/test/addressbooktests.cpp \
|
||||||
qt/test/paymentservertests.cpp \
|
|
||||||
qt/test/wallettests.cpp \
|
qt/test/wallettests.cpp \
|
||||||
wallet/test/wallet_test_fixture.cpp
|
wallet/test/wallet_test_fixture.cpp
|
||||||
endif
|
if ENABLE_BIP70
|
||||||
|
qt_test_test_bitcoin_qt_SOURCES += \
|
||||||
|
qt/test/paymentservertests.cpp
|
||||||
|
endif # ENABLE_BIP70
|
||||||
|
endif # ENABLE_WALLET
|
||||||
|
|
||||||
nodist_qt_test_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP)
|
nodist_qt_test_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP)
|
||||||
|
|
||||||
|
|
|
@ -440,8 +440,10 @@ void BitcoinApplication::addWallet(WalletModel* walletModel)
|
||||||
window->setCurrentWallet(walletModel->getWalletName());
|
window->setCurrentWallet(walletModel->getWalletName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
connect(walletModel, &WalletModel::coinsSent,
|
connect(walletModel, &WalletModel::coinsSent,
|
||||||
paymentServer, &PaymentServer::fetchPaymentACK);
|
paymentServer, &PaymentServer::fetchPaymentACK);
|
||||||
|
#endif
|
||||||
connect(walletModel, &WalletModel::unload, this, &BitcoinApplication::removeWallet);
|
connect(walletModel, &WalletModel::unload, this, &BitcoinApplication::removeWallet);
|
||||||
|
|
||||||
m_wallet_models.push_back(walletModel);
|
m_wallet_models.push_back(walletModel);
|
||||||
|
@ -468,7 +470,9 @@ void BitcoinApplication::initializeResult(bool success)
|
||||||
// Log this only after AppInitMain finishes, as then logging setup is guaranteed complete
|
// Log this only after AppInitMain finishes, as then logging setup is guaranteed complete
|
||||||
qWarning() << "Platform customization:" << platformStyle->getName();
|
qWarning() << "Platform customization:" << platformStyle->getName();
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
PaymentServer::LoadRootCAs();
|
PaymentServer::LoadRootCAs();
|
||||||
|
#endif
|
||||||
paymentServer->setOptionsModel(optionsModel);
|
paymentServer->setOptionsModel(optionsModel);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -537,7 +541,7 @@ WId BitcoinApplication::getMainWinId() const
|
||||||
|
|
||||||
static void SetupUIArgs()
|
static void SetupUIArgs()
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_WALLET
|
#if defined(ENABLE_WALLET) && defined(ENABLE_BIP70)
|
||||||
gArgs.AddArg("-allowselfsignedrootcertificates", strprintf("Allow self signed root certificates (default: %u)", DEFAULT_SELFSIGNED_ROOTCERTS), true, OptionsCategory::GUI);
|
gArgs.AddArg("-allowselfsignedrootcertificates", strprintf("Allow self signed root certificates (default: %u)", DEFAULT_SELFSIGNED_ROOTCERTS), true, OptionsCategory::GUI);
|
||||||
#endif
|
#endif
|
||||||
gArgs.AddArg("-choosedatadir", strprintf("Choose data directory on startup (default: %u)", DEFAULT_CHOOSE_DATADIR), false, OptionsCategory::GUI);
|
gArgs.AddArg("-choosedatadir", strprintf("Choose data directory on startup (default: %u)", DEFAULT_CHOOSE_DATADIR), false, OptionsCategory::GUI);
|
||||||
|
|
|
@ -2,10 +2,15 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H)
|
||||||
|
#include <config/bitcoin-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <qt/coincontroldialog.h>
|
#include <qt/coincontroldialog.h>
|
||||||
#include <qt/forms/ui_coincontroldialog.h>
|
#include <qt/forms/ui_coincontroldialog.h>
|
||||||
|
|
||||||
#include <qt/addresstablemodel.h>
|
#include <qt/addresstablemodel.h>
|
||||||
|
#include <base58.h>
|
||||||
#include <qt/bitcoinunits.h>
|
#include <qt/bitcoinunits.h>
|
||||||
#include <qt/guiutil.h>
|
#include <qt/guiutil.h>
|
||||||
#include <qt/optionsmodel.h>
|
#include <qt/optionsmodel.h>
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H)
|
||||||
|
#include <config/bitcoin-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <qt/paymentserver.h>
|
#include <qt/paymentserver.h>
|
||||||
|
|
||||||
#include <qt/bitcoinunits.h>
|
#include <qt/bitcoinunits.h>
|
||||||
|
@ -45,6 +49,7 @@
|
||||||
|
|
||||||
const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds
|
const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds
|
||||||
const QString BITCOIN_IPC_PREFIX("bitcoin:");
|
const QString BITCOIN_IPC_PREFIX("bitcoin:");
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
// BIP70 payment protocol messages
|
// BIP70 payment protocol messages
|
||||||
const char* BIP70_MESSAGE_PAYMENTACK = "PaymentACK";
|
const char* BIP70_MESSAGE_PAYMENTACK = "PaymentACK";
|
||||||
const char* BIP70_MESSAGE_PAYMENTREQUEST = "PaymentRequest";
|
const char* BIP70_MESSAGE_PAYMENTREQUEST = "PaymentRequest";
|
||||||
|
@ -67,6 +72,7 @@ namespace // Anon namespace
|
||||||
{
|
{
|
||||||
std::unique_ptr<X509_STORE, X509StoreDeleter> certStore;
|
std::unique_ptr<X509_STORE, X509StoreDeleter> certStore;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create a name that is unique for:
|
// Create a name that is unique for:
|
||||||
|
@ -93,6 +99,7 @@ static QString ipcServerName()
|
||||||
|
|
||||||
static QList<QString> savedPaymentRequests;
|
static QList<QString> savedPaymentRequests;
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
static void ReportInvalidCertificate(const QSslCertificate& cert)
|
static void ReportInvalidCertificate(const QSslCertificate& cert)
|
||||||
{
|
{
|
||||||
qDebug() << QString("%1: Payment server found an invalid certificate: ").arg(__func__) << cert.serialNumber() << cert.subjectInfo(QSslCertificate::CommonName) << cert.subjectInfo(QSslCertificate::DistinguishedNameQualifier) << cert.subjectInfo(QSslCertificate::OrganizationalUnitName);
|
qDebug() << QString("%1: Payment server found an invalid certificate: ").arg(__func__) << cert.serialNumber() << cert.subjectInfo(QSslCertificate::CommonName) << cert.subjectInfo(QSslCertificate::DistinguishedNameQualifier) << cert.subjectInfo(QSslCertificate::OrganizationalUnitName);
|
||||||
|
@ -180,6 +187,7 @@ void PaymentServer::LoadRootCAs(X509_STORE* _store)
|
||||||
// or use Qt's blacklist?
|
// or use Qt's blacklist?
|
||||||
// "certificate stapling" with server-side caching is more efficient
|
// "certificate stapling" with server-side caching is more efficient
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sending to the server is done synchronously, at startup.
|
// Sending to the server is done synchronously, at startup.
|
||||||
|
@ -221,6 +229,7 @@ void PaymentServer::ipcParseCommandLine(interfaces::Node& node, int argc, char*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
else if (QFile::exists(arg)) // Filename
|
else if (QFile::exists(arg)) // Filename
|
||||||
{
|
{
|
||||||
savedPaymentRequests.append(arg);
|
savedPaymentRequests.append(arg);
|
||||||
|
@ -244,6 +253,7 @@ void PaymentServer::ipcParseCommandLine(interfaces::Node& node, int argc, char*
|
||||||
// GUI hasn't started yet so we can't pop up a message box.
|
// GUI hasn't started yet so we can't pop up a message box.
|
||||||
qWarning() << "PaymentServer::ipcSendCommandLine: Payment request file does not exist: " << arg;
|
qWarning() << "PaymentServer::ipcSendCommandLine: Payment request file does not exist: " << arg;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,12 +300,16 @@ PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
saveURIs(true),
|
saveURIs(true),
|
||||||
uriServer(0),
|
uriServer(0),
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
netManager(0),
|
netManager(0),
|
||||||
|
#endif
|
||||||
optionsModel(0)
|
optionsModel(0)
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
// Verify that the version of the library that we linked against is
|
// Verify that the version of the library that we linked against is
|
||||||
// compatible with the version of the headers we compiled against.
|
// compatible with the version of the headers we compiled against.
|
||||||
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
GOOGLE_PROTOBUF_VERIFY_VERSION;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Install global event filter to catch QFileOpenEvents
|
// Install global event filter to catch QFileOpenEvents
|
||||||
// on Mac: sent when you click bitcoin: links
|
// on Mac: sent when you click bitcoin: links
|
||||||
|
@ -319,14 +333,18 @@ PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) :
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
connect(uriServer, &QLocalServer::newConnection, this, &PaymentServer::handleURIConnection);
|
connect(uriServer, &QLocalServer::newConnection, this, &PaymentServer::handleURIConnection);
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
connect(this, &PaymentServer::receivedPaymentACK, this, &PaymentServer::handlePaymentACK);
|
connect(this, &PaymentServer::receivedPaymentACK, this, &PaymentServer::handlePaymentACK);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PaymentServer::~PaymentServer()
|
PaymentServer::~PaymentServer()
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
google::protobuf::ShutdownProtobufLibrary();
|
google::protobuf::ShutdownProtobufLibrary();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -349,6 +367,7 @@ bool PaymentServer::eventFilter(QObject *object, QEvent *event)
|
||||||
return QObject::eventFilter(object, event);
|
return QObject::eventFilter(object, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
void PaymentServer::initNetManager()
|
void PaymentServer::initNetManager()
|
||||||
{
|
{
|
||||||
if (!optionsModel)
|
if (!optionsModel)
|
||||||
|
@ -372,10 +391,13 @@ void PaymentServer::initNetManager()
|
||||||
connect(netManager, &QNetworkAccessManager::finished, this, &PaymentServer::netRequestFinished);
|
connect(netManager, &QNetworkAccessManager::finished, this, &PaymentServer::netRequestFinished);
|
||||||
connect(netManager, &QNetworkAccessManager::sslErrors, this, &PaymentServer::reportSslErrors);
|
connect(netManager, &QNetworkAccessManager::sslErrors, this, &PaymentServer::reportSslErrors);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void PaymentServer::uiReady()
|
void PaymentServer::uiReady()
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
initNetManager();
|
initNetManager();
|
||||||
|
#endif
|
||||||
|
|
||||||
saveURIs = false;
|
saveURIs = false;
|
||||||
for (const QString& s : savedPaymentRequests)
|
for (const QString& s : savedPaymentRequests)
|
||||||
|
@ -403,6 +425,7 @@ void PaymentServer::handleURIOrFile(const QString& s)
|
||||||
QUrlQuery uri((QUrl(s)));
|
QUrlQuery uri((QUrl(s)));
|
||||||
if (uri.hasQueryItem("r")) // payment request URI
|
if (uri.hasQueryItem("r")) // payment request URI
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
QByteArray temp;
|
QByteArray temp;
|
||||||
temp.append(uri.queryItemValue("r"));
|
temp.append(uri.queryItemValue("r"));
|
||||||
QString decoded = QUrl::fromPercentEncoding(temp);
|
QString decoded = QUrl::fromPercentEncoding(temp);
|
||||||
|
@ -420,7 +443,11 @@ void PaymentServer::handleURIOrFile(const QString& s)
|
||||||
tr("Payment request fetch URL is invalid: %1").arg(fetchUrl.toString()),
|
tr("Payment request fetch URL is invalid: %1").arg(fetchUrl.toString()),
|
||||||
CClientUIInterface::ICON_WARNING);
|
CClientUIInterface::ICON_WARNING);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
Q_EMIT message(tr("URI handling"),
|
||||||
|
tr("Cannot process payment request because BIP70 support was not compiled in."),
|
||||||
|
CClientUIInterface::ICON_WARNING);
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else // normal URI
|
else // normal URI
|
||||||
|
@ -444,6 +471,7 @@ void PaymentServer::handleURIOrFile(const QString& s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
if (QFile::exists(s)) // payment request file
|
if (QFile::exists(s)) // payment request file
|
||||||
{
|
{
|
||||||
PaymentRequestPlus request;
|
PaymentRequestPlus request;
|
||||||
|
@ -459,6 +487,7 @@ void PaymentServer::handleURIOrFile(const QString& s)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaymentServer::handleURIConnection()
|
void PaymentServer::handleURIConnection()
|
||||||
|
@ -481,6 +510,7 @@ void PaymentServer::handleURIConnection()
|
||||||
handleURIOrFile(msg);
|
handleURIOrFile(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
//
|
//
|
||||||
// Warning: readPaymentRequestFromFile() is used in ipcSendCommandLine()
|
// Warning: readPaymentRequestFromFile() is used in ipcSendCommandLine()
|
||||||
// so don't use "Q_EMIT message()", but "QMessageBox::"!
|
// so don't use "Q_EMIT message()", but "QMessageBox::"!
|
||||||
|
@ -730,12 +760,14 @@ void PaymentServer::reportSslErrors(QNetworkReply* reply, const QList<QSslError>
|
||||||
}
|
}
|
||||||
Q_EMIT message(tr("Network request error"), errString, CClientUIInterface::MSG_ERROR);
|
Q_EMIT message(tr("Network request error"), errString, CClientUIInterface::MSG_ERROR);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void PaymentServer::setOptionsModel(OptionsModel *_optionsModel)
|
void PaymentServer::setOptionsModel(OptionsModel *_optionsModel)
|
||||||
{
|
{
|
||||||
this->optionsModel = _optionsModel;
|
this->optionsModel = _optionsModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
void PaymentServer::handlePaymentACK(const QString& paymentACKMsg)
|
void PaymentServer::handlePaymentACK(const QString& paymentACKMsg)
|
||||||
{
|
{
|
||||||
// currently we don't further process or store the paymentACK message
|
// currently we don't further process or store the paymentACK message
|
||||||
|
@ -794,3 +826,4 @@ X509_STORE* PaymentServer::getCertStore()
|
||||||
{
|
{
|
||||||
return certStore.get();
|
return certStore.get();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -32,7 +32,13 @@
|
||||||
// sends them to the server.
|
// sends them to the server.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H)
|
||||||
|
#include <config/bitcoin-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
#include <qt/paymentrequestplus.h>
|
#include <qt/paymentrequestplus.h>
|
||||||
|
#endif
|
||||||
#include <qt/walletmodel.h>
|
#include <qt/walletmodel.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -73,6 +79,7 @@ public:
|
||||||
explicit PaymentServer(QObject* parent, bool startLocalServer = true);
|
explicit PaymentServer(QObject* parent, bool startLocalServer = true);
|
||||||
~PaymentServer();
|
~PaymentServer();
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
// Load root certificate authorities. Pass nullptr (default)
|
// Load root certificate authorities. Pass nullptr (default)
|
||||||
// to read from the file specified in the -rootcertificates setting,
|
// to read from the file specified in the -rootcertificates setting,
|
||||||
// or, if that's not set, to use the system default root certificates.
|
// or, if that's not set, to use the system default root certificates.
|
||||||
|
@ -82,10 +89,12 @@ public:
|
||||||
|
|
||||||
// Return certificate store
|
// Return certificate store
|
||||||
static X509_STORE* getCertStore();
|
static X509_STORE* getCertStore();
|
||||||
|
#endif
|
||||||
|
|
||||||
// OptionsModel is used for getting proxy settings and display unit
|
// OptionsModel is used for getting proxy settings and display unit
|
||||||
void setOptionsModel(OptionsModel *optionsModel);
|
void setOptionsModel(OptionsModel *optionsModel);
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
// Verify that the payment request network matches the client network
|
// Verify that the payment request network matches the client network
|
||||||
static bool verifyNetwork(interfaces::Node& node, const payments::PaymentDetails& requestDetails);
|
static bool verifyNetwork(interfaces::Node& node, const payments::PaymentDetails& requestDetails);
|
||||||
// Verify if the payment request is expired
|
// Verify if the payment request is expired
|
||||||
|
@ -94,13 +103,16 @@ public:
|
||||||
static bool verifySize(qint64 requestSize);
|
static bool verifySize(qint64 requestSize);
|
||||||
// Verify the payment request amount is valid
|
// Verify the payment request amount is valid
|
||||||
static bool verifyAmount(const CAmount& requestAmount);
|
static bool verifyAmount(const CAmount& requestAmount);
|
||||||
|
#endif
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
// Fired when a valid payment request is received
|
// Fired when a valid payment request is received
|
||||||
void receivedPaymentRequest(SendCoinsRecipient);
|
void receivedPaymentRequest(SendCoinsRecipient);
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
// Fired when a valid PaymentACK is received
|
// Fired when a valid PaymentACK is received
|
||||||
void receivedPaymentACK(const QString &paymentACKMsg);
|
void receivedPaymentACK(const QString &paymentACKMsg);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Fired when a message should be reported to the user
|
// Fired when a message should be reported to the user
|
||||||
void message(const QString &title, const QString &message, unsigned int style);
|
void message(const QString &title, const QString &message, unsigned int style);
|
||||||
|
@ -110,17 +122,21 @@ public Q_SLOTS:
|
||||||
// to display payment requests to the user
|
// to display payment requests to the user
|
||||||
void uiReady();
|
void uiReady();
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
// Submit Payment message to a merchant, get back PaymentACK:
|
// Submit Payment message to a merchant, get back PaymentACK:
|
||||||
void fetchPaymentACK(WalletModel* walletModel, const SendCoinsRecipient& recipient, QByteArray transaction);
|
void fetchPaymentACK(WalletModel* walletModel, const SendCoinsRecipient& recipient, QByteArray transaction);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Handle an incoming URI, URI with local file scheme or file
|
// Handle an incoming URI, URI with local file scheme or file
|
||||||
void handleURIOrFile(const QString& s);
|
void handleURIOrFile(const QString& s);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void handleURIConnection();
|
void handleURIConnection();
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
void netRequestFinished(QNetworkReply*);
|
void netRequestFinished(QNetworkReply*);
|
||||||
void reportSslErrors(QNetworkReply*, const QList<QSslError> &);
|
void reportSslErrors(QNetworkReply*, const QList<QSslError> &);
|
||||||
void handlePaymentACK(const QString& paymentACKMsg);
|
void handlePaymentACK(const QString& paymentACKMsg);
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Constructor registers this on the parent QApplication to
|
// Constructor registers this on the parent QApplication to
|
||||||
|
@ -128,17 +144,21 @@ protected:
|
||||||
bool eventFilter(QObject *object, QEvent *event);
|
bool eventFilter(QObject *object, QEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
static bool readPaymentRequestFromFile(const QString& filename, PaymentRequestPlus& request);
|
static bool readPaymentRequestFromFile(const QString& filename, PaymentRequestPlus& request);
|
||||||
bool processPaymentRequest(const PaymentRequestPlus& request, SendCoinsRecipient& recipient);
|
bool processPaymentRequest(const PaymentRequestPlus& request, SendCoinsRecipient& recipient);
|
||||||
void fetchRequest(const QUrl& url);
|
void fetchRequest(const QUrl& url);
|
||||||
|
|
||||||
// Setup networking
|
// Setup networking
|
||||||
void initNetManager();
|
void initNetManager();
|
||||||
|
#endif
|
||||||
|
|
||||||
bool saveURIs; // true during startup
|
bool saveURIs; // true during startup
|
||||||
QLocalServer* uriServer;
|
QLocalServer* uriServer;
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
QNetworkAccessManager* netManager; // Used to fetch payment requests
|
QNetworkAccessManager* netManager; // Used to fetch payment requests
|
||||||
|
#endif
|
||||||
|
|
||||||
OptionsModel *optionsModel;
|
OptionsModel *optionsModel;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H)
|
||||||
|
#include <config/bitcoin-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <qt/sendcoinsdialog.h>
|
#include <qt/sendcoinsdialog.h>
|
||||||
#include <qt/forms/ui_sendcoinsdialog.h>
|
#include <qt/forms/ui_sendcoinsdialog.h>
|
||||||
|
|
||||||
|
@ -290,7 +294,9 @@ void SendCoinsDialog::on_sendButton_clicked()
|
||||||
QString recipientElement;
|
QString recipientElement;
|
||||||
recipientElement = "<br />";
|
recipientElement = "<br />";
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
if (!rcp.paymentRequest.IsInitialized()) // normal payment
|
if (!rcp.paymentRequest.IsInitialized()) // normal payment
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if(rcp.label.length() > 0) // label with address
|
if(rcp.label.length() > 0) // label with address
|
||||||
{
|
{
|
||||||
|
@ -302,6 +308,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
||||||
recipientElement.append(tr("%1 to %2").arg(amount, address));
|
recipientElement.append(tr("%1 to %2").arg(amount, address));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
else if(!rcp.authenticatedMerchant.isEmpty()) // authenticated payment request
|
else if(!rcp.authenticatedMerchant.isEmpty()) // authenticated payment request
|
||||||
{
|
{
|
||||||
recipientElement.append(tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant)));
|
recipientElement.append(tr("%1 to %2").arg(amount, GUIUtil::HtmlEscape(rcp.authenticatedMerchant)));
|
||||||
|
@ -310,6 +317,7 @@ void SendCoinsDialog::on_sendButton_clicked()
|
||||||
{
|
{
|
||||||
recipientElement.append(tr("%1 to %2").arg(amount, address));
|
recipientElement.append(tr("%1 to %2").arg(amount, address));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
formatted.append(recipientElement);
|
formatted.append(recipientElement);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H)
|
||||||
|
#include <config/bitcoin-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <qt/sendcoinsentry.h>
|
#include <qt/sendcoinsentry.h>
|
||||||
#include <qt/forms/ui_sendcoinsentry.h>
|
#include <qt/forms/ui_sendcoinsentry.h>
|
||||||
|
|
||||||
|
@ -133,9 +137,11 @@ bool SendCoinsEntry::validate(interfaces::Node& node)
|
||||||
// Check input validity
|
// Check input validity
|
||||||
bool retval = true;
|
bool retval = true;
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
// Skip checks for payment request
|
// Skip checks for payment request
|
||||||
if (recipient.paymentRequest.IsInitialized())
|
if (recipient.paymentRequest.IsInitialized())
|
||||||
return retval;
|
return retval;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!model->validateAddress(ui->payTo->text()))
|
if (!model->validateAddress(ui->payTo->text()))
|
||||||
{
|
{
|
||||||
|
@ -166,9 +172,11 @@ bool SendCoinsEntry::validate(interfaces::Node& node)
|
||||||
|
|
||||||
SendCoinsRecipient SendCoinsEntry::getValue()
|
SendCoinsRecipient SendCoinsEntry::getValue()
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
// Payment request
|
// Payment request
|
||||||
if (recipient.paymentRequest.IsInitialized())
|
if (recipient.paymentRequest.IsInitialized())
|
||||||
return recipient;
|
return recipient;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Normal payment
|
// Normal payment
|
||||||
recipient.address = ui->payTo->text();
|
recipient.address = ui->payTo->text();
|
||||||
|
@ -196,6 +204,7 @@ void SendCoinsEntry::setValue(const SendCoinsRecipient &value)
|
||||||
{
|
{
|
||||||
recipient = value;
|
recipient = value;
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
if (recipient.paymentRequest.IsInitialized()) // payment request
|
if (recipient.paymentRequest.IsInitialized()) // payment request
|
||||||
{
|
{
|
||||||
if (recipient.authenticatedMerchant.isEmpty()) // unauthenticated
|
if (recipient.authenticatedMerchant.isEmpty()) // unauthenticated
|
||||||
|
@ -216,6 +225,7 @@ void SendCoinsEntry::setValue(const SendCoinsRecipient &value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // normal payment
|
else // normal payment
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
// message
|
// message
|
||||||
ui->messageTextLabel->setText(recipient.message);
|
ui->messageTextLabel->setText(recipient.message);
|
||||||
|
|
|
@ -2,7 +2,13 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H)
|
||||||
|
#include <config/bitcoin-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ENABLE_WALLET) && defined(ENABLE_BIP70)
|
||||||
#include <qt/paymentrequestplus.h> // this includes protobuf's port.h which defines its own bswap macos
|
#include <qt/paymentrequestplus.h> // this includes protobuf's port.h which defines its own bswap macos
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <qt/test/compattests.h>
|
#include <qt/test/compattests.h>
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,11 @@
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
#include <qt/test/addressbooktests.h>
|
#include <qt/test/addressbooktests.h>
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
#include <qt/test/paymentservertests.h>
|
#include <qt/test/paymentservertests.h>
|
||||||
|
#endif // ENABLE_BIP70
|
||||||
#include <qt/test/wallettests.h>
|
#include <qt/test/wallettests.h>
|
||||||
#endif
|
#endif // ENABLE_WALLET
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -74,7 +76,7 @@ int main(int argc, char *argv[])
|
||||||
if (QTest::qExec(&test1) != 0) {
|
if (QTest::qExec(&test1) != 0) {
|
||||||
fInvalid = true;
|
fInvalid = true;
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_WALLET
|
#if defined(ENABLE_WALLET) && defined(ENABLE_BIP70)
|
||||||
PaymentServerTests test2;
|
PaymentServerTests test2;
|
||||||
if (QTest::qExec(&test2) != 0) {
|
if (QTest::qExec(&test2) != 0) {
|
||||||
fInvalid = true;
|
fInvalid = true;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <qt/test/util.h>
|
#include <qt/test/util.h>
|
||||||
|
|
||||||
#include <interfaces/node.h>
|
#include <interfaces/node.h>
|
||||||
|
#include <base58.h>
|
||||||
#include <qt/bitcoinamountfield.h>
|
#include <qt/bitcoinamountfield.h>
|
||||||
#include <qt/callback.h>
|
#include <qt/callback.h>
|
||||||
#include <qt/optionsmodel.h>
|
#include <qt/optionsmodel.h>
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config/bitcoin-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <qt/transactiondesc.h>
|
#include <qt/transactiondesc.h>
|
||||||
|
|
||||||
#include <qt/bitcoinunits.h>
|
#include <qt/bitcoinunits.h>
|
||||||
|
@ -257,6 +261,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
||||||
if (r.first == "Message")
|
if (r.first == "Message")
|
||||||
strHTML += "<br><b>" + tr("Message") + ":</b><br>" + GUIUtil::HtmlEscape(r.second, true) + "<br>";
|
strHTML += "<br><b>" + tr("Message") + ":</b><br>" + GUIUtil::HtmlEscape(r.second, true) + "<br>";
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
//
|
//
|
||||||
// PaymentRequest info:
|
// PaymentRequest info:
|
||||||
//
|
//
|
||||||
|
@ -271,6 +276,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
|
||||||
strHTML += "<b>" + tr("Merchant") + ":</b> " + GUIUtil::HtmlEscape(merchant) + "<br>";
|
strHTML += "<b>" + tr("Merchant") + ":</b> " + GUIUtil::HtmlEscape(merchant) + "<br>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (wtx.is_coinbase)
|
if (wtx.is_coinbase)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
#include <qt/clientmodel.h>
|
#include <qt/clientmodel.h>
|
||||||
#include <qt/guiconstants.h>
|
#include <qt/guiconstants.h>
|
||||||
#include <qt/intro.h>
|
#include <qt/intro.h>
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
#include <qt/paymentrequestplus.h>
|
#include <qt/paymentrequestplus.h>
|
||||||
|
#endif
|
||||||
#include <qt/guiutil.h>
|
#include <qt/guiutil.h>
|
||||||
|
|
||||||
#include <clientversion.h>
|
#include <clientversion.h>
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H)
|
||||||
|
#include <config/bitcoin-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <qt/walletmodel.h>
|
#include <qt/walletmodel.h>
|
||||||
|
|
||||||
#include <qt/addresstablemodel.h>
|
#include <qt/addresstablemodel.h>
|
||||||
|
@ -142,6 +146,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
|
||||||
if (rcp.fSubtractFeeFromAmount)
|
if (rcp.fSubtractFeeFromAmount)
|
||||||
fSubtractFeeFromAmount = true;
|
fSubtractFeeFromAmount = true;
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
if (rcp.paymentRequest.IsInitialized())
|
if (rcp.paymentRequest.IsInitialized())
|
||||||
{ // PaymentRequest...
|
{ // PaymentRequest...
|
||||||
CAmount subtotal = 0;
|
CAmount subtotal = 0;
|
||||||
|
@ -164,6 +169,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
|
||||||
total += subtotal;
|
total += subtotal;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{ // User-entered bitcoin address / amount:
|
{ // User-entered bitcoin address / amount:
|
||||||
if(!validateAddress(rcp.address))
|
if(!validateAddress(rcp.address))
|
||||||
{
|
{
|
||||||
|
@ -235,6 +241,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
|
||||||
std::vector<std::pair<std::string, std::string>> vOrderForm;
|
std::vector<std::pair<std::string, std::string>> vOrderForm;
|
||||||
for (const SendCoinsRecipient &rcp : transaction.getRecipients())
|
for (const SendCoinsRecipient &rcp : transaction.getRecipients())
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
if (rcp.paymentRequest.IsInitialized())
|
if (rcp.paymentRequest.IsInitialized())
|
||||||
{
|
{
|
||||||
// Make sure any payment requests involved are still valid.
|
// Make sure any payment requests involved are still valid.
|
||||||
|
@ -247,7 +254,9 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
|
||||||
rcp.paymentRequest.SerializeToString(&value);
|
rcp.paymentRequest.SerializeToString(&value);
|
||||||
vOrderForm.emplace_back("PaymentRequest", std::move(value));
|
vOrderForm.emplace_back("PaymentRequest", std::move(value));
|
||||||
}
|
}
|
||||||
else if (!rcp.message.isEmpty()) // Message from normal bitcoin:URI (bitcoin:123...?message=example)
|
else
|
||||||
|
#endif
|
||||||
|
if (!rcp.message.isEmpty()) // Message from normal bitcoin:URI (bitcoin:123...?message=example)
|
||||||
vOrderForm.emplace_back("Message", rcp.message.toStdString());
|
vOrderForm.emplace_back("Message", rcp.message.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +275,9 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
|
||||||
for (const SendCoinsRecipient &rcp : transaction.getRecipients())
|
for (const SendCoinsRecipient &rcp : transaction.getRecipients())
|
||||||
{
|
{
|
||||||
// Don't touch the address book when we have a payment request
|
// Don't touch the address book when we have a payment request
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
if (!rcp.paymentRequest.IsInitialized())
|
if (!rcp.paymentRequest.IsInitialized())
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
std::string strAddress = rcp.address.toStdString();
|
std::string strAddress = rcp.address.toStdString();
|
||||||
CTxDestination dest = DecodeDestination(strAddress);
|
CTxDestination dest = DecodeDestination(strAddress);
|
||||||
|
|
|
@ -10,7 +10,13 @@
|
||||||
#include <serialize.h>
|
#include <serialize.h>
|
||||||
#include <script/standard.h>
|
#include <script/standard.h>
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H)
|
||||||
|
#include <config/bitcoin-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
#include <qt/paymentrequestplus.h>
|
#include <qt/paymentrequestplus.h>
|
||||||
|
#endif
|
||||||
#include <qt/walletmodeltransaction.h>
|
#include <qt/walletmodeltransaction.h>
|
||||||
|
|
||||||
#include <interfaces/wallet.h>
|
#include <interfaces/wallet.h>
|
||||||
|
@ -63,8 +69,14 @@ public:
|
||||||
// If from a payment request, this is used for storing the memo
|
// If from a payment request, this is used for storing the memo
|
||||||
QString message;
|
QString message;
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
// If from a payment request, paymentRequest.IsInitialized() will be true
|
// If from a payment request, paymentRequest.IsInitialized() will be true
|
||||||
PaymentRequestPlus paymentRequest;
|
PaymentRequestPlus paymentRequest;
|
||||||
|
#else
|
||||||
|
// If building with BIP70 is disabled, keep the payment request around as
|
||||||
|
// serialized string to ensure load/store is lossless
|
||||||
|
std::string sPaymentRequest;
|
||||||
|
#endif
|
||||||
// Empty if no authentication or invalid signature/cert/etc.
|
// Empty if no authentication or invalid signature/cert/etc.
|
||||||
QString authenticatedMerchant;
|
QString authenticatedMerchant;
|
||||||
|
|
||||||
|
@ -80,9 +92,11 @@ public:
|
||||||
std::string sAddress = address.toStdString();
|
std::string sAddress = address.toStdString();
|
||||||
std::string sLabel = label.toStdString();
|
std::string sLabel = label.toStdString();
|
||||||
std::string sMessage = message.toStdString();
|
std::string sMessage = message.toStdString();
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
std::string sPaymentRequest;
|
std::string sPaymentRequest;
|
||||||
if (!ser_action.ForRead() && paymentRequest.IsInitialized())
|
if (!ser_action.ForRead() && paymentRequest.IsInitialized())
|
||||||
paymentRequest.SerializeToString(&sPaymentRequest);
|
paymentRequest.SerializeToString(&sPaymentRequest);
|
||||||
|
#endif
|
||||||
std::string sAuthenticatedMerchant = authenticatedMerchant.toStdString();
|
std::string sAuthenticatedMerchant = authenticatedMerchant.toStdString();
|
||||||
|
|
||||||
READWRITE(this->nVersion);
|
READWRITE(this->nVersion);
|
||||||
|
@ -98,8 +112,10 @@ public:
|
||||||
address = QString::fromStdString(sAddress);
|
address = QString::fromStdString(sAddress);
|
||||||
label = QString::fromStdString(sLabel);
|
label = QString::fromStdString(sLabel);
|
||||||
message = QString::fromStdString(sMessage);
|
message = QString::fromStdString(sMessage);
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
if (!sPaymentRequest.empty())
|
if (!sPaymentRequest.empty())
|
||||||
paymentRequest.parse(QByteArray::fromRawData(sPaymentRequest.data(), sPaymentRequest.size()));
|
paymentRequest.parse(QByteArray::fromRawData(sPaymentRequest.data(), sPaymentRequest.size()));
|
||||||
|
#endif
|
||||||
authenticatedMerchant = QString::fromStdString(sAuthenticatedMerchant);
|
authenticatedMerchant = QString::fromStdString(sAuthenticatedMerchant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config/bitcoin-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <qt/walletmodeltransaction.h>
|
#include <qt/walletmodeltransaction.h>
|
||||||
|
|
||||||
#include <interfaces/node.h>
|
#include <interfaces/node.h>
|
||||||
|
@ -46,6 +50,7 @@ void WalletModelTransaction::reassignAmounts(int nChangePosRet)
|
||||||
{
|
{
|
||||||
SendCoinsRecipient& rcp = (*it);
|
SendCoinsRecipient& rcp = (*it);
|
||||||
|
|
||||||
|
#ifdef ENABLE_BIP70
|
||||||
if (rcp.paymentRequest.IsInitialized())
|
if (rcp.paymentRequest.IsInitialized())
|
||||||
{
|
{
|
||||||
CAmount subtotal = 0;
|
CAmount subtotal = 0;
|
||||||
|
@ -62,6 +67,7 @@ void WalletModelTransaction::reassignAmounts(int nChangePosRet)
|
||||||
rcp.amount = subtotal;
|
rcp.amount = subtotal;
|
||||||
}
|
}
|
||||||
else // normal recipient (no payment request)
|
else // normal recipient (no payment request)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (i == nChangePosRet)
|
if (i == nChangePosRet)
|
||||||
i++;
|
i++;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <qt/walletmodel.h>
|
#include <qt/walletmodel.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <amount.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue