aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.qttest.include22
-rw-r--r--src/Makefile.test.include1
-rw-r--r--src/bitcoin-tx.cpp16
-rw-r--r--src/chainparams.cpp3
-rw-r--r--src/chainparams.h3
-rw-r--r--src/coins.h1
-rw-r--r--src/compat.h11
-rw-r--r--src/dbwrapper.h4
-rw-r--r--src/httpserver.cpp7
-rw-r--r--src/net.cpp12
-rw-r--r--src/net.h2
-rw-r--r--src/netbase.cpp2
-rw-r--r--src/qt/forms/debugwindow.ui2
-rw-r--r--src/qt/forms/sendcoinsdialog.ui16
-rw-r--r--src/qt/sendcoinsdialog.cpp10
-rw-r--r--src/qt/test/rpcnestedtests.cpp4
-rw-r--r--src/qt/test/test_main.cpp40
-rw-r--r--src/qt/test/wallettests.cpp104
-rw-r--r--src/qt/test/wallettests.h15
-rw-r--r--src/qt/walletmodel.cpp5
-rw-r--r--src/qt/walletmodel.h2
-rw-r--r--src/rpc/server.h1
-rw-r--r--src/sync.cpp2
-rw-r--r--src/sync.h1
-rw-r--r--src/test/key_tests.cpp28
-rw-r--r--src/test/script_tests.cpp5
-rw-r--r--src/test/test_bitcoin.cpp28
-rw-r--r--src/test/test_bitcoin_main.cpp26
-rw-r--r--src/util.h4
-rw-r--r--src/wallet/coincontrol.h4
-rw-r--r--src/wallet/rpcdump.cpp10
-rw-r--r--src/wallet/wallet.cpp3
-rw-r--r--src/wallet/wallet.h1
33 files changed, 257 insertions, 138 deletions
diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include
index 039f8ac547..948e13a9e1 100644
--- a/src/Makefile.qttest.include
+++ b/src/Makefile.qttest.include
@@ -11,7 +11,9 @@ TEST_QT_MOC_CPP = \
qt/test/moc_uritests.cpp
if ENABLE_WALLET
-TEST_QT_MOC_CPP += qt/test/moc_paymentservertests.cpp
+TEST_QT_MOC_CPP += \
+ qt/test/moc_paymentservertests.cpp \
+ qt/test/moc_wallettests.cpp
endif
TEST_QT_H = \
@@ -19,7 +21,16 @@ TEST_QT_H = \
qt/test/rpcnestedtests.h \
qt/test/uritests.h \
qt/test/paymentrequestdata.h \
- qt/test/paymentservertests.h
+ qt/test/paymentservertests.h \
+ qt/test/wallettests.h
+
+TEST_BITCOIN_CPP = \
+ test/test_bitcoin.cpp \
+ test/testutil.cpp
+
+TEST_BITCOIN_H = \
+ test/test_bitcoin.h \
+ test/testutil.h
qt_test_test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \
$(QT_INCLUDES) $(QT_TEST_INCLUDES) $(PROTOBUF_CFLAGS)
@@ -29,10 +40,13 @@ qt_test_test_bitcoin_qt_SOURCES = \
qt/test/rpcnestedtests.cpp \
qt/test/test_main.cpp \
qt/test/uritests.cpp \
- $(TEST_QT_H)
+ $(TEST_QT_H) \
+ $(TEST_BITCOIN_CPP) \
+ $(TEST_BITCOIN_H)
if ENABLE_WALLET
qt_test_test_bitcoin_qt_SOURCES += \
- qt/test/paymentservertests.cpp
+ qt/test/paymentservertests.cpp \
+ qt/test/wallettests.cpp
endif
nodist_qt_test_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP)
diff --git a/src/Makefile.test.include b/src/Makefile.test.include
index 5517132465..cfd08b8238 100644
--- a/src/Makefile.test.include
+++ b/src/Makefile.test.include
@@ -127,6 +127,7 @@ BITCOIN_TESTS =\
test/streams_tests.cpp \
test/test_bitcoin.cpp \
test/test_bitcoin.h \
+ test/test_bitcoin_main.cpp \
test/test_random.h \
test/testutil.cpp \
test/testutil.h \
diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp
index 3c3646523a..61e0eb74e6 100644
--- a/src/bitcoin-tx.cpp
+++ b/src/bitcoin-tx.cpp
@@ -483,22 +483,6 @@ static bool findSighashFlags(int& flags, const std::string& flagStr)
return false;
}
-uint256 ParseHashUO(std::map<std::string,UniValue>& o, std::string strKey)
-{
- if (!o.count(strKey))
- return uint256();
- return ParseHashUV(o[strKey], strKey);
-}
-
-std::vector<unsigned char> ParseHexUO(std::map<std::string,UniValue>& o, std::string strKey)
-{
- if (!o.count(strKey)) {
- std::vector<unsigned char> emptyVec;
- return emptyVec;
- }
- return ParseHexUV(o[strKey], strKey);
-}
-
static CAmount AmountFromValue(const UniValue& value)
{
if (!value.isNum() && !value.isStr())
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 8c38558829..1dc29826af 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -135,7 +135,6 @@ public:
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
- fMiningRequiresPeers = true;
fDefaultConsistencyChecks = false;
fRequireStandard = true;
fMineBlocksOnDemand = false;
@@ -235,7 +234,6 @@ public:
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));
- fMiningRequiresPeers = true;
fDefaultConsistencyChecks = false;
fRequireStandard = false;
fMineBlocksOnDemand = false;
@@ -307,7 +305,6 @@ public:
vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
- fMiningRequiresPeers = false;
fDefaultConsistencyChecks = true;
fRequireStandard = false;
fMineBlocksOnDemand = true;
diff --git a/src/chainparams.h b/src/chainparams.h
index db524e8f8e..4fe88c691c 100644
--- a/src/chainparams.h
+++ b/src/chainparams.h
@@ -61,8 +61,6 @@ public:
int GetDefaultPort() const { return nDefaultPort; }
const CBlock& GenesisBlock() const { return genesis; }
- /** Make miner wait to have peers to avoid wasting work */
- bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
/** Default value for -checkmempool and -checkblockindex argument */
bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
/** Policy: Filter transactions that do not match well-defined patterns */
@@ -89,7 +87,6 @@ protected:
std::string strNetworkID;
CBlock genesis;
std::vector<SeedSpec6> vFixedSeeds;
- bool fMiningRequiresPeers;
bool fDefaultConsistencyChecks;
bool fRequireStandard;
bool fMineBlocksOnDemand;
diff --git a/src/coins.h b/src/coins.h
index d921f5c2a5..8ee49b33ae 100644
--- a/src/coins.h
+++ b/src/coins.h
@@ -290,7 +290,6 @@ public:
virtual bool GetKey(uint256 &key) const = 0;
virtual bool GetValue(CCoins &coins) const = 0;
- /* Don't care about GetKeySize here */
virtual unsigned int GetValueSize() const = 0;
virtual bool Valid() const = 0;
diff --git a/src/compat.h b/src/compat.h
index 28aa77eea2..e76ab94c82 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -47,10 +47,8 @@
#include <unistd.h>
#endif
-#ifdef WIN32
-#define MSG_DONTWAIT 0
-#else
-typedef u_int SOCKET;
+#ifndef WIN32
+typedef unsigned int SOCKET;
#include "errno.h"
#define WSAGetLastError() errno
#define WSAEINVAL EINVAL
@@ -74,11 +72,6 @@ typedef u_int SOCKET;
#define MAX_PATH 1024
#endif
-// As Solaris does not have the MSG_NOSIGNAL flag for send(2) syscall, it is defined as 0
-#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
-#define MSG_NOSIGNAL 0
-#endif
-
#if HAVE_DECL_STRNLEN == 0
size_t strnlen( const char *start, size_t max_len);
#endif // HAVE_DECL_STRNLEN
diff --git a/src/dbwrapper.h b/src/dbwrapper.h
index dd59cc00ff..414df76a7c 100644
--- a/src/dbwrapper.h
+++ b/src/dbwrapper.h
@@ -132,10 +132,6 @@ public:
return true;
}
- unsigned int GetKeySize() {
- return piter->key().size();
- }
-
template<typename V> bool GetValue(V& value) {
leveldb::Slice slValue = piter->value();
try {
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index e1763c6ad2..dbd08ff2e1 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -146,13 +146,6 @@ public:
while (numThreads > 0)
cond.wait(lock);
}
-
- /** Return current depth of queue */
- size_t Depth()
- {
- std::unique_lock<std::mutex> lock(cs);
- return queue.size();
- }
};
struct HTTPPathHandler
diff --git a/src/net.cpp b/src/net.cpp
index 4434793c4c..4c5b04b785 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -44,10 +44,15 @@
// We add a random period time (0 to 1 seconds) to feeler connections to prevent synchronization.
#define FEELER_SLEEP_WINDOW 1
-#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
+#if !defined(HAVE_MSG_NOSIGNAL)
#define MSG_NOSIGNAL 0
#endif
+// MSG_DONTWAIT is not available on some platforms, if it doesn't exist define it as 0
+#if !defined(HAVE_MSG_DONTWAIT)
+#define MSG_DONTWAIT 0
+#endif
+
// Fix for ancient MinGW versions, that don't have defined these in ws2tcpip.h.
// Todo: Can be removed when our pull-tester is upgraded to a modern MinGW version.
#ifdef WIN32
@@ -2406,11 +2411,6 @@ void CConnman::MarkAddressGood(const CAddress& addr)
addrman.Good(addr);
}
-void CConnman::AddNewAddress(const CAddress& addr, const CAddress& addrFrom, int64_t nTimePenalty)
-{
- addrman.Add(addr, addrFrom, nTimePenalty);
-}
-
void CConnman::AddNewAddresses(const std::vector<CAddress>& vAddr, const CAddress& addrFrom, int64_t nTimePenalty)
{
addrman.Add(vAddr, addrFrom, nTimePenalty);
diff --git a/src/net.h b/src/net.h
index 29b6a44c88..3bbe386173 100644
--- a/src/net.h
+++ b/src/net.h
@@ -207,10 +207,8 @@ public:
size_t GetAddressCount() const;
void SetServices(const CService &addr, ServiceFlags nServices);
void MarkAddressGood(const CAddress& addr);
- void AddNewAddress(const CAddress& addr, const CAddress& addrFrom, int64_t nTimePenalty = 0);
void AddNewAddresses(const std::vector<CAddress>& vAddr, const CAddress& addrFrom, int64_t nTimePenalty = 0);
std::vector<CAddress> GetAddresses();
- void AddressCurrentlyConnected(const CService& addr);
// Denial-of-service detection/prevention
// The idea is to detect peers that are behaving
diff --git a/src/netbase.cpp b/src/netbase.cpp
index fc9a6ed0be..0f02e93e46 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -25,7 +25,7 @@
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()
-#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
+#if !defined(HAVE_MSG_NOSIGNAL)
#define MSG_NOSIGNAL 0
#endif
diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui
index 8be4a955b3..093e644bdc 100644
--- a/src/qt/forms/debugwindow.ui
+++ b/src/qt/forms/debugwindow.ui
@@ -645,7 +645,7 @@
<item>
<widget class="QPushButton" name="btnClearTrafficGraph">
<property name="text">
- <string>&amp;Clear</string>
+ <string>&amp;Reset</string>
</property>
<property name="autoDefault">
<bool>false</bool>
diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui
index ca2da6bf37..cc183908d4 100644
--- a/src/qt/forms/sendcoinsdialog.ui
+++ b/src/qt/forms/sendcoinsdialog.ui
@@ -762,7 +762,7 @@
<item>
<widget class="QLabel" name="fallbackFeeWarningLabel">
<property name="toolTip">
- <string>Using the fallbackfee can result in sending a transaction that will take serval hours or days (or never) to confirm. Consider choosing your fee manually or wait until your have validated the complete chain.</string>
+ <string>Using the fallbackfee can result in sending a transaction that will take several hours or days (or never) to confirm. Consider choosing your fee manually or wait until your have validated the complete chain.</string>
</property>
<property name="font">
<font>
@@ -1180,6 +1180,16 @@
</item>
</layout>
</item>
+ <item>
+ <widget class="QCheckBox" name="optInRBF">
+ <property name="text">
+ <string>Request Replace-By-Fee</string>
+ </property>
+ <property name="toolTip">
+ <string>Indicates that the sender may wish to replace this transaction with a new one paying higher fees (prior to being confirmed).</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
@@ -1190,8 +1200,8 @@
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>800</width>
- <height>1</height>
+ <width>40</width>
+ <height>5</height>
</size>
</property>
</spacer>
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 65ca007552..ed7eab03f3 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -114,6 +114,7 @@ SendCoinsDialog::SendCoinsDialog(const PlatformStyle *_platformStyle, QWidget *p
ui->groupCustomFee->button((int)std::max(0, std::min(1, settings.value("nCustomFeeRadio").toInt())))->setChecked(true);
ui->customFee->setValue(settings.value("nTransactionFee").toLongLong());
ui->checkBoxMinimumFee->setChecked(settings.value("fPayOnlyMinFee").toBool());
+ ui->optInRBF->setCheckState(model->getDefaultWalletRbf() ? Qt::Checked : Qt::Unchecked);
minimizeFeeSection(settings.value("fFeeSectionMinimized").toBool());
}
@@ -247,6 +248,8 @@ void SendCoinsDialog::on_sendButton_clicked()
else
ctrl.nConfirmTarget = 0;
+ ctrl.signalRbf = ui->optInRBF->isChecked();
+
prepareStatus = model->prepareTransaction(currentTransaction, &ctrl);
// process prepareStatus and on error generate message shown to user
@@ -326,6 +329,13 @@ void SendCoinsDialog::on_sendButton_clicked()
questionString.append(QString("<span style='font-size:10pt;font-weight:normal;'><br />(=%2)</span>")
.arg(alternativeUnits.join(" " + tr("or") + "<br />")));
+ if (ui->optInRBF->isChecked())
+ {
+ questionString.append("<hr /><span>");
+ questionString.append(tr("This transaction signals replaceability (optin-RBF)."));
+ questionString.append("</span>");
+ }
+
SendConfirmationDialog confirmationDialog(tr("Confirm send coins"),
questionString.arg(formatted.join("<br />")), SEND_CONFIRM_DELAY, this);
confirmationDialog.exec();
diff --git a/src/qt/test/rpcnestedtests.cpp b/src/qt/test/rpcnestedtests.cpp
index bd496f149c..a7b82117d8 100644
--- a/src/qt/test/rpcnestedtests.cpp
+++ b/src/qt/test/rpcnestedtests.cpp
@@ -148,9 +148,13 @@ void RPCNestedTests::rpcNestedTests()
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,)"), std::runtime_error); //don't tollerate empty arguments when using ,
#endif
+ UnloadBlockIndex();
delete pcoinsTip;
+ pcoinsTip = nullptr;
delete pcoinsdbview;
+ pcoinsdbview = nullptr;
delete pblocktree;
+ pblocktree = nullptr;
boost::filesystem::remove_all(boost::filesystem::path(path));
}
diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp
index d44d711315..d8bcfedb7c 100644
--- a/src/qt/test/test_main.cpp
+++ b/src/qt/test/test_main.cpp
@@ -7,7 +7,6 @@
#endif
#include "chainparams.h"
-#include "key.h"
#include "rpcnestedtests.h"
#include "util.h"
#include "uritests.h"
@@ -15,20 +14,31 @@
#ifdef ENABLE_WALLET
#include "paymentservertests.h"
+#include "wallettests.h"
#endif
-#include <QCoreApplication>
+#include <QApplication>
#include <QObject>
#include <QTest>
#include <openssl/ssl.h>
-#if defined(QT_STATICPLUGIN) && QT_VERSION < 0x050000
+#if defined(QT_STATICPLUGIN)
#include <QtPlugin>
+#if QT_VERSION < 0x050000
Q_IMPORT_PLUGIN(qcncodecs)
Q_IMPORT_PLUGIN(qjpcodecs)
Q_IMPORT_PLUGIN(qtwcodecs)
Q_IMPORT_PLUGIN(qkrcodecs)
+#else
+#if defined(QT_QPA_PLATFORM_XCB)
+Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
+#elif defined(QT_QPA_PLATFORM_WINDOWS)
+Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
+#elif defined(QT_QPA_PLATFORM_COCOA)
+Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
+#endif
+#endif
#endif
extern void noui_connect();
@@ -36,7 +46,6 @@ extern void noui_connect();
// This is all you need to run all the tests
int main(int argc, char *argv[])
{
- ECC_Start();
SetupEnvironment();
SetupNetworking();
SelectParams(CBaseChainParams::MAIN);
@@ -45,27 +54,36 @@ int main(int argc, char *argv[])
bool fInvalid = false;
// Don't remove this, it's needed to access
- // QCoreApplication:: in the tests
- QCoreApplication app(argc, argv);
+ // QApplication:: and QCoreApplication:: in the tests
+ QApplication app(argc, argv);
app.setApplicationName("Bitcoin-Qt-test");
SSL_library_init();
URITests test1;
- if (QTest::qExec(&test1) != 0)
+ if (QTest::qExec(&test1) != 0) {
fInvalid = true;
+ }
#ifdef ENABLE_WALLET
PaymentServerTests test2;
- if (QTest::qExec(&test2) != 0)
+ if (QTest::qExec(&test2) != 0) {
fInvalid = true;
+ }
#endif
RPCNestedTests test3;
- if (QTest::qExec(&test3) != 0)
+ if (QTest::qExec(&test3) != 0) {
fInvalid = true;
+ }
CompatTests test4;
- if (QTest::qExec(&test4) != 0)
+ if (QTest::qExec(&test4) != 0) {
fInvalid = true;
+ }
+#ifdef ENABLE_WALLET
+ WalletTests test5;
+ if (QTest::qExec(&test5) != 0) {
+ fInvalid = true;
+ }
+#endif
- ECC_Stop();
return fInvalid;
}
diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp
new file mode 100644
index 0000000000..2bb7f01fdd
--- /dev/null
+++ b/src/qt/test/wallettests.cpp
@@ -0,0 +1,104 @@
+#include "wallettests.h"
+
+#include "qt/bitcoinamountfield.h"
+#include "qt/optionsmodel.h"
+#include "qt/platformstyle.h"
+#include "qt/qvalidatedlineedit.h"
+#include "qt/sendcoinsdialog.h"
+#include "qt/sendcoinsentry.h"
+#include "qt/transactiontablemodel.h"
+#include "qt/walletmodel.h"
+#include "test/test_bitcoin.h"
+#include "validation.h"
+#include "wallet/wallet.h"
+
+#include <QAbstractButton>
+#include <QApplication>
+#include <QTimer>
+#include <QVBoxLayout>
+
+namespace
+{
+//! Press "Yes" button in modal send confirmation dialog.
+void ConfirmSend()
+{
+ QTimer::singleShot(0, Qt::PreciseTimer, []() {
+ for (QWidget* widget : QApplication::topLevelWidgets()) {
+ if (widget->inherits("SendConfirmationDialog")) {
+ SendConfirmationDialog* dialog = qobject_cast<SendConfirmationDialog*>(widget);
+ QAbstractButton* button = dialog->button(QMessageBox::Yes);
+ button->setEnabled(true);
+ button->click();
+ }
+ }
+ });
+}
+
+//! Send coins to address and return txid.
+uint256 SendCoins(CWallet& wallet, SendCoinsDialog& sendCoinsDialog, const CBitcoinAddress& address, CAmount amount)
+{
+ QVBoxLayout* entries = sendCoinsDialog.findChild<QVBoxLayout*>("entries");
+ SendCoinsEntry* entry = qobject_cast<SendCoinsEntry*>(entries->itemAt(0)->widget());
+ entry->findChild<QValidatedLineEdit*>("payTo")->setText(QString::fromStdString(address.ToString()));
+ entry->findChild<BitcoinAmountField*>("payAmount")->setValue(amount);
+ uint256 txid;
+ boost::signals2::scoped_connection c = wallet.NotifyTransactionChanged.connect([&txid](CWallet*, const uint256& hash, ChangeType status) {
+ if (status == CT_NEW) txid = hash;
+ });
+ ConfirmSend();
+ QMetaObject::invokeMethod(&sendCoinsDialog, "on_sendButton_clicked");
+ return txid;
+}
+
+//! Find index of txid in transaction list.
+QModelIndex FindTx(const QAbstractItemModel& model, const uint256& txid)
+{
+ QString hash = QString::fromStdString(txid.ToString());
+ int rows = model.rowCount({});
+ for (int row = 0; row < rows; ++row) {
+ QModelIndex index = model.index(row, 0, {});
+ if (model.data(index, TransactionTableModel::TxHashRole) == hash) {
+ return index;
+ }
+ }
+ return {};
+}
+}
+
+//! Simple qt wallet tests.
+void WalletTests::walletTests()
+{
+ // Set up wallet and chain with 101 blocks (1 mature block for spending).
+ TestChain100Setup test;
+ test.CreateAndProcessBlock({}, GetScriptForRawPubKey(test.coinbaseKey.GetPubKey()));
+ bitdb.MakeMock();
+ CWallet wallet("wallet_test.dat");
+ bool firstRun;
+ wallet.LoadWallet(firstRun);
+ {
+ LOCK(wallet.cs_wallet);
+ wallet.SetAddressBook(test.coinbaseKey.GetPubKey().GetID(), "", "receive");
+ wallet.AddKeyPubKey(test.coinbaseKey, test.coinbaseKey.GetPubKey());
+ }
+ wallet.ScanForWalletTransactions(chainActive.Genesis(), true);
+ wallet.SetBroadcastTransactions(true);
+
+ // Create widgets for sending coins and listing transactions.
+ std::unique_ptr<const PlatformStyle> platformStyle(PlatformStyle::instantiate("other"));
+ SendCoinsDialog sendCoinsDialog(platformStyle.get());
+ OptionsModel optionsModel;
+ WalletModel walletModel(platformStyle.get(), &wallet, &optionsModel);
+ sendCoinsDialog.setModel(&walletModel);
+
+ // Send two transactions, and verify they are added to transaction list.
+ TransactionTableModel* transactionTableModel = walletModel.getTransactionTableModel();
+ QCOMPARE(transactionTableModel->rowCount({}), 101);
+ uint256 txid1 = SendCoins(wallet, sendCoinsDialog, CBitcoinAddress(CKeyID()), 5 * COIN);
+ uint256 txid2 = SendCoins(wallet, sendCoinsDialog, CBitcoinAddress(CKeyID()), 10 * COIN);
+ QCOMPARE(transactionTableModel->rowCount({}), 103);
+ QVERIFY(FindTx(*transactionTableModel, txid1).isValid());
+ QVERIFY(FindTx(*transactionTableModel, txid2).isValid());
+
+ bitdb.Flush(true);
+ bitdb.Reset();
+}
diff --git a/src/qt/test/wallettests.h b/src/qt/test/wallettests.h
new file mode 100644
index 0000000000..342f7916c3
--- /dev/null
+++ b/src/qt/test/wallettests.h
@@ -0,0 +1,15 @@
+#ifndef BITCOIN_QT_TEST_WALLETTESTS_H
+#define BITCOIN_QT_TEST_WALLETTESTS_H
+
+#include <QObject>
+#include <QTest>
+
+class WalletTests : public QObject
+{
+ Q_OBJECT
+
+private Q_SLOTS:
+ void walletTests();
+};
+
+#endif // BITCOIN_QT_TEST_WALLETTESTS_H
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 878b7d58ae..ebcac53c25 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -706,3 +706,8 @@ int WalletModel::getDefaultConfirmTarget() const
{
return nTxConfirmTarget;
}
+
+bool WalletModel::getDefaultWalletRbf() const
+{
+ return fWalletRbf;
+}
diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h
index cd7585635f..78e45dc369 100644
--- a/src/qt/walletmodel.h
+++ b/src/qt/walletmodel.h
@@ -213,6 +213,8 @@ public:
int getDefaultConfirmTarget() const;
+ bool getDefaultWalletRbf() const;
+
private:
CWallet *wallet;
bool fHaveWatchOnly;
diff --git a/src/rpc/server.h b/src/rpc/server.h
index 68d8a6ec96..ad064e5690 100644
--- a/src/rpc/server.h
+++ b/src/rpc/server.h
@@ -28,7 +28,6 @@ namespace RPCServer
void OnStarted(boost::function<void ()> slot);
void OnStopped(boost::function<void ()> slot);
void OnPreCommand(boost::function<void (const CRPCCommand&)> slot);
- void OnPostCommand(boost::function<void (const CRPCCommand&)> slot);
}
class CBlockIndex;
diff --git a/src/sync.cpp b/src/sync.cpp
index fce57f1df9..552682ab67 100644
--- a/src/sync.cpp
+++ b/src/sync.cpp
@@ -46,8 +46,6 @@ struct CLockLocation {
return mutexName + " " + sourceFile + ":" + itostr(sourceLine) + (fTry ? " (TRY)" : "");
}
- std::string MutexName() const { return mutexName; }
-
bool fTry;
private:
std::string mutexName;
diff --git a/src/sync.h b/src/sync.h
index 3b29050e0e..9274f50d8b 100644
--- a/src/sync.h
+++ b/src/sync.h
@@ -97,7 +97,6 @@ public:
}
};
-typedef CCriticalSection CDynamicCriticalSection;
/** Wrapped boost mutex: supports waiting but not recursive locking */
typedef AnnotatedMixin<boost::mutex> CWaitableCriticalSection;
diff --git a/src/test/key_tests.cpp b/src/test/key_tests.cpp
index 40a7fdf11d..559b3caf1c 100644
--- a/src/test/key_tests.cpp
+++ b/src/test/key_tests.cpp
@@ -29,34 +29,6 @@ static const CBitcoinAddress addr2C("1CRj2HyM1CXWzHAXLQtiGLyggNT9WQqsDs");
static const std::string strAddressBad("1HV9Lc3sNHZxwj4Zk6fB38tEmBryq2cBiF");
-#ifdef KEY_TESTS_DUMPINFO
-void dumpKeyInfo(uint256 privkey)
-{
- CKey key;
- key.resize(32);
- memcpy(&secret[0], &privkey, 32);
- std::vector<unsigned char> sec;
- sec.resize(32);
- memcpy(&sec[0], &secret[0], 32);
- printf(" * secret (hex): %s\n", HexStr(sec).c_str());
-
- for (int nCompressed=0; nCompressed<2; nCompressed++)
- {
- bool fCompressed = nCompressed == 1;
- printf(" * %s:\n", fCompressed ? "compressed" : "uncompressed");
- CBitcoinSecret bsecret;
- bsecret.SetSecret(secret, fCompressed);
- printf(" * secret (base58): %s\n", bsecret.ToString().c_str());
- CKey key;
- key.SetSecret(secret, fCompressed);
- std::vector<unsigned char> vchPubKey = key.GetPubKey();
- printf(" * pubkey (hex): %s\n", HexStr(vchPubKey).c_str());
- printf(" * address (base58): %s\n", CBitcoinAddress(vchPubKey).ToString().c_str());
- }
-}
-#endif
-
-
BOOST_FIXTURE_TEST_SUITE(key_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(key_test1)
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index 32184165f7..c365ad7555 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -455,11 +455,6 @@ public:
{
return comment;
}
-
- const CScript& GetScriptPubKey()
- {
- return creditTx->vout[0].scriptPubKey;
- }
};
std::string JSONPrettyPrint(const UniValue& univalue)
diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp
index 2297644c0b..abaec45cd7 100644
--- a/src/test/test_bitcoin.cpp
+++ b/src/test/test_bitcoin.cpp
@@ -2,8 +2,6 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#define BOOST_TEST_MODULE Bitcoin Test Suite
-
#include "test_bitcoin.h"
#include "chainparams.h"
@@ -27,10 +25,8 @@
#include <memory>
#include <boost/filesystem.hpp>
-#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp>
-std::unique_ptr<CConnman> g_connman;
FastRandomContext insecure_rand_ctx(true);
extern bool fPrintToConsole;
@@ -69,11 +65,14 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
pblocktree = new CBlockTreeDB(1 << 20, true);
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
pcoinsTip = new CCoinsViewCache(pcoinsdbview);
- BOOST_REQUIRE(InitBlockIndex(chainparams));
+ if (!InitBlockIndex(chainparams)) {
+ throw std::runtime_error("InitBlockIndex failed.");
+ }
{
CValidationState state;
- bool ok = ActivateBestChain(state, chainparams);
- BOOST_REQUIRE(ok);
+ if (!ActivateBestChain(state, chainparams)) {
+ throw std::runtime_error("ActivateBestChain failed.");
+ }
}
nScriptCheckThreads = 3;
for (int i=0; i < nScriptCheckThreads-1; i++)
@@ -150,18 +149,3 @@ CTxMemPoolEntry TestMemPoolEntryHelper::FromTx(const CTransaction &txn) {
return CTxMemPoolEntry(MakeTransactionRef(txn), nFee, nTime, nHeight,
spendsCoinbase, sigOpCost, lp);
}
-
-void Shutdown(void* parg)
-{
- exit(EXIT_SUCCESS);
-}
-
-void StartShutdown()
-{
- exit(EXIT_SUCCESS);
-}
-
-bool ShutdownRequested()
-{
- return false;
-}
diff --git a/src/test/test_bitcoin_main.cpp b/src/test/test_bitcoin_main.cpp
new file mode 100644
index 0000000000..34beef5539
--- /dev/null
+++ b/src/test/test_bitcoin_main.cpp
@@ -0,0 +1,26 @@
+// Copyright (c) 2011-2016 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#define BOOST_TEST_MODULE Bitcoin Test Suite
+
+#include "net.h"
+
+#include <boost/test/unit_test.hpp>
+
+std::unique_ptr<CConnman> g_connman;
+
+void Shutdown(void* parg)
+{
+ exit(EXIT_SUCCESS);
+}
+
+void StartShutdown()
+{
+ exit(EXIT_SUCCESS);
+}
+
+bool ShutdownRequested()
+{
+ return false;
+}
diff --git a/src/util.h b/src/util.h
index 87eb16c91b..61dc0d366c 100644
--- a/src/util.h
+++ b/src/util.h
@@ -80,9 +80,9 @@ template<typename... Args> std::string FormatStringFromLogArgs(const char *fmt,
std::string _log_msg_; /* Unlikely name to avoid shadowing variables */ \
try { \
_log_msg_ = tfm::format(__VA_ARGS__); \
- } catch (tinyformat::format_error &e) { \
+ } catch (tinyformat::format_error &fmterr) { \
/* Original format string will have newline so don't add one here */ \
- _log_msg_ = "Error \"" + std::string(e.what()) + "\" while formatting log message: " + FormatStringFromLogArgs(__VA_ARGS__); \
+ _log_msg_ = "Error \"" + std::string(fmterr.what()) + "\" while formatting log message: " + FormatStringFromLogArgs(__VA_ARGS__); \
} \
LogPrintStr(_log_msg_); \
} while(0)
diff --git a/src/wallet/coincontrol.h b/src/wallet/coincontrol.h
index eaf4ff8062..4e93e929be 100644
--- a/src/wallet/coincontrol.h
+++ b/src/wallet/coincontrol.h
@@ -6,6 +6,7 @@
#define BITCOIN_WALLET_COINCONTROL_H
#include "primitives/transaction.h"
+#include "wallet/wallet.h"
/** Coin Control Features. */
class CCoinControl
@@ -24,6 +25,8 @@ public:
CFeeRate nFeeRate;
//! Override the default confirmation target, 0 = use default
int nConfirmTarget;
+ //! Signal BIP-125 replace by fee.
+ bool signalRbf;
CCoinControl()
{
@@ -40,6 +43,7 @@ public:
nFeeRate = CFeeRate(0);
fOverrideFeeRate = false;
nConfirmTarget = 0;
+ signalRbf = fWalletRbf;
}
bool HasSelected() const
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
index 9554f0541e..7ff9e7ae58 100644
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -743,7 +743,7 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6
pwallet->MarkDirty();
- if (!pwallet->HaveWatchOnly(redeemScript) && !pwallet->AddWatchOnly(redeemScript, timestamp)) {
+ if (!pwallet->AddWatchOnly(redeemScript, timestamp)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet");
}
@@ -760,7 +760,7 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6
pwallet->MarkDirty();
- if (!pwallet->HaveWatchOnly(redeemDestination) && !pwallet->AddWatchOnly(redeemDestination, timestamp)) {
+ if (!pwallet->AddWatchOnly(redeemDestination, timestamp)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet");
}
@@ -853,7 +853,7 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6
pwallet->MarkDirty();
- if (!pwallet->HaveWatchOnly(pubKeyScript) && !pwallet->AddWatchOnly(pubKeyScript, timestamp)) {
+ if (!pwallet->AddWatchOnly(pubKeyScript, timestamp)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet");
}
@@ -871,7 +871,7 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6
pwallet->MarkDirty();
- if (!pwallet->HaveWatchOnly(scriptRawPubKey) && !pwallet->AddWatchOnly(scriptRawPubKey, timestamp)) {
+ if (!pwallet->AddWatchOnly(scriptRawPubKey, timestamp)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet");
}
@@ -945,7 +945,7 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6
pwallet->MarkDirty();
- if (!pwallet->HaveWatchOnly(script) && !pwallet->AddWatchOnly(script, timestamp)) {
+ if (!pwallet->AddWatchOnly(script, timestamp)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet");
}
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 9e3c8be3f2..445e40b043 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2517,9 +2517,10 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
// to avoid conflicting with other possible uses of nSequence,
// and in the spirit of "smallest possible change from prior
// behavior."
+ bool rbf = coinControl ? coinControl->signalRbf : fWalletRbf;
for (const auto& coin : setCoins)
txNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second,CScript(),
- std::numeric_limits<unsigned int>::max() - (fWalletRbf ? 2 : 1)));
+ std::numeric_limits<unsigned int>::max() - (rbf ? 2 : 1)));
// Fill in dummy signatures for fee calculation.
if (!DummySignTx(txNew, setCoins)) {
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 80201e8ce0..ae4321eef8 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -725,6 +725,7 @@ public:
nLastResend = 0;
nTimeFirstKey = 0;
fBroadcastTransactions = false;
+ nRelockTime = 0;
}
std::map<uint256, CWalletTx> mapWallet;