...
 
Commits (193)
Makefile
*.cmake
*.a
CMakeCache.txt
CMakeFiles
include/
lib/
\ No newline at end of file
......@@ -6,7 +6,6 @@ stages:
- deploy
variables:
HUB_IMG: flowee/hub
PACKAGE_NAME: flowee-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}
##### Debian stable
......@@ -24,7 +23,7 @@ build-debian-stable:
paths:
- bin
- build/testing/*/test_*
expire_in: 10 hrs
expire_in: 100 hrs
test_utxo:
stage: test
......@@ -33,6 +32,12 @@ test_utxo:
dependencies:
- build-debian-stable
test_api:
stage: test
script: build/testing/api/test_api bin/hub
dependencies:
- build-debian-stable
test_prevector:
stage: test
script: build/testing/prevector/test_prevector
......@@ -86,7 +91,7 @@ build-static:
- bin
- etc/flowee
- systemd
expire_in: 1 hrs
expire_in: 100 hrs
flowee-deb:
stage: deploy
......@@ -102,9 +107,6 @@ flowee-deb:
- dpkg-deb --build $PACKAGE_NAME
dependencies:
- build-static
only:
- master
- "2019.05"
artifacts:
paths:
- ${PACKAGE_NAME}.deb
......@@ -121,25 +123,6 @@ flowee-linux.zip:
- ${PACKAGE_NAME}
dependencies:
- build-static
only:
- master
- "2019.05"
createHubDocker:
stage: deploy
script:
- docker login -u flowee -p $DOCKER_TOKEN
- mv bin support/docker/hub
- docker build --tag=$HUB_IMG:${CI_COMMIT_REF_NAME} support/docker/hub
- docker image push $HUB_IMG:${CI_COMMIT_REF_NAME}
- docker tag $HUB_IMG:${CI_COMMIT_REF_NAME} $HUB_IMG:latest
- docker push $HUB_IMG:latest
image: docker:latest
services:
- docker:dind
dependencies:
- build-static
allow_failure: true
##### Build as standard as it gets.
......
......@@ -14,18 +14,18 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required (VERSION 3.0.2)
cmake_minimum_required (VERSION 3.13)
project (Flowee)
set(COPYRIGHT_YEAR 2019)
set(CLIENT_VERSION_MAJOR ${COPYRIGHT_YEAR})
set(CLIENT_VERSION_MINOR 5)
set(CLIENT_VERSION_MINOR 7)
set(CLIENT_VERSION_REVISION 1)
set(HUB_SERIES 1)
# ------------------------------------------------------------------------------------
set(CLIENT_VERSION_IS_RELEASE 1)
set(CLIENT_VERSION_IS_RELEASE 0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/support/cmake)
......@@ -61,7 +61,7 @@ option(dev_setup "Enable developer build, not safe for real-life usage!" OFF)
option(build_tests "Compile the unit tests" ${dev_setup})
if (dev_setup)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DBTC_LOGCONTEXT -DUSE_UNSAFE_RANDOM -DENABLE_CRASH_CATCHER")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DBCH_LOGCONTEXT -DUSE_UNSAFE_RANDOM -DENABLE_CRASH_CATCHER")
message(STATUS "Setting built type to Debug, with unsafe random and other dev options.")
elseif (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'ReleaseWithDebugInfo' as none was specified.")
......@@ -93,37 +93,88 @@ if (mark_release)
endif ()
endif ()
######################
#### Include hierarchy
######################
set(UNIVALUE_LIBRARY "${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}univalue${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(LEVELDB_LIBRARY
"${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}leveldb${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}memenv${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
set(SECP256K1_LIBRARY "${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}secp256k1${CMAKE_STATIC_LIBRARY_SUFFIX}")
# required packages below this
message ("===== Find required dependencies")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl@1.1/")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/usr/local/opt/qt")
endif()
# define the include dirs for each section
set(3RDPARTY_INCLUDES ${CMAKE_BINARY_DIR}/include)
find_package(OpenSSL REQUIRED)
message ("Using OpenSSL ${OPENSSL_VERSION}")
set(LIBCRYPTO_INCLUDES
${3RDPARTY_INCLUDES}
${OPENSSL_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/libs/crypto
${CMAKE_SOURCE_DIR}/libs
find_package(Boost 1.67.0
REQUIRED
chrono filesystem iostreams program_options system thread ${boost_test_lib}
)
set(LIBUTILS_INCLUDES ${LIBCRYPTO_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/utils ${CMAKE_SOURCE_DIR}/libs/interfaces)
set(LIBNETWORKMANAGER_INCLUDES ${LIBUTILS_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/networkmanager)
set(LIBAPPUTILS_INCLUDES ${LIBNETWORKMANAGER_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/apputils)
set(LIBUTXO_INCLUDES ${LIBUTILS_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/utxo)
set(LIBCONSOLE_INCLUDES ${LIBUTILS_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/console)
if (enable_wallet)
find_package(BerkeleyDB REQUIRED)
message ("NOTICE: txVulcano is not compiled when wallet is enabled")
endif ()
# these two should only ever be used by the hub hub-qt and the unit tests.
set(LIBSERVER_INCLUDES ${LIBNETWORKMANAGER_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/server ${CMAKE_SOURCE_DIR}/libs/server/wallet)
set(LIBAPI_INCLUDES ${LIBSERVER_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/api)
# Since our 3rd party require this, lets give a nice warning here.
find_program(AUTOCONF autoconf)
if (NOT AUTOCONF)
message ("ERROR: autoconf is required for 3rd-party libraries compilation.")
endif()
find_package(Event REQUIRED)
message ("===== Find optional dependencies")
find_package(ZeroMQ 4.0)
if (${ZMQ_FOUND})
set (ENABLE_ZMQ 1)
else ()
# remove "NOTFOUND" so we can just link to it, which then is a no-op
set (ZMQ_LIBRARIES "")
endif ()
find_package(Miniupnpc)
if (${MINIUPNP_FOUND})
set (USE_UPNP 1)
else ()
set (MINIUPNP_LIBRARY "")
endif ()
find_package(QREncode)
if (${QREncode_FOUND})
set (USE_QRCODE 1)
else ()
set (QREncode_LIBRARIES "")
endif()
find_package(Qt5Core)
if (${Qt5Core_FOUND})
message("-- Qt5 found, version ${Qt5Core_VERSION_STRING}")
find_package(Qt5Network)
else()
message("Missing qt5 (core) library, not building pos, hub-qt, txVulcano")
set (enable_gui FALSE)
endif()
if (enable_gui)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Qt GUI apps require bundles on Mac, needs work to support
message("GUIs not supported on MacOS (yet).")
set (enable_gui FALSE)
else ()
find_package(Qt5Widgets)
if (NOT ${Qt5Widgets_FOUND})
message("Missing Qt5 (widgets) library, not building hub-qt")
set (enable_gui FALSE)
endif ()
endif ()
endif ()
if (enable_gui)
find_package(Qt5DBus)
if (${Qt5DBus_FOUND})
set (USE_DBUS 1)
endif ()
endif ()
######################
#### Generate config.h
......@@ -163,22 +214,12 @@ set (WORDS_BIGENDIAN ${CMAKE_WORDS_BIGENDIAN})
include (TestBigEndian)
test_big_endian(CMAKE_WORDS_BIGENDIAN)
include(CheckCSourceCompiles)
check_c_source_compiles(
"#include <string.h>
int main() {
char buffer[1];
char* c = strerror_r(0, buffer, 0);
(void)c;
}
"
STRERROR_R_CHAR_P)
include(CheckCXXSourceCompiles)
# older cmake doesn't set C++11 flags, do it ourselves.
set (_V "CPP11_ARGS")
foreach (ARG "" "-std=gnu++11" "-std=c++11")
set (CMAKE_REQUIRED_FLAGS ${ARG})
check_c_source_compiles(
check_cxx_source_compiles(
"#if __cplusplus < 201103L
# error
#endif
......@@ -192,73 +233,15 @@ foreach (ARG "" "-std=gnu++11" "-std=c++11")
set (_V "${_V}_")
endforeach()
message ("===== Find optional dependencies")
find_package(ZeroMQ 4.0)
if (${ZMQ_FOUND})
set (ENABLE_ZMQ 1)
else ()
# remove "NOTFOUND" so we can just link to it, which then is a no-op
set (ZMQ_LIBRARIES "")
endif ()
find_package(Miniupnpc)
if (${MINIUPNP_FOUND})
set (USE_UPNP 1)
else ()
set (MINIUPNP_LIBRARY "")
endif ()
find_package(QREncode)
if (${QREncode_FOUND})
set (USE_QRCODE 1)
else ()
set (QREncode_LIBRARIES "")
endif()
find_package(Qt5Core)
if (${Qt5Core_FOUND})
message("-- Qt5 found, version ${Qt5Core_VERSION_STRING}")
find_package(Qt5Network)
else()
message("Missing qt5 (core) library, not building pos, hub-qt, txVulcano")
set (enable_gui FALSE)
endif()
if (enable_gui)
find_package(Qt5Widgets)
if (NOT ${Qt5Widgets_FOUND})
message("Missing qt5 (widgets) library, not building hub-qt")
set (enable_gui FALSE)
endif ()
endif ()
if (enable_gui)
find_package(Qt5DBus)
if (${Qt5DBus_FOUND})
set (USE_DBUS 1)
endif ()
endif ()
# required packages below this
message ("===== Find required dependencies")
find_package(Boost 1.56.0
REQUIRED
chrono filesystem iostreams program_options system thread ${boost_test_lib}
)
if (enable_wallet)
find_package(BerkeleyDB REQUIRED)
message ("NOTICE: txVulcano is not compiled when wallet is enabled")
endif ()
# Since our 3rd party require this, lets give a nice warning here.
find_program(AUTOCONF autoconf)
if (NOT AUTOCONF)
message ("ERROR: autoconf is required for 3rd-party libraries compilation.")
endif()
find_package(Event REQUIRED)
check_cxx_source_compiles(
"#include <string.h>
int main() {
char buffer[10];
const char* c = strerror_r(0, buffer, 3);
(void)c;
}
"
STRERROR_R_CHAR_P)
configure_file (
"${CMAKE_SOURCE_DIR}/libs/config/flowee-config.h.in"
......@@ -275,6 +258,41 @@ add_definitions(-DHAVE_CONFIG_H -DHAVE_BUILD_INFO)
# no-deprecated is needed for dbwrapper (leveldb)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wvla -pthread -Wno-deprecated ")
######################
#### Include hierarchy
######################
set(UNIVALUE_LIBRARY "${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}univalue${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(LEVELDB_LIBRARY
"${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}leveldb${CMAKE_STATIC_LIBRARY_SUFFIX}"
"${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}memenv${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
set(SECP256K1_LIBRARY "${CMAKE_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}secp256k1${CMAKE_STATIC_LIBRARY_SUFFIX}")
# define the include dirs for each section
set(3RDPARTY_INCLUDES)
set(LIBCRYPTO_INCLUDES
${3RDPARTY_INCLUDES}
${Boost_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/libs/crypto
${CMAKE_SOURCE_DIR}/libs
)
message ("OpenSSL includes: ${OPENSSL_INCLUDE_DIR}")
set(LIBUTILS_INCLUDES ${LIBCRYPTO_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/utils ${CMAKE_SOURCE_DIR}/libs/interfaces)
set(LIBNETWORKMANAGER_INCLUDES ${LIBUTILS_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/networkmanager)
set(LIBAPPUTILS_INCLUDES ${LIBNETWORKMANAGER_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/apputils)
set(LIBUTXO_INCLUDES ${LIBUTILS_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/utxo)
set(LIBCONSOLE_INCLUDES ${LIBUTILS_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/console)
# these two should only ever be used by the hub hub-qt and the unit tests.
set(LIBSERVER_INCLUDES ${LIBNETWORKMANAGER_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/server ${CMAKE_SOURCE_DIR}/libs/server/wallet)
set(LIBAPI_INCLUDES ${LIBSERVER_INCLUDES} ${CMAKE_SOURCE_DIR}/libs/api)
add_subdirectory(libs)
add_subdirectory(hub)
add_subdirectory(hub-cli)
......
The MIT License (MIT)
Copyright (c) 2009-2010 Satoshi Nakamoto
Copyright (c) 2009-2015 The Bitcoin Core developers
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
......@@ -3,6 +3,20 @@ Flowee the Hub repository
[![pipeline status](https://gitlab.com/FloweeTheHub/thehub/badges/master/pipeline.svg)](https://gitlab.com/FloweeTheHub/thehub/commits/master)
# Flowee is a series of applications to get the most out of Bitcoin Cash (BCH)
See more details on https://flowee.org/about/
This repository contains
* the Hub: the headless (server) Bitcoin Cash node software
* Hub-qt: a GUI version of the Hub
* Indexer: Provides various data-stores to speed up lookups on the blockchain.
* pos / cachier: a beta version of the point-of-sale application.
* Libraries shared between many of the Flowee applications.
# Building a Hub that connects you to Bitcoin Cash
Bitcoin Cash is
......@@ -19,29 +33,40 @@ compatibility issues. Flowee is adjusted for greatly increased speed and
reliability as well as for scaling up to much larger blocks than the
competition.
The libs/httpengine directory is LGPL licensed as this is derived from the
qhttpengine open source project.
The original Satoshi codebase was MIT licensed. This has been combined with
copyrighted works from Tom Zander which are GPLv3 licensed with the result
that those files are new licensed under the GPLv3.
# Installation
The fastest way to try Flowee is by installing docker. See more details [here](support/docker/hub).
To compile and install Flowee on Ubuntu, install the dependencies
`sudo apt install libevent-dev libboost-all-dev libminiupnpc-dev qt5-default protobuf-compiler libprotobuf-dev`
`sudo apt install libevent-dev libboost-all-dev libminiupnpc-dev qt5-default protobuf-compiler libprotobuf-dev pkgconf`
Then clone the repo and use cmake to create the makefile
To compile and install Flowee on MacOS, install the dependencies
`cmake CMakeLists.txt`
`brew install cmake libevent boost miniupnpc qt protobuf pkg-config`
`make`
Then clone the repo and use cmake to create the makefile
`make install`
```
mkdir thehub/build
cd thehub/build
cmake CMakeLists.txt ..
make
make install
```
# More details
* https://www.flowee.org
* https://flowee.org
* https://gitlab.com/FloweeTheHub/thehub
# Social
* Twitter: https://twitter.com/floweethehub
* Discord: https://discord.gg/WXPcf6G
* Email group: https://groups.google.com/d/forum/flowee
......@@ -17,8 +17,7 @@
project (hub-cli)
include_directories(. ${LIBS_INCLUDES})
include_directories(${LIBSERVER_INCLUDES} ${LIBCONSOLE_INCLUDES})
include_directories(${LIBSERVER_INCLUDES} ${LIBCONSOLE_INCLUDES} ${CMAKE_BINARY_DIR}/include)
set (CLI_LIBS
flowee_server
......
......@@ -22,7 +22,7 @@
#include "clientversion.h"
#include "rpcclient.h"
#include "rpcprotocol.h"
#include "util.h"
#include <serverutil.h>
#include "utilstrencodings.h"
#include <boost/filesystem/operations.hpp>
......
......@@ -23,7 +23,7 @@ set_property(SOURCE qrc_bitcoin.cpp PROPERTY SKIP_AUTOGEN ON)
set_property(SOURCE paymentrequest.pb.cc PROPERTY SKIP_AUTOGEN ON)
set_property(SOURCE paymentrequest.pb.h PROPERTY SKIP_AUTOGEN ON)
include_directories(${LIBAPI_INCLUDES} ${LIBCONSOLE_INCLUDES})
include_directories(${LIBAPI_INCLUDES} ${LIBCONSOLE_INCLUDES} ${CMAKE_BINARY_DIR}/include)
set (HUB_QT_LIBS
flowee_api
......@@ -31,7 +31,6 @@ set (HUB_QT_LIBS
flowee_networkmanager
flowee_console
flowee_utils
flowee_crypto
${LEVELDB_LIBRARY}
${SECP256K1_LIBRARY}
......@@ -42,7 +41,6 @@ set (HUB_QT_LIBS
${BERKELEY_DB_LIBRARIES}
${MINIUPNP_LIBRARY}
${OPENSSL_LIBRARIES}
${BOOST_THREAD_LIBRARY}
${QREncode_LIBRARIES}
)
......
......@@ -44,7 +44,7 @@
#include "rpcserver.h"
#include "scheduler.h"
#include "UiInterface.h"
#include "util.h"
#include <serverutil.h>
#include <SettingsDefaults.h>
#ifdef ENABLE_WALLET
......@@ -106,6 +106,16 @@ static void InitMessage(const std::string &message)
logCritical(Log::Bitcoin) << "init message:" << message;
}
/** Signals for translation. */
class CTranslationInterface
{
public:
/** Translate a message to the native language of the user. */
boost::signals2::signal<std::string (const char* psz)> Translate;
};
CTranslationInterface translationInterface;
/*
Translate string to current locale using Qt.
*/
......
/*
* This file is part of the Flowee project
* Copyright (c) 2011-2014 The Bitcoin Core developers
* Copyright (C) 2017 Tom Zander <tomz@freedommail.ch>
* Copyright (C) 2017,2019 Tom Zander <tomz@freedommail.ch>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -22,6 +22,7 @@
#include <encodings_legacy.h>
#include <Application.h>
#include <cashaddr.h>
/* Base58 characters are:
"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
......@@ -45,9 +46,16 @@ QValidator::State BitcoinAddressEntryValidator::validate(QString &input, int &po
if (input.isEmpty())
return QValidator::Intermediate;
enum Type {
Old,
Cash
};
static const QString CashPrefix = "bitcoincash:";
Type type = (input.startsWith('q') || input.startsWith('p')
|| input.startsWith(CashPrefix.left(10))) ? Cash : Old;
// Correction
for (int idx = 0; idx < input.size();)
{
for (int idx = 0; idx < input.size();) {
bool removeChar = false;
QChar ch = input.at(idx);
// Corrections made are very conservative on purpose, to avoid
......@@ -69,32 +77,41 @@ QValidator::State BitcoinAddressEntryValidator::validate(QString &input, int &po
removeChar = true;
// To next character
if (removeChar)
if (removeChar) {
input.remove(idx, 1);
else
} else {
if (type == Cash && ch.isUpper())
input[idx] = input.at(idx).toLower();
++idx;
}
}
// Validation
QValidator::State state = QValidator::Acceptable;
for (int idx = 0; idx < input.size(); ++idx)
{
int idx = 0;
if (type == Cash) { // skip over the 'bitcoincash:' prefix
QString left = input.left(12);
if (CashPrefix.left(left.size()) == left)
idx = left.size();
}
for (; idx < input.size(); ++idx) {
int ch = input.at(idx).unicode();
if (((ch >= '0' && ch<='9') ||
(ch >= 'a' && ch<='z') ||
(ch >= 'A' && ch<='Z')) &&
ch != 'l' && ch != 'I' && ch != '0' && ch != 'O')
{
switch (type) {
case Old:
// Alphanumeric and not a 'forbidden' character
}
else
{
state = QValidator::Invalid;
if (!(((ch >= '0' && ch<='9') || (ch >= 'a' && ch<='z') || (ch >= 'A' && ch<='Z'))
&& ch != 'l' && ch != 'I' && ch != '0' && ch != 'O'))
return QValidator::Invalid;
break;
case Cash:
if (!(((ch >= '0' && ch<='9') || (ch >= 'a' && ch<='z'))
&& ch != 'i' && ch != 'b' && ch != 'i' && ch != 'o'))
return QValidator::Invalid;
break;
}
}
return state;
return QValidator::Acceptable;
}
BitcoinAddressCheckValidator::BitcoinAddressCheckValidator(QObject *parent) :
......@@ -110,5 +127,9 @@ QValidator::State BitcoinAddressCheckValidator::validate(QString &input, int &po
if (addr.IsValid())
return QValidator::Acceptable;
CashAddress::Content c = CashAddress::decodeCashAddrContent(input.toStdString(), "bitcoincash");
if ((c.type == CashAddress::PUBKEY_TYPE || c.type == CashAddress::SCRIPT_TYPE) && c.hash.size() == 20)
return QValidator::Acceptable;
return QValidator::Invalid;
}
......@@ -489,7 +489,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
}
}
QString sPriorityLabel = tr("none");
QString sPriorityLabel = tr("fine");
CAmount nAmount = 0;
CAmount nPayFee = 0;
CAmount nAfterFee = 0;
......@@ -500,7 +500,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
double dPriorityInputs = 0;
unsigned int nQuantity = 0;
int nQuantityUncompressed = 0;
bool fAllowFree = false;
bool fAllowFree = true;
std::vector<COutPoint> vCoinControl;
std::vector<COutput> vOutputs;
......@@ -551,11 +551,6 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
// Bytes
nBytes = nBytesInputs + ((CoinControlDialog::payAmounts.size() > 0 ? CoinControlDialog::payAmounts.size() + 1 : 2) * 34) + 10; // always assume +1 output for change here
// Priority
double mempoolEstimatePriority = mempool.estimateSmartPriority(nTxConfirmTarget);
dPriority = dPriorityInputs / (nBytes - nBytesInputs + (nQuantityUncompressed * 29)); // 29 = 180 - 151 (uncompressed public keys are over the limit. max 151 bytes of the input are ignored for priority)
sPriorityLabel = CoinControlDialog::getPriorityLabel(dPriority, mempoolEstimatePriority);
// in the subtract fee from amount case, we can tell if zero change already and subtract the bytes, so that fee calculation afterwards is accurate
if (CoinControlDialog::fSubtractFeeFromAmount)
if (nAmount - nPayAmount == 0)
......@@ -567,10 +562,6 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
nPayFee = coinControl->nMinimumTotalFee;
// Allow free? (require at least hard-coded threshold and default to that if no estimate)
double dPriorityNeeded = std::max(mempoolEstimatePriority, AllowFreeThreshold());
fAllowFree = (dPriority >= dPriorityNeeded);
if (fSendFreeTransactions)
if (fAllowFree && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE)
nPayFee = 0;
......@@ -660,21 +651,9 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
QString toolTip3 = tr("This label turns red if any recipient receives an amount smaller than %1.").arg(BitcoinUnits::formatHtmlWithUnit(nDisplayUnit, ::minRelayTxFee.GetFee(546)));
// how many satoshis the estimated fee can vary per byte we guess wrong
double dFeeVary;
if (payTxFee.GetFeePerK() > 0)
dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000), payTxFee.GetFeePerK()) / 1000;
else {
dFeeVary = (double)std::max(CWallet::GetRequiredFee(1000), mempool.estimateSmartFee(nTxConfirmTarget).GetFeePerK()) / 1000;
}
QString toolTip4 = tr("Can vary +/- %1 satoshi(s) per input.").arg(dFeeVary);
l3->setToolTip(toolTip4);
l4->setToolTip(toolTip4);
l5->setToolTip(toolTip1);
l6->setToolTip(toolTip2);
l7->setToolTip(toolTip3);
l8->setToolTip(toolTip4);
dialog->findChild<QLabel *>("labelCoinControlFeeText") ->setToolTip(l3->toolTip());
dialog->findChild<QLabel *>("labelCoinControlAfterFeeText") ->setToolTip(l4->toolTip());
dialog->findChild<QLabel *>("labelCoinControlBytesText") ->setToolTip(l5->toolTip());
......@@ -702,7 +681,6 @@ void CoinControlDialog::updateView()
QFlags<Qt::ItemFlag> flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsTristate;
int nDisplayUnit = model->getOptionsModel()->getDisplayUnit();
double mempoolEstimatePriority = mempool.estimateSmartPriority(nTxConfirmTarget);
std::map<QString, std::vector<COutput> > mapCoins;
model->listCoins(mapCoins);
......@@ -790,7 +768,7 @@ void CoinControlDialog::updateView()
// priority
double dPriority = ((double)out.tx->vout[out.i].nValue / (nInputSize + 78)) * (out.nDepth+1); // 78 = 2 * 34 + 10
itemOutput->setText(COLUMN_PRIORITY, CoinControlDialog::getPriorityLabel(dPriority, mempoolEstimatePriority));
itemOutput->setText(COLUMN_PRIORITY, CoinControlDialog::getPriorityLabel(dPriority, -1));
itemOutput->setText(COLUMN_PRIORITY_INT64, strPad(QString::number((int64_t)dPriority), 20, " "));
dPrioritySum += (double)out.tx->vout[out.i].nValue * (out.nDepth+1);
nInputSum += nInputSize;
......@@ -823,7 +801,6 @@ void CoinControlDialog::updateView()
itemWalletAddress->setText(COLUMN_CHECKBOX, "(" + QString::number(nChildren) + ")");
itemWalletAddress->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, nSum));
itemWalletAddress->setText(COLUMN_AMOUNT_INT64, strPad(QString::number(nSum), 15, " "));
itemWalletAddress->setText(COLUMN_PRIORITY, CoinControlDialog::getPriorityLabel(dPrioritySum, mempoolEstimatePriority));
itemWalletAddress->setText(COLUMN_PRIORITY_INT64, strPad(QString::number((int64_t)dPrioritySum), 20, " "));
}
}
......
/*
* This file is part of the Flowee project
* Copyright (c) 2011-2015 The Bitcoin Core developers
* Copyright (C) 2017 Tom Zander <tomz@freedommail.ch>
* Copyright (C) 2017,2019 Tom Zander <tomz@freedommail.ch>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -71,6 +71,7 @@
#include <QSettings>
#include <QTextDocument> // for Qt::mightBeRichText
#include <QThread>
#include <cashaddr.h>
#if QT_VERSION < 0x050000
#include <QUrl>
......@@ -131,7 +132,7 @@ void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent)
#if QT_VERSION >= 0x040700
// We don't want translators to use own addresses in translations
// and this is the only place, where this address is supplied.
widget->setPlaceholderText(QObject::tr("Enter a Bitcoin address (e.g. %1)").arg("1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L"));
widget->setPlaceholderText(QObject::tr("Enter a Bitcoin address (e.g. %1)").arg("qpgn5ka4jptc98a9ftycvujxx33e79nxuqlz5mvxns"));
#endif
widget->setValidator(new BitcoinAddressEntryValidator(parent));
widget->setCheckValidator(new BitcoinAddressCheckValidator(parent));
......@@ -984,9 +985,19 @@ QString uriPrefix()
QString convertCashBitcoinAddress(const QString &address)
{
CBitcoinAddress orig(address.toStdString());
if (!orig.IsValid()) {
// TODO attempt convert from cashaddress
CashAddress::Content c = CashAddress::decodeCashAddrContent(address.toStdString(), "bitcoincash");
if (c.type == CashAddress::PUBKEY_TYPE && c.hash.size() == 20) {
CKeyID id(reinterpret_cast<const char*>(&c.hash[0]));
orig.Set(id);
return QString::fromStdString(orig.ToString());
}
if (c.type == CashAddress::SCRIPT_TYPE && c.hash.size() == 20) {
uint160 bytes(reinterpret_cast<const char*>(&c.hash[0]));
CScriptID id(bytes);
orig.Set(id);
return QString::fromStdString(orig.ToString());
}
}
return address;
}
......
......@@ -27,6 +27,7 @@
#include "amount.h"
#include "init.h"
#include "util.h"
#include "main.h" // For DEFAULT_SCRIPTCHECK_THREADS
#include "net.h"
#include "policy/policy.h" // for DEFAULT_BLOCK_ACCEPT_SIZE
......
......@@ -841,7 +841,7 @@ void RPCConsole::banSelectedNode(int bantime)
if (CNode *bannedNode = FindNode(strNode.toStdString())) {
std::string nStr = strNode.toStdString();
std::string addr;
int port = 0;
uint16_t port = 0;
SplitHostPort(nStr, port, addr);
CNode::Ban(CNetAddr(addr), BanReasonManuallyAdded, bantime);
......
......@@ -215,16 +215,8 @@ void SendCoinsDialog::on_sendButton_clicked()
if(!model || !model->getOptionsModel())
return;
if (Application::uahfChainState() == Application::UAHFWaiting) {
QMessageBox::information(this, tr("Unsafe to create transaction"),
"You selected this wallet to operate on the BCH network, which is not active yet. Please wait until activation.",
QMessageBox::Ok);
return;
}
QList<SendCoinsRecipient> recipients;
bool valid = true;
for(int i = 0; i < ui->entries->count(); ++i)
{
SendCoinsEntry *entry = qobject_cast<SendCoinsEntry*>(ui->entries->itemAt(i)->widget());
......@@ -658,23 +650,10 @@ void SendCoinsDialog::updateSmartFeeLabel()
if(!model || !model->getOptionsModel())
return;
int nBlocksToConfirm = defaultConfirmTarget - ui->sliderSmartFee->value();
int estimateFoundAtBlocks = nBlocksToConfirm;
CFeeRate feeRate = mempool.estimateSmartFee(nBlocksToConfirm, &estimateFoundAtBlocks);
if (feeRate <= CFeeRate(0)) // not enough data => minfee
{
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(),
std::max(CWallet::fallbackFee.GetFeePerK(), CWallet::GetRequiredFee(1000))) + "/kB");
ui->labelSmartFee2->show(); // (Smart fee not initialized yet. This usually takes a few blocks...)
ui->labelFeeEstimation->setText("");
}
else
{
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(),
std::max(feeRate.GetFeePerK(), CWallet::GetRequiredFee(1000))) + "/kB");
ui->labelSmartFee2->hide();
ui->labelFeeEstimation->setText(tr("Estimated to begin confirmation within %n block(s).", "", estimateFoundAtBlocks));
}
ui->labelSmartFee->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(),
CWallet::GetRequiredFee(1000)) + "/kB");
ui->labelSmartFee2->hide();
ui->labelFeeEstimation->setText("Estimated to begin confirmation within 1 block(s).");
updateFeeMinimizedLabel();
}
......
......@@ -16,15 +16,13 @@
project (hub)
include_directories(${LIBAPI_INCLUDES} ${LIBCONSOLE_INCLUDES})
include_directories(${LIBAPI_INCLUDES} ${LIBCONSOLE_INCLUDES} ${CMAKE_BINARY_DIR}/include)
set (HUB_LIBS
flowee_api
flowee_server
flowee_networkmanager
flowee_console
flowee_utils
flowee_crypto
${LEVELDB_LIBRARY}
${SECP256K1_LIBRARY}
......
......@@ -24,7 +24,7 @@
#include "init.h"
#include "noui.h"
#include "scheduler.h"
#include "util.h"
#include <serverutil.h>
#include "httpserver.h"
#include "httprpc.h"
#include "rpcserver.h"
......
This diff is collapsed.
......@@ -19,27 +19,35 @@
#define ADDRESSINDEXER_H
#include <QList>
#include <qobject.h>
#include <QThread>
#include <qsqldatabase.h>
#include <qsqlquery.h>
#include <streaming/ConstBuffer.h>
#include "HashStorage.h"
#include <boost/filesystem/path.hpp>
class QSettings;
class DirtyData;
class Indexer;
class TableSpecification;
class AddressIndexer : public QObject
class AddressIndexer : public QThread
{
Q_OBJECT
public:
AddressIndexer(const boost::filesystem::path &basedir);
AddressIndexer(const boost::filesystem::path &basedir, Indexer *datasource);
~AddressIndexer() override;
void loadSetting(const QSettings &settings);
int blockheight();
void blockFinished(int blockheight, const uint256 &blockId);
void insert(const Streaming::ConstBuffer &addressId, int outputIndex, int blockHeight, int offsetInBlock);
void reachedTopOfChain();
struct TxData {
int offsetInBlock = 0;
int blockHeight = -1;
......@@ -48,37 +56,11 @@ public:
std::vector<TxData> find(const uint160 &address) const;
bool isCommitting() const;
void flush();
signals:
void finishedProcessingBlock();
private slots:
void commitFinished(int blockHeight);
void createNewDirtyData();
void run() override;
private:
void createTables();
DirtyData *m_dirtyData = nullptr;
HashStorage m_addresses;
QString m_basedir;
QSqlDatabase m_db;
QList<QSqlQuery> m_insertQuery;
int m_lastKnownHeight = -1;
bool m_isCommitting = false; // if there is DirtyData running in another thread committing stuff
};
class DirtyData : public QObject {
Q_OBJECT
public:
DirtyData(QObject *parent, QSqlDatabase *db);
void commitAllData();
struct Entry {
short outIndex;
......@@ -86,18 +68,24 @@ public:
};
std::vector<std::deque<Entry> > m_uncommittedData;
int m_uncommittedCount = 0;
int m_height = -1;
void setHeight(int height);
public slots:
void commitAllData();
HashStorage m_addresses;
QString m_basedir;
Indexer *m_dataSource;
signals:
void finished(int height);
QSqlDatabase m_insertDb;
QSqlDatabase m_selectDb;
QList<QSqlQuery> m_insertQuery;
QAtomicInt m_flushRequested;
enum TopOfChain {
InInitialSync = 0,
InitialSyncFinished = 1,
FlushRequested = 2
};
QAtomicInt m_topOfChain;
private:
int m_height;
QSqlDatabase *m_db;
TableSpecification *m_spec = nullptr;
};
#endif
......@@ -24,17 +24,16 @@ add_definitions(-DLOG_DEFAULT_SECTION=8000)
find_package(Qt5Sql)
include_directories(${LIBAPPUTILS_INCLUDES} ${LIBUTXO_INCLUDES})
include_directories(${LIBAPPUTILS_INCLUDES} ${LIBUTXO_INCLUDES} ${CMAKE_BINARY_DIR}/include)
set (IDX_LIBS
flowee_utxo
flowee_apputils
flowee_networkmanager
flowee_apputils
flowee_utils
${OPENSSL_LIBRARIES}
${Boost_LIBRARIES}
${BOOST_THREAD_LIBRARY}
)
if (${Qt5Sql_FOUND})
......@@ -43,6 +42,7 @@ if (${Qt5Sql_FOUND})
AddressIndexer.cpp
HashStorage.cpp
Indexer.cpp
SpentOuputIndexer.cpp
TxIndexer.cpp
)
......
This diff is collapsed.
......@@ -18,60 +18,86 @@
#ifndef INDEXER_H
#define INDEXER_H
#include "AddressIndexer.h"
#include "TxIndexer.h"
#include <QString>
#include <Message.h>
#include <NetworkManager.h>
#include <NetworkService.h>
#include <QMutex>
#include <QWaitCondition>
#include <WorkerThreads.h>
#include <qtimer.h>
class AddressIndexer;
class TxIndexer;
class SpentOutputIndexer;
class Indexer : public QObject, public NetworkService
{
Q_OBJECT
public:
Indexer(const boost::filesystem::path &basedir);
~Indexer();
~Indexer() override;
/// connect to server
void tryConnectHub(const EndPoint &ep);
/// listen to incoming requests
void bind(boost::asio::ip::tcp::endpoint endpoint);
void bind(const boost::asio::ip::tcp::endpoint &endpoint);
void loadConfig(const QString &filename);
/// load config, if prioHubLocation is valid prefer that one.
void loadConfig(const QString &filename, const EndPoint &prioHubLocation);