From bf2225622b5c3805997d5c63da9b1a7ce882af00 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 21:02:15 -0400 Subject: [PATCH 001/469] Update qt.mk --- depends/packages/qt.mk | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 9579f605..0588caf1 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -1,9 +1,9 @@ PACKAGE=qt -$(package)_version=5.7.1 -$(package)_download_path=https://download.qt.io/new_archive/qt/5.7/$($(package)_version)/submodules -$(package)_suffix=opensource-src-$($(package)_version).tar.gz +$(package)_version=5.15.0 +$(package)_download_path=https://download.qt.io/official_releases/qt/5.15/$($(package)_version)/submodules +$(package)_suffix=qtbase-everywhere-src-$($(package)_version).tar.gz $(package)_file_name=qtbase-$($(package)_suffix) -$(package)_sha256_hash=95f83e532d23b3ddbde7973f380ecae1bac13230340557276f75f2e37984e410 +$(package)_sha256_hash=9e7af10aece15fa9500369efde69cb220eee8ec3a6818afe01ce1e7d484824c5 $(package)_dependencies=openssl zlib $(package)_linux_dependencies=freetype fontconfig libxcb libX11 xproto libXext $(package)_build_subdir=qtbase @@ -14,11 +14,11 @@ $(package)_patches+=fix_qt_configure.patch fix_qt_pkgconfig.patch fix-cocoahelpe # Remove it after bumping $(package)_version to 5.8+. $(package)_qttranslations_file_name=qttranslations-$($(package)_suffix) -$(package)_qttranslations_sha256_hash=3a15aebd523c6d89fb97b2d3df866c94149653a26d27a00aac9b6d3020bc5a1d +$(package)_qttranslations_sha256_hash=45c43268d9df50784d4d8ca345fce9288a1055fd074ac0ef508097f7aeba22fe $(package)_qttools_file_name=qttools-$($(package)_suffix) -$(package)_qttools_sha256_hash=22d67de915cb8cd93e16fdd38fa006224ad9170bd217c2be1e53045a8dd02f0f +$(package)_qttools_sha256_hash=ddbcb49aab3a2e3672582c6e2e7bec0058feff790f67472343c79e2895e0e437 $(package)_extra_sources = $($(package)_qttranslations_file_name) $(package)_extra_sources += $($(package)_qttools_file_name) From a56311e38ca3c109bc1a521fd7adbbd981f34713 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 21:04:48 -0400 Subject: [PATCH 002/469] Update qt.mk --- depends/packages/qt.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 0588caf1..4c5243a7 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -1,6 +1,6 @@ PACKAGE=qt $(package)_version=5.15.0 -$(package)_download_path=https://download.qt.io/official_releases/qt/5.15/$($(package)_version)/submodules +$(package)_download_path=https://download.qt.io/official_releases/qt/5.15/5.15.0/$($(package)_version)/submodules $(package)_suffix=qtbase-everywhere-src-$($(package)_version).tar.gz $(package)_file_name=qtbase-$($(package)_suffix) $(package)_sha256_hash=9e7af10aece15fa9500369efde69cb220eee8ec3a6818afe01ce1e7d484824c5 From fa380d403d12939ba1a075c9eb95f2951525662d Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 21:06:05 -0400 Subject: [PATCH 003/469] Update qt.mk --- depends/packages/qt.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 4c5243a7..83cf8652 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -1,7 +1,7 @@ PACKAGE=qt $(package)_version=5.15.0 $(package)_download_path=https://download.qt.io/official_releases/qt/5.15/5.15.0/$($(package)_version)/submodules -$(package)_suffix=qtbase-everywhere-src-$($(package)_version).tar.gz +$(package)_suffix=everywhere-src-$($(package)_version).tar.gz $(package)_file_name=qtbase-$($(package)_suffix) $(package)_sha256_hash=9e7af10aece15fa9500369efde69cb220eee8ec3a6818afe01ce1e7d484824c5 $(package)_dependencies=openssl zlib From 2095edb82c4cde5c2da82d05c2e717be784f4feb Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 21:07:04 -0400 Subject: [PATCH 004/469] Update qt.mk --- depends/packages/qt.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 83cf8652..7c28b336 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -1,6 +1,6 @@ PACKAGE=qt $(package)_version=5.15.0 -$(package)_download_path=https://download.qt.io/official_releases/qt/5.15/5.15.0/$($(package)_version)/submodules +$(package)_download_path=https://download.qt.io/official_releases/qt/5.15/$($(package)_version)/submodules $(package)_suffix=everywhere-src-$($(package)_version).tar.gz $(package)_file_name=qtbase-$($(package)_suffix) $(package)_sha256_hash=9e7af10aece15fa9500369efde69cb220eee8ec3a6818afe01ce1e7d484824c5 From 2fe75b233a7bc818d01b068dfeb83841045932c9 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 21:08:33 -0400 Subject: [PATCH 005/469] Update qt.mk --- depends/packages/qt.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 7c28b336..f817f6bd 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -1,7 +1,7 @@ PACKAGE=qt $(package)_version=5.15.0 $(package)_download_path=https://download.qt.io/official_releases/qt/5.15/$($(package)_version)/submodules -$(package)_suffix=everywhere-src-$($(package)_version).tar.gz +$(package)_suffix=everywhere-src-$($(package)_version).tar.xz $(package)_file_name=qtbase-$($(package)_suffix) $(package)_sha256_hash=9e7af10aece15fa9500369efde69cb220eee8ec3a6818afe01ce1e7d484824c5 $(package)_dependencies=openssl zlib From 508735b83072f2aa6ef4df086de0a5950681d2fd Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 21:51:22 -0400 Subject: [PATCH 006/469] Update qt.mk --- depends/packages/qt.mk | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index f817f6bd..1817279a 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -8,8 +8,8 @@ $(package)_dependencies=openssl zlib $(package)_linux_dependencies=freetype fontconfig libxcb libX11 xproto libXext $(package)_build_subdir=qtbase $(package)_qt_libs=corelib network widgets gui plugins testlib -$(package)_patches=mac-qmake.conf mingw-uuidof.patch pidlist_absolute.patch fix-xcb-include-order.patch -$(package)_patches+=fix_qt_configure.patch fix_qt_pkgconfig.patch fix-cocoahelpers-macos.patch qfixed-coretext.patch +#$(package)_patches=mac-qmake.conf mingw-uuidof.patch pidlist_absolute.patch fix-xcb-include-order.patch +#$(package)_patches+=fix_qt_configure.patch fix_qt_pkgconfig.patch fix-cocoahelpers-macos.patch qfixed-coretext.patch # NOTE: fix_qt_configure.patch is only needed for Qt 5.7, newer versions don't have this issue. # Remove it after bumping $(package)_version to 5.8+. @@ -140,13 +140,13 @@ define $(package)_preprocess_cmds cp -f qtbase/mkspecs/macx-clang/Info.plist.app qtbase/mkspecs/macx-clang-linux/ &&\ cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\ cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \ - patch -p1 < $($(package)_patch_dir)/mingw-uuidof.patch && \ - patch -p1 < $($(package)_patch_dir)/pidlist_absolute.patch && \ - patch -p1 < $($(package)_patch_dir)/fix-xcb-include-order.patch && \ - patch -p1 < $($(package)_patch_dir)/fix_qt_configure.patch && \ - patch -p1 < $($(package)_patch_dir)/fix_qt_pkgconfig.patch && \ - patch -p1 < $($(package)_patch_dir)/fix-cocoahelpers-macos.patch && \ - patch -p1 < $($(package)_patch_dir)/qfixed-coretext.patch && \ + #patch -p1 < $($(package)_patch_dir)/mingw-uuidof.patch && \ + #patch -p1 < $($(package)_patch_dir)/pidlist_absolute.patch && \ + #patch -p1 < $($(package)_patch_dir)/fix-xcb-include-order.patch && \ + #patch -p1 < $($(package)_patch_dir)/fix_qt_configure.patch && \ + #patch -p1 < $($(package)_patch_dir)/fix_qt_pkgconfig.patch && \ + #patch -p1 < $($(package)_patch_dir)/fix-cocoahelpers-macos.patch && \ + #patch -p1 < $($(package)_patch_dir)/qfixed-coretext.patch && \ echo "!host_build: QMAKE_CFLAGS += $($(package)_cflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ echo "!host_build: QMAKE_CXXFLAGS += $($(package)_cxxflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ echo "!host_build: QMAKE_LFLAGS += $($(package)_ldflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ From 85ddb3b5c22cb9e41bfe8ab21a2eee775a25af99 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 21:57:42 -0400 Subject: [PATCH 007/469] Update qt.mk --- depends/packages/qt.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 1817279a..110baca6 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -139,7 +139,7 @@ define $(package)_preprocess_cmds cp -f qtbase/mkspecs/macx-clang/Info.plist.lib qtbase/mkspecs/macx-clang-linux/ &&\ cp -f qtbase/mkspecs/macx-clang/Info.plist.app qtbase/mkspecs/macx-clang-linux/ &&\ cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\ - cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \ + cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && #patch -p1 < $($(package)_patch_dir)/mingw-uuidof.patch && \ #patch -p1 < $($(package)_patch_dir)/pidlist_absolute.patch && \ #patch -p1 < $($(package)_patch_dir)/fix-xcb-include-order.patch && \ From dd063422d043fd60f32e601d176b5e60d584e557 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 22:00:50 -0400 Subject: [PATCH 008/469] Update qt.mk --- depends/packages/qt.mk | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 110baca6..d4a2663f 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -139,14 +139,14 @@ define $(package)_preprocess_cmds cp -f qtbase/mkspecs/macx-clang/Info.plist.lib qtbase/mkspecs/macx-clang-linux/ &&\ cp -f qtbase/mkspecs/macx-clang/Info.plist.app qtbase/mkspecs/macx-clang-linux/ &&\ cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\ - cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && - #patch -p1 < $($(package)_patch_dir)/mingw-uuidof.patch && \ - #patch -p1 < $($(package)_patch_dir)/pidlist_absolute.patch && \ - #patch -p1 < $($(package)_patch_dir)/fix-xcb-include-order.patch && \ - #patch -p1 < $($(package)_patch_dir)/fix_qt_configure.patch && \ - #patch -p1 < $($(package)_patch_dir)/fix_qt_pkgconfig.patch && \ - #patch -p1 < $($(package)_patch_dir)/fix-cocoahelpers-macos.patch && \ - #patch -p1 < $($(package)_patch_dir)/qfixed-coretext.patch && \ + cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \ + patch -p1 < $($(package)_patch_dir)/mingw-uuidof.patch && \ + patch -p1 < $($(package)_patch_dir)/pidlist_absolute.patch && \ + patch -p1 < $($(package)_patch_dir)/fix-xcb-include-order.patch && \ + patch -p1 < $($(package)_patch_dir)/fix_qt_configure.patch && \ + patch -p1 < $($(package)_patch_dir)/fix_qt_pkgconfig.patch && \ + patch -p1 < $($(package)_patch_dir)/fix-cocoahelpers-macos.patch && \ + patch -p1 < $($(package)_patch_dir)/qfixed-coretext.patch && \ echo "!host_build: QMAKE_CFLAGS += $($(package)_cflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ echo "!host_build: QMAKE_CXXFLAGS += $($(package)_cxxflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ echo "!host_build: QMAKE_LFLAGS += $($(package)_ldflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ From bc24cceccf18abb1b2e7659aa9c2644ef870c4e0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 22:01:00 -0400 Subject: [PATCH 009/469] Update qt.mk --- depends/packages/qt.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index d4a2663f..f817f6bd 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -8,8 +8,8 @@ $(package)_dependencies=openssl zlib $(package)_linux_dependencies=freetype fontconfig libxcb libX11 xproto libXext $(package)_build_subdir=qtbase $(package)_qt_libs=corelib network widgets gui plugins testlib -#$(package)_patches=mac-qmake.conf mingw-uuidof.patch pidlist_absolute.patch fix-xcb-include-order.patch -#$(package)_patches+=fix_qt_configure.patch fix_qt_pkgconfig.patch fix-cocoahelpers-macos.patch qfixed-coretext.patch +$(package)_patches=mac-qmake.conf mingw-uuidof.patch pidlist_absolute.patch fix-xcb-include-order.patch +$(package)_patches+=fix_qt_configure.patch fix_qt_pkgconfig.patch fix-cocoahelpers-macos.patch qfixed-coretext.patch # NOTE: fix_qt_configure.patch is only needed for Qt 5.7, newer versions don't have this issue. # Remove it after bumping $(package)_version to 5.8+. From dfee913728ea46f335f6dbfeacea6b055a0f4db2 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 22:01:36 -0400 Subject: [PATCH 010/469] Update qt.mk --- depends/packages/qt.mk | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index f817f6bd..92e27803 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -9,7 +9,7 @@ $(package)_linux_dependencies=freetype fontconfig libxcb libX11 xproto libXext $(package)_build_subdir=qtbase $(package)_qt_libs=corelib network widgets gui plugins testlib $(package)_patches=mac-qmake.conf mingw-uuidof.patch pidlist_absolute.patch fix-xcb-include-order.patch -$(package)_patches+=fix_qt_configure.patch fix_qt_pkgconfig.patch fix-cocoahelpers-macos.patch qfixed-coretext.patch +$(package)_patches+=fix_qt_pkgconfig.patch fix-cocoahelpers-macos.patch qfixed-coretext.patch # NOTE: fix_qt_configure.patch is only needed for Qt 5.7, newer versions don't have this issue. # Remove it after bumping $(package)_version to 5.8+. @@ -143,7 +143,6 @@ define $(package)_preprocess_cmds patch -p1 < $($(package)_patch_dir)/mingw-uuidof.patch && \ patch -p1 < $($(package)_patch_dir)/pidlist_absolute.patch && \ patch -p1 < $($(package)_patch_dir)/fix-xcb-include-order.patch && \ - patch -p1 < $($(package)_patch_dir)/fix_qt_configure.patch && \ patch -p1 < $($(package)_patch_dir)/fix_qt_pkgconfig.patch && \ patch -p1 < $($(package)_patch_dir)/fix-cocoahelpers-macos.patch && \ patch -p1 < $($(package)_patch_dir)/qfixed-coretext.patch && \ From b6848281fef12e161e509f47e5b4c327e77c9110 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 22:46:25 -0400 Subject: [PATCH 011/469] Update qt.mk --- depends/packages/qt.mk | 8 -------- 1 file changed, 8 deletions(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 92e27803..8401f824 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -8,8 +8,6 @@ $(package)_dependencies=openssl zlib $(package)_linux_dependencies=freetype fontconfig libxcb libX11 xproto libXext $(package)_build_subdir=qtbase $(package)_qt_libs=corelib network widgets gui plugins testlib -$(package)_patches=mac-qmake.conf mingw-uuidof.patch pidlist_absolute.patch fix-xcb-include-order.patch -$(package)_patches+=fix_qt_pkgconfig.patch fix-cocoahelpers-macos.patch qfixed-coretext.patch # NOTE: fix_qt_configure.patch is only needed for Qt 5.7, newer versions don't have this issue. # Remove it after bumping $(package)_version to 5.8+. @@ -140,12 +138,6 @@ define $(package)_preprocess_cmds cp -f qtbase/mkspecs/macx-clang/Info.plist.app qtbase/mkspecs/macx-clang-linux/ &&\ cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\ cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \ - patch -p1 < $($(package)_patch_dir)/mingw-uuidof.patch && \ - patch -p1 < $($(package)_patch_dir)/pidlist_absolute.patch && \ - patch -p1 < $($(package)_patch_dir)/fix-xcb-include-order.patch && \ - patch -p1 < $($(package)_patch_dir)/fix_qt_pkgconfig.patch && \ - patch -p1 < $($(package)_patch_dir)/fix-cocoahelpers-macos.patch && \ - patch -p1 < $($(package)_patch_dir)/qfixed-coretext.patch && \ echo "!host_build: QMAKE_CFLAGS += $($(package)_cflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ echo "!host_build: QMAKE_CXXFLAGS += $($(package)_cxxflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ echo "!host_build: QMAKE_LFLAGS += $($(package)_ldflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ From 6a947c0e601664e17b65baa433c06d7d12f46022 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 22:50:51 -0400 Subject: [PATCH 012/469] Update qt.mk --- depends/packages/qt.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 8401f824..c3b1e33f 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -137,7 +137,6 @@ define $(package)_preprocess_cmds cp -f qtbase/mkspecs/macx-clang/Info.plist.lib qtbase/mkspecs/macx-clang-linux/ &&\ cp -f qtbase/mkspecs/macx-clang/Info.plist.app qtbase/mkspecs/macx-clang-linux/ &&\ cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\ - cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \ echo "!host_build: QMAKE_CFLAGS += $($(package)_cflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ echo "!host_build: QMAKE_CXXFLAGS += $($(package)_cxxflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ echo "!host_build: QMAKE_LFLAGS += $($(package)_ldflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ From e94037672c72a19e85d7eff13eac97c266d3b44b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 22:55:53 -0400 Subject: [PATCH 013/469] Update qt.mk --- depends/packages/qt.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index c3b1e33f..816f3aea 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -29,7 +29,6 @@ $(package)_config_opts += -c++std c++11 $(package)_config_opts += -confirm-license $(package)_config_opts += -dbus-runtime $(package)_config_opts += -hostprefix $(build_prefix) -$(package)_config_opts += -no-alsa $(package)_config_opts += -no-audio-backend $(package)_config_opts += -no-cups $(package)_config_opts += -no-egl From 9f778b482f264628c588f6d3b56bdb0ae336686f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 23:00:36 -0400 Subject: [PATCH 014/469] Update qt.mk --- depends/packages/qt.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 816f3aea..2b1e0285 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -29,7 +29,6 @@ $(package)_config_opts += -c++std c++11 $(package)_config_opts += -confirm-license $(package)_config_opts += -dbus-runtime $(package)_config_opts += -hostprefix $(build_prefix) -$(package)_config_opts += -no-audio-backend $(package)_config_opts += -no-cups $(package)_config_opts += -no-egl $(package)_config_opts += -no-eglfs From 5ec0bf00facfeb3d4670f0d233525029162879b7 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 23:02:44 -0400 Subject: [PATCH 015/469] Update qt.mk --- depends/packages/qt.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 2b1e0285..0ea19281 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -32,7 +32,6 @@ $(package)_config_opts += -hostprefix $(build_prefix) $(package)_config_opts += -no-cups $(package)_config_opts += -no-egl $(package)_config_opts += -no-eglfs -$(package)_config_opts += -no-feature-style-windowsmobile $(package)_config_opts += -no-feature-style-windowsce $(package)_config_opts += -no-freetype $(package)_config_opts += -no-gif From fa33fb8c8928f0e48977e2eafa5aca618f0818a3 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 23:05:15 -0400 Subject: [PATCH 016/469] Update qt.mk --- depends/packages/qt.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 0ea19281..91712a6e 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -32,7 +32,6 @@ $(package)_config_opts += -hostprefix $(build_prefix) $(package)_config_opts += -no-cups $(package)_config_opts += -no-egl $(package)_config_opts += -no-eglfs -$(package)_config_opts += -no-feature-style-windowsce $(package)_config_opts += -no-freetype $(package)_config_opts += -no-gif $(package)_config_opts += -no-glib From e4927c5816bf53a57bcb50db2f0f30333f5b9de0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 23:07:06 -0400 Subject: [PATCH 017/469] Update qt.mk --- depends/packages/qt.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 91712a6e..b85ac986 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -35,7 +35,6 @@ $(package)_config_opts += -no-eglfs $(package)_config_opts += -no-freetype $(package)_config_opts += -no-gif $(package)_config_opts += -no-glib -$(package)_config_opts += -no-gstreamer $(package)_config_opts += -no-icu $(package)_config_opts += -no-iconv $(package)_config_opts += -no-kms From d94c3eed4a02649aabf70cc166ea2c83deec0be8 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 23:09:34 -0400 Subject: [PATCH 018/469] Update qt.mk --- depends/packages/qt.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index b85ac986..257f44ab 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -40,7 +40,6 @@ $(package)_config_opts += -no-iconv $(package)_config_opts += -no-kms $(package)_config_opts += -no-linuxfb $(package)_config_opts += -no-libudev -$(package)_config_opts += -no-mitshm $(package)_config_opts += -no-mtdev $(package)_config_opts += -no-pulseaudio $(package)_config_opts += -no-openvg From ef2626a408c36dc21a12ca97b0ae982313ac1a62 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 23:13:13 -0400 Subject: [PATCH 019/469] Update qt.mk --- depends/packages/qt.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 257f44ab..f3136174 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -41,7 +41,6 @@ $(package)_config_opts += -no-kms $(package)_config_opts += -no-linuxfb $(package)_config_opts += -no-libudev $(package)_config_opts += -no-mtdev -$(package)_config_opts += -no-pulseaudio $(package)_config_opts += -no-openvg $(package)_config_opts += -no-reduce-relocations $(package)_config_opts += -no-qml-debug From 5792aa300d49db84d9456a383c7d6e9202034be7 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 23:15:34 -0400 Subject: [PATCH 020/469] Update qt.mk --- depends/packages/qt.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index f3136174..9e591433 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -43,7 +43,6 @@ $(package)_config_opts += -no-libudev $(package)_config_opts += -no-mtdev $(package)_config_opts += -no-openvg $(package)_config_opts += -no-reduce-relocations -$(package)_config_opts += -no-qml-debug $(package)_config_opts += -no-sql-db2 $(package)_config_opts += -no-sql-ibase $(package)_config_opts += -no-sql-oci From 6a45396770af98ff1286c73ba049c180eb1fbb5f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 23:17:22 -0400 Subject: [PATCH 021/469] Update qt.mk --- depends/packages/qt.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 9e591433..43fc8eb7 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -53,7 +53,6 @@ $(package)_config_opts += -no-sql-psql $(package)_config_opts += -no-sql-sqlite $(package)_config_opts += -no-sql-sqlite2 $(package)_config_opts += -no-use-gold-linker -$(package)_config_opts += -no-xinput2 $(package)_config_opts += -no-xrender $(package)_config_opts += -nomake examples $(package)_config_opts += -nomake tests From 4ddf0b5d040a88f78c419c2893a043bbbc39be1a Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 23:19:05 -0400 Subject: [PATCH 022/469] Update qt.mk --- depends/packages/qt.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 43fc8eb7..8623088c 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -53,7 +53,6 @@ $(package)_config_opts += -no-sql-psql $(package)_config_opts += -no-sql-sqlite $(package)_config_opts += -no-sql-sqlite2 $(package)_config_opts += -no-use-gold-linker -$(package)_config_opts += -no-xrender $(package)_config_opts += -nomake examples $(package)_config_opts += -nomake tests $(package)_config_opts += -opensource From e41b1f0532db5eba1e2ebde51abf94d09c84412e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 23:22:52 -0400 Subject: [PATCH 023/469] Update qt.mk --- depends/packages/qt.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 8623088c..6e914faf 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -4,7 +4,7 @@ $(package)_download_path=https://download.qt.io/official_releases/qt/5.15/$($(pa $(package)_suffix=everywhere-src-$($(package)_version).tar.xz $(package)_file_name=qtbase-$($(package)_suffix) $(package)_sha256_hash=9e7af10aece15fa9500369efde69cb220eee8ec3a6818afe01ce1e7d484824c5 -$(package)_dependencies=openssl zlib +$(package)_dependencies=zlib $(package)_linux_dependencies=freetype fontconfig libxcb libX11 xproto libXext $(package)_build_subdir=qtbase $(package)_qt_libs=corelib network widgets gui plugins testlib From 6da07fc4357d8c46a30389ed1ff9984a7d91ed5a Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 26 May 2020 23:26:49 -0400 Subject: [PATCH 024/469] Update qt.mk --- depends/packages/qt.mk | 3 --- 1 file changed, 3 deletions(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 6e914faf..f354e36d 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -56,17 +56,14 @@ $(package)_config_opts += -no-use-gold-linker $(package)_config_opts += -nomake examples $(package)_config_opts += -nomake tests $(package)_config_opts += -opensource -$(package)_config_opts += -openssl-linked $(package)_config_opts += -optimized-qmake $(package)_config_opts += -pch -$(package)_config_opts += -pkg-config $(package)_config_opts += -prefix $(host_prefix) $(package)_config_opts += -qt-libpng $(package)_config_opts += -qt-libjpeg $(package)_config_opts += -qt-pcre $(package)_config_opts += -qt-harfbuzz $(package)_config_opts += -system-zlib -$(package)_config_opts += -reduce-exports $(package)_config_opts += -static $(package)_config_opts += -silent $(package)_config_opts += -v From 9f1805f290cda1aae012c1a73aa75551da5d6e83 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 21:14:07 -0400 Subject: [PATCH 025/469] Update qt.mk --- depends/packages/qt.mk | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index f354e36d..62d2f176 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -1,9 +1,9 @@ PACKAGE=qt -$(package)_version=5.15.0 -$(package)_download_path=https://download.qt.io/official_releases/qt/5.15/$($(package)_version)/submodules +$(package)_version=5.12.8 +$(package)_download_path=https://download.qt.io/official_releases/qt/5.12/$($(package)_version)/submodules $(package)_suffix=everywhere-src-$($(package)_version).tar.xz $(package)_file_name=qtbase-$($(package)_suffix) -$(package)_sha256_hash=9e7af10aece15fa9500369efde69cb220eee8ec3a6818afe01ce1e7d484824c5 +$(package)_sha256_hash=19592fbd0a524a17c35e413988fe494251103619ef7dd49aecdf3170973aabd8 $(package)_dependencies=zlib $(package)_linux_dependencies=freetype fontconfig libxcb libX11 xproto libXext $(package)_build_subdir=qtbase @@ -12,11 +12,11 @@ $(package)_qt_libs=corelib network widgets gui plugins testlib # Remove it after bumping $(package)_version to 5.8+. $(package)_qttranslations_file_name=qttranslations-$($(package)_suffix) -$(package)_qttranslations_sha256_hash=45c43268d9df50784d4d8ca345fce9288a1055fd074ac0ef508097f7aeba22fe +$(package)_qttranslations_sha256_hash=180ea07c0aff6803ffad214c34f8ed1a77f8cac02e62f6e219bd1ede1dd66b6e $(package)_qttools_file_name=qttools-$($(package)_suffix) -$(package)_qttools_sha256_hash=ddbcb49aab3a2e3672582c6e2e7bec0058feff790f67472343c79e2895e0e437 +$(package)_qttools_sha256_hash=21347e8e2422689d63a08195e27c637983c0d4261d5205ce6b493a2adfe826b4 $(package)_extra_sources = $($(package)_qttranslations_file_name) $(package)_extra_sources += $($(package)_qttools_file_name) From 833fef9ce557844fba06cb691572eae2b7e6e133 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 21:18:01 -0400 Subject: [PATCH 026/469] Update qt.mk --- depends/packages/qt.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 62d2f176..a54995a1 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -63,7 +63,6 @@ $(package)_config_opts += -qt-libpng $(package)_config_opts += -qt-libjpeg $(package)_config_opts += -qt-pcre $(package)_config_opts += -qt-harfbuzz -$(package)_config_opts += -system-zlib $(package)_config_opts += -static $(package)_config_opts += -silent $(package)_config_opts += -v From d1df94f1bc47de779e0c106c954e4b8a48a483de Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 21:42:51 -0400 Subject: [PATCH 027/469] Update qt.mk --- depends/packages/qt.mk | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index a54995a1..9579f605 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -1,22 +1,24 @@ PACKAGE=qt -$(package)_version=5.12.8 -$(package)_download_path=https://download.qt.io/official_releases/qt/5.12/$($(package)_version)/submodules -$(package)_suffix=everywhere-src-$($(package)_version).tar.xz +$(package)_version=5.7.1 +$(package)_download_path=https://download.qt.io/new_archive/qt/5.7/$($(package)_version)/submodules +$(package)_suffix=opensource-src-$($(package)_version).tar.gz $(package)_file_name=qtbase-$($(package)_suffix) -$(package)_sha256_hash=19592fbd0a524a17c35e413988fe494251103619ef7dd49aecdf3170973aabd8 -$(package)_dependencies=zlib +$(package)_sha256_hash=95f83e532d23b3ddbde7973f380ecae1bac13230340557276f75f2e37984e410 +$(package)_dependencies=openssl zlib $(package)_linux_dependencies=freetype fontconfig libxcb libX11 xproto libXext $(package)_build_subdir=qtbase $(package)_qt_libs=corelib network widgets gui plugins testlib +$(package)_patches=mac-qmake.conf mingw-uuidof.patch pidlist_absolute.patch fix-xcb-include-order.patch +$(package)_patches+=fix_qt_configure.patch fix_qt_pkgconfig.patch fix-cocoahelpers-macos.patch qfixed-coretext.patch # NOTE: fix_qt_configure.patch is only needed for Qt 5.7, newer versions don't have this issue. # Remove it after bumping $(package)_version to 5.8+. $(package)_qttranslations_file_name=qttranslations-$($(package)_suffix) -$(package)_qttranslations_sha256_hash=180ea07c0aff6803ffad214c34f8ed1a77f8cac02e62f6e219bd1ede1dd66b6e +$(package)_qttranslations_sha256_hash=3a15aebd523c6d89fb97b2d3df866c94149653a26d27a00aac9b6d3020bc5a1d $(package)_qttools_file_name=qttools-$($(package)_suffix) -$(package)_qttools_sha256_hash=21347e8e2422689d63a08195e27c637983c0d4261d5205ce6b493a2adfe826b4 +$(package)_qttools_sha256_hash=22d67de915cb8cd93e16fdd38fa006224ad9170bd217c2be1e53045a8dd02f0f $(package)_extra_sources = $($(package)_qttranslations_file_name) $(package)_extra_sources += $($(package)_qttools_file_name) @@ -29,20 +31,28 @@ $(package)_config_opts += -c++std c++11 $(package)_config_opts += -confirm-license $(package)_config_opts += -dbus-runtime $(package)_config_opts += -hostprefix $(build_prefix) +$(package)_config_opts += -no-alsa +$(package)_config_opts += -no-audio-backend $(package)_config_opts += -no-cups $(package)_config_opts += -no-egl $(package)_config_opts += -no-eglfs +$(package)_config_opts += -no-feature-style-windowsmobile +$(package)_config_opts += -no-feature-style-windowsce $(package)_config_opts += -no-freetype $(package)_config_opts += -no-gif $(package)_config_opts += -no-glib +$(package)_config_opts += -no-gstreamer $(package)_config_opts += -no-icu $(package)_config_opts += -no-iconv $(package)_config_opts += -no-kms $(package)_config_opts += -no-linuxfb $(package)_config_opts += -no-libudev +$(package)_config_opts += -no-mitshm $(package)_config_opts += -no-mtdev +$(package)_config_opts += -no-pulseaudio $(package)_config_opts += -no-openvg $(package)_config_opts += -no-reduce-relocations +$(package)_config_opts += -no-qml-debug $(package)_config_opts += -no-sql-db2 $(package)_config_opts += -no-sql-ibase $(package)_config_opts += -no-sql-oci @@ -53,16 +63,22 @@ $(package)_config_opts += -no-sql-psql $(package)_config_opts += -no-sql-sqlite $(package)_config_opts += -no-sql-sqlite2 $(package)_config_opts += -no-use-gold-linker +$(package)_config_opts += -no-xinput2 +$(package)_config_opts += -no-xrender $(package)_config_opts += -nomake examples $(package)_config_opts += -nomake tests $(package)_config_opts += -opensource +$(package)_config_opts += -openssl-linked $(package)_config_opts += -optimized-qmake $(package)_config_opts += -pch +$(package)_config_opts += -pkg-config $(package)_config_opts += -prefix $(host_prefix) $(package)_config_opts += -qt-libpng $(package)_config_opts += -qt-libjpeg $(package)_config_opts += -qt-pcre $(package)_config_opts += -qt-harfbuzz +$(package)_config_opts += -system-zlib +$(package)_config_opts += -reduce-exports $(package)_config_opts += -static $(package)_config_opts += -silent $(package)_config_opts += -v @@ -123,6 +139,14 @@ define $(package)_preprocess_cmds cp -f qtbase/mkspecs/macx-clang/Info.plist.lib qtbase/mkspecs/macx-clang-linux/ &&\ cp -f qtbase/mkspecs/macx-clang/Info.plist.app qtbase/mkspecs/macx-clang-linux/ &&\ cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\ + cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \ + patch -p1 < $($(package)_patch_dir)/mingw-uuidof.patch && \ + patch -p1 < $($(package)_patch_dir)/pidlist_absolute.patch && \ + patch -p1 < $($(package)_patch_dir)/fix-xcb-include-order.patch && \ + patch -p1 < $($(package)_patch_dir)/fix_qt_configure.patch && \ + patch -p1 < $($(package)_patch_dir)/fix_qt_pkgconfig.patch && \ + patch -p1 < $($(package)_patch_dir)/fix-cocoahelpers-macos.patch && \ + patch -p1 < $($(package)_patch_dir)/qfixed-coretext.patch && \ echo "!host_build: QMAKE_CFLAGS += $($(package)_cflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ echo "!host_build: QMAKE_CXXFLAGS += $($(package)_cxxflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ echo "!host_build: QMAKE_LFLAGS += $($(package)_ldflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ From c9fa10641c03eb5e0b9680e2f408e0a0fd69dd28 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:03:05 -0400 Subject: [PATCH 028/469] Create newproposaldialog.cpp --- src/qt/newproposaldialog.cpp | 852 +++++++++++++++++++++++++++++++++++ 1 file changed, 852 insertions(+) create mode 100644 src/qt/newproposaldialog.cpp diff --git a/src/qt/newproposaldialog.cpp b/src/qt/newproposaldialog.cpp new file mode 100644 index 00000000..4517dfb2 --- /dev/null +++ b/src/qt/newproposaldialog.cpp @@ -0,0 +1,852 @@ +// Copyright (c) 2017-2018 The Aywa Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "guiutil.h" +#include "newproposaldialog.h" +#include "governance-validators.h" +#include "utilstrencodings.h" +#include "addressbookpage.h" +#include "masternode-sync.h" +#include "masternodeman.h" +#include "activemasternode.h" +#include "walletmodel.h" +#include "bitcoingui.h" +#include "governance-object.h" +#include "governance.h" +#include "init.h" +#include "transactionrecord.h" +//#ifdef ENABLE_WALLET //TODO: uncomment +#include "wallet/wallet.h" +#include "rpc/server.h" +//#include "univalue.h" +//#endif // ENABLE_WALLET +#include "validation.h" +#include "ui_newproposaldialog.h" +#include "smessage.h" + +#include "masternodeconfig.h" +#include "messagesigner.h" + + +#include +#include +#include +#include +#include +#include + +uint256 txidFee; +std::string strProposalName, strProposalDescriptionHex, strPaymentAddress, + sProposalChannelAddress, strProposalChannelPubKey, strProposalChannelPrivKey, strProposalStatus, + strProposalUrl, nPaymentEndDate_str; +int nProposalRevision, nProposalTime, nPaymentStartDate, nPaymentEndDate, nPaymentAmount; +int GetNextSuperblockTime(); +CGovernanceObject* pGovObj; + +NewProposalDialog::NewProposalDialog(const std::string idx, QWidget *parent) : + QWidget(parent), + ui(new Ui::NewProposalDialog) +{ + //GUIUtil::restoreWindowGeometry("NewProposalDialogWindow", this->size(), this);//TODO + ui->setupUi(this); + /* Open CSS when configured */ + this->setStyleSheet(GUIUtil::loadStyleSheet()); + + ui->labelProposalChannelAddress->setVisible(false); + ui->lineeditPrivateChatAddress->setVisible(false); + ui->lineeditChannelPrivKey->setVisible(false); + ui->lineeditPrivateChatPubKey->setVisible(false); + ui->labelPublicKey->setVisible(false); + ui->labelPrivKey->setVisible(false); + ui->pushbuttonReset->setVisible(false); + + + if (!idx.empty()) { //Open exists proposal item + uint256 hash = uint256S(idx); + //CGovernanceObject* + pGovObj = governance.FindGovernanceObject(hash); + if (!pGovObj) return; //only GOVERNANCE_OBJECT_PROPOSAL can be opened + UniValue objJSON = pGovObj->GetJSONObject(); + std::string strName = objJSON["name"].get_str(); + std::string strWindowTitle = "Aywa Core - Proposal "+strName; + int nEnd_epoch = objJSON["end_epoch"].get_int(); + std::string strPayment_address = objJSON["payment_address"].get_str(); + int nPayment_amount = objJSON["payment_amount"].get_int(); + int nStart_epoch = objJSON["start_epoch"].get_int(); + std::string strUrl = objJSON["url"].get_str(); + std::string strProposalChannelAddress, strProposalChannelPrivKey, strProposalChannelPubKey; + try{//some proposals dont have a description + strProposalChannelAddress = objJSON["smsg_addr"].get_str(); + strProposalChannelPubKey = objJSON["smsg_pubkey"].get_str(); + strProposalChannelPrivKey = objJSON["smsg_privkey"].get_str(); + std::string strDescription = objJSON["description"].get_str(); + std::vector v = ParseHex(strDescription); + std::string strProposalDescription(v.begin(), v.end()); + ui->texteditProposalDescription->setHtml(strProposalDescription.c_str()); + } + catch(std::exception& e) + { + ui->texteditProposalDescription->setText(e.what()); + }; + + ui->lineeditProposalName->setText(strName.c_str()); + ui->lineeditProposalName->setReadOnly(true); + + ui->texteditProposalDescription->setReadOnly(true); + ui->lineeditPaymentAddress->setText(strPayment_address.c_str()); + ui->lineeditPaymentAddress->setReadOnly(true); + ui->dateeditPaymentStartDate->setDateTime(QDateTime::fromTime_t(nStart_epoch+43200));// + Params().GetConsensus().nBudgetPaymentsCycleBlocks * Params().GetConsensus().nPowTargetSpacing / 2)); + ui->dateeditPaymentStartDate->setEnabled(false); + ui->dateeditPaymentEndDate->setDateTime(QDateTime::fromTime_t(nEnd_epoch-43200));// - Params().GetConsensus().nBudgetPaymentsCycleBlocks * Params().GetConsensus().nPowTargetSpacing / 2)); + ui->dateeditPaymentEndDate->setEnabled(false); + ui->spinboxAmount->setValue(nPayment_amount); + ui->spinboxAmount->setEnabled(false); + const Consensus::Params& consensusParams = Params().GetConsensus(); + const int nBudgetPaymentsCycleBlocks = consensusParams.nBudgetPaymentsCycleBlocks; + ui->spinboxPeriod->setValue((nEnd_epoch - nStart_epoch)/86400); + + ui->spinboxPeriod->setEnabled(false); + + ui->lineeditProposalUrl->setText(strUrl.c_str()); + ui->lineeditProposalUrl->setReadOnly(true); + + ui->lineeditPrivateChatAddress->setText(strProposalChannelAddress.c_str()); + ui->lineeditPrivateChatPubKey->setText(strProposalChannelPubKey.c_str()); + ui->lineeditChannelPrivKey->setText(strProposalChannelPrivKey.c_str()); + + ui->bnJoinChannel->setEnabled(!GetIsChannelSubscribed(ui->lineeditPrivateChatAddress->text().toStdString())); + + ui->lineeditPrivateChatAddress->setReadOnly(true); + ui->pushbuttonCheck->setEnabled(false); + ui->toolbuttonSelectPaymentAddress->setEnabled(false); + this->setWindowTitle(strWindowTitle.c_str()); +// connect(MasternodeList.voteAction();, ) + } + else //new item + { + ui->dateeditPaymentStartDate->setMaximumDate(QDate::currentDate().addDays(30));//no more, than 1 month planning future + + int nNextSuperBlockTime = GetNextSuperblockTime(); + int nProposalRecommendedTime = nNextSuperBlockTime + Params().GetConsensus().nBudgetPaymentsCycleBlocks * Params().GetConsensus().nPowTargetSpacing; + int nProposalMinimumTime = nNextSuperBlockTime; + + + ui->dateeditPaymentStartDate->setDateTime(QDateTime::fromTime_t(nProposalRecommendedTime)); + ui->dateeditPaymentStartDate->setMinimumDateTime(QDateTime::fromTime_t(nProposalMinimumTime)); + + ui->dateeditPaymentStartDate->setMaximumTime(ui->dateeditPaymentStartDate->time()); + int nPeriod = 0; + ui->dateeditPaymentEndDate->setDateTime(QDateTime::fromTime_t(ui->dateeditPaymentStartDate->dateTime().toTime_t() + nPeriod*Params().GetConsensus().nPowTargetSpacing*Params().GetConsensus().nBudgetPaymentsCycleBlocks)); + std::string strAddress, strPubKey, strPrivateKey; + GetNewChannelAddress(strAddress, strPubKey, strPrivateKey); + ui->lineeditPrivateChatAddress->setText(strAddress.c_str()); + ui->lineeditPrivateChatPubKey->setText(strPubKey.c_str()); + ui->lineeditChannelPrivKey->setText(strPrivateKey.c_str()); + ui->bnJoinChannel->setEnabled(false); + ui->bnVoteYes->setVisible(false); + ui->bnVoteNo->setVisible(false); + ui->bnVoteAbstain->setVisible(false); + } + ui->labelTotalProposalBudget->setText(QString::number(ui->spinboxPeriod->value()*ui->spinboxAmount->value())); +} + +NewProposalDialog::~NewProposalDialog() +{ + GUIUtil::saveWindowGeometry("NewProposalDialogWindow", this); + delete ui; +} + + + +void NewProposalDialog::on_spinboxPeriod_valueChanged(int nPeriod) +{ + ui->labelTotalProposalBudget->setText(QString::number(ui->spinboxPeriod->value()*ui->spinboxAmount->value())); + ui->dateeditPaymentEndDate->setDateTime(QDateTime::fromTime_t(ui->dateeditPaymentStartDate->dateTime().toTime_t() + (nPeriod-1) * Params().GetConsensus().nPowTargetSpacing*Params().GetConsensus().nBudgetPaymentsCycleBlocks)); + //ui->dateeditPaymentStartDate->setDisplayFormat("dd.MM.yyyy hh:mm"); +} + +void NewProposalDialog::on_pushbuttonCheck_clicked() +{ + uint256 hashParent; + int nRevision = 1; + strProposalName = ui->lineeditProposalName->text().toStdString(); + strProposalDescriptionHex = HexStr(ui->texteditProposalDescription->toHtml().toStdString());//TODO: toHtml/toPlainText + std::vector v = ParseHex(strProposalDescriptionHex); + std::string strProposalDescription(v.begin(), v.end()); + ui->texteditProposalDescription->setHtml(strProposalDescription.c_str()); + strPaymentAddress = ui->lineeditPaymentAddress->text().toStdString(); + sProposalChannelAddress = ui->lineeditPrivateChatAddress->text().toStdString(); + strProposalChannelPubKey = ui->lineeditPrivateChatPubKey->text().toStdString(); + strProposalUrl = ui->lineeditProposalUrl->text().toStdString(); + //strProposalStatus = "NEW"; + nPaymentStartDate = ui->dateeditPaymentStartDate->dateTime().toTime_t() - Params().GetConsensus().nBudgetPaymentsCycleBlocks*Params().GetConsensus().nPowTargetSpacing/2;//Adding payment window for superblock-half payment/superblock cycle size. + nPaymentEndDate = ui->dateeditPaymentEndDate->dateTime().toTime_t() + Params().GetConsensus().nBudgetPaymentsCycleBlocks*Params().GetConsensus().nPowTargetSpacing/2; + nPaymentAmount = ui->spinboxAmount->value(); + //nPaymentEndDate_str = boost::lexical_cast(nPaymentEndDate); + UniValue uvProposalData (UniValue::VARR); + uvProposalData.push_back("proposal"); + UniValue uvStrData (UniValue::VOBJ); + uvStrData.pushKV("end_epoch",nPaymentEndDate); + uvStrData.pushKV("name",strProposalName); + uvStrData.pushKV("payment_address",strPaymentAddress); + uvStrData.pushKV("payment_amount",nPaymentAmount); + uvStrData.pushKV("start_epoch",nPaymentStartDate); + uvStrData.pushKV("type",1); + uvStrData.pushKV("url",strProposalUrl); + uvStrData.pushKV("description",strProposalDescriptionHex); + uvStrData.pushKV("smsg_addr",sProposalChannelAddress); + uvStrData.pushKV("smsg_pubkey",strProposalChannelPubKey); + uvStrData.pushKV("smsg_pubkey","PUBKEY"); + uvStrData.pushKV("smsg_privkey","PRIVKEY"); + uvProposalData.push_back(uvStrData); + + UniValue uvProposal (UniValue::VARR); + uvProposal.push_back(uvProposalData); + + std::string strDataAll = uvProposal.write(); + std::string strErrorMessages; + std::string strData = HexStr (strDataAll); + //ui->texteditProposalDescription->setText(QString::fromStdString(strData)); + //ui->texteditHEX->setText(QString::fromStdString(strData)); + int64_t nTime = GetAdjustedTime(); + strData = GetCurrentPropsalDataStr(); + CGovernanceObject govobj(hashParent, nRevision, nTime, uint256(), strData); + if(govobj.GetObjectType() == GOVERNANCE_OBJECT_PROPOSAL) { + CProposalValidator validator(strData); + if(!validator.Validate()) { + std::string strErrorMessages = validator.GetErrorMessages(); + QMessageBox msgBox; + strErrorMessages = "Invalid proposal data, error messages: "+strErrorMessages; + msgBox.setText("Proposal validation error!"); + msgBox.setInformativeText(strErrorMessages.c_str()); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); + return; + } + } + else{ + strErrorMessages = "Invalid object type, only proposals can be validated"; + QMessageBox msgBox; + msgBox.setText("Proposal validation error!"); + msgBox.setInformativeText(strErrorMessages.c_str()); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); + return; + } + //objResult.push_back(Pair("Object status", "OK")); + ui->labelProposalStatus->setText(QString::fromStdString("CHECKED")); + ui->pushbuttonCheck->setEnabled(false); + ui->pushbuttonPrepare->setEnabled(true); + ui->pushbuttonReset->setEnabled(true); + + ui->lineeditProposalName->setReadOnly(true); + ui->texteditProposalDescription->setReadOnly(true); + ui->lineeditPaymentAddress->setReadOnly(true); + ui->dateeditPaymentStartDate->setEnabled(false); + ui->dateeditPaymentEndDate->setEnabled(false); + ui->spinboxAmount->setEnabled(false); + ui->spinboxPeriod->setEnabled(false); + + ui->lineeditProposalUrl->setReadOnly(true); + + + QMessageBox msgBox; + msgBox.setText("Proposal validation passed."); + msgBox.setInformativeText("Proposal is valid. " + "Press 'Prepare' button to create 1 AYWA proposal collateral tx."); + msgBox.setIcon(QMessageBox::Information); + msgBox.exec(); + +} + +void NewProposalDialog::on_spinboxAmount_valueChanged(int arg1) +{ + ui->labelTotalProposalBudget->setText(QString::number(ui->spinboxPeriod->value()*ui->spinboxAmount->value())); + +} + +void NewProposalDialog::on_pushbuttonPrepare_clicked() +{ + uint256 hashParent; hashParent = uint256();//TODO - + std::string strRevision = "1";//TODO Check it later + int nRevision = boost::lexical_cast(strRevision); + int nTime = GetAdjustedTime(); + nProposalTime = nTime; + std::string strData = GetCurrentPropsalDataStr(); + + // CREATE A NEW COLLATERAL TRANSACTION FOR THIS SPECIFIC OBJECT + + CGovernanceObject govobj(hashParent, nRevision, nTime, uint256(), strData); + //TODO:Logging object creation details. + if(govobj.GetObjectType() == GOVERNANCE_OBJECT_PROPOSAL) { + CProposalValidator validator(strData); + if(!validator.Validate()) { + std::string strErrorMessages = "Invalid proposal data, error messages: "+validator.GetErrorMessages(); + QMessageBox msgBox; + msgBox.setText("Proposal prepare error!"); + msgBox.setInformativeText(strErrorMessages.c_str()); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); + return; + } + } + if((govobj.GetObjectType() == GOVERNANCE_OBJECT_TRIGGER) || + (govobj.GetObjectType() == GOVERNANCE_OBJECT_WATCHDOG)) { + std::string strErrorMessages = "Trigger and watchdog objects need not be prepared (however only masternodes can create them)."; + QMessageBox msgBox; + msgBox.setText("Proposal preapare error!"); + msgBox.setInformativeText(strErrorMessages.c_str()); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); + return; + } + { + LOCK(cs_main); + std::string strError = ""; + if(!govobj.IsValidLocally(strError, false)){ + std::string strErrorMessages = "Governance object is not valid - " + govobj.GetHash().ToString() + " - " + strError; + QMessageBox msgBox; + msgBox.setText("Proposal prepare error!"); + msgBox.setInformativeText(strErrorMessages.c_str()); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); + return; + } + } + + // request unlock only if was locked or unlocked for mixing: + // this way we let users unlock by walletpassphrase or by menu + // and make many transactions while unlocking through this dialog + // will call relock + if(!walletModel || !walletModel->getOptionsModel()) + return; + WalletModel::EncryptionStatus encStatus = walletModel->getEncryptionStatus(); + if(encStatus == walletModel->Locked || encStatus == walletModel->UnlockedForMixingOnly) + { + WalletModel::UnlockContext ctx(walletModel->requestUnlock()); + if(!ctx.isValid()) + { + // Unlock wallet was cancelled + //fNewRecipientAllowed = true; + return; + } + //TODO - code duplicate. remove it + CWalletTx wtx; + if(!pwalletMain->GetBudgetSystemCollateralTX(wtx, govobj.GetHash(), govobj.GetMinCollateralFee(), false)) { + std::string strErrorMessages = "Error making collateral transaction for governance object. Please check your wallet balance."; + QMessageBox msgBox; + msgBox.setText("Proposal validation error!"); + msgBox.setInformativeText(strErrorMessages.c_str()); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); + return; + } + + // -- make our change address + CReserveKey reservekey(pwalletMain); + // Display message box + QMessageBox::StandardButton retval = QMessageBox::question(this, + tr("Confirm the creation if a collateral tx for the proposal. \n"), + tr("Are you sure you want to spend 1 AYWA? \n" + "This operation can not be cancelled."), + QMessageBox::Yes | QMessageBox::Cancel, + QMessageBox::Cancel); + + if(retval != QMessageBox::Yes) return; + // -- send the tx to the network + pwalletMain->CommitTransaction(wtx, reservekey, g_connman.get(), NetMsgType::TX); + txidFee = wtx.GetHash(); + ui->pushbuttonPrepare->setEnabled(false); + ui->pushbuttonSubmit->setEnabled(true); + ui->lineeditProposalName->setEnabled(false); + ui->texteditProposalDescription->setReadOnly(true); + ui->labelProposalStatus->setText(QString::fromStdString("PREPARED")); + return; + } + CWalletTx wtx; + if(!pwalletMain->GetBudgetSystemCollateralTX(wtx, govobj.GetHash(), govobj.GetMinCollateralFee(), false)) { + std::string strErrorMessages = "Error making collateral transaction for governance object. Please check your wallet balance and make sure your wallet is unlocked."; + QMessageBox msgBox; + msgBox.setText("Proposal validation error!"); + msgBox.setInformativeText(strErrorMessages.c_str()); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); + return; + } + + // -- make our change address + CReserveKey reservekey(pwalletMain); + + + QMessageBox::StandardButton retval = QMessageBox::question(this, + tr("Confirm the creation of the collateral tx for the proposal"), + tr("Are you sure you want to spend 1 AYWA to prepare proposal? \n" + "This operation can not be cancelled."), + QMessageBox::Yes | QMessageBox::Cancel, + QMessageBox::Cancel); + + if(retval != QMessageBox::Yes) return; + // -- send the tx to the network + pwalletMain->CommitTransaction(wtx, reservekey, g_connman.get(), NetMsgType::TX); + txidFee = wtx.GetHash(); + ui->pushbuttonPrepare->setEnabled(false); + ui->pushbuttonSubmit->setEnabled(true); + ui->lineeditProposalName->setEnabled(false); + ui->texteditProposalDescription->setReadOnly(true); + ui->labelProposalStatus->setText(QString::fromStdString("PREPARED")); + + + + ui->lineeditProposalName->setReadOnly(true); + ui->texteditProposalDescription->setReadOnly(true); + ui->lineeditPaymentAddress->setReadOnly(true); + ui->dateeditPaymentStartDate->setEnabled(false); + ui->dateeditPaymentEndDate->setEnabled(false); + ui->spinboxAmount->setEnabled(false); + ui->spinboxPeriod->setEnabled(false); + + ui->lineeditProposalUrl->setReadOnly(true); + + + //TODO: disable close button or add reminder. + std::string strMessages = "Please wait about 1-5 min until transaction confirmed.\n" + "Do not close this form, before submit the proposal.\n"; + QMessageBox msgBox; + msgBox.setText("The proposal collateral tx is sucsessfully sent to blockchain."); + msgBox.setInformativeText(strMessages.c_str()); + msgBox.setIcon(QMessageBox::Information); + msgBox.exec(); + +} + +void NewProposalDialog::on_toolbuttonSelectPaymentAddress_clicked() +{ + if (ui->lineeditProposalName->text().isEmpty()) + { + // QMessageBox msgBox; + // msgBox.setText("The Proposal Channel is successfully subscribed"); + // msgBox.setIcon(QMessageBox::Information); + // msgBox.exec(); + ui->lineeditProposalName->setFocus(); + QToolTip::showText(ui->lineeditProposalName->mapToGlobal(QPoint()), tr("Type Proposal Name first")); + return;//TODO insert dlg here + } + //TODO: Check if lineeditProposalName has correct text. Check if wallet address label already present. + UniValue label = ui->lineeditProposalName->text().toStdString(); + UniValue params (UniValue::VARR); + params.push_back(label); + UniValue newAddress = getnewaddress(params, false); + try + { + ui->lineeditPaymentAddress->setText(newAddress.get_str().c_str()); + + } + catch(...){ + } + ui->toolbuttonSelectPaymentAddress->setEnabled(false); +} + +void NewProposalDialog::on_toolButton_2_clicked() +{ + if(!walletModel) + return; + AddressBookPage dlg(AddressBookPage::ForSelection, AddressBookPage::ReceivingTab, this); + dlg.setModel(walletModel->getAddressTableModel()); + + if(dlg.exec()) + { + ui->lineeditPaymentAddress->setText(dlg.getReturnValue()); + + } +} + +void NewProposalDialog::on_pushbuttonSubmit_clicked() +{ + if(!masternodeSync.IsBlockchainSynced()) { + std::string strErrorMessages = "Must wait for client to sync with masternode network. Try again in a minute or so."; + QMessageBox msgBox; + msgBox.setText("Proposal subit error!"); + msgBox.setInformativeText(strErrorMessages.c_str()); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); + + } + + //bool fMnFound = mnodeman.Has(activeMasternode.outpoint); + uint256 hashParent; hashParent = uint256();//TODO - + std::string strRevision = "1"; + int nRevision = boost::lexical_cast(strRevision); + int nTime = nProposalTime; + std::string strData = GetCurrentPropsalDataStr(); + CGovernanceObject govobj(hashParent, nRevision, nTime, txidFee, strData);//TODO CHECK Hash Parent + if(govobj.GetObjectType() == GOVERNANCE_OBJECT_PROPOSAL) { + CProposalValidator validator(strData); + if(!validator.Validate()) { + std::string strErrorMessages = "Invalid proposal data, error messages:" + validator.GetErrorMessages(); + QMessageBox msgBox; + msgBox.setText("Proposal subit error!"); + msgBox.setInformativeText(strErrorMessages.c_str()); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); + return; + } + } + std::string strHash = govobj.GetHash().ToString(); + //TODO: Logging result strHash etc. + LogPrintf("gobject(submit) -- Proposal submittred. Hash:%s", strHash); + + + std::string strError = ""; + bool fMissingMasternode = false; + bool fMissingConfirmations = false; + { + LOCK(cs_main); + if(!govobj.IsValidLocally(strError, fMissingMasternode, fMissingConfirmations, true) && !fMissingConfirmations) { + LogPrintf("gobject(submit) -- Object submission rejected because object is not valid - hash = %s, strError = %s\n", strHash, strError); + std::string strErrorMessages = "Governance object is not valid - " + strHash + " - " + strError; + QMessageBox msgBox; + msgBox.setText("Proposal subit error!"); + msgBox.setInformativeText(strErrorMessages.c_str()); + msgBox.setIcon(QMessageBox::Warning); + msgBox.exec(); + return; + } + } + // RELAY THIS OBJECT + // Reject if rate check fails but don't update buffer + if(!governance.MasternodeRateCheck(govobj)) { + LogPrintf("gobject(submit) -- Object submission rejected because of rate check failure - hash = %s\n", strHash); + //return; + } + + LogPrintf("gobject(submit) -- Adding locally created governance object - %s\n", strHash); + + if(fMissingConfirmations) { + governance.AddPostponedObject(govobj); + govobj.Relay(*g_connman); + } else { + governance.AddGovernanceObject(govobj, *g_connman); + } + SetChannelSubscribtion(ui->lineeditPrivateChatAddress->text().toStdString(), + ui->lineeditPrivateChatPubKey->text().toStdString(), + ui->lineeditChannelPrivKey->text().toStdString(), + std::string("Proposal ") + ui->lineeditProposalName->text().toStdString()); + + strHash = govobj.GetHash().ToString(); + //TODO: oLgging it + std::string strErrorMessages = "Proposal hash - " + strHash + "\n"+ + "You can view approval status if type following command in the Console: \n" + "gobject getvotes "+ strHash +"\n"; + QMessageBox msgBox; + msgBox.setText("The proposal sucsessfully submited!"); + msgBox.setInformativeText(strErrorMessages.c_str()); + msgBox.setIcon(QMessageBox::Information); + msgBox.exec(); + ui->pushbuttonSubmit->setEnabled(false); + ui->labelProposalStatus->setText(QString::fromStdString("SUBMITED")); + + ui->lineeditProposalName->setReadOnly(true); + ui->texteditProposalDescription->setReadOnly(true); + ui->lineeditPaymentAddress->setReadOnly(true); + ui->dateeditPaymentStartDate->setEnabled(false); + ui->dateeditPaymentEndDate->setEnabled(false); + ui->spinboxAmount->setEnabled(false); + ui->spinboxPeriod->setEnabled(false); + + ui->lineeditProposalUrl->setReadOnly(true); + +} + +void NewProposalDialog::on_dateeditPaymentStartDate_userDateChanged(const QDate &date) +{ + ui->dateeditPaymentEndDate->setDate(date.addDays(ui->spinboxPeriod->value()-1)); +} + +void NewProposalDialog::on_dateeditPaymentEndDate_userDateChanged(const QDate &date) +{ + //ui->spinboxPeriod->setValue(date-(ui->dateeditPaymentStartDate->day())); + //TODO Later + +} + +void NewProposalDialog::on_dateeditPaymentEndDate_dateChanged(const QDate &date) +{ + +} + +void NewProposalDialog::on_pushbuttonClose_clicked() +{ +// if (ui->pushbuttonCheck->isEnabled()) + + this->close(); +} + +void NewProposalDialog::on_dateeditPaymentStartDate_dateTimeChanged(const QDateTime &dateTime) +{ + const Consensus::Params& consensusParams = Params().GetConsensus(); + ui->dateeditPaymentEndDate->setDateTime(QDateTime::fromTime_t(dateTime.toTime_t()+(ui->spinboxPeriod->value()-1)*consensusParams.nPowTargetSpacing*consensusParams.nBudgetPaymentsCycleBlocks)); + +} + +void NewProposalDialog::setWalletModel(WalletModel *model) +{ + this->walletModel = model; +} + +void NewProposalDialog::on_bnShowHideChannelDetails_clicked() +{ + ui->labelProposalChannelAddress->setVisible(!ui->labelProposalChannelAddress->isVisible()); + ui->lineeditPrivateChatAddress->setVisible(!ui->lineeditPrivateChatAddress->isVisible()); + ui->lineeditChannelPrivKey->setVisible(!ui->lineeditChannelPrivKey->isVisible()); + ui->lineeditPrivateChatPubKey->setVisible(!ui->lineeditPrivateChatPubKey->isVisible()); + ui->labelPublicKey->setVisible(!ui->labelPublicKey->isVisible()); + ui->labelPrivKey->setVisible(!ui->labelPrivKey->isVisible()); +} + +string NewProposalDialog::GetCurrentPropsalDataStr() +{ + std::string strProposalName = ui->lineeditProposalName->text().toStdString(); + std::string strProposalDescriptionHex = HexStr(ui->texteditProposalDescription->toHtml().toStdString());//TODO: toHtml/toPlainText + std::string strPaymentAddress = ui->lineeditPaymentAddress->text().toStdString(); + std::string strPrivateChatAddress = ui->lineeditPrivateChatAddress->text().toStdString(); + std::string strPrivatChatPubKey = ui->lineeditPrivateChatPubKey->text().toStdString(); + std::string strChannelPrivKey = ui->lineeditChannelPrivKey->text().toStdString(); + std::string strProposalUrl = ui->lineeditProposalUrl->text().toStdString(); + //int nPaymentStartDate = ui->dateeditPaymentStartDate->dateTime().toTime_t(); + //int nPaymentEndDate = ui->dateeditPaymentEndDate->dateTime().toTime_t(); + int nPaymentStartDate = ui->dateeditPaymentStartDate->dateTime().toTime_t() - Params().GetConsensus().nBudgetPaymentsCycleBlocks*Params().GetConsensus().nPowTargetSpacing/2;//Adding payment window for superblock-half payment/superblock cycle size. + int nPaymentEndDate = ui->dateeditPaymentEndDate->dateTime().toTime_t() + Params().GetConsensus().nBudgetPaymentsCycleBlocks*Params().GetConsensus().nPowTargetSpacing/2; + + int nPaymentAmount = ui->spinboxAmount->value(); + //nPaymentEndDate_str = boost::lexical_cast(nPaymentEndDate); + UniValue uvProposalData (UniValue::VARR); + uvProposalData.push_back("proposal"); + UniValue uvStrData (UniValue::VOBJ); + uvStrData.pushKV("end_epoch",nPaymentEndDate); + uvStrData.pushKV("name",strProposalName); + uvStrData.pushKV("payment_address",strPaymentAddress); + uvStrData.pushKV("payment_amount",nPaymentAmount); + uvStrData.pushKV("start_epoch",nPaymentStartDate); + uvStrData.pushKV("type",1); + uvStrData.pushKV("url",strProposalUrl); + uvStrData.pushKV("description",strProposalDescriptionHex); + uvStrData.pushKV("smsg_addr",strPrivateChatAddress); + uvStrData.pushKV("smsg_pubkey",strPrivatChatPubKey); + uvStrData.pushKV("smsg_privkey",strChannelPrivKey); + uvProposalData.push_back(uvStrData); + UniValue uvProposal (UniValue::VARR); + uvProposal.push_back(uvProposalData); + std::string strCurrentPropsalData = uvProposal.write(); + std::string strCurrentPropsalDataHex = HexStr (strCurrentPropsalData); + return strCurrentPropsalDataHex; +} + +void NewProposalDialog::on_toolButton_clicked() +{ + //if empty - paste, else openURL; +} + +void NewProposalDialog::on_pushbuttonDetails_clicked() +{ + QMessageBox msgBox; + msgBox.setText("Proposal details"); + msgBox.setInformativeText("Do not close this dialog. "); + msgBox.setIcon(QMessageBox::Information); + msgBox.exec(); +} + +int GetNextSuperblockTime() +{ + //return 0; + // Compute last/next superblock + int nLastSuperblock, nNextSuperblock; + + // Get current block height + int nBlockHeight = 0; + { + LOCK(cs_main); + nBlockHeight = (int)chainActive.Height(); + } + // getgovernanceinfo(); + + // Get chain parameters + int nSuperblockStartBlock = Params().GetConsensus().nSuperblockStartBlock; + int nSuperblockCycle = Params().GetConsensus().nSuperblockCycle; + + // Get first superblock + int nFirstSuperblockOffset = (nSuperblockCycle - nSuperblockStartBlock % nSuperblockCycle) % nSuperblockCycle; + int nFirstSuperblock = nSuperblockStartBlock + nFirstSuperblockOffset; + + if(nBlockHeight < nFirstSuperblock){ + nLastSuperblock = 0; + nNextSuperblock = nFirstSuperblock; + } else { + nLastSuperblock = nBlockHeight - nBlockHeight % nSuperblockCycle; + nNextSuperblock = nLastSuperblock + nSuperblockCycle; + } + + + return nNextSuperblock*Params().GetConsensus().nPowTargetSpacing + +chainActive.Genesis()->GetBlockTime(); + +} + +void NewProposalDialog::on_bnVoteYes_clicked() +{ + voteAction( "yes",""); +} + +void NewProposalDialog::voteAction(std::string vote, std::string strProposalHash ="") +{ + + strProposalHash = pGovObj->GetHash().ToString(); + uint256 hash; + hash = uint256S(strProposalHash); + std::string strVoteSignal, strVoteOutcome; + if (vote == "yes" || vote == "no" || vote =="abstain"){ + strVoteSignal = "funding"; + strVoteOutcome = vote; + } + else if (vote == "delete"){ + strVoteSignal = "delete"; + strVoteOutcome = "yes"; + }; + + vote_signal_enum_t eVoteSignal = CGovernanceVoting::ConvertVoteSignal(strVoteSignal); + vote_outcome_enum_t eVoteOutcome = CGovernanceVoting::ConvertVoteOutcome(strVoteOutcome); + int nSuccessful = 0; + int nFailed = 0; + + std::vector mnEntries; + mnEntries = masternodeConfig.getEntries(); + + UniValue resultsObj(UniValue::VOBJ); + + BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, mnEntries) { + std::string strError; + std::vector vchMasterNodeSignature; + std::string strMasterNodeSignMessage; + + CPubKey pubKeyCollateralAddress; + CKey keyCollateralAddress; + CPubKey pubKeyMasternode; + CKey keyMasternode; + + UniValue statusObj(UniValue::VOBJ); + + if(!CMessageSigner::GetKeysFromSecret(mne.getPrivKey(), keyMasternode, pubKeyMasternode)){ + nFailed++; + statusObj.push_back(Pair("result", "failed")); + statusObj.push_back(Pair("errorMessage", "Masternode signing error, could not set key correctly")); + resultsObj.push_back(Pair(mne.getAlias(), statusObj)); + continue; + } + + uint256 nTxHash; + nTxHash.SetHex(mne.getTxHash()); + + int nOutputIndex = 0; + if(!ParseInt32(mne.getOutputIndex(), &nOutputIndex)) { + continue; + } + + COutPoint outpoint(nTxHash, nOutputIndex); + + CMasternode mn; + bool fMnFound = mnodeman.Get(outpoint, mn); + + if(!fMnFound) { + nFailed++; + statusObj.push_back(Pair("result", "failed")); + statusObj.push_back(Pair("errorMessage", "Can't find masternode by collateral output")); + resultsObj.push_back(Pair(mne.getAlias(), statusObj)); + continue; + } + + CGovernanceVote vote(mn.vin.prevout, hash, eVoteSignal, eVoteOutcome); + if(!vote.Sign(keyMasternode, pubKeyMasternode)){ + nFailed++; + statusObj.push_back(Pair("result", "failed")); + statusObj.push_back(Pair("errorMessage", "Failure to sign.")); + resultsObj.push_back(Pair(mne.getAlias(), statusObj)); + continue; + } + + CGovernanceException exception; + if(governance.ProcessVoteAndRelay(vote, exception, *g_connman)) { + nSuccessful++; + statusObj.push_back(Pair("result", "success")); + } + else { + nFailed++; + statusObj.push_back(Pair("result", "failed")); + // statusObj.push_back(Pair("errorMessage", exception.GetMessage())); + } + + resultsObj.push_back(Pair(mne.getAlias(), statusObj)); + } + + UniValue returnObj(UniValue::VOBJ); + returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed))); + returnObj.push_back(Pair("detail", resultsObj)); + + + QMessageBox msgBox; + msgBox.setText(QString::fromStdString(returnObj[0].get_str()));// ..get_str())); + //msgBox.setInformativeText(strErrorMessages.c_str()); + msgBox.setIcon(QMessageBox::Information); + msgBox.exec(); +} + +void NewProposalDialog::on_bnVoteNo_clicked() +{ + voteAction("no"); +} + +void NewProposalDialog::on_bnVoteAbstain_clicked() +{ + voteAction("abstain"); +} + +void NewProposalDialog::on_bnJoinChannel_clicked() +{ + if (ui->lineeditPrivateChatAddress->text().isEmpty()){ + std::string strAddress, strPubKey, strPrivateKey; + GetNewChannelAddress(strAddress, strPubKey, strPrivateKey); + ui->lineeditPrivateChatAddress->setText(strAddress.c_str()); + ui->lineeditPrivateChatPubKey->setText(strPubKey.c_str()); + ui->lineeditChannelPrivKey->setText(strPrivateKey.c_str()); + } + else{ + //add dialog here for confirmations + SetChannelSubscribtion(ui->lineeditPrivateChatAddress->text().toStdString(), + ui->lineeditPrivateChatPubKey->text().toStdString(), + ui->lineeditChannelPrivKey->text().toStdString(), + std::string("PR-") + ui->lineeditProposalName->text().toStdString() + ); + ui->bnJoinChannel->setEnabled(!GetIsChannelSubscribed(ui->lineeditPrivateChatAddress->text().toStdString())); +// QMessageBox msgBox; +// msgBox.setText("The Proposal Channel is successfully subscribed"); +// msgBox.setIcon(QMessageBox::Information); +// msgBox.exec(); + + } +} + +void NewProposalDialog::on_bnOpenURL_clicked() +{ + QDesktopServices::openUrl (QUrl(ui->lineeditProposalUrl->text())); +} + +void NewProposalDialog::on_texteditProposalDescription_textChanged() +{ + if (ui->texteditProposalDescription->toPlainText().size()>1000) + { + QTextCursor cursor = ui->texteditProposalDescription->textCursor(); + QToolTip::showText(ui->texteditProposalDescription->mapToGlobal(QPoint()), tr("Only 1000 symbols allowed for description. Please use additional recource, if required.")); + ui->texteditProposalDescription->setText(ui->texteditProposalDescription->toPlainText().left(1000)); + //ui->texteditProposalDescription->setCursorPosition(1000); + ui->texteditProposalDescription->setTextCursor( cursor ); + } +} From 560487ac019671af739cea6311b8f43a47040c7a Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:03:27 -0400 Subject: [PATCH 029/469] Create newproposaldialog.h --- src/qt/newproposaldialog.h | 82 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/qt/newproposaldialog.h diff --git a/src/qt/newproposaldialog.h b/src/qt/newproposaldialog.h new file mode 100644 index 00000000..6be32ff4 --- /dev/null +++ b/src/qt/newproposaldialog.h @@ -0,0 +1,82 @@ +// Copyright (c) 2017-2018 The Aywa Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_NEWPROPOSALDIALOG_H +#define BITCOIN_QT_NEWPROPOSALDIALOG_H + +#include + +class WalletModel; +class PlatformStyle; + +namespace Ui { + class NewProposalDialog; +} + +QT_BEGIN_NAMESPACE +class QModelIndex; +QT_END_NAMESPACE + +/** Dialog showing transaction details. */ +class NewProposalDialog : public QWidget +{ + Q_OBJECT + +public: + explicit NewProposalDialog(const std::string idx, QWidget *parent = 0); + ~NewProposalDialog(); + + void setWalletModel(WalletModel *walletModel); + void voteAction (std::string vote, std::string strProposalHash); + +private: + WalletModel *walletModel; + const PlatformStyle *platformStyle; + std::string GetCurrentPropsalDataStr(); + +private Q_SLOTS: + void on_spinboxPeriod_valueChanged(int nPeriod); + + void on_pushbuttonCheck_clicked(); + + void on_spinboxAmount_valueChanged(int arg1); + + void on_pushbuttonPrepare_clicked(); + + void on_toolbuttonSelectPaymentAddress_clicked(); + + void on_toolButton_2_clicked(); + + void on_pushbuttonSubmit_clicked(); + + void on_dateeditPaymentStartDate_userDateChanged(const QDate &date); + + void on_dateeditPaymentEndDate_userDateChanged(const QDate &date); + + void on_dateeditPaymentEndDate_dateChanged(const QDate &date); + + void on_pushbuttonClose_clicked(); + + void on_dateeditPaymentStartDate_dateTimeChanged(const QDateTime &dateTime); + + void on_bnShowHideChannelDetails_clicked(); + + void on_toolButton_clicked(); + + void on_pushbuttonDetails_clicked(); + + void on_bnVoteYes_clicked(); + void on_bnVoteNo_clicked(); + void on_bnVoteAbstain_clicked(); + void on_bnJoinChannel_clicked(); + void on_bnOpenURL_clicked(); + void on_texteditProposalDescription_textChanged(); + + + +private: + Ui::NewProposalDialog *ui; +}; + +#endif // BITCOIN_QT_NEWPROPOSALDIALOG_H From cab4ffe3a8fec8af401acb9bbb5b398218df97ae Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:04:03 -0400 Subject: [PATCH 030/469] Create newproposaldialog.ui --- src/qt/forms/newproposaldialog.ui | 781 ++++++++++++++++++++++++++++++ 1 file changed, 781 insertions(+) create mode 100644 src/qt/forms/newproposaldialog.ui diff --git a/src/qt/forms/newproposaldialog.ui b/src/qt/forms/newproposaldialog.ui new file mode 100644 index 00000000..3338e6e9 --- /dev/null +++ b/src/qt/forms/newproposaldialog.ui @@ -0,0 +1,781 @@ + + + NewProposalDialog + + + + 0 + 0 + 611 + 682 + + + + Aywa Core: New Proposal + + + + + + + + 0 + + + + + + 0 + 0 + + + + Payment Address: + + + + + + + + 0 + 0 + + + + + + + Generete a new one or paste your AYWA wallet address. + + + + + + + true + + + + 0 + 0 + + + + Generate + + + + + + + false + + + + 0 + 0 + + + + Add to Address Book + + + true + + + + + + + + + 0 + + + + + Qt::LeftToRight + + + Proposal discussion channel: + + + Qt::AlignCenter + + + + + + + <ChannelAddress> + + + + + + + true + + + Create/Join channel + + + + :/images/trad/drkblue_downArrow_small:/images/trad/drkblue_downArrow_small + + + + + + + If button is disabled, channel is already subscribed + + + Join Channel + + + + + + + + + + + + 0 + 0 + + + + + 150 + 0 + + + + QAbstractSpinBox::NoButtons + + + false + + + true + + + Qt::LocalTime + + + + + + + Payment start date: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Payment end date: + + + + + + + Payments count: + + + + + + + 0 + + + 0 + + + + + + 0 + 0 + + + + 1 + + + 150 + + + 1 + + + + + + + payment(s) + + + + + + + + + Payment amount: + + + + + + + Qt::Horizontal + + + + 100 + 20 + + + + + + + + false + + + Qt::ImhDate + + + QAbstractSpinBox::NoButtons + + + + + + true + + + Qt::LocalTime + + + + + + + 0 + + + 0 + + + + + + 0 + 0 + + + + 1 + + + 1000 + + + 10 + + + + + + + AYWA + + + + + + + + + + + Qt::Horizontal + + + + + + + 1000 symbols max + + + + + + + Qt::Horizontal + + + + + + + Proposal description: + + + + + + + Proposal name: + + + + + + + Qt::ImhUrlCharactersOnly + + + 40 + + + Max - 40 symbols. Only letters, numbers and '_' symbol. Space is not allowed. + + + + + + + 0 + + + + + Proposal Channel Address: + + + + + + + true + + + true + + + + + + + + + 0 + + + + + PublicKey: + + + + + + + true + + + true + + + + + + + Channel PrivKey: + + + + + + + true + + + true + + + + + + + + + 0 + + + + + + 0 + 0 + + + + Discussion URL: + + + + + + + + 0 + 0 + + + + + + + Paste only real URL here. No space allowed. + + + + + + + true + + + + 0 + 0 + + + + -> + + + + + + + + + 10 + + + + + + 0 + 0 + + + + + 50 + false + + + + Total proposal budget: + + + + + + + + 50 + false + + + + 0 + + + + + + + + 0 + 0 + + + + AYWA + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + Revision: + + + + + + + + 0 + 0 + + + + 0 + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + Proposal Status: + + + + + + + NEW + + + + + + + + + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Vote 'YES' + + + + + + + Vote 'NO' + + + + + + + Vote 'ABSTAIN' + + + + + + + + + 0 + + + + + Check + + + + + + + false + + + Prepare + + + + + + + false + + + Submit + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + + + + Reset + + + false + + + + + + + Close + + + + + + + + + lineeditProposalName + texteditProposalDescription + bnOpenURL + lineeditPaymentAddress + toolbuttonSelectPaymentAddress + dateeditPaymentStartDate + dateeditPaymentEndDate + lineeditPrivateChatAddress + lineeditPrivateChatPubKey + pushbuttonCheck + pushbuttonPrepare + pushbuttonSubmit + pushbuttonReset + pushbuttonClose + + + + + + + lineeditPrivateChatAddress + textChanged(QString) + label_17 + setText(QString) + + + 272 + 471 + + + 284 + 444 + + + + + From 37a429809d3d710a95ca6fd36aa5aa31fc3a0d4e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:05:51 -0400 Subject: [PATCH 031/469] Update Makefile.qt.include --- src/Makefile.qt.include | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 49c453a9..a7d8c1dd 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -41,6 +41,7 @@ QT_FORMS_UI = \ qt/forms/intro.ui \ qt/forms/modaloverlay.ui \ qt/forms/masternodelist.ui \ + qt/forms/newproposaldialog.ui \ qt/forms/qrdialog.ui \ qt/forms/openuridialog.ui \ qt/forms/optionsdialog.ui \ @@ -76,6 +77,7 @@ QT_MOC_CPP = \ qt/moc_macnotificationhandler.cpp \ qt/moc_modaloverlay.cpp \ qt/moc_masternodelist.cpp \ + qt/moc_newproposaldialog.cpp \ qt/moc_notificator.cpp \ qt/moc_openuridialog.cpp \ qt/moc_optionsdialog.cpp \ @@ -153,6 +155,7 @@ BITCOIN_QT_H = \ qt/modaloverlay.h \ qt/masternodelist.h \ qt/networkstyle.h \ + qt/newproposaldialog.h \ qt/notificator.h \ qt/openuridialog.h \ qt/optionsdialog.h \ @@ -504,6 +507,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/governancelist.cpp \ qt/governancedialog.cpp \ qt/masternodelist.cpp \ + qt/newproposaldialog.cpp \ qt/openuridialog.cpp \ qt/overviewpage.cpp \ qt/privatesendpage.cpp \ From 28aff2fd65404100fad38b10b0f989a7c0bcd94c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:10:23 -0400 Subject: [PATCH 032/469] Update newproposaldialog.cpp --- src/qt/newproposaldialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/newproposaldialog.cpp b/src/qt/newproposaldialog.cpp index 4517dfb2..98a61ad8 100644 --- a/src/qt/newproposaldialog.cpp +++ b/src/qt/newproposaldialog.cpp @@ -8,7 +8,7 @@ #include "utilstrencodings.h" #include "addressbookpage.h" #include "masternode-sync.h" -#include "masternodeman.h" +/* #include "masternodeman.h" */ #include "activemasternode.h" #include "walletmodel.h" #include "bitcoingui.h" From 4dfeaeab7ba56e9861861c345af6c9d983263029 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:20:30 -0400 Subject: [PATCH 033/469] Update newproposaldialog.cpp --- src/qt/newproposaldialog.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qt/newproposaldialog.cpp b/src/qt/newproposaldialog.cpp index 98a61ad8..1de9c619 100644 --- a/src/qt/newproposaldialog.cpp +++ b/src/qt/newproposaldialog.cpp @@ -23,7 +23,6 @@ //#endif // ENABLE_WALLET #include "validation.h" #include "ui_newproposaldialog.h" -#include "smessage.h" #include "masternodeconfig.h" #include "messagesigner.h" @@ -69,7 +68,7 @@ NewProposalDialog::NewProposalDialog(const std::string idx, QWidget *parent) : if (!pGovObj) return; //only GOVERNANCE_OBJECT_PROPOSAL can be opened UniValue objJSON = pGovObj->GetJSONObject(); std::string strName = objJSON["name"].get_str(); - std::string strWindowTitle = "Aywa Core - Proposal "+strName; + std::string strWindowTitle = "HTH - Proposal "+strName; int nEnd_epoch = objJSON["end_epoch"].get_int(); std::string strPayment_address = objJSON["payment_address"].get_str(); int nPayment_amount = objJSON["payment_amount"].get_int(); From 5ddf9a54891afe99229170913417751ea79d85c4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:21:29 -0400 Subject: [PATCH 034/469] Update newproposaldialog.cpp --- src/qt/newproposaldialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/newproposaldialog.cpp b/src/qt/newproposaldialog.cpp index 1de9c619..8fb33933 100644 --- a/src/qt/newproposaldialog.cpp +++ b/src/qt/newproposaldialog.cpp @@ -24,7 +24,7 @@ #include "validation.h" #include "ui_newproposaldialog.h" -#include "masternodeconfig.h" +#include "masternode-utils.h" #include "messagesigner.h" From df372986c2c37dc2bbb4bdfef34be00070632b6b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:30:44 -0400 Subject: [PATCH 035/469] Update newproposaldialog.cpp --- src/qt/newproposaldialog.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/qt/newproposaldialog.cpp b/src/qt/newproposaldialog.cpp index 8fb33933..1fd7cf00 100644 --- a/src/qt/newproposaldialog.cpp +++ b/src/qt/newproposaldialog.cpp @@ -150,6 +150,20 @@ NewProposalDialog::NewProposalDialog(const std::string idx, QWidget *parent) : ui->labelTotalProposalBudget->setText(QString::number(ui->spinboxPeriod->value()*ui->spinboxAmount->value())); } +//Return random string data for channel subsciption. Not wallet data. +void GetNewChannelAddress(std::string & strAddress, std::string & strPubKey, std::string & strPrivateKey) +{ + CKey secret; + CPubKey pubKey; + secret.MakeNewKey(true); + pubKey = secret.GetPubKey(); + assert(secret.VerifyPubKey(pubKey)); + CKeyID keyID = pubKey.GetID(); + strAddress = CBitcoinAddress(keyID).ToString(); + strPubKey = EncodeBase58(pubKey.begin(), pubKey.end()); + strPrivateKey = CBitcoinSecret(secret).ToString(); +} + NewProposalDialog::~NewProposalDialog() { GUIUtil::saveWindowGeometry("NewProposalDialogWindow", this); From c77c5ed8867672a8cb06d58490368c879ca96269 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:31:47 -0400 Subject: [PATCH 036/469] Update newproposaldialog.h --- src/qt/newproposaldialog.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/newproposaldialog.h b/src/qt/newproposaldialog.h index 6be32ff4..b3325922 100644 --- a/src/qt/newproposaldialog.h +++ b/src/qt/newproposaldialog.h @@ -72,6 +72,7 @@ private Q_SLOTS: void on_bnJoinChannel_clicked(); void on_bnOpenURL_clicked(); void on_texteditProposalDescription_textChanged(); + void GetNewChannelAddress(std::string & strAddress, std::string & strPubKey, std::string & strPrivateKey); From c63f584aa86e98d0d68b934afa79280d67f8af1d Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:32:56 -0400 Subject: [PATCH 037/469] Update newproposaldialog.h --- src/qt/newproposaldialog.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qt/newproposaldialog.h b/src/qt/newproposaldialog.h index b3325922..55b1629f 100644 --- a/src/qt/newproposaldialog.h +++ b/src/qt/newproposaldialog.h @@ -73,6 +73,11 @@ private Q_SLOTS: void on_bnOpenURL_clicked(); void on_texteditProposalDescription_textChanged(); void GetNewChannelAddress(std::string & strAddress, std::string & strPubKey, std::string & strPrivateKey); + void SetChannelSubscribtion(std::string strAddress, std::string strPubKey, + std::string strPrivateKey, std::string strName); +bool GetIsChannelSubscribed (std::string strChannelAddress); +bool GetChannelKeys(std::string strAddress, std::string & strPubKey, std::string & strPrivKey); +std::string GetChannelName(std::string strAddress); From b9847a9d691eba93d8a7c09b8eaa129083a486b3 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:34:14 -0400 Subject: [PATCH 038/469] Update newproposaldialog.cpp --- src/qt/newproposaldialog.cpp | 75 ++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/src/qt/newproposaldialog.cpp b/src/qt/newproposaldialog.cpp index 1fd7cf00..262657e5 100644 --- a/src/qt/newproposaldialog.cpp +++ b/src/qt/newproposaldialog.cpp @@ -164,6 +164,81 @@ void GetNewChannelAddress(std::string & strAddress, std::string & strPubKey, std strPrivateKey = CBitcoinSecret(secret).ToString(); } +void SetChannelSubscribtion(std::string strAddress, std::string strPubKey, + std::string strPrivateKey, std::string strName = std::string("")) +{ + + if (GetIsChannelSubscribed (strAddress)) + return; + + smsgChannels.push_back(SecMsgChannel(std::string(strAddress), std::string(strPubKey), + std::string(strPrivateKey), true, true, + strName));//TODO:add name + + if (!SecureMsgWriteIni()) + return; + +// static boost::thread_group* scanBucketsThreads = NULL; + +// if (scanBucketsThreads != NULL) +// { +// scanBucketsThreads->interrupt_all(); +// delete scanBucketsThreads; +// scanBucketsThreads = NULL; +// } + +// scanBucketsThreads = new boost::thread_group(); +// int nThreads = 1; +// for (int i = 0; i < nThreads; i++) +// scanBucketsThreads->create_thread(boost::bind(&SecureMsgScanBuckets)); + +// SecureMsgScanBuckets(); + +} + +bool GetIsChannelSubscribed (std::string strChannelAddress) +{ + BOOST_FOREACH(SecMsgChannel curChannel, smsgChannels) { + if (curChannel.sAddress==strChannelAddress) + return true; + }; + return false; +} + +bool GetChannelKeys(std::string strAddress, std::string & strPubKey, std::string & strPrivKey) +{ + //std::string strPrivKev; + //TODO: + BOOST_FOREACH(SecMsgChannel curChannel, smsgChannels) { + if (curChannel.sAddress==strAddress) { + strPubKey = curChannel.sPubKey; + strPrivKey = curChannel.sPrivKey; + break; + } + }; + CBitcoinSecret vchSecret; + if (!vchSecret.SetString(strPrivKey)) + { + error("%s: Could not get private key for addressFrom.", __func__); + return false; } + CKey keyFrom = vchSecret.GetKey(); + if (!keyFrom.IsValid()){ + error("%s: Could not get private key for addressFrom.", __func__); + return false; + } + return true; +} + +std::string GetChannelName(std::string strAddress) +{ + BOOST_FOREACH(SecMsgChannel curChannel, smsgChannels) { + if (curChannel.sAddress==strAddress) { + return (curChannel.sName); + } + }; + return std::string(""); +} + NewProposalDialog::~NewProposalDialog() { GUIUtil::saveWindowGeometry("NewProposalDialogWindow", this); From f416dfed5beb7cc12ec8865815ab0ae672135dfd Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:35:35 -0400 Subject: [PATCH 039/469] Delete newproposaldialog.cpp --- src/qt/newproposaldialog.cpp | 940 ----------------------------------- 1 file changed, 940 deletions(-) delete mode 100644 src/qt/newproposaldialog.cpp diff --git a/src/qt/newproposaldialog.cpp b/src/qt/newproposaldialog.cpp deleted file mode 100644 index 262657e5..00000000 --- a/src/qt/newproposaldialog.cpp +++ /dev/null @@ -1,940 +0,0 @@ -// Copyright (c) 2017-2018 The Aywa Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "guiutil.h" -#include "newproposaldialog.h" -#include "governance-validators.h" -#include "utilstrencodings.h" -#include "addressbookpage.h" -#include "masternode-sync.h" -/* #include "masternodeman.h" */ -#include "activemasternode.h" -#include "walletmodel.h" -#include "bitcoingui.h" -#include "governance-object.h" -#include "governance.h" -#include "init.h" -#include "transactionrecord.h" -//#ifdef ENABLE_WALLET //TODO: uncomment -#include "wallet/wallet.h" -#include "rpc/server.h" -//#include "univalue.h" -//#endif // ENABLE_WALLET -#include "validation.h" -#include "ui_newproposaldialog.h" - -#include "masternode-utils.h" -#include "messagesigner.h" - - -#include -#include -#include -#include -#include -#include - -uint256 txidFee; -std::string strProposalName, strProposalDescriptionHex, strPaymentAddress, - sProposalChannelAddress, strProposalChannelPubKey, strProposalChannelPrivKey, strProposalStatus, - strProposalUrl, nPaymentEndDate_str; -int nProposalRevision, nProposalTime, nPaymentStartDate, nPaymentEndDate, nPaymentAmount; -int GetNextSuperblockTime(); -CGovernanceObject* pGovObj; - -NewProposalDialog::NewProposalDialog(const std::string idx, QWidget *parent) : - QWidget(parent), - ui(new Ui::NewProposalDialog) -{ - //GUIUtil::restoreWindowGeometry("NewProposalDialogWindow", this->size(), this);//TODO - ui->setupUi(this); - /* Open CSS when configured */ - this->setStyleSheet(GUIUtil::loadStyleSheet()); - - ui->labelProposalChannelAddress->setVisible(false); - ui->lineeditPrivateChatAddress->setVisible(false); - ui->lineeditChannelPrivKey->setVisible(false); - ui->lineeditPrivateChatPubKey->setVisible(false); - ui->labelPublicKey->setVisible(false); - ui->labelPrivKey->setVisible(false); - ui->pushbuttonReset->setVisible(false); - - - if (!idx.empty()) { //Open exists proposal item - uint256 hash = uint256S(idx); - //CGovernanceObject* - pGovObj = governance.FindGovernanceObject(hash); - if (!pGovObj) return; //only GOVERNANCE_OBJECT_PROPOSAL can be opened - UniValue objJSON = pGovObj->GetJSONObject(); - std::string strName = objJSON["name"].get_str(); - std::string strWindowTitle = "HTH - Proposal "+strName; - int nEnd_epoch = objJSON["end_epoch"].get_int(); - std::string strPayment_address = objJSON["payment_address"].get_str(); - int nPayment_amount = objJSON["payment_amount"].get_int(); - int nStart_epoch = objJSON["start_epoch"].get_int(); - std::string strUrl = objJSON["url"].get_str(); - std::string strProposalChannelAddress, strProposalChannelPrivKey, strProposalChannelPubKey; - try{//some proposals dont have a description - strProposalChannelAddress = objJSON["smsg_addr"].get_str(); - strProposalChannelPubKey = objJSON["smsg_pubkey"].get_str(); - strProposalChannelPrivKey = objJSON["smsg_privkey"].get_str(); - std::string strDescription = objJSON["description"].get_str(); - std::vector v = ParseHex(strDescription); - std::string strProposalDescription(v.begin(), v.end()); - ui->texteditProposalDescription->setHtml(strProposalDescription.c_str()); - } - catch(std::exception& e) - { - ui->texteditProposalDescription->setText(e.what()); - }; - - ui->lineeditProposalName->setText(strName.c_str()); - ui->lineeditProposalName->setReadOnly(true); - - ui->texteditProposalDescription->setReadOnly(true); - ui->lineeditPaymentAddress->setText(strPayment_address.c_str()); - ui->lineeditPaymentAddress->setReadOnly(true); - ui->dateeditPaymentStartDate->setDateTime(QDateTime::fromTime_t(nStart_epoch+43200));// + Params().GetConsensus().nBudgetPaymentsCycleBlocks * Params().GetConsensus().nPowTargetSpacing / 2)); - ui->dateeditPaymentStartDate->setEnabled(false); - ui->dateeditPaymentEndDate->setDateTime(QDateTime::fromTime_t(nEnd_epoch-43200));// - Params().GetConsensus().nBudgetPaymentsCycleBlocks * Params().GetConsensus().nPowTargetSpacing / 2)); - ui->dateeditPaymentEndDate->setEnabled(false); - ui->spinboxAmount->setValue(nPayment_amount); - ui->spinboxAmount->setEnabled(false); - const Consensus::Params& consensusParams = Params().GetConsensus(); - const int nBudgetPaymentsCycleBlocks = consensusParams.nBudgetPaymentsCycleBlocks; - ui->spinboxPeriod->setValue((nEnd_epoch - nStart_epoch)/86400); - - ui->spinboxPeriod->setEnabled(false); - - ui->lineeditProposalUrl->setText(strUrl.c_str()); - ui->lineeditProposalUrl->setReadOnly(true); - - ui->lineeditPrivateChatAddress->setText(strProposalChannelAddress.c_str()); - ui->lineeditPrivateChatPubKey->setText(strProposalChannelPubKey.c_str()); - ui->lineeditChannelPrivKey->setText(strProposalChannelPrivKey.c_str()); - - ui->bnJoinChannel->setEnabled(!GetIsChannelSubscribed(ui->lineeditPrivateChatAddress->text().toStdString())); - - ui->lineeditPrivateChatAddress->setReadOnly(true); - ui->pushbuttonCheck->setEnabled(false); - ui->toolbuttonSelectPaymentAddress->setEnabled(false); - this->setWindowTitle(strWindowTitle.c_str()); -// connect(MasternodeList.voteAction();, ) - } - else //new item - { - ui->dateeditPaymentStartDate->setMaximumDate(QDate::currentDate().addDays(30));//no more, than 1 month planning future - - int nNextSuperBlockTime = GetNextSuperblockTime(); - int nProposalRecommendedTime = nNextSuperBlockTime + Params().GetConsensus().nBudgetPaymentsCycleBlocks * Params().GetConsensus().nPowTargetSpacing; - int nProposalMinimumTime = nNextSuperBlockTime; - - - ui->dateeditPaymentStartDate->setDateTime(QDateTime::fromTime_t(nProposalRecommendedTime)); - ui->dateeditPaymentStartDate->setMinimumDateTime(QDateTime::fromTime_t(nProposalMinimumTime)); - - ui->dateeditPaymentStartDate->setMaximumTime(ui->dateeditPaymentStartDate->time()); - int nPeriod = 0; - ui->dateeditPaymentEndDate->setDateTime(QDateTime::fromTime_t(ui->dateeditPaymentStartDate->dateTime().toTime_t() + nPeriod*Params().GetConsensus().nPowTargetSpacing*Params().GetConsensus().nBudgetPaymentsCycleBlocks)); - std::string strAddress, strPubKey, strPrivateKey; - GetNewChannelAddress(strAddress, strPubKey, strPrivateKey); - ui->lineeditPrivateChatAddress->setText(strAddress.c_str()); - ui->lineeditPrivateChatPubKey->setText(strPubKey.c_str()); - ui->lineeditChannelPrivKey->setText(strPrivateKey.c_str()); - ui->bnJoinChannel->setEnabled(false); - ui->bnVoteYes->setVisible(false); - ui->bnVoteNo->setVisible(false); - ui->bnVoteAbstain->setVisible(false); - } - ui->labelTotalProposalBudget->setText(QString::number(ui->spinboxPeriod->value()*ui->spinboxAmount->value())); -} - -//Return random string data for channel subsciption. Not wallet data. -void GetNewChannelAddress(std::string & strAddress, std::string & strPubKey, std::string & strPrivateKey) -{ - CKey secret; - CPubKey pubKey; - secret.MakeNewKey(true); - pubKey = secret.GetPubKey(); - assert(secret.VerifyPubKey(pubKey)); - CKeyID keyID = pubKey.GetID(); - strAddress = CBitcoinAddress(keyID).ToString(); - strPubKey = EncodeBase58(pubKey.begin(), pubKey.end()); - strPrivateKey = CBitcoinSecret(secret).ToString(); -} - -void SetChannelSubscribtion(std::string strAddress, std::string strPubKey, - std::string strPrivateKey, std::string strName = std::string("")) -{ - - if (GetIsChannelSubscribed (strAddress)) - return; - - smsgChannels.push_back(SecMsgChannel(std::string(strAddress), std::string(strPubKey), - std::string(strPrivateKey), true, true, - strName));//TODO:add name - - if (!SecureMsgWriteIni()) - return; - -// static boost::thread_group* scanBucketsThreads = NULL; - -// if (scanBucketsThreads != NULL) -// { -// scanBucketsThreads->interrupt_all(); -// delete scanBucketsThreads; -// scanBucketsThreads = NULL; -// } - -// scanBucketsThreads = new boost::thread_group(); -// int nThreads = 1; -// for (int i = 0; i < nThreads; i++) -// scanBucketsThreads->create_thread(boost::bind(&SecureMsgScanBuckets)); - -// SecureMsgScanBuckets(); - -} - -bool GetIsChannelSubscribed (std::string strChannelAddress) -{ - BOOST_FOREACH(SecMsgChannel curChannel, smsgChannels) { - if (curChannel.sAddress==strChannelAddress) - return true; - }; - return false; -} - -bool GetChannelKeys(std::string strAddress, std::string & strPubKey, std::string & strPrivKey) -{ - //std::string strPrivKev; - //TODO: - BOOST_FOREACH(SecMsgChannel curChannel, smsgChannels) { - if (curChannel.sAddress==strAddress) { - strPubKey = curChannel.sPubKey; - strPrivKey = curChannel.sPrivKey; - break; - } - }; - CBitcoinSecret vchSecret; - if (!vchSecret.SetString(strPrivKey)) - { - error("%s: Could not get private key for addressFrom.", __func__); - return false; } - CKey keyFrom = vchSecret.GetKey(); - if (!keyFrom.IsValid()){ - error("%s: Could not get private key for addressFrom.", __func__); - return false; - } - return true; -} - -std::string GetChannelName(std::string strAddress) -{ - BOOST_FOREACH(SecMsgChannel curChannel, smsgChannels) { - if (curChannel.sAddress==strAddress) { - return (curChannel.sName); - } - }; - return std::string(""); -} - -NewProposalDialog::~NewProposalDialog() -{ - GUIUtil::saveWindowGeometry("NewProposalDialogWindow", this); - delete ui; -} - - - -void NewProposalDialog::on_spinboxPeriod_valueChanged(int nPeriod) -{ - ui->labelTotalProposalBudget->setText(QString::number(ui->spinboxPeriod->value()*ui->spinboxAmount->value())); - ui->dateeditPaymentEndDate->setDateTime(QDateTime::fromTime_t(ui->dateeditPaymentStartDate->dateTime().toTime_t() + (nPeriod-1) * Params().GetConsensus().nPowTargetSpacing*Params().GetConsensus().nBudgetPaymentsCycleBlocks)); - //ui->dateeditPaymentStartDate->setDisplayFormat("dd.MM.yyyy hh:mm"); -} - -void NewProposalDialog::on_pushbuttonCheck_clicked() -{ - uint256 hashParent; - int nRevision = 1; - strProposalName = ui->lineeditProposalName->text().toStdString(); - strProposalDescriptionHex = HexStr(ui->texteditProposalDescription->toHtml().toStdString());//TODO: toHtml/toPlainText - std::vector v = ParseHex(strProposalDescriptionHex); - std::string strProposalDescription(v.begin(), v.end()); - ui->texteditProposalDescription->setHtml(strProposalDescription.c_str()); - strPaymentAddress = ui->lineeditPaymentAddress->text().toStdString(); - sProposalChannelAddress = ui->lineeditPrivateChatAddress->text().toStdString(); - strProposalChannelPubKey = ui->lineeditPrivateChatPubKey->text().toStdString(); - strProposalUrl = ui->lineeditProposalUrl->text().toStdString(); - //strProposalStatus = "NEW"; - nPaymentStartDate = ui->dateeditPaymentStartDate->dateTime().toTime_t() - Params().GetConsensus().nBudgetPaymentsCycleBlocks*Params().GetConsensus().nPowTargetSpacing/2;//Adding payment window for superblock-half payment/superblock cycle size. - nPaymentEndDate = ui->dateeditPaymentEndDate->dateTime().toTime_t() + Params().GetConsensus().nBudgetPaymentsCycleBlocks*Params().GetConsensus().nPowTargetSpacing/2; - nPaymentAmount = ui->spinboxAmount->value(); - //nPaymentEndDate_str = boost::lexical_cast(nPaymentEndDate); - UniValue uvProposalData (UniValue::VARR); - uvProposalData.push_back("proposal"); - UniValue uvStrData (UniValue::VOBJ); - uvStrData.pushKV("end_epoch",nPaymentEndDate); - uvStrData.pushKV("name",strProposalName); - uvStrData.pushKV("payment_address",strPaymentAddress); - uvStrData.pushKV("payment_amount",nPaymentAmount); - uvStrData.pushKV("start_epoch",nPaymentStartDate); - uvStrData.pushKV("type",1); - uvStrData.pushKV("url",strProposalUrl); - uvStrData.pushKV("description",strProposalDescriptionHex); - uvStrData.pushKV("smsg_addr",sProposalChannelAddress); - uvStrData.pushKV("smsg_pubkey",strProposalChannelPubKey); - uvStrData.pushKV("smsg_pubkey","PUBKEY"); - uvStrData.pushKV("smsg_privkey","PRIVKEY"); - uvProposalData.push_back(uvStrData); - - UniValue uvProposal (UniValue::VARR); - uvProposal.push_back(uvProposalData); - - std::string strDataAll = uvProposal.write(); - std::string strErrorMessages; - std::string strData = HexStr (strDataAll); - //ui->texteditProposalDescription->setText(QString::fromStdString(strData)); - //ui->texteditHEX->setText(QString::fromStdString(strData)); - int64_t nTime = GetAdjustedTime(); - strData = GetCurrentPropsalDataStr(); - CGovernanceObject govobj(hashParent, nRevision, nTime, uint256(), strData); - if(govobj.GetObjectType() == GOVERNANCE_OBJECT_PROPOSAL) { - CProposalValidator validator(strData); - if(!validator.Validate()) { - std::string strErrorMessages = validator.GetErrorMessages(); - QMessageBox msgBox; - strErrorMessages = "Invalid proposal data, error messages: "+strErrorMessages; - msgBox.setText("Proposal validation error!"); - msgBox.setInformativeText(strErrorMessages.c_str()); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); - return; - } - } - else{ - strErrorMessages = "Invalid object type, only proposals can be validated"; - QMessageBox msgBox; - msgBox.setText("Proposal validation error!"); - msgBox.setInformativeText(strErrorMessages.c_str()); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); - return; - } - //objResult.push_back(Pair("Object status", "OK")); - ui->labelProposalStatus->setText(QString::fromStdString("CHECKED")); - ui->pushbuttonCheck->setEnabled(false); - ui->pushbuttonPrepare->setEnabled(true); - ui->pushbuttonReset->setEnabled(true); - - ui->lineeditProposalName->setReadOnly(true); - ui->texteditProposalDescription->setReadOnly(true); - ui->lineeditPaymentAddress->setReadOnly(true); - ui->dateeditPaymentStartDate->setEnabled(false); - ui->dateeditPaymentEndDate->setEnabled(false); - ui->spinboxAmount->setEnabled(false); - ui->spinboxPeriod->setEnabled(false); - - ui->lineeditProposalUrl->setReadOnly(true); - - - QMessageBox msgBox; - msgBox.setText("Proposal validation passed."); - msgBox.setInformativeText("Proposal is valid. " - "Press 'Prepare' button to create 1 AYWA proposal collateral tx."); - msgBox.setIcon(QMessageBox::Information); - msgBox.exec(); - -} - -void NewProposalDialog::on_spinboxAmount_valueChanged(int arg1) -{ - ui->labelTotalProposalBudget->setText(QString::number(ui->spinboxPeriod->value()*ui->spinboxAmount->value())); - -} - -void NewProposalDialog::on_pushbuttonPrepare_clicked() -{ - uint256 hashParent; hashParent = uint256();//TODO - - std::string strRevision = "1";//TODO Check it later - int nRevision = boost::lexical_cast(strRevision); - int nTime = GetAdjustedTime(); - nProposalTime = nTime; - std::string strData = GetCurrentPropsalDataStr(); - - // CREATE A NEW COLLATERAL TRANSACTION FOR THIS SPECIFIC OBJECT - - CGovernanceObject govobj(hashParent, nRevision, nTime, uint256(), strData); - //TODO:Logging object creation details. - if(govobj.GetObjectType() == GOVERNANCE_OBJECT_PROPOSAL) { - CProposalValidator validator(strData); - if(!validator.Validate()) { - std::string strErrorMessages = "Invalid proposal data, error messages: "+validator.GetErrorMessages(); - QMessageBox msgBox; - msgBox.setText("Proposal prepare error!"); - msgBox.setInformativeText(strErrorMessages.c_str()); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); - return; - } - } - if((govobj.GetObjectType() == GOVERNANCE_OBJECT_TRIGGER) || - (govobj.GetObjectType() == GOVERNANCE_OBJECT_WATCHDOG)) { - std::string strErrorMessages = "Trigger and watchdog objects need not be prepared (however only masternodes can create them)."; - QMessageBox msgBox; - msgBox.setText("Proposal preapare error!"); - msgBox.setInformativeText(strErrorMessages.c_str()); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); - return; - } - { - LOCK(cs_main); - std::string strError = ""; - if(!govobj.IsValidLocally(strError, false)){ - std::string strErrorMessages = "Governance object is not valid - " + govobj.GetHash().ToString() + " - " + strError; - QMessageBox msgBox; - msgBox.setText("Proposal prepare error!"); - msgBox.setInformativeText(strErrorMessages.c_str()); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); - return; - } - } - - // request unlock only if was locked or unlocked for mixing: - // this way we let users unlock by walletpassphrase or by menu - // and make many transactions while unlocking through this dialog - // will call relock - if(!walletModel || !walletModel->getOptionsModel()) - return; - WalletModel::EncryptionStatus encStatus = walletModel->getEncryptionStatus(); - if(encStatus == walletModel->Locked || encStatus == walletModel->UnlockedForMixingOnly) - { - WalletModel::UnlockContext ctx(walletModel->requestUnlock()); - if(!ctx.isValid()) - { - // Unlock wallet was cancelled - //fNewRecipientAllowed = true; - return; - } - //TODO - code duplicate. remove it - CWalletTx wtx; - if(!pwalletMain->GetBudgetSystemCollateralTX(wtx, govobj.GetHash(), govobj.GetMinCollateralFee(), false)) { - std::string strErrorMessages = "Error making collateral transaction for governance object. Please check your wallet balance."; - QMessageBox msgBox; - msgBox.setText("Proposal validation error!"); - msgBox.setInformativeText(strErrorMessages.c_str()); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); - return; - } - - // -- make our change address - CReserveKey reservekey(pwalletMain); - // Display message box - QMessageBox::StandardButton retval = QMessageBox::question(this, - tr("Confirm the creation if a collateral tx for the proposal. \n"), - tr("Are you sure you want to spend 1 AYWA? \n" - "This operation can not be cancelled."), - QMessageBox::Yes | QMessageBox::Cancel, - QMessageBox::Cancel); - - if(retval != QMessageBox::Yes) return; - // -- send the tx to the network - pwalletMain->CommitTransaction(wtx, reservekey, g_connman.get(), NetMsgType::TX); - txidFee = wtx.GetHash(); - ui->pushbuttonPrepare->setEnabled(false); - ui->pushbuttonSubmit->setEnabled(true); - ui->lineeditProposalName->setEnabled(false); - ui->texteditProposalDescription->setReadOnly(true); - ui->labelProposalStatus->setText(QString::fromStdString("PREPARED")); - return; - } - CWalletTx wtx; - if(!pwalletMain->GetBudgetSystemCollateralTX(wtx, govobj.GetHash(), govobj.GetMinCollateralFee(), false)) { - std::string strErrorMessages = "Error making collateral transaction for governance object. Please check your wallet balance and make sure your wallet is unlocked."; - QMessageBox msgBox; - msgBox.setText("Proposal validation error!"); - msgBox.setInformativeText(strErrorMessages.c_str()); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); - return; - } - - // -- make our change address - CReserveKey reservekey(pwalletMain); - - - QMessageBox::StandardButton retval = QMessageBox::question(this, - tr("Confirm the creation of the collateral tx for the proposal"), - tr("Are you sure you want to spend 1 AYWA to prepare proposal? \n" - "This operation can not be cancelled."), - QMessageBox::Yes | QMessageBox::Cancel, - QMessageBox::Cancel); - - if(retval != QMessageBox::Yes) return; - // -- send the tx to the network - pwalletMain->CommitTransaction(wtx, reservekey, g_connman.get(), NetMsgType::TX); - txidFee = wtx.GetHash(); - ui->pushbuttonPrepare->setEnabled(false); - ui->pushbuttonSubmit->setEnabled(true); - ui->lineeditProposalName->setEnabled(false); - ui->texteditProposalDescription->setReadOnly(true); - ui->labelProposalStatus->setText(QString::fromStdString("PREPARED")); - - - - ui->lineeditProposalName->setReadOnly(true); - ui->texteditProposalDescription->setReadOnly(true); - ui->lineeditPaymentAddress->setReadOnly(true); - ui->dateeditPaymentStartDate->setEnabled(false); - ui->dateeditPaymentEndDate->setEnabled(false); - ui->spinboxAmount->setEnabled(false); - ui->spinboxPeriod->setEnabled(false); - - ui->lineeditProposalUrl->setReadOnly(true); - - - //TODO: disable close button or add reminder. - std::string strMessages = "Please wait about 1-5 min until transaction confirmed.\n" - "Do not close this form, before submit the proposal.\n"; - QMessageBox msgBox; - msgBox.setText("The proposal collateral tx is sucsessfully sent to blockchain."); - msgBox.setInformativeText(strMessages.c_str()); - msgBox.setIcon(QMessageBox::Information); - msgBox.exec(); - -} - -void NewProposalDialog::on_toolbuttonSelectPaymentAddress_clicked() -{ - if (ui->lineeditProposalName->text().isEmpty()) - { - // QMessageBox msgBox; - // msgBox.setText("The Proposal Channel is successfully subscribed"); - // msgBox.setIcon(QMessageBox::Information); - // msgBox.exec(); - ui->lineeditProposalName->setFocus(); - QToolTip::showText(ui->lineeditProposalName->mapToGlobal(QPoint()), tr("Type Proposal Name first")); - return;//TODO insert dlg here - } - //TODO: Check if lineeditProposalName has correct text. Check if wallet address label already present. - UniValue label = ui->lineeditProposalName->text().toStdString(); - UniValue params (UniValue::VARR); - params.push_back(label); - UniValue newAddress = getnewaddress(params, false); - try - { - ui->lineeditPaymentAddress->setText(newAddress.get_str().c_str()); - - } - catch(...){ - } - ui->toolbuttonSelectPaymentAddress->setEnabled(false); -} - -void NewProposalDialog::on_toolButton_2_clicked() -{ - if(!walletModel) - return; - AddressBookPage dlg(AddressBookPage::ForSelection, AddressBookPage::ReceivingTab, this); - dlg.setModel(walletModel->getAddressTableModel()); - - if(dlg.exec()) - { - ui->lineeditPaymentAddress->setText(dlg.getReturnValue()); - - } -} - -void NewProposalDialog::on_pushbuttonSubmit_clicked() -{ - if(!masternodeSync.IsBlockchainSynced()) { - std::string strErrorMessages = "Must wait for client to sync with masternode network. Try again in a minute or so."; - QMessageBox msgBox; - msgBox.setText("Proposal subit error!"); - msgBox.setInformativeText(strErrorMessages.c_str()); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); - - } - - //bool fMnFound = mnodeman.Has(activeMasternode.outpoint); - uint256 hashParent; hashParent = uint256();//TODO - - std::string strRevision = "1"; - int nRevision = boost::lexical_cast(strRevision); - int nTime = nProposalTime; - std::string strData = GetCurrentPropsalDataStr(); - CGovernanceObject govobj(hashParent, nRevision, nTime, txidFee, strData);//TODO CHECK Hash Parent - if(govobj.GetObjectType() == GOVERNANCE_OBJECT_PROPOSAL) { - CProposalValidator validator(strData); - if(!validator.Validate()) { - std::string strErrorMessages = "Invalid proposal data, error messages:" + validator.GetErrorMessages(); - QMessageBox msgBox; - msgBox.setText("Proposal subit error!"); - msgBox.setInformativeText(strErrorMessages.c_str()); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); - return; - } - } - std::string strHash = govobj.GetHash().ToString(); - //TODO: Logging result strHash etc. - LogPrintf("gobject(submit) -- Proposal submittred. Hash:%s", strHash); - - - std::string strError = ""; - bool fMissingMasternode = false; - bool fMissingConfirmations = false; - { - LOCK(cs_main); - if(!govobj.IsValidLocally(strError, fMissingMasternode, fMissingConfirmations, true) && !fMissingConfirmations) { - LogPrintf("gobject(submit) -- Object submission rejected because object is not valid - hash = %s, strError = %s\n", strHash, strError); - std::string strErrorMessages = "Governance object is not valid - " + strHash + " - " + strError; - QMessageBox msgBox; - msgBox.setText("Proposal subit error!"); - msgBox.setInformativeText(strErrorMessages.c_str()); - msgBox.setIcon(QMessageBox::Warning); - msgBox.exec(); - return; - } - } - // RELAY THIS OBJECT - // Reject if rate check fails but don't update buffer - if(!governance.MasternodeRateCheck(govobj)) { - LogPrintf("gobject(submit) -- Object submission rejected because of rate check failure - hash = %s\n", strHash); - //return; - } - - LogPrintf("gobject(submit) -- Adding locally created governance object - %s\n", strHash); - - if(fMissingConfirmations) { - governance.AddPostponedObject(govobj); - govobj.Relay(*g_connman); - } else { - governance.AddGovernanceObject(govobj, *g_connman); - } - SetChannelSubscribtion(ui->lineeditPrivateChatAddress->text().toStdString(), - ui->lineeditPrivateChatPubKey->text().toStdString(), - ui->lineeditChannelPrivKey->text().toStdString(), - std::string("Proposal ") + ui->lineeditProposalName->text().toStdString()); - - strHash = govobj.GetHash().ToString(); - //TODO: oLgging it - std::string strErrorMessages = "Proposal hash - " + strHash + "\n"+ - "You can view approval status if type following command in the Console: \n" - "gobject getvotes "+ strHash +"\n"; - QMessageBox msgBox; - msgBox.setText("The proposal sucsessfully submited!"); - msgBox.setInformativeText(strErrorMessages.c_str()); - msgBox.setIcon(QMessageBox::Information); - msgBox.exec(); - ui->pushbuttonSubmit->setEnabled(false); - ui->labelProposalStatus->setText(QString::fromStdString("SUBMITED")); - - ui->lineeditProposalName->setReadOnly(true); - ui->texteditProposalDescription->setReadOnly(true); - ui->lineeditPaymentAddress->setReadOnly(true); - ui->dateeditPaymentStartDate->setEnabled(false); - ui->dateeditPaymentEndDate->setEnabled(false); - ui->spinboxAmount->setEnabled(false); - ui->spinboxPeriod->setEnabled(false); - - ui->lineeditProposalUrl->setReadOnly(true); - -} - -void NewProposalDialog::on_dateeditPaymentStartDate_userDateChanged(const QDate &date) -{ - ui->dateeditPaymentEndDate->setDate(date.addDays(ui->spinboxPeriod->value()-1)); -} - -void NewProposalDialog::on_dateeditPaymentEndDate_userDateChanged(const QDate &date) -{ - //ui->spinboxPeriod->setValue(date-(ui->dateeditPaymentStartDate->day())); - //TODO Later - -} - -void NewProposalDialog::on_dateeditPaymentEndDate_dateChanged(const QDate &date) -{ - -} - -void NewProposalDialog::on_pushbuttonClose_clicked() -{ -// if (ui->pushbuttonCheck->isEnabled()) - - this->close(); -} - -void NewProposalDialog::on_dateeditPaymentStartDate_dateTimeChanged(const QDateTime &dateTime) -{ - const Consensus::Params& consensusParams = Params().GetConsensus(); - ui->dateeditPaymentEndDate->setDateTime(QDateTime::fromTime_t(dateTime.toTime_t()+(ui->spinboxPeriod->value()-1)*consensusParams.nPowTargetSpacing*consensusParams.nBudgetPaymentsCycleBlocks)); - -} - -void NewProposalDialog::setWalletModel(WalletModel *model) -{ - this->walletModel = model; -} - -void NewProposalDialog::on_bnShowHideChannelDetails_clicked() -{ - ui->labelProposalChannelAddress->setVisible(!ui->labelProposalChannelAddress->isVisible()); - ui->lineeditPrivateChatAddress->setVisible(!ui->lineeditPrivateChatAddress->isVisible()); - ui->lineeditChannelPrivKey->setVisible(!ui->lineeditChannelPrivKey->isVisible()); - ui->lineeditPrivateChatPubKey->setVisible(!ui->lineeditPrivateChatPubKey->isVisible()); - ui->labelPublicKey->setVisible(!ui->labelPublicKey->isVisible()); - ui->labelPrivKey->setVisible(!ui->labelPrivKey->isVisible()); -} - -string NewProposalDialog::GetCurrentPropsalDataStr() -{ - std::string strProposalName = ui->lineeditProposalName->text().toStdString(); - std::string strProposalDescriptionHex = HexStr(ui->texteditProposalDescription->toHtml().toStdString());//TODO: toHtml/toPlainText - std::string strPaymentAddress = ui->lineeditPaymentAddress->text().toStdString(); - std::string strPrivateChatAddress = ui->lineeditPrivateChatAddress->text().toStdString(); - std::string strPrivatChatPubKey = ui->lineeditPrivateChatPubKey->text().toStdString(); - std::string strChannelPrivKey = ui->lineeditChannelPrivKey->text().toStdString(); - std::string strProposalUrl = ui->lineeditProposalUrl->text().toStdString(); - //int nPaymentStartDate = ui->dateeditPaymentStartDate->dateTime().toTime_t(); - //int nPaymentEndDate = ui->dateeditPaymentEndDate->dateTime().toTime_t(); - int nPaymentStartDate = ui->dateeditPaymentStartDate->dateTime().toTime_t() - Params().GetConsensus().nBudgetPaymentsCycleBlocks*Params().GetConsensus().nPowTargetSpacing/2;//Adding payment window for superblock-half payment/superblock cycle size. - int nPaymentEndDate = ui->dateeditPaymentEndDate->dateTime().toTime_t() + Params().GetConsensus().nBudgetPaymentsCycleBlocks*Params().GetConsensus().nPowTargetSpacing/2; - - int nPaymentAmount = ui->spinboxAmount->value(); - //nPaymentEndDate_str = boost::lexical_cast(nPaymentEndDate); - UniValue uvProposalData (UniValue::VARR); - uvProposalData.push_back("proposal"); - UniValue uvStrData (UniValue::VOBJ); - uvStrData.pushKV("end_epoch",nPaymentEndDate); - uvStrData.pushKV("name",strProposalName); - uvStrData.pushKV("payment_address",strPaymentAddress); - uvStrData.pushKV("payment_amount",nPaymentAmount); - uvStrData.pushKV("start_epoch",nPaymentStartDate); - uvStrData.pushKV("type",1); - uvStrData.pushKV("url",strProposalUrl); - uvStrData.pushKV("description",strProposalDescriptionHex); - uvStrData.pushKV("smsg_addr",strPrivateChatAddress); - uvStrData.pushKV("smsg_pubkey",strPrivatChatPubKey); - uvStrData.pushKV("smsg_privkey",strChannelPrivKey); - uvProposalData.push_back(uvStrData); - UniValue uvProposal (UniValue::VARR); - uvProposal.push_back(uvProposalData); - std::string strCurrentPropsalData = uvProposal.write(); - std::string strCurrentPropsalDataHex = HexStr (strCurrentPropsalData); - return strCurrentPropsalDataHex; -} - -void NewProposalDialog::on_toolButton_clicked() -{ - //if empty - paste, else openURL; -} - -void NewProposalDialog::on_pushbuttonDetails_clicked() -{ - QMessageBox msgBox; - msgBox.setText("Proposal details"); - msgBox.setInformativeText("Do not close this dialog. "); - msgBox.setIcon(QMessageBox::Information); - msgBox.exec(); -} - -int GetNextSuperblockTime() -{ - //return 0; - // Compute last/next superblock - int nLastSuperblock, nNextSuperblock; - - // Get current block height - int nBlockHeight = 0; - { - LOCK(cs_main); - nBlockHeight = (int)chainActive.Height(); - } - // getgovernanceinfo(); - - // Get chain parameters - int nSuperblockStartBlock = Params().GetConsensus().nSuperblockStartBlock; - int nSuperblockCycle = Params().GetConsensus().nSuperblockCycle; - - // Get first superblock - int nFirstSuperblockOffset = (nSuperblockCycle - nSuperblockStartBlock % nSuperblockCycle) % nSuperblockCycle; - int nFirstSuperblock = nSuperblockStartBlock + nFirstSuperblockOffset; - - if(nBlockHeight < nFirstSuperblock){ - nLastSuperblock = 0; - nNextSuperblock = nFirstSuperblock; - } else { - nLastSuperblock = nBlockHeight - nBlockHeight % nSuperblockCycle; - nNextSuperblock = nLastSuperblock + nSuperblockCycle; - } - - - return nNextSuperblock*Params().GetConsensus().nPowTargetSpacing - +chainActive.Genesis()->GetBlockTime(); - -} - -void NewProposalDialog::on_bnVoteYes_clicked() -{ - voteAction( "yes",""); -} - -void NewProposalDialog::voteAction(std::string vote, std::string strProposalHash ="") -{ - - strProposalHash = pGovObj->GetHash().ToString(); - uint256 hash; - hash = uint256S(strProposalHash); - std::string strVoteSignal, strVoteOutcome; - if (vote == "yes" || vote == "no" || vote =="abstain"){ - strVoteSignal = "funding"; - strVoteOutcome = vote; - } - else if (vote == "delete"){ - strVoteSignal = "delete"; - strVoteOutcome = "yes"; - }; - - vote_signal_enum_t eVoteSignal = CGovernanceVoting::ConvertVoteSignal(strVoteSignal); - vote_outcome_enum_t eVoteOutcome = CGovernanceVoting::ConvertVoteOutcome(strVoteOutcome); - int nSuccessful = 0; - int nFailed = 0; - - std::vector mnEntries; - mnEntries = masternodeConfig.getEntries(); - - UniValue resultsObj(UniValue::VOBJ); - - BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, mnEntries) { - std::string strError; - std::vector vchMasterNodeSignature; - std::string strMasterNodeSignMessage; - - CPubKey pubKeyCollateralAddress; - CKey keyCollateralAddress; - CPubKey pubKeyMasternode; - CKey keyMasternode; - - UniValue statusObj(UniValue::VOBJ); - - if(!CMessageSigner::GetKeysFromSecret(mne.getPrivKey(), keyMasternode, pubKeyMasternode)){ - nFailed++; - statusObj.push_back(Pair("result", "failed")); - statusObj.push_back(Pair("errorMessage", "Masternode signing error, could not set key correctly")); - resultsObj.push_back(Pair(mne.getAlias(), statusObj)); - continue; - } - - uint256 nTxHash; - nTxHash.SetHex(mne.getTxHash()); - - int nOutputIndex = 0; - if(!ParseInt32(mne.getOutputIndex(), &nOutputIndex)) { - continue; - } - - COutPoint outpoint(nTxHash, nOutputIndex); - - CMasternode mn; - bool fMnFound = mnodeman.Get(outpoint, mn); - - if(!fMnFound) { - nFailed++; - statusObj.push_back(Pair("result", "failed")); - statusObj.push_back(Pair("errorMessage", "Can't find masternode by collateral output")); - resultsObj.push_back(Pair(mne.getAlias(), statusObj)); - continue; - } - - CGovernanceVote vote(mn.vin.prevout, hash, eVoteSignal, eVoteOutcome); - if(!vote.Sign(keyMasternode, pubKeyMasternode)){ - nFailed++; - statusObj.push_back(Pair("result", "failed")); - statusObj.push_back(Pair("errorMessage", "Failure to sign.")); - resultsObj.push_back(Pair(mne.getAlias(), statusObj)); - continue; - } - - CGovernanceException exception; - if(governance.ProcessVoteAndRelay(vote, exception, *g_connman)) { - nSuccessful++; - statusObj.push_back(Pair("result", "success")); - } - else { - nFailed++; - statusObj.push_back(Pair("result", "failed")); - // statusObj.push_back(Pair("errorMessage", exception.GetMessage())); - } - - resultsObj.push_back(Pair(mne.getAlias(), statusObj)); - } - - UniValue returnObj(UniValue::VOBJ); - returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed))); - returnObj.push_back(Pair("detail", resultsObj)); - - - QMessageBox msgBox; - msgBox.setText(QString::fromStdString(returnObj[0].get_str()));// ..get_str())); - //msgBox.setInformativeText(strErrorMessages.c_str()); - msgBox.setIcon(QMessageBox::Information); - msgBox.exec(); -} - -void NewProposalDialog::on_bnVoteNo_clicked() -{ - voteAction("no"); -} - -void NewProposalDialog::on_bnVoteAbstain_clicked() -{ - voteAction("abstain"); -} - -void NewProposalDialog::on_bnJoinChannel_clicked() -{ - if (ui->lineeditPrivateChatAddress->text().isEmpty()){ - std::string strAddress, strPubKey, strPrivateKey; - GetNewChannelAddress(strAddress, strPubKey, strPrivateKey); - ui->lineeditPrivateChatAddress->setText(strAddress.c_str()); - ui->lineeditPrivateChatPubKey->setText(strPubKey.c_str()); - ui->lineeditChannelPrivKey->setText(strPrivateKey.c_str()); - } - else{ - //add dialog here for confirmations - SetChannelSubscribtion(ui->lineeditPrivateChatAddress->text().toStdString(), - ui->lineeditPrivateChatPubKey->text().toStdString(), - ui->lineeditChannelPrivKey->text().toStdString(), - std::string("PR-") + ui->lineeditProposalName->text().toStdString() - ); - ui->bnJoinChannel->setEnabled(!GetIsChannelSubscribed(ui->lineeditPrivateChatAddress->text().toStdString())); -// QMessageBox msgBox; -// msgBox.setText("The Proposal Channel is successfully subscribed"); -// msgBox.setIcon(QMessageBox::Information); -// msgBox.exec(); - - } -} - -void NewProposalDialog::on_bnOpenURL_clicked() -{ - QDesktopServices::openUrl (QUrl(ui->lineeditProposalUrl->text())); -} - -void NewProposalDialog::on_texteditProposalDescription_textChanged() -{ - if (ui->texteditProposalDescription->toPlainText().size()>1000) - { - QTextCursor cursor = ui->texteditProposalDescription->textCursor(); - QToolTip::showText(ui->texteditProposalDescription->mapToGlobal(QPoint()), tr("Only 1000 symbols allowed for description. Please use additional recource, if required.")); - ui->texteditProposalDescription->setText(ui->texteditProposalDescription->toPlainText().left(1000)); - //ui->texteditProposalDescription->setCursorPosition(1000); - ui->texteditProposalDescription->setTextCursor( cursor ); - } -} From f04af16e83cf60a5b598316748900d8c26d2395f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:35:43 -0400 Subject: [PATCH 040/469] Delete newproposaldialog.h --- src/qt/newproposaldialog.h | 88 -------------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 src/qt/newproposaldialog.h diff --git a/src/qt/newproposaldialog.h b/src/qt/newproposaldialog.h deleted file mode 100644 index 55b1629f..00000000 --- a/src/qt/newproposaldialog.h +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2017-2018 The Aywa Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_QT_NEWPROPOSALDIALOG_H -#define BITCOIN_QT_NEWPROPOSALDIALOG_H - -#include - -class WalletModel; -class PlatformStyle; - -namespace Ui { - class NewProposalDialog; -} - -QT_BEGIN_NAMESPACE -class QModelIndex; -QT_END_NAMESPACE - -/** Dialog showing transaction details. */ -class NewProposalDialog : public QWidget -{ - Q_OBJECT - -public: - explicit NewProposalDialog(const std::string idx, QWidget *parent = 0); - ~NewProposalDialog(); - - void setWalletModel(WalletModel *walletModel); - void voteAction (std::string vote, std::string strProposalHash); - -private: - WalletModel *walletModel; - const PlatformStyle *platformStyle; - std::string GetCurrentPropsalDataStr(); - -private Q_SLOTS: - void on_spinboxPeriod_valueChanged(int nPeriod); - - void on_pushbuttonCheck_clicked(); - - void on_spinboxAmount_valueChanged(int arg1); - - void on_pushbuttonPrepare_clicked(); - - void on_toolbuttonSelectPaymentAddress_clicked(); - - void on_toolButton_2_clicked(); - - void on_pushbuttonSubmit_clicked(); - - void on_dateeditPaymentStartDate_userDateChanged(const QDate &date); - - void on_dateeditPaymentEndDate_userDateChanged(const QDate &date); - - void on_dateeditPaymentEndDate_dateChanged(const QDate &date); - - void on_pushbuttonClose_clicked(); - - void on_dateeditPaymentStartDate_dateTimeChanged(const QDateTime &dateTime); - - void on_bnShowHideChannelDetails_clicked(); - - void on_toolButton_clicked(); - - void on_pushbuttonDetails_clicked(); - - void on_bnVoteYes_clicked(); - void on_bnVoteNo_clicked(); - void on_bnVoteAbstain_clicked(); - void on_bnJoinChannel_clicked(); - void on_bnOpenURL_clicked(); - void on_texteditProposalDescription_textChanged(); - void GetNewChannelAddress(std::string & strAddress, std::string & strPubKey, std::string & strPrivateKey); - void SetChannelSubscribtion(std::string strAddress, std::string strPubKey, - std::string strPrivateKey, std::string strName); -bool GetIsChannelSubscribed (std::string strChannelAddress); -bool GetChannelKeys(std::string strAddress, std::string & strPubKey, std::string & strPrivKey); -std::string GetChannelName(std::string strAddress); - - - -private: - Ui::NewProposalDialog *ui; -}; - -#endif // BITCOIN_QT_NEWPROPOSALDIALOG_H From 836d73745695ffbfdfe8f1b25a5dfd1db4996f8b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:35:53 -0400 Subject: [PATCH 041/469] Delete newproposaldialog.ui --- src/qt/forms/newproposaldialog.ui | 781 ------------------------------ 1 file changed, 781 deletions(-) delete mode 100644 src/qt/forms/newproposaldialog.ui diff --git a/src/qt/forms/newproposaldialog.ui b/src/qt/forms/newproposaldialog.ui deleted file mode 100644 index 3338e6e9..00000000 --- a/src/qt/forms/newproposaldialog.ui +++ /dev/null @@ -1,781 +0,0 @@ - - - NewProposalDialog - - - - 0 - 0 - 611 - 682 - - - - Aywa Core: New Proposal - - - - - - - - 0 - - - - - - 0 - 0 - - - - Payment Address: - - - - - - - - 0 - 0 - - - - - - - Generete a new one or paste your AYWA wallet address. - - - - - - - true - - - - 0 - 0 - - - - Generate - - - - - - - false - - - - 0 - 0 - - - - Add to Address Book - - - true - - - - - - - - - 0 - - - - - Qt::LeftToRight - - - Proposal discussion channel: - - - Qt::AlignCenter - - - - - - - <ChannelAddress> - - - - - - - true - - - Create/Join channel - - - - :/images/trad/drkblue_downArrow_small:/images/trad/drkblue_downArrow_small - - - - - - - If button is disabled, channel is already subscribed - - - Join Channel - - - - - - - - - - - - 0 - 0 - - - - - 150 - 0 - - - - QAbstractSpinBox::NoButtons - - - false - - - true - - - Qt::LocalTime - - - - - - - Payment start date: - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Payment end date: - - - - - - - Payments count: - - - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - 1 - - - 150 - - - 1 - - - - - - - payment(s) - - - - - - - - - Payment amount: - - - - - - - Qt::Horizontal - - - - 100 - 20 - - - - - - - - false - - - Qt::ImhDate - - - QAbstractSpinBox::NoButtons - - - - - - true - - - Qt::LocalTime - - - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - 1 - - - 1000 - - - 10 - - - - - - - AYWA - - - - - - - - - - - Qt::Horizontal - - - - - - - 1000 symbols max - - - - - - - Qt::Horizontal - - - - - - - Proposal description: - - - - - - - Proposal name: - - - - - - - Qt::ImhUrlCharactersOnly - - - 40 - - - Max - 40 symbols. Only letters, numbers and '_' symbol. Space is not allowed. - - - - - - - 0 - - - - - Proposal Channel Address: - - - - - - - true - - - true - - - - - - - - - 0 - - - - - PublicKey: - - - - - - - true - - - true - - - - - - - Channel PrivKey: - - - - - - - true - - - true - - - - - - - - - 0 - - - - - - 0 - 0 - - - - Discussion URL: - - - - - - - - 0 - 0 - - - - - - - Paste only real URL here. No space allowed. - - - - - - - true - - - - 0 - 0 - - - - -> - - - - - - - - - 10 - - - - - - 0 - 0 - - - - - 50 - false - - - - Total proposal budget: - - - - - - - - 50 - false - - - - 0 - - - - - - - - 0 - 0 - - - - AYWA - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Revision: - - - - - - - - 0 - 0 - - - - 0 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - Proposal Status: - - - - - - - NEW - - - - - - - - - - - 0 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Vote 'YES' - - - - - - - Vote 'NO' - - - - - - - Vote 'ABSTAIN' - - - - - - - - - 0 - - - - - Check - - - - - - - false - - - Prepare - - - - - - - false - - - Submit - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - - - - Reset - - - false - - - - - - - Close - - - - - - - - - lineeditProposalName - texteditProposalDescription - bnOpenURL - lineeditPaymentAddress - toolbuttonSelectPaymentAddress - dateeditPaymentStartDate - dateeditPaymentEndDate - lineeditPrivateChatAddress - lineeditPrivateChatPubKey - pushbuttonCheck - pushbuttonPrepare - pushbuttonSubmit - pushbuttonReset - pushbuttonClose - - - - - - - lineeditPrivateChatAddress - textChanged(QString) - label_17 - setText(QString) - - - 272 - 471 - - - 284 - 444 - - - - - From 454fb35fc3004ed360be949b61642b227173ceb9 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 22:36:41 -0400 Subject: [PATCH 042/469] Update Makefile.qt.include --- src/Makefile.qt.include | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index a7d8c1dd..49c453a9 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -41,7 +41,6 @@ QT_FORMS_UI = \ qt/forms/intro.ui \ qt/forms/modaloverlay.ui \ qt/forms/masternodelist.ui \ - qt/forms/newproposaldialog.ui \ qt/forms/qrdialog.ui \ qt/forms/openuridialog.ui \ qt/forms/optionsdialog.ui \ @@ -77,7 +76,6 @@ QT_MOC_CPP = \ qt/moc_macnotificationhandler.cpp \ qt/moc_modaloverlay.cpp \ qt/moc_masternodelist.cpp \ - qt/moc_newproposaldialog.cpp \ qt/moc_notificator.cpp \ qt/moc_openuridialog.cpp \ qt/moc_optionsdialog.cpp \ @@ -155,7 +153,6 @@ BITCOIN_QT_H = \ qt/modaloverlay.h \ qt/masternodelist.h \ qt/networkstyle.h \ - qt/newproposaldialog.h \ qt/notificator.h \ qt/openuridialog.h \ qt/optionsdialog.h \ @@ -507,7 +504,6 @@ BITCOIN_QT_WALLET_CPP = \ qt/governancelist.cpp \ qt/governancedialog.cpp \ qt/masternodelist.cpp \ - qt/newproposaldialog.cpp \ qt/openuridialog.cpp \ qt/overviewpage.cpp \ qt/privatesendpage.cpp \ From 1d76ec364324b0e7720710b6a886688cddebae94 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 27 May 2020 23:08:13 -0400 Subject: [PATCH 043/469] Update modaloverlay.ui --- src/qt/forms/modaloverlay.ui | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/qt/forms/modaloverlay.ui b/src/qt/forms/modaloverlay.ui index f63b94b7..0f46c9c3 100644 --- a/src/qt/forms/modaloverlay.ui +++ b/src/qt/forms/modaloverlay.ui @@ -206,10 +206,10 @@ 0 0 651 - 81 + 85 - + 20 @@ -257,22 +257,6 @@ - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 113 - 20 - - - - From fd90f2006fa6ed00ad45b207c2eb5db4b9480ff2 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 17:52:42 -0400 Subject: [PATCH 044/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 65 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 31acdd39..139cc143 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -70,12 +70,18 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) currentWatchOnlyBalance(-1), currentWatchUnconfBalance(-1), currentWatchImmatureBalance(-1), + labelCurrentMarket(0), + labelCurrentPrice(0), + pricingTimer(0), cachedNumISLocks(-1) { ui->setupUi(this); QString theme = GUIUtil::getThemeName(); + labelCurrentMarket = new QLabel(); + labelCurrentPrice = new QLabel(); + pricingTimer = new QTimer(); ui->pushButton_Website->setStatusTip(tr("Visit Help The Homeless Worldwide A NJ Nonprofit Corporation")); @@ -102,6 +108,11 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) timerinfo_peers = new QTimer(this); connect(timerinfo_peers, SIGNAL(timeout()), this, SLOT(updatePeersInfo())); timerinfo_peers->start(1000); + + // Create the timer + connect(pricingTimer, SIGNAL(timeout()), this, SLOT(getPriceInfo())); + pricingTimer->start(10000); + getPriceInfo(); // start with displaying the "out of sync" warnings @@ -221,6 +232,60 @@ void OverviewPage::updateDisplayUnit() /**** Blockchain Information *****/ +// Network request code for the header widget + QObject::connect(networkManager, &QNetworkAccessManager::finished, + this, [=](QNetworkReply *reply) { + if (reply->error()) { + labelCurrentPrice->setText(""); + qDebug() << reply->errorString(); + return; + } + // Get the data from the network request + QString answer = reply->readAll(); + + // Create regex expression to find the value with 8 decimals + QRegExp rx("\\d*.\\d\\d\\d\\d\\d\\d\\d\\d"); + rx.indexIn(answer); + + // List the found values + QStringList list = rx.capturedTexts(); + + QString currentPriceStyleSheet = ".QLabel{color: %1;}"; + // Evaluate the current and next numbers and assign a color (green for positive, red for negative) + bool ok; + if (!list.isEmpty()) { + double next = list.first().toDouble(&ok); + if (!ok) { + labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name())); + labelCurrentPrice->setText(""); + } else { + double current = labelCurrentPrice->text().toDouble(&ok); + if (!ok) { + current = 0.00000000; + } else { + if (next < current) + labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg("red")); + else if (next > current) + labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg("green")); + else + labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name())); + } + labelCurrentPrice->setText(QString("%1").arg(QString().setNum(next, 'f', 8))); + labelCurrentPrice->setToolTip(tr("Brought to you by HTH Coin")); + } + } + } + ); + + +void OverviewPage::getPriceInfo() +{ + request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); + networkManager->get(*request); +} + + + void OverviewPage::updateMasternodeInfo() { if (!clientModel) { From 5546a00916a794fab8e0c44c2e8e3dba1f4fca8c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 17:53:29 -0400 Subject: [PATCH 045/469] Update overviewpage.h --- src/qt/overviewpage.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index c7db811b..ecb17132 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -85,6 +85,9 @@ public Q_SLOTS: QTimer* timerinfo_mn; QTimer* timerinfo_blockchain; QTimer* timerinfo_peers; + QLabel *labelCurrentMarket; + QLabel *labelCurrentPrice; + QTimer *pricingTimer; Ui::OverviewPage *ui; ClientModel *clientModel; WalletModel *walletModel; @@ -127,6 +130,8 @@ private Q_SLOTS: void updateBlockChainInfo(); void updateMasternodeInfo(); void updatePeersInfo(); + void getPriceInfo(); + }; #endif // BITCOIN_QT_OVERVIEWPAGE_H From 8dd10b4bc2682e5da6e2bf3d4212691ff8ff3ab1 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 17:56:37 -0400 Subject: [PATCH 046/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 139cc143..2f167a3c 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -275,7 +275,7 @@ void OverviewPage::updateDisplayUnit() } } } - ); + ) void OverviewPage::getPriceInfo() From e13170b7e5961530333c79634bbc66ee29814080 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 17:59:21 -0400 Subject: [PATCH 047/469] Update overviewpage.ui --- src/qt/forms/overviewpage.ui | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui index 095fb42b..f6338394 100644 --- a/src/qt/forms/overviewpage.ui +++ b/src/qt/forms/overviewpage.ui @@ -1084,6 +1084,32 @@ font-size: 11px; Qt::AlignCenter + + + + 500 + 630 + 111 + 21 + + + + TextLabel + + + + + + 740 + 630 + 111 + 21 + + + + TextLabel + + From 4ad4955ca453ac69c6195fbad2ff3400571632e0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:10:05 -0400 Subject: [PATCH 048/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 68 +++++++---------------------------------- 1 file changed, 11 insertions(+), 57 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 2f167a3c..8e621b8a 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -70,8 +70,6 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) currentWatchOnlyBalance(-1), currentWatchUnconfBalance(-1), currentWatchImmatureBalance(-1), - labelCurrentMarket(0), - labelCurrentPrice(0), pricingTimer(0), cachedNumISLocks(-1) @@ -79,8 +77,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) ui->setupUi(this); QString theme = GUIUtil::getThemeName(); - labelCurrentMarket = new QLabel(); - labelCurrentPrice = new QLabel(); + pricingTimer = new QTimer(); @@ -232,59 +229,6 @@ void OverviewPage::updateDisplayUnit() /**** Blockchain Information *****/ -// Network request code for the header widget - QObject::connect(networkManager, &QNetworkAccessManager::finished, - this, [=](QNetworkReply *reply) { - if (reply->error()) { - labelCurrentPrice->setText(""); - qDebug() << reply->errorString(); - return; - } - // Get the data from the network request - QString answer = reply->readAll(); - - // Create regex expression to find the value with 8 decimals - QRegExp rx("\\d*.\\d\\d\\d\\d\\d\\d\\d\\d"); - rx.indexIn(answer); - - // List the found values - QStringList list = rx.capturedTexts(); - - QString currentPriceStyleSheet = ".QLabel{color: %1;}"; - // Evaluate the current and next numbers and assign a color (green for positive, red for negative) - bool ok; - if (!list.isEmpty()) { - double next = list.first().toDouble(&ok); - if (!ok) { - labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name())); - labelCurrentPrice->setText(""); - } else { - double current = labelCurrentPrice->text().toDouble(&ok); - if (!ok) { - current = 0.00000000; - } else { - if (next < current) - labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg("red")); - else if (next > current) - labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg("green")); - else - labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name())); - } - labelCurrentPrice->setText(QString("%1").arg(QString().setNum(next, 'f', 8))); - labelCurrentPrice->setToolTip(tr("Brought to you by HTH Coin")); - } - } - } - ) - - -void OverviewPage::getPriceInfo() -{ - request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); - networkManager->get(*request); -} - - void OverviewPage::updateMasternodeInfo() { @@ -313,6 +257,16 @@ void OverviewPage::getPriceInfo() } } + +void OverviewPage::getPriceInfo() +{ + (timerinfo_priceTimer->interval() == 1000); + timerinfo_priceTimer->setInterval(180000); + request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); + networkManager->get(*request); + ui->labelCurrentPrice->setText(QString::number(getPriceInfo)); +} + void OverviewPage::updateBlockChainInfo() { if (masternodeSync.IsBlockchainSynced()) From e938d82f5e38d1d357b8a98808911a0ff7e7e95f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:10:30 -0400 Subject: [PATCH 049/469] Update overviewpage.h --- src/qt/overviewpage.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index ecb17132..23a82641 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -85,8 +85,6 @@ public Q_SLOTS: QTimer* timerinfo_mn; QTimer* timerinfo_blockchain; QTimer* timerinfo_peers; - QLabel *labelCurrentMarket; - QLabel *labelCurrentPrice; QTimer *pricingTimer; Ui::OverviewPage *ui; ClientModel *clientModel; From c55aa5c937f5a4c0954f9af11c53e743f7dbccbf Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:11:23 -0400 Subject: [PATCH 050/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 8e621b8a..8739bff7 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -260,8 +260,8 @@ void OverviewPage::updateDisplayUnit() void OverviewPage::getPriceInfo() { - (timerinfo_priceTimer->interval() == 1000); - timerinfo_priceTimer->setInterval(180000); + (pricingTimer->interval() == 1000); + pricingTimer->setInterval(180000); request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); networkManager->get(*request); ui->labelCurrentPrice->setText(QString::number(getPriceInfo)); From 435f5baecb119bc8acf8b91e0f0581c1d1105d8c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:12:04 -0400 Subject: [PATCH 051/469] Update overviewpage.ui --- src/qt/forms/overviewpage.ui | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui index f6338394..f7ef4234 100644 --- a/src/qt/forms/overviewpage.ui +++ b/src/qt/forms/overviewpage.ui @@ -1084,24 +1084,11 @@ font-size: 11px; Qt::AlignCenter - - - - 500 - 630 - 111 - 21 - - - - TextLabel - - - 740 - 630 + 510 + 620 111 21 From 1ddc5b8ba8bd28ae5edfca095e35b861422a927b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:17:40 -0400 Subject: [PATCH 052/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 8739bff7..80716876 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -265,6 +265,51 @@ void OverviewPage::getPriceInfo() request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); networkManager->get(*request); ui->labelCurrentPrice->setText(QString::number(getPriceInfo)); + + // Network request code for the header widget + QObject::connect(networkManager, &QNetworkAccessManager::finished, + this, [=](QNetworkReply *reply) { + if (reply->error()) { + labelCurrentPrice->setText(""); + qDebug() << reply->errorString(); + return; + } + // Get the data from the network request + QString answer = reply->readAll(); + + // Create regex expression to find the value with 8 decimals + QRegExp rx("\\d*.\\d\\d\\d\\d\\d\\d\\d\\d"); + rx.indexIn(answer); + + // List the found values + QStringList list = rx.capturedTexts(); + + QString currentPriceStyleSheet = ".QLabel{color: %1;}"; + // Evaluate the current and next numbers and assign a color (green for positive, red for negative) + bool ok; + if (!list.isEmpty()) { + double next = list.first().toDouble(&ok); + if (!ok) { + labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name())); + labelCurrentPrice->setText(""); + } else { + double current = labelCurrentPrice->text().toDouble(&ok); + if (!ok) { + current = 0.00000000; + } else { + if (next < current) + labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg("red")); + else if (next > current) + labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg("green")); + else + labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name())); + } + labelCurrentPrice->setText(QString("%1").arg(QString().setNum(next, 'f', 8))); + labelCurrentPrice->setToolTip(tr("Brought to you by binance.com")); + } + } + } + ) } void OverviewPage::updateBlockChainInfo() From d3cb31d605b3048a7972a6e7e719c9be5e8b7109 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:20:05 -0400 Subject: [PATCH 053/469] Update overviewpage.h --- src/qt/overviewpage.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 23a82641..04a13162 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -30,6 +30,8 @@ class TransactionFilterProxy; /* class TxViewDelegate; */ class PlatformStyle; class WalletModel; +class QNetworkAccessManager; +class QNetworkRequest; namespace Ui { @@ -86,6 +88,8 @@ public Q_SLOTS: QTimer* timerinfo_blockchain; QTimer* timerinfo_peers; QTimer *pricingTimer; + QNetworkAccessManager* networkManager; + QNetworkRequest* request; Ui::OverviewPage *ui; ClientModel *clientModel; WalletModel *walletModel; From 18546e8754362f01522a1d8638429a555d38dd3c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:22:28 -0400 Subject: [PATCH 054/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 80716876..e4ed3915 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -70,7 +70,10 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) currentWatchOnlyBalance(-1), currentWatchUnconfBalance(-1), currentWatchImmatureBalance(-1), + labelCurrentPrice(0), pricingTimer(0), + networkManager(0), + request(0), cachedNumISLocks(-1) { @@ -260,8 +263,7 @@ void OverviewPage::updateDisplayUnit() void OverviewPage::getPriceInfo() { - (pricingTimer->interval() == 1000); - pricingTimer->setInterval(180000); + request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); networkManager->get(*request); ui->labelCurrentPrice->setText(QString::number(getPriceInfo)); From e7049dce46cbee7c1ca63ba0390989a8ad5839bb Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:24:20 -0400 Subject: [PATCH 055/469] Update overviewpage.h --- src/qt/overviewpage.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 04a13162..cc2adbb2 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -88,6 +88,7 @@ public Q_SLOTS: QTimer* timerinfo_blockchain; QTimer* timerinfo_peers; QTimer *pricingTimer; + QLabel *labelCurrentPrice; QNetworkAccessManager* networkManager; QNetworkRequest* request; Ui::OverviewPage *ui; From 486080ed92e806da80fd6dd27818727d1916baa3 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:25:44 -0400 Subject: [PATCH 056/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index e4ed3915..fa74f201 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -80,7 +80,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) ui->setupUi(this); QString theme = GUIUtil::getThemeName(); - + labelCurrentPrice = new QLabel(); pricingTimer = new QTimer(); From 8b6d58b06725ed1bcf4b758a21e36a0dde93d385 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:26:51 -0400 Subject: [PATCH 057/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 44 ----------------------------------------- 1 file changed, 44 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index fa74f201..214457c5 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -268,50 +268,6 @@ void OverviewPage::getPriceInfo() networkManager->get(*request); ui->labelCurrentPrice->setText(QString::number(getPriceInfo)); - // Network request code for the header widget - QObject::connect(networkManager, &QNetworkAccessManager::finished, - this, [=](QNetworkReply *reply) { - if (reply->error()) { - labelCurrentPrice->setText(""); - qDebug() << reply->errorString(); - return; - } - // Get the data from the network request - QString answer = reply->readAll(); - - // Create regex expression to find the value with 8 decimals - QRegExp rx("\\d*.\\d\\d\\d\\d\\d\\d\\d\\d"); - rx.indexIn(answer); - - // List the found values - QStringList list = rx.capturedTexts(); - - QString currentPriceStyleSheet = ".QLabel{color: %1;}"; - // Evaluate the current and next numbers and assign a color (green for positive, red for negative) - bool ok; - if (!list.isEmpty()) { - double next = list.first().toDouble(&ok); - if (!ok) { - labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name())); - labelCurrentPrice->setText(""); - } else { - double current = labelCurrentPrice->text().toDouble(&ok); - if (!ok) { - current = 0.00000000; - } else { - if (next < current) - labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg("red")); - else if (next > current) - labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg("green")); - else - labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name())); - } - labelCurrentPrice->setText(QString("%1").arg(QString().setNum(next, 'f', 8))); - labelCurrentPrice->setToolTip(tr("Brought to you by binance.com")); - } - } - } - ) } void OverviewPage::updateBlockChainInfo() From 20d0553ca448f764343a8a4f03d1bf2fe2d749e1 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:27:07 -0400 Subject: [PATCH 058/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 214457c5..598a4d74 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -70,7 +70,6 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) currentWatchOnlyBalance(-1), currentWatchUnconfBalance(-1), currentWatchImmatureBalance(-1), - labelCurrentPrice(0), pricingTimer(0), networkManager(0), request(0), @@ -80,7 +79,6 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) ui->setupUi(this); QString theme = GUIUtil::getThemeName(); - labelCurrentPrice = new QLabel(); pricingTimer = new QTimer(); From 8514b43649874300e54af88627747e487203495f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:27:26 -0400 Subject: [PATCH 059/469] Update overviewpage.h --- src/qt/overviewpage.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index cc2adbb2..04a13162 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -88,7 +88,6 @@ public Q_SLOTS: QTimer* timerinfo_blockchain; QTimer* timerinfo_peers; QTimer *pricingTimer; - QLabel *labelCurrentPrice; QNetworkAccessManager* networkManager; QNetworkRequest* request; Ui::OverviewPage *ui; From b37d867a9e2eac8f653ec261d30b07e6610198d4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:29:58 -0400 Subject: [PATCH 060/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 598a4d74..844b6b1a 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -264,7 +264,8 @@ void OverviewPage::getPriceInfo() request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); networkManager->get(*request); - ui->labelCurrentPrice->setText(QString::number(getPriceInfo)); + int PriceInfo = clientModel->getPriceInfo(); + ui->labelCurrentPrice->setText(QString::number(PriceInfo)); } From c7e805d588cc9571b7f5092550713cf6e544f83f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:33:30 -0400 Subject: [PATCH 061/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 844b6b1a..5581b74e 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -262,9 +262,7 @@ void OverviewPage::updateDisplayUnit() void OverviewPage::getPriceInfo() { - request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); - networkManager->get(*request); - int PriceInfo = clientModel->getPriceInfo(); + int PriceInfo = clientModel->getPriceInfo(); ui->labelCurrentPrice->setText(QString::number(PriceInfo)); } From ff0df5c98b46d87199dd32751b3fa8829268ed86 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:34:31 -0400 Subject: [PATCH 062/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index ffe7a99d..118f3827 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -236,6 +236,12 @@ enum BlockSource ClientModel::getBlockSource() const return BLOCK_SOURCE_NONE; } +void ClientModel::getPriceInfo() +{ + request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); + networkManager->get(*request); +} + void ClientModel::setNetworkActive(bool active) { if (g_connman) { From 0117ff8192fd76b5c8ce77a4ecc60e759eff7024 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:35:29 -0400 Subject: [PATCH 063/469] Update clientmodel.h --- src/qt/clientmodel.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index ba30a287..f8fd09cd 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -136,6 +136,7 @@ public Q_SLOTS: void updateNetworkActive(bool networkActive); void updateAlert(const QString &hash, int status); void updateBanlist(); + void getPriceInfo(); }; #endif // BITCOIN_QT_CLIENTMODEL_H From e79f1ddd7688c9e6d889bbce1aaf4cd31f211f41 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:35:54 -0400 Subject: [PATCH 064/469] Update overviewpage.h --- src/qt/overviewpage.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 04a13162..240873d6 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -131,8 +131,7 @@ private Q_SLOTS: void on_pushButton_Mine_AMD_clicked(); void updateBlockChainInfo(); void updateMasternodeInfo(); - void updatePeersInfo(); - void getPriceInfo(); + void updatePeersInfo(); }; From ac06884c0ceaa7d0a505d43c063e709f5d1d81dd Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:36:13 -0400 Subject: [PATCH 065/469] Update overviewpage.h --- src/qt/overviewpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 240873d6..c97299f1 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -132,7 +132,7 @@ private Q_SLOTS: void updateBlockChainInfo(); void updateMasternodeInfo(); void updatePeersInfo(); - + void getPriceInfo(); }; #endif // BITCOIN_QT_OVERVIEWPAGE_H From ebdd63081e738cbd2c1d58284c15b66f7979cbe4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:38:21 -0400 Subject: [PATCH 066/469] Update clientmodel.h --- src/qt/clientmodel.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index f8fd09cd..e12831cf 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -19,6 +19,8 @@ class BanTableModel; class OptionsModel; class PeerTableModel; class TransactionTableModel; +class QNetworkAccessManager; +class QNetworkRequest; class CWallet; class CBlockIndex; @@ -101,6 +103,8 @@ class ClientModel : public QObject OptionsModel *optionsModel; PeerTableModel *peerTableModel; BanTableModel *banTableModel; + QNetworkAccessManager* networkManager; + QNetworkRequest* request; QTimer *pollTimer; From 2df49829f29a62fcddb8ef65d5e657c394566904 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:39:17 -0400 Subject: [PATCH 067/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 118f3827..ce1682ab 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -29,6 +29,10 @@ #include #include +#include +#include +#include +#include class CBlockIndex; From 30d8cfacb2aa2107adf563c440d532f791bfcd25 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:43:37 -0400 Subject: [PATCH 068/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 5581b74e..780ce01f 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -259,7 +259,7 @@ void OverviewPage::updateDisplayUnit() } -void OverviewPage::getPriceInfo() +void OverviewPage::updatePriceInfo() { int PriceInfo = clientModel->getPriceInfo(); From 1a56e56bdcade38d0737eb2407d482b0224e0051 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:43:53 -0400 Subject: [PATCH 069/469] Update overviewpage.h --- src/qt/overviewpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index c97299f1..93b362d7 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -132,7 +132,7 @@ private Q_SLOTS: void updateBlockChainInfo(); void updateMasternodeInfo(); void updatePeersInfo(); - void getPriceInfo(); + void updatePriceInfo(); }; #endif // BITCOIN_QT_OVERVIEWPAGE_H From 6a21b0c6eccb4edf0dcbf8fac2940f95aa975332 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:45:35 -0400 Subject: [PATCH 070/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 780ce01f..b981e4bc 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -110,7 +110,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) // Create the timer connect(pricingTimer, SIGNAL(timeout()), this, SLOT(getPriceInfo())); pricingTimer->start(10000); - getPriceInfo(); + updatetPriceInfo(); // start with displaying the "out of sync" warnings From 28d2da516bc19d69374723918bd5ecfbf937db2e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:48:42 -0400 Subject: [PATCH 071/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index b981e4bc..eda97c2e 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -79,7 +79,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) ui->setupUi(this); QString theme = GUIUtil::getThemeName(); - pricingTimer = new QTimer(); + ui->pushButton_Website->setStatusTip(tr("Visit Help The Homeless Worldwide A NJ Nonprofit Corporation")); @@ -108,9 +108,10 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) timerinfo_peers->start(1000); // Create the timer + pricingTimer = new QTimer(); connect(pricingTimer, SIGNAL(timeout()), this, SLOT(getPriceInfo())); pricingTimer->start(10000); - updatetPriceInfo(); + // start with displaying the "out of sync" warnings From dc1aa3f14eab14d7d6b0ce9449d5eed6fcc4bbb5 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:50:29 -0400 Subject: [PATCH 072/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index ce1682ab..aa3bd176 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -240,7 +240,7 @@ enum BlockSource ClientModel::getBlockSource() const return BLOCK_SOURCE_NONE; } -void ClientModel::getPriceInfo() +int ClientModel::getPriceInfo() { request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); networkManager->get(*request); From 74d5473b6b7339052c0429376ebcf46838f58eb7 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:51:14 -0400 Subject: [PATCH 073/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index aa3bd176..ce1682ab 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -240,7 +240,7 @@ enum BlockSource ClientModel::getBlockSource() const return BLOCK_SOURCE_NONE; } -int ClientModel::getPriceInfo() +void ClientModel::getPriceInfo() { request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); networkManager->get(*request); From edac30ab679b31c9b20eb0353cf41fda4a98b646 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:55:13 -0400 Subject: [PATCH 074/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index ce1682ab..6b2d71a6 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -244,6 +244,28 @@ void ClientModel::getPriceInfo() { request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); networkManager->get(*request); + + // Network request code for the header widget + QObject::connect(networkManager, &QNetworkAccessManager::finished, + this, [=](QNetworkReply *reply) { + if (reply->error()) { + labelCurrentPrice->setText(""); + qDebug() << reply->errorString(); + return; + } + // Get the data from the network request + QString answer = reply->readAll(); + + // Create regex expression to find the value with 8 decimals + QRegExp rx("\\d*.\\d\\d\\d\\d\\d\\d\\d\\d"); + rx.indexIn(answer); + + // List the found values + QStringList list = rx.capturedTexts(); + + } + ); + } void ClientModel::setNetworkActive(bool active) From 6fa44b1245ea859700852486b62ea209bf501aaa Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:55:52 -0400 Subject: [PATCH 075/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 6b2d71a6..3f6c4099 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -243,29 +243,7 @@ enum BlockSource ClientModel::getBlockSource() const void ClientModel::getPriceInfo() { request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); - networkManager->get(*request); - - // Network request code for the header widget - QObject::connect(networkManager, &QNetworkAccessManager::finished, - this, [=](QNetworkReply *reply) { - if (reply->error()) { - labelCurrentPrice->setText(""); - qDebug() << reply->errorString(); - return; - } - // Get the data from the network request - QString answer = reply->readAll(); - - // Create regex expression to find the value with 8 decimals - QRegExp rx("\\d*.\\d\\d\\d\\d\\d\\d\\d\\d"); - rx.indexIn(answer); - - // List the found values - QStringList list = rx.capturedTexts(); - - } - ); - + networkManager->get(*request); } void ClientModel::setNetworkActive(bool active) From a48ffd3d5c2d5dfae174413d34f8ace1f94a0142 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:58:11 -0400 Subject: [PATCH 076/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index eda97c2e..01d706bd 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -260,7 +260,7 @@ void OverviewPage::updateDisplayUnit() } -void OverviewPage::updatePriceInfo() +int OverviewPage::updatePriceInfo() { int PriceInfo = clientModel->getPriceInfo(); From 1a002d13b6c26ab012f7946d6a978c0281b56961 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:59:14 -0400 Subject: [PATCH 077/469] Update overviewpage.h --- src/qt/overviewpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 93b362d7..06a7a21f 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -132,7 +132,7 @@ private Q_SLOTS: void updateBlockChainInfo(); void updateMasternodeInfo(); void updatePeersInfo(); - void updatePriceInfo(); + int updatePriceInfo(); }; #endif // BITCOIN_QT_OVERVIEWPAGE_H From 5c26d2b424b80edf111ff268ad1dbd333d7111b0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 18:59:54 -0400 Subject: [PATCH 078/469] Update overviewpage.h --- src/qt/overviewpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 06a7a21f..93b362d7 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -132,7 +132,7 @@ private Q_SLOTS: void updateBlockChainInfo(); void updateMasternodeInfo(); void updatePeersInfo(); - int updatePriceInfo(); + void updatePriceInfo(); }; #endif // BITCOIN_QT_OVERVIEWPAGE_H From 225760f0016cdb1b3bfc62a5dc6e8feb533ac3a7 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:00:10 -0400 Subject: [PATCH 079/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 01d706bd..09ac4a08 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -260,10 +260,10 @@ void OverviewPage::updateDisplayUnit() } -int OverviewPage::updatePriceInfo() +void OverviewPage::updatePriceInfo() { - int PriceInfo = clientModel->getPriceInfo(); + int PriceInfo = clientModel->getPriceInfo(PriceInfo); ui->labelCurrentPrice->setText(QString::number(PriceInfo)); } From 2cb312499b85a842c19023874e4a65e71f95cb5f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:00:29 -0400 Subject: [PATCH 080/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 09ac4a08..423679e8 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -263,7 +263,7 @@ void OverviewPage::updateDisplayUnit() void OverviewPage::updatePriceInfo() { - int PriceInfo = clientModel->getPriceInfo(PriceInfo); + int PriceInfo = clientModel->getPriceInfo; ui->labelCurrentPrice->setText(QString::number(PriceInfo)); } From c447a4e6a24f68d7852809b24500602f5c36ac2a Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:00:42 -0400 Subject: [PATCH 081/469] Update overviewpage.h --- src/qt/overviewpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 93b362d7..4469c340 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -132,7 +132,7 @@ private Q_SLOTS: void updateBlockChainInfo(); void updateMasternodeInfo(); void updatePeersInfo(); - void updatePriceInfo(); + void updatePriceInfo; }; #endif // BITCOIN_QT_OVERVIEWPAGE_H From 68178365e804241bfadf3c211d206de8d535cc1e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:01:48 -0400 Subject: [PATCH 082/469] Update overviewpage.h --- src/qt/overviewpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 4469c340..93b362d7 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -132,7 +132,7 @@ private Q_SLOTS: void updateBlockChainInfo(); void updateMasternodeInfo(); void updatePeersInfo(); - void updatePriceInfo; + void updatePriceInfo(); }; #endif // BITCOIN_QT_OVERVIEWPAGE_H From f46ffc54afd3801a49daabb7baddb4517ae36491 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:02:10 -0400 Subject: [PATCH 083/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 423679e8..a4688588 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -260,7 +260,7 @@ void OverviewPage::updateDisplayUnit() } -void OverviewPage::updatePriceInfo() +void OverviewPage::updatePriceInfo; { int PriceInfo = clientModel->getPriceInfo; From 0285ba1b7fd39023504298a60c29ed66fab1aacb Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:02:20 -0400 Subject: [PATCH 084/469] Update overviewpage.h --- src/qt/overviewpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 93b362d7..4469c340 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -132,7 +132,7 @@ private Q_SLOTS: void updateBlockChainInfo(); void updateMasternodeInfo(); void updatePeersInfo(); - void updatePriceInfo(); + void updatePriceInfo; }; #endif // BITCOIN_QT_OVERVIEWPAGE_H From d03d1679168b320ac1019d75674549f52b63031c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:03:25 -0400 Subject: [PATCH 085/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index a4688588..ae12ec3a 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -260,10 +260,10 @@ void OverviewPage::updateDisplayUnit() } -void OverviewPage::updatePriceInfo; +void OverviewPage::updatePriceInfo(); { - int PriceInfo = clientModel->getPriceInfo; + int PriceInfo = clientModel->getPriceInfo(); ui->labelCurrentPrice->setText(QString::number(PriceInfo)); } From b29d62677f165b39887278f26c8b9b1681ccc7b4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:03:37 -0400 Subject: [PATCH 086/469] Update overviewpage.h --- src/qt/overviewpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 4469c340..93b362d7 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -132,7 +132,7 @@ private Q_SLOTS: void updateBlockChainInfo(); void updateMasternodeInfo(); void updatePeersInfo(); - void updatePriceInfo; + void updatePriceInfo(); }; #endif // BITCOIN_QT_OVERVIEWPAGE_H From 76ab11674e3a4c8c4e70043fa04bcb6840000123 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:05:17 -0400 Subject: [PATCH 087/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 3f6c4099..6b2d0c38 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -242,8 +242,8 @@ enum BlockSource ClientModel::getBlockSource() const void ClientModel::getPriceInfo() { - request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); - networkManager->get(*request); + QDesktopServices::openUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); + } void ClientModel::setNetworkActive(bool active) From 31da1d61885f004cd701b8e2717309b666ad34a1 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:06:55 -0400 Subject: [PATCH 088/469] Update clientmodel.h --- src/qt/clientmodel.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index e12831cf..b9180d38 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -11,6 +11,10 @@ #include #include +#include +#include +#include +#include #include From 68585ff02f8cbc95c4fa70e59fad159c6b382e97 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:09:18 -0400 Subject: [PATCH 089/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 6b2d0c38..bbace4b4 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -242,7 +242,9 @@ enum BlockSource ClientModel::getBlockSource() const void ClientModel::getPriceInfo() { - QDesktopServices::openUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); + + request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); + networkManager->get(*request); } From 72d17c63c041b09b0acbbd754fcc50bbb3544fe3 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:12:33 -0400 Subject: [PATCH 090/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index ae12ec3a..eda97c2e 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -260,7 +260,7 @@ void OverviewPage::updateDisplayUnit() } -void OverviewPage::updatePriceInfo(); +void OverviewPage::updatePriceInfo() { int PriceInfo = clientModel->getPriceInfo(); From 8da5e563479f800b762cec5377db35e34d56cdd4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:33:55 -0400 Subject: [PATCH 091/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index eda97c2e..31087d16 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -260,7 +260,7 @@ void OverviewPage::updateDisplayUnit() } -void OverviewPage::updatePriceInfo() +float OverviewPage::updatePriceInfo() { int PriceInfo = clientModel->getPriceInfo(); From 12715b0c699119db05d608ecf155bcd9dfe00c3c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:34:31 -0400 Subject: [PATCH 092/469] Update overviewpage.h --- src/qt/overviewpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 93b362d7..d557c11a 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -132,7 +132,7 @@ private Q_SLOTS: void updateBlockChainInfo(); void updateMasternodeInfo(); void updatePeersInfo(); - void updatePriceInfo(); + float updatePriceInfo(); }; #endif // BITCOIN_QT_OVERVIEWPAGE_H From 35e27f6760a624c91b7e9762bc141e453f8c60de Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:45:53 -0400 Subject: [PATCH 093/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 31087d16..fd0c3614 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -79,6 +79,20 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) ui->setupUi(this); QString theme = GUIUtil::getThemeName(); + + manager = new QNetworkAccessManager(); + QObject::connect(manager, &QNetworkAccessManager::finished, + this, [=](QNetworkReply *reply) { + if (reply->error()) { + qDebug() << reply->errorString(); + return; + } + + QString answer = reply->readAll(); + + qDebug() << answer; + } + ); From 1ae205155e76ae6d919135c712c27ad34a67664e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:48:30 -0400 Subject: [PATCH 094/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index fd0c3614..69aa5c6a 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -84,6 +84,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) QObject::connect(manager, &QNetworkAccessManager::finished, this, [=](QNetworkReply *reply) { if (reply->error()) { + labelCurrentPrice->setText(""); qDebug() << reply->errorString(); return; } From e20325f08a8db5984355e0101c1d44e1c19acb57 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:49:56 -0400 Subject: [PATCH 095/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 69aa5c6a..b293cb67 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -80,8 +80,8 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) ui->setupUi(this); QString theme = GUIUtil::getThemeName(); - manager = new QNetworkAccessManager(); - QObject::connect(manager, &QNetworkAccessManager::finished, + request = new QNetworkAccessManager(); + QObject::connect(request, &QNetworkAccessManager::finished, this, [=](QNetworkReply *reply) { if (reply->error()) { labelCurrentPrice->setText(""); From ff3ef9b76ec64150eae3590c0ce80653c3106283 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:51:03 -0400 Subject: [PATCH 096/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index b293cb67..3f7cfaaa 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -80,8 +80,8 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) ui->setupUi(this); QString theme = GUIUtil::getThemeName(); - request = new QNetworkAccessManager(); - QObject::connect(request, &QNetworkAccessManager::finished, + request = new QNetworkRequest(); + QObject::connect(request, &QNetworkRequest::finished, this, [=](QNetworkReply *reply) { if (reply->error()) { labelCurrentPrice->setText(""); From 730558b9231f6f66d5f054f9fc769255852153d3 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:52:29 -0400 Subject: [PATCH 097/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 3f7cfaaa..6f53f97d 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -80,20 +80,14 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) ui->setupUi(this); QString theme = GUIUtil::getThemeName(); - request = new QNetworkRequest(); - QObject::connect(request, &QNetworkRequest::finished, - this, [=](QNetworkReply *reply) { - if (reply->error()) { - labelCurrentPrice->setText(""); - qDebug() << reply->errorString(); - return; - } - - QString answer = reply->readAll(); - - qDebug() << answer; - } - ); + QObject::connect(networkManager, &QNetworkAccessManager::finished, + this, [=](QNetworkReply *reply) { + if (reply->error()) { + labelCurrentPrice->setText(""); + qDebug() << reply->errorString(); + return; + } + ); From 75157321d804846586287a21126967f2835a89e4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:55:27 -0400 Subject: [PATCH 098/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 6f53f97d..463dc6de 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -71,6 +71,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) currentWatchUnconfBalance(-1), currentWatchImmatureBalance(-1), pricingTimer(0), + labelCurrentPrice(0), networkManager(0), request(0), cachedNumISLocks(-1) @@ -87,6 +88,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) qDebug() << reply->errorString(); return; } + } ); @@ -117,6 +119,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) timerinfo_peers->start(1000); // Create the timer + labelCurrentMarket = new QLabel(); pricingTimer = new QTimer(); connect(pricingTimer, SIGNAL(timeout()), this, SLOT(getPriceInfo())); pricingTimer->start(10000); From e9317038f81b9dacf26b2dce6b38da823dc5055d Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:55:38 -0400 Subject: [PATCH 099/469] Update overviewpage.h --- src/qt/overviewpage.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index d557c11a..110a1363 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -88,6 +88,7 @@ public Q_SLOTS: QTimer* timerinfo_blockchain; QTimer* timerinfo_peers; QTimer *pricingTimer; + QLabel *labelCurrentPrice; QNetworkAccessManager* networkManager; QNetworkRequest* request; Ui::OverviewPage *ui; From 013e2af28492dd6e597de4350d18c0cd1bb417a2 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:56:46 -0400 Subject: [PATCH 100/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 463dc6de..721202e7 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -71,7 +71,6 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) currentWatchUnconfBalance(-1), currentWatchImmatureBalance(-1), pricingTimer(0), - labelCurrentPrice(0), networkManager(0), request(0), cachedNumISLocks(-1) @@ -119,7 +118,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) timerinfo_peers->start(1000); // Create the timer - labelCurrentMarket = new QLabel(); + pricingTimer = new QTimer(); connect(pricingTimer, SIGNAL(timeout()), this, SLOT(getPriceInfo())); pricingTimer->start(10000); From 05a4b2ae24a81e2bff03a08968579bcef2539e1f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 19:56:53 -0400 Subject: [PATCH 101/469] Update overviewpage.h --- src/qt/overviewpage.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 110a1363..d557c11a 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -88,7 +88,6 @@ public Q_SLOTS: QTimer* timerinfo_blockchain; QTimer* timerinfo_peers; QTimer *pricingTimer; - QLabel *labelCurrentPrice; QNetworkAccessManager* networkManager; QNetworkRequest* request; Ui::OverviewPage *ui; From 29f6c45d030ed2a5a1cc8de902b39b6b179f470f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:02:11 -0400 Subject: [PATCH 102/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 721202e7..d27ec248 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -80,15 +80,20 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) ui->setupUi(this); QString theme = GUIUtil::getThemeName(); - QObject::connect(networkManager, &QNetworkAccessManager::finished, - this, [=](QNetworkReply *reply) { - if (reply->error()) { + + int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + QNetworkAccessManager *manager = new QNetworkAccessManager; + QEventLoop loop; + QObject::connect(manager, &QNetworkAccessManager::finished, &loop, &QEventLoop::quit); + QNetworkReply *reply = manager->get(QNetworkRequest(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC"))); + if (reply->error()) { labelCurrentPrice->setText(""); qDebug() << reply->errorString(); return; - } - } - ); +} From 4d35a8e0b9f12bcda3e692329e6903c0d431ccfa Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:03:17 -0400 Subject: [PATCH 103/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index d27ec248..318be318 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -95,7 +95,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) return; } - + } ui->pushButton_Website->setStatusTip(tr("Visit Help The Homeless Worldwide A NJ Nonprofit Corporation")); ui->pushButton_Website_1->setStatusTip(tr("Visit Help The Homeless Coin")); From a15eb97fd39f2b4c08a116414dfe379a4afb90ab Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:04:37 -0400 Subject: [PATCH 104/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index bbace4b4..19518efd 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -240,7 +240,7 @@ enum BlockSource ClientModel::getBlockSource() const return BLOCK_SOURCE_NONE; } -void ClientModel::getPriceInfo() +float ClientModel::getPriceInfo() { request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); From f887cec21c04265ab4daf54dc05575dce03245db Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:05:01 -0400 Subject: [PATCH 105/469] Update clientmodel.h --- src/qt/clientmodel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index b9180d38..b8b99699 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -144,7 +144,7 @@ public Q_SLOTS: void updateNetworkActive(bool networkActive); void updateAlert(const QString &hash, int status); void updateBanlist(); - void getPriceInfo(); + float getPriceInfo(); }; #endif // BITCOIN_QT_CLIENTMODEL_H From e540bfdf8145bab1ad756d636b263ad3ee457529 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:05:07 -0400 Subject: [PATCH 106/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 318be318..711e9689 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -80,22 +80,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) ui->setupUi(this); QString theme = GUIUtil::getThemeName(); - - int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - - QNetworkAccessManager *manager = new QNetworkAccessManager; - QEventLoop loop; - QObject::connect(manager, &QNetworkAccessManager::finished, &loop, &QEventLoop::quit); - QNetworkReply *reply = manager->get(QNetworkRequest(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC"))); - if (reply->error()) { - labelCurrentPrice->setText(""); - qDebug() << reply->errorString(); - return; -} - - } + ui->pushButton_Website->setStatusTip(tr("Visit Help The Homeless Worldwide A NJ Nonprofit Corporation")); ui->pushButton_Website_1->setStatusTip(tr("Visit Help The Homeless Coin")); From 4e1f116b482ba20c3de3608ea83c85cb9768a042 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:14:49 -0400 Subject: [PATCH 107/469] Update overviewpage.ui --- src/qt/forms/overviewpage.ui | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui index f7ef4234..4aa0a513 100644 --- a/src/qt/forms/overviewpage.ui +++ b/src/qt/forms/overviewpage.ui @@ -1084,17 +1084,39 @@ font-size: 11px; Qt::AlignCenter - + - 510 + 500 620 - 111 + 101 + 30 + + + + + 100 + 30 + + + + HTH Price: + + + Qt::AlignCenter + + + + + + 670 + 625 + 101 21 - TextLabel + From 7d083826f31fe99892172741247b119f233d01af Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:19:30 -0400 Subject: [PATCH 108/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 711e9689..22a4b2ec 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -265,7 +265,7 @@ float OverviewPage::updatePriceInfo() { int PriceInfo = clientModel->getPriceInfo(); - ui->labelCurrentPrice->setText(QString::number(PriceInfo)); + ui->labelCurrentPrice->setText(QString(PriceInfo).arg(QString().setNum(next, 'f', 8))); } From 0c8f4d6fe1adc1c49407933edd96a8fc2bb08dc2 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:21:10 -0400 Subject: [PATCH 109/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 22a4b2ec..7862fcc4 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -265,7 +265,7 @@ float OverviewPage::updatePriceInfo() { int PriceInfo = clientModel->getPriceInfo(); - ui->labelCurrentPrice->setText(QString(PriceInfo).arg(QString().setNum(next, 'f', 8))); + ui->labelCurrentPrice->setText(QString(PriceInfo).arg(QString().setNum(PriceInfo, 'f', 8))); } From 3d1ebc459e7767add07e8705dc762d9d3b2cbd95 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:22:32 -0400 Subject: [PATCH 110/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 7862fcc4..a03d9d72 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -265,7 +265,7 @@ float OverviewPage::updatePriceInfo() { int PriceInfo = clientModel->getPriceInfo(); - ui->labelCurrentPrice->setText(QString(PriceInfo).arg(QString().setNum(PriceInfo, 'f', 8))); + ui->labelCurrentPrice->setText(QString(PriceInfo).arg(QString(PriceInfo))); } From b64d9b42f7c56a27dec3719ec9655980f0fbc6a6 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:27:07 -0400 Subject: [PATCH 111/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index a03d9d72..7a018c4a 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -266,6 +266,7 @@ float OverviewPage::updatePriceInfo() int PriceInfo = clientModel->getPriceInfo(); ui->labelCurrentPrice->setText(QString(PriceInfo).arg(QString(PriceInfo))); + connect(ui->labelCurrentPrice, SIGNAL(PriceInfo()), this, SLOT(labelCurrentPrice())); } From 4233c34da1eb4c9911b731dd6c2289fe17c41cf8 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:32:47 -0400 Subject: [PATCH 112/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 19518efd..b6c7a899 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -243,7 +243,7 @@ enum BlockSource ClientModel::getBlockSource() const float ClientModel::getPriceInfo() { - request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC")); + request->setUrl(QUrl("https://altmarkets.io/api/v2/tickers/hthbtc")); networkManager->get(*request); } From ebe3ba8f2f3db497d4a28da50206cffba4cf78db Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:41:33 -0400 Subject: [PATCH 113/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 7a018c4a..364206fc 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -265,8 +265,7 @@ float OverviewPage::updatePriceInfo() { int PriceInfo = clientModel->getPriceInfo(); - ui->labelCurrentPrice->setText(QString(PriceInfo).arg(QString(PriceInfo))); - connect(ui->labelCurrentPrice, SIGNAL(PriceInfo()), this, SLOT(labelCurrentPrice())); + ui->labelCurrentPrice->setText(QString::number(PriceInfo,'f',4)); } From 3098429e11dd0f1417621cc5096d741a5e02ea25 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:42:58 -0400 Subject: [PATCH 114/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 364206fc..1b775962 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -263,7 +263,9 @@ void OverviewPage::updateDisplayUnit() float OverviewPage::updatePriceInfo() { - + if (!clientModel) { + return; + } int PriceInfo = clientModel->getPriceInfo(); ui->labelCurrentPrice->setText(QString::number(PriceInfo,'f',4)); From d1e6624b6af3f8c59a0fcc50ec29a5f0b99b1242 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:44:41 -0400 Subject: [PATCH 115/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 1b775962..c8d9cf45 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -263,9 +263,8 @@ void OverviewPage::updateDisplayUnit() float OverviewPage::updatePriceInfo() { - if (!clientModel) { - return; - } + (pricingTimer->interval() == 1000); + pricingTimer->setInterval(180000); int PriceInfo = clientModel->getPriceInfo(); ui->labelCurrentPrice->setText(QString::number(PriceInfo,'f',4)); From f358ee205ad3c86e873124974df78eeef7e448e9 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:46:35 -0400 Subject: [PATCH 116/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index b6c7a899..3fdc4cd2 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -240,14 +240,6 @@ enum BlockSource ClientModel::getBlockSource() const return BLOCK_SOURCE_NONE; } -float ClientModel::getPriceInfo() -{ - - request->setUrl(QUrl("https://altmarkets.io/api/v2/tickers/hthbtc")); - networkManager->get(*request); - -} - void ClientModel::setNetworkActive(bool active) { if (g_connman) { From 7151d79b65c494e477ab2ad00b2ecf0023805b30 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:47:17 -0400 Subject: [PATCH 117/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index c8d9cf45..6c62734e 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -260,6 +260,13 @@ void OverviewPage::updateDisplayUnit() } } +float OverviewPage::getPriceInfo() +{ + + request->setUrl(QUrl("https://altmarkets.io/api/v2/tickers/hthbtc")); + networkManager->get(*request); + +} float OverviewPage::updatePriceInfo() { From 7b4e3e57be205aff9633a1df3c8a0c13eaaa13ad Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:47:39 -0400 Subject: [PATCH 118/469] Update clientmodel.h --- src/qt/clientmodel.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index b8b99699..7f9a9f69 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -144,7 +144,6 @@ public Q_SLOTS: void updateNetworkActive(bool networkActive); void updateAlert(const QString &hash, int status); void updateBanlist(); - float getPriceInfo(); }; #endif // BITCOIN_QT_CLIENTMODEL_H From 79eb7fd6a0494cb462bf78972d2c532811bc0f14 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:51:38 -0400 Subject: [PATCH 119/469] Update overviewpage.h --- src/qt/overviewpage.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index d557c11a..5ebddde2 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -133,6 +133,7 @@ private Q_SLOTS: void updateMasternodeInfo(); void updatePeersInfo(); float updatePriceInfo(); + float getPriceInfo(); }; #endif // BITCOIN_QT_OVERVIEWPAGE_H From 4f81e5ff6ad83e15394268fe15150c342092b933 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:52:40 -0400 Subject: [PATCH 120/469] Update clientmodel.h --- src/qt/clientmodel.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index 7f9a9f69..b8b99699 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -144,6 +144,7 @@ public Q_SLOTS: void updateNetworkActive(bool networkActive); void updateAlert(const QString &hash, int status); void updateBanlist(); + float getPriceInfo(); }; #endif // BITCOIN_QT_CLIENTMODEL_H From 2b41533c911ef77409bd56be681818c632c7f740 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:53:40 -0400 Subject: [PATCH 121/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 3fdc4cd2..1e7930d4 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -196,6 +196,14 @@ void ClientModel::updateTimer() Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); } +float OverviewPage::getPriceInfo() +{ + + request->setUrl(QUrl("https://altmarkets.io/api/v2/tickers/hthbtc")); + networkManager->get(*request); + +} + void ClientModel::updateNumConnections(int numConnections) { Q_EMIT numConnectionsChanged(numConnections); From 3eddcab91f2d6d5572ac26d1ddc6e7b9ed3a35a7 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:54:46 -0400 Subject: [PATCH 122/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 1e7930d4..ea0e4c41 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -196,7 +196,7 @@ void ClientModel::updateTimer() Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); } -float OverviewPage::getPriceInfo() +float ClientModel::getPriceInfo() { request->setUrl(QUrl("https://altmarkets.io/api/v2/tickers/hthbtc")); From 831c22154fd7899a458728a34ac3859c4ad825f2 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:56:57 -0400 Subject: [PATCH 123/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 6c62734e..53559671 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -260,14 +260,6 @@ void OverviewPage::updateDisplayUnit() } } -float OverviewPage::getPriceInfo() -{ - - request->setUrl(QUrl("https://altmarkets.io/api/v2/tickers/hthbtc")); - networkManager->get(*request); - -} - float OverviewPage::updatePriceInfo() { (pricingTimer->interval() == 1000); From 3082ec57c42c10dbdc106550b605fb12ea71d1ea Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:57:13 -0400 Subject: [PATCH 124/469] Update overviewpage.h --- src/qt/overviewpage.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 5ebddde2..d557c11a 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -133,7 +133,6 @@ private Q_SLOTS: void updateMasternodeInfo(); void updatePeersInfo(); float updatePriceInfo(); - float getPriceInfo(); }; #endif // BITCOIN_QT_OVERVIEWPAGE_H From 49ec122a9ad84a7f9b9112c212090064c3b9e87c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 20:58:52 -0400 Subject: [PATCH 125/469] Update overviewpage.ui --- src/qt/forms/overviewpage.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui index 4aa0a513..55c76d6e 100644 --- a/src/qt/forms/overviewpage.ui +++ b/src/qt/forms/overviewpage.ui @@ -1116,7 +1116,7 @@ font-size: 11px; - + 0 From 10bb205686875a2e320b944d353213eaa19c7f35 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:00:02 -0400 Subject: [PATCH 126/469] Update drkblue.css --- src/qt/res/css/drkblue.css | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/qt/res/css/drkblue.css b/src/qt/res/css/drkblue.css index beff53fc..152f0368 100644 --- a/src/qt/res/css/drkblue.css +++ b/src/qt/res/css/drkblue.css @@ -2089,6 +2089,18 @@ QWidget .QFrame#frameBlockchainInfo_2 .QLabel#label_6 { font-size:15px; } +QWidget .QFrame# .QLabel#labelCurrentName { + background-color:transparent; + color:#34bcaa; + font-size:15px; + } + +QWidget .QFrame# .QLabel#labelCurrentPrice { + background-color:transparent; + color:#34bcaa; + font-size:15px; + } + /* MODAL OVERLAY */ From ce27f8a57c55f4ce6bb2bcfd9b4005780ca27c51 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:01:59 -0400 Subject: [PATCH 127/469] Update drkblue.css --- src/qt/res/css/drkblue.css | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/qt/res/css/drkblue.css b/src/qt/res/css/drkblue.css index 152f0368..dd50a599 100644 --- a/src/qt/res/css/drkblue.css +++ b/src/qt/res/css/drkblue.css @@ -2089,17 +2089,6 @@ QWidget .QFrame#frameBlockchainInfo_2 .QLabel#label_6 { font-size:15px; } -QWidget .QFrame# .QLabel#labelCurrentName { - background-color:transparent; - color:#34bcaa; - font-size:15px; - } - -QWidget .QFrame# .QLabel#labelCurrentPrice { - background-color:transparent; - color:#34bcaa; - font-size:15px; - } /* MODAL OVERLAY */ From 5df32dcf5c54072591ea8b35447496e06b47a3c3 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:02:15 -0400 Subject: [PATCH 128/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index ea0e4c41..3fdc4cd2 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -196,14 +196,6 @@ void ClientModel::updateTimer() Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); } -float ClientModel::getPriceInfo() -{ - - request->setUrl(QUrl("https://altmarkets.io/api/v2/tickers/hthbtc")); - networkManager->get(*request); - -} - void ClientModel::updateNumConnections(int numConnections) { Q_EMIT numConnectionsChanged(numConnections); From 3d9e173e201cd0a7b90250e37124be7264104b73 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:02:31 -0400 Subject: [PATCH 129/469] Update clientmodel.h --- src/qt/clientmodel.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index b8b99699..7f9a9f69 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -144,7 +144,6 @@ public Q_SLOTS: void updateNetworkActive(bool networkActive); void updateAlert(const QString &hash, int status); void updateBanlist(); - float getPriceInfo(); }; #endif // BITCOIN_QT_CLIENTMODEL_H From 1f286741dcef4804e32fe68d0df53ca0f2dd7f00 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:04:43 -0400 Subject: [PATCH 130/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 53559671..0cb44fc6 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -265,7 +265,7 @@ float OverviewPage::updatePriceInfo() (pricingTimer->interval() == 1000); pricingTimer->setInterval(180000); int PriceInfo = clientModel->getPriceInfo(); - ui->labelCurrentPrice->setText(QString::number(PriceInfo,'f',4)); + connect(labelCurrentPrice, SIGNAL(PriceInfo()), this, SLOT(getPriceInfo())); } From 33ca43a6f176a9abb5df4a929469f73da2a0a742 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:05:26 -0400 Subject: [PATCH 131/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 3fdc4cd2..db0d2229 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -196,6 +196,14 @@ void ClientModel::updateTimer() Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); } +float ClientModel::getPriceInfo() +{ + + request->setUrl(QUrl("https://altmarkets.io/api/v2/tickers/hthbtc")); + networkManager->get(*request); + +} + void ClientModel::updateNumConnections(int numConnections) { Q_EMIT numConnectionsChanged(numConnections); From 7df3767fc87b57d768b540933a5d213a535f2b2f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:05:50 -0400 Subject: [PATCH 132/469] Update clientmodel.h --- src/qt/clientmodel.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index 7f9a9f69..b8b99699 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -144,6 +144,7 @@ public Q_SLOTS: void updateNetworkActive(bool networkActive); void updateAlert(const QString &hash, int status); void updateBanlist(); + float getPriceInfo(); }; #endif // BITCOIN_QT_CLIENTMODEL_H From 6aa62bf05c4fafbe29624c3b0cd8102d26c55437 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:08:59 -0400 Subject: [PATCH 133/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 0cb44fc6..e2c21e4a 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -73,12 +73,14 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) pricingTimer(0), networkManager(0), request(0), + labelCurrentPrice(0), cachedNumISLocks(-1) { ui->setupUi(this); QString theme = GUIUtil::getThemeName(); + labelCurrentPrice = new QLabel(); From 2845fc1321f3d3017c5fa1e4083b098a87f22ec9 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:10:02 -0400 Subject: [PATCH 134/469] Update overviewpage.h --- src/qt/overviewpage.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index d557c11a..110a1363 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -88,6 +88,7 @@ public Q_SLOTS: QTimer* timerinfo_blockchain; QTimer* timerinfo_peers; QTimer *pricingTimer; + QLabel *labelCurrentPrice; QNetworkAccessManager* networkManager; QNetworkRequest* request; Ui::OverviewPage *ui; From 906c4e62bc3de7ae9f6e5afa1eb4ef8e8d629607 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:11:13 -0400 Subject: [PATCH 135/469] Update overviewpage.h --- src/qt/overviewpage.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 110a1363..4adbe676 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -21,6 +21,7 @@ #include #include #include +#include #define MASTERNODELIST_UPDATE_SECONDS 3 #define MASTERNODELIST_FILTER_COOLDOWN_SECONDS 3 From 18a3e34ee268f1298e7676c05fa08a9cef4600cd Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:11:32 -0400 Subject: [PATCH 136/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index e2c21e4a..9eec2ee2 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #define ICON_OFFSET 16 #define DECORATION_SIZE 54 From b45e42cb0d7202132aded296f5bac8d9e564c877 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:36:13 -0400 Subject: [PATCH 137/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 53 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 9eec2ee2..9195a152 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -110,11 +110,58 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) connect(timerinfo_peers, SIGNAL(timeout()), this, SLOT(updatePeersInfo())); timerinfo_peers->start(1000); - // Create the timer - - pricingTimer = new QTimer(); + // Network request code for the header widget + QObject::connect(networkManager, &QNetworkAccessManager::finished, + this, [=](QNetworkReply *reply) { + if (reply->error()) { + labelCurrentPrice->setText(""); + qDebug() << reply->errorString(); + return; + } + // Get the data from the network request + QString answer = reply->readAll(); + + // Create regex expression to find the value with 8 decimals + QRegExp rx("\\d*.\\d\\d\\d\\d\\d\\d\\d\\d"); + rx.indexIn(answer); + + // List the found values + QStringList list = rx.capturedTexts(); + + QString currentPriceStyleSheet = ".QLabel{color: %1;}"; + // Evaluate the current and next numbers and assign a color (green for positive, red for negative) + bool ok; + if (!list.isEmpty()) { + double next = list.first().toDouble(&ok); + if (!ok) { + labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name())); + labelCurrentPrice->setText(""); + } else { + double current = labelCurrentPrice->text().toDouble(&ok); + if (!ok) { + current = 0.00000000; + } else { + if (next < current) + labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg("red")); + else if (next > current) + labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg("green")); + else + labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name())); + } + labelCurrentPrice->setText(QString("%1").arg(QString().setNum(next, 'f', 8))); + labelCurrentPrice->setToolTip(tr("Brought to you by AltExchange.io")); + } + } + } + ); + + connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + + // Create the timer connect(pricingTimer, SIGNAL(timeout()), this, SLOT(getPriceInfo())); pricingTimer->start(10000); + getPriceInfo(); + /** RVN END */ From 3f695ceab2b153441ca28587d48e66317b912a81 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:36:44 -0400 Subject: [PATCH 138/469] Update guiconstants.h --- src/qt/guiconstants.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h index 8a10b956..f4eb8931 100644 --- a/src/qt/guiconstants.h +++ b/src/qt/guiconstants.h @@ -37,6 +37,9 @@ static const bool DEFAULT_SPLASHSCREEN = true; /* Transaction list -- TX status decoration - LockedByInstantSend color */ #define COLOR_TX_STATUS_LOCKED QColor(0, 128, 255) +/* Color of labels */ +#define COLOR_LABELS QColor("#000") + /* Tooltips longer than this (in characters) are converted into rich text, so that they can be word-wrapped. */ From 56f5663e53f56edaa14f5a319e8c1fb971d3f567 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:39:10 -0400 Subject: [PATCH 139/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 9195a152..4f7d0851 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -155,10 +155,8 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) } ); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - // Create the timer - connect(pricingTimer, SIGNAL(timeout()), this, SLOT(getPriceInfo())); + connect(pricingTimer, SIGNAL(timeout()), this, SLOT(updatePriceInfo())); pricingTimer->start(10000); getPriceInfo(); /** RVN END */ From 60125f9a0daa8f9c1d40d699c8ad2371547646ad Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:40:01 -0400 Subject: [PATCH 140/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 4f7d0851..c472588e 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -158,7 +158,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) // Create the timer connect(pricingTimer, SIGNAL(timeout()), this, SLOT(updatePriceInfo())); pricingTimer->start(10000); - getPriceInfo(); + updatePriceInfo(); /** RVN END */ From 30f1a39763ccb1fecb845bfb6b5bc443e0ca826c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:43:03 -0400 Subject: [PATCH 141/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index c472588e..4a91250d 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -313,7 +313,7 @@ float OverviewPage::updatePriceInfo() (pricingTimer->interval() == 1000); pricingTimer->setInterval(180000); int PriceInfo = clientModel->getPriceInfo(); - connect(labelCurrentPrice, SIGNAL(PriceInfo()), this, SLOT(getPriceInfo())); + ui->label_count_2->setText(QString::number(PriceInfo)); } From 8d83b888bbf6fcdda41f8ac9c2022178a963f19b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:49:36 -0400 Subject: [PATCH 142/469] Update overviewpage.cpp --- src/qt/overviewpage.cpp | 69 +---------------------------------------- 1 file changed, 1 insertion(+), 68 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 4a91250d..7299c197 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -71,19 +71,12 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) currentWatchOnlyBalance(-1), currentWatchUnconfBalance(-1), currentWatchImmatureBalance(-1), - pricingTimer(0), - networkManager(0), - request(0), - labelCurrentPrice(0), cachedNumISLocks(-1) { ui->setupUi(this); QString theme = GUIUtil::getThemeName(); - labelCurrentPrice = new QLabel(); - - ui->pushButton_Website->setStatusTip(tr("Visit Help The Homeless Worldwide A NJ Nonprofit Corporation")); ui->pushButton_Website_1->setStatusTip(tr("Visit Help The Homeless Coin")); @@ -110,58 +103,7 @@ OverviewPage::OverviewPage(const PlatformStyle *platformStyle, QWidget *parent) connect(timerinfo_peers, SIGNAL(timeout()), this, SLOT(updatePeersInfo())); timerinfo_peers->start(1000); - // Network request code for the header widget - QObject::connect(networkManager, &QNetworkAccessManager::finished, - this, [=](QNetworkReply *reply) { - if (reply->error()) { - labelCurrentPrice->setText(""); - qDebug() << reply->errorString(); - return; - } - // Get the data from the network request - QString answer = reply->readAll(); - - // Create regex expression to find the value with 8 decimals - QRegExp rx("\\d*.\\d\\d\\d\\d\\d\\d\\d\\d"); - rx.indexIn(answer); - - // List the found values - QStringList list = rx.capturedTexts(); - - QString currentPriceStyleSheet = ".QLabel{color: %1;}"; - // Evaluate the current and next numbers and assign a color (green for positive, red for negative) - bool ok; - if (!list.isEmpty()) { - double next = list.first().toDouble(&ok); - if (!ok) { - labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name())); - labelCurrentPrice->setText(""); - } else { - double current = labelCurrentPrice->text().toDouble(&ok); - if (!ok) { - current = 0.00000000; - } else { - if (next < current) - labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg("red")); - else if (next > current) - labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg("green")); - else - labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name())); - } - labelCurrentPrice->setText(QString("%1").arg(QString().setNum(next, 'f', 8))); - labelCurrentPrice->setToolTip(tr("Brought to you by AltExchange.io")); - } - } - } - ); - - // Create the timer - connect(pricingTimer, SIGNAL(timeout()), this, SLOT(updatePriceInfo())); - pricingTimer->start(10000); - updatePriceInfo(); - /** RVN END */ - - + // start with displaying the "out of sync" warnings showOutOfSyncWarning(true); @@ -308,15 +250,6 @@ void OverviewPage::updateDisplayUnit() } } -float OverviewPage::updatePriceInfo() -{ - (pricingTimer->interval() == 1000); - pricingTimer->setInterval(180000); - int PriceInfo = clientModel->getPriceInfo(); - ui->label_count_2->setText(QString::number(PriceInfo)); - -} - void OverviewPage::updateBlockChainInfo() { if (masternodeSync.IsBlockchainSynced()) From 1ec1ad9cc764abd9b824fa5310ae6cd473bef5c1 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:49:56 -0400 Subject: [PATCH 143/469] Update clientmodel.cpp --- src/qt/clientmodel.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index db0d2229..3fdc4cd2 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -196,14 +196,6 @@ void ClientModel::updateTimer() Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); } -float ClientModel::getPriceInfo() -{ - - request->setUrl(QUrl("https://altmarkets.io/api/v2/tickers/hthbtc")); - networkManager->get(*request); - -} - void ClientModel::updateNumConnections(int numConnections) { Q_EMIT numConnectionsChanged(numConnections); From 4a9a9a0ab122d9a218f241cda8c839de95465241 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:50:15 -0400 Subject: [PATCH 144/469] Update clientmodel.h --- src/qt/clientmodel.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index b8b99699..7f9a9f69 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -144,7 +144,6 @@ public Q_SLOTS: void updateNetworkActive(bool networkActive); void updateAlert(const QString &hash, int status); void updateBanlist(); - float getPriceInfo(); }; #endif // BITCOIN_QT_CLIENTMODEL_H From 1f585b52626ee407f0d9dad4084c47738d8d6d8e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:50:44 -0400 Subject: [PATCH 145/469] Update overviewpage.h --- src/qt/overviewpage.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 4adbe676..71c54401 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -88,8 +88,6 @@ public Q_SLOTS: QTimer* timerinfo_mn; QTimer* timerinfo_blockchain; QTimer* timerinfo_peers; - QTimer *pricingTimer; - QLabel *labelCurrentPrice; QNetworkAccessManager* networkManager; QNetworkRequest* request; Ui::OverviewPage *ui; @@ -134,7 +132,6 @@ private Q_SLOTS: void updateBlockChainInfo(); void updateMasternodeInfo(); void updatePeersInfo(); - float updatePriceInfo(); }; #endif // BITCOIN_QT_OVERVIEWPAGE_H From 0ae48ca000c9aa90c3de68496bf71d992a3bc7dc Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 28 May 2020 21:54:25 -0400 Subject: [PATCH 146/469] Update overviewpage.ui --- src/qt/forms/overviewpage.ui | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui index 55c76d6e..095fb42b 100644 --- a/src/qt/forms/overviewpage.ui +++ b/src/qt/forms/overviewpage.ui @@ -1084,41 +1084,6 @@ font-size: 11px; Qt::AlignCenter - - - - 500 - 620 - 101 - 30 - - - - - 100 - 30 - - - - HTH Price: - - - Qt::AlignCenter - - - - - - 670 - 625 - 101 - 21 - - - - 0 - - From e9e038483f8e2460784d8030e38af79b176509f8 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 19:58:52 -0400 Subject: [PATCH 147/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 345ac7c8..a6f02cb7 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -600,6 +600,10 @@ void BitcoinGUI::createActions() // HTHW Donate externalDonate = new QAction(QIcon(":/icons/" + theme + "/about"), tr("Donate To HTHW"), this); externalDonate->setStatusTip(tr("Donate to Help The Homeless Worldwide")); + + // HTH Create Proposal + createProposal = new QAction(QIcon(":/icons/" + theme + "/about"), tr("Create Proposals"), this); + createProposal->setStatusTip(tr("Create a HTH Proposal")); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); @@ -614,6 +618,10 @@ void BitcoinGUI::createActions() // HTHW Donate connect(externalDonate, SIGNAL(triggered()), this, SLOT(openDonate())); + // HTH Create Proposal + + connect(createProposal, SIGNAL(clicked()), this, SLOT(createProposal())); + // Jump directly to tabs in RPC-console connect(openInfoAction, SIGNAL(triggered()), this, SLOT(showInfo())); connect(openRPCConsoleAction, SIGNAL(triggered()), this, SLOT(showConsole())); @@ -714,6 +722,9 @@ void BitcoinGUI::createMenuBar() QMenu* donate = appMenuBar->addMenu(tr("&Donate")); donate->addAction(externalDonate); + QMenu* proposals = appMenuBar->addMenu(tr("&Create Proposals")); + proposals->addAction(createProposal); + } void BitcoinGUI::createToolBars() @@ -1038,6 +1049,15 @@ void BitcoinGUI::openClicked() } } +void BitcoinGUI::createProposal() +{ + ProposalDialog dlg(ProposalDialog::PrepareProposal, this); + if (QDialog::Accepted == dlg.exec()) + { + refreshProposals(true); + } +} + void BitcoinGUI::openDonate() { openExternalURL("https://helpthehomelessworldwide.org/donate"); From 75615245ae7d7fe8932607c5fb26cb6a580798a2 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:00:41 -0400 Subject: [PATCH 148/469] Update bitcoingui.h --- src/qt/bitcoingui.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 9011d71d..683d660c 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -103,6 +103,7 @@ class BitcoinGUI : public QMainWindow QMenuBar *appMenuBar; + QAction* createProposal; QAction* externalDonate; QAction *governanceAction; /* QAction* privatesendAction; */ @@ -263,6 +264,7 @@ private Q_SLOTS: /** Open external URL */ void openDonate(); void openExternalURL(QString url = ""); + void createProposal(); /** Show debug window and set focus to the appropriate tab */ void showInfo(); From 3cac67c1dcf7ddab90ba3de2e72a1f8dc64afdc0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:01:44 -0400 Subject: [PATCH 149/469] Add files via upload --- src/qt/proposaldialog.cpp | 297 ++++++++++++++++++++++++++++++++++++++ src/qt/proposaldialog.h | 64 ++++++++ 2 files changed, 361 insertions(+) create mode 100644 src/qt/proposaldialog.cpp create mode 100644 src/qt/proposaldialog.h diff --git a/src/qt/proposaldialog.cpp b/src/qt/proposaldialog.cpp new file mode 100644 index 00000000..943bf952 --- /dev/null +++ b/src/qt/proposaldialog.cpp @@ -0,0 +1,297 @@ +// Copyright (c) 2017-2018 The Bulwark Developers +// Copyright (c) 2019 The Phore Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#if defined(HAVE_CONFIG_H) +#include +#endif + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +ProposalDialog::ProposalDialog(Mode mode, QWidget* parent) : QDialog(parent), ui(new Ui::ProposalDialog), mapper(0), mode(mode), counter(0) +{ + ui->setupUi(this); + + switch (mode) { + case PrepareProposal: + setWindowTitle(tr("Prepare Proposal")); + ui->confirmLabel->setVisible(false); + ui->hashEdit->setVisible(false); + ui->hashLabel->setVisible(false); + break; + case SubmitProposal: + setWindowTitle(tr("Submit Proposal")); + ui->confirmLabel->setVisible(true); + ui->hashEdit->setVisible(true); + ui->hashLabel->setVisible(true); + break; + } + + ui->nameEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->nameEdit->setPlaceholderText(tr("Provide a proposal name, keep it short")); + ui->nameEdit->setToolTip(tr("Provide a proposal name, keep it short")); + + ui->urlEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->urlEdit->setPlaceholderText(tr("Valid http or https URL (include http:// or https://")); + ui->urlEdit->setToolTip(tr("Valid http or https URL (include http:// or https://")); + + ui->paymentsEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->paymentsEdit->setPlaceholderText(tr("How many monthly payments, 1 per budget cycle")); + ui->paymentsEdit->setToolTip(tr("How many monthly payments, 1 per budget cycle")); + ui->paymentsEdit->setValidator(new QIntValidator(1, 100)); + + ui->blockEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->blockEdit->setPlaceholderText(tr("The governance budget block for the desired cycle (default to next)")); + ui->blockEdit->setToolTip(tr("The governance budget block for the desired cycle (default to next)")); + ui->blockEdit->setValidator(new QIntValidator(1, INT_MAX)); + + ui->addressEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->addressEdit->setPlaceholderText(tr("The public ODIN address that will receive the funds")); + ui->addressEdit->setToolTip(tr("The public ODIN address that will receive the funds")); + + ui->amountEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->amountEdit->setPlaceholderText(tr("The amount to be paid per month or cycle")); + ui->amountEdit->setToolTip(tr("The amount to be paid per month or cycle")); + ui->amountEdit->setValidator(new QIntValidator(10, INT_MAX)); + + ui->hashEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->hashEdit->setPlaceholderText(tr("The TXID of the proposal hash, must be confirmed before use")); + ui->hashEdit->setToolTip(tr("The TXID of the proposal hash, must be confirmed before use")); + + ui->confirmLabel->setWordWrap(true); + ui->infoLabel->setWordWrap(true); + + // Load next superblock number. + CBlockIndex* pindexPrev = chainActive.Tip(); + if (!pindexPrev) return; + int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); + ui->blockEdit->setText(QString::number(nNext)); + + // Start periodic updates to handle submit block depth validation. + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(checkProposalTX())); +} + +ProposalDialog::~ProposalDialog() +{ + delete ui; +} + +void ProposalDialog::prepareProposal() +{ + std::string strError = ""; + + if (pwalletMain->IsLocked()) + { + strError = "Error: Please enter the wallet passphrase with walletpassphrase first."; + QMessageBox::critical(this, "Prepare Proposal Error", QString::fromStdString(strError)); + return; + } + + std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); + std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); + int nPaymentCount = ui->paymentsEdit->text().toInt(); + int nBlockStart = ui->blockEdit->text().toInt(); + std::string address = ui->addressEdit->text().toStdString(); + CScript scriptPubKey = GetScriptForDestination(DecodeDestination(address)); + CAmount nAmount = AmountFromValue(ui->amountEdit->text().toInt()); + + //************************************************************************* + + // create the proposal incase we're the first to make it + CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, 0); + std::string err; + if (!budgetProposalBroadcast.IsValid(err, false)) strError = "Proposal is not valid - " + budgetProposalBroadcast.GetHash().ToString() + " - " + err; + + bool useIX = false; + if (strError.empty() && !pwalletMain->GetBudgetSystemCollateralTX(wtx, budgetProposalBroadcast.GetHash(), useIX)) + { + strError = "Error making collateral transaction for proposal. Please check your wallet balance."; + } + + // make our change address + CReserveKey reservekey(pwalletMain); + // send the tx to the network + if (strError.empty() && !pwalletMain->CommitTransaction(wtx, reservekey, useIX ? "ix" : "tx")) + { + strError = "Unable to commit proposal transaction."; + } + + if (!strError.empty()) + { + std::cout << strError << std::endl; + QMessageBox::critical(this, "Prepare Proposal Error", QString::fromStdString(strError)); + return; + } + + // update the local view with submit view + ui->cancelButton->setDisabled(true); + ui->nameEdit->setDisabled(true); + ui->urlEdit->setDisabled(true); + ui->paymentsEdit->setDisabled(true); + ui->blockEdit->setDisabled(true); + ui->addressEdit->setDisabled(true); + ui->amountEdit->setDisabled(true); + ui->hashEdit->setDisabled(true); + + ui->acceptButton->setDisabled(true); + ui->acceptButton->setText(tr("Waiting...")); + + ui->confirmLabel->setVisible(true); + ui->confirmLabel->setText(QString::fromStdString("Waiting for confirmations...")); + + ui->hashEdit->setText(QString::fromStdString(wtx.GetHash().ToString())); + ui->hashEdit->setVisible(true); + ui->hashLabel->setVisible(true); + + mode = SubmitProposal; + setWindowTitle(tr("Submit Proposal")); + + timer->start(1000); + counter = chainActive.Tip()->nHeight + 1; +} + +void ProposalDialog::submitProposal() +{ + std::string strError = ""; + + std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); + std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); + int nPaymentCount = ui->paymentsEdit->text().toInt(); + int nBlockStart = ui->blockEdit->text().toInt(); + std::string address = ui->addressEdit->text().toStdString(); + CScript scriptPubKey = GetScriptForDestination(DecodeDestination(address)); + CAmount nAmount = AmountFromValue(ui->amountEdit->text().toInt()); + uint256 hash = ParseHashV(ui->hashEdit->text().toStdString(), "parameter 1"); + + //************************************************************************* + + // create the proposal incase we're the first to make it + int nConf = 0; + std::string err = ""; + CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, hash); + if (!IsBudgetCollateralValid(hash, budgetProposalBroadcast.GetHash(), err, budgetProposalBroadcast.nTime, nConf)) + { + strError = "Proposal FeeTX is not valid - " + hash.ToString() + " - " + err; + } + + if (strError.empty() && !budget.AddProposal(budgetProposalBroadcast)) strError = "Invalid proposal, see debug.log for details."; + + if (!strError.empty()) + { + std::cout << strError << std::endl; + QMessageBox::critical(this, tr("Submit Proposal Error"), QString::fromStdString(strError)); + return; + } + + budget.mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast)); + budgetProposalBroadcast.Relay(); + + this->accept(); +} + +bool ProposalDialog::validateProposal() +{ + std::string strError = ""; + + if (!masternodeSync.IsBlockchainSynced()) strError = "Must wait for client to sync with masternode network. Try again in a minute or so."; + + std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); + if (strProposalName.size() > 20) strError = "Invalid proposal name, limit of 20 characters."; + + std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); + if (strURL.size() > 64) strError = "Invalid url, limit of 64 characters."; + + int nPaymentCount = ui->paymentsEdit->text().toInt(); + if (nPaymentCount < 1) strError = "Invalid payment count, must be more than zero."; + + // Start must be in the next budget cycle + int nBlockMin = 0; + CBlockIndex* pindexPrev = chainActive.Tip(); + if (pindexPrev != NULL) nBlockMin = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); + + int nBlockStart = ui->blockEdit->text().toInt(); + if (nBlockStart < nBlockMin) strError = "Invalid block start, must be more than current height."; + if (nBlockStart % GetBudgetPaymentCycleBlocks() != 0) + { + int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); + strError = strprintf("Invalid block start - must be a budget cycle block. Next valid block: %d", nNext); + } + + int nBlockEnd = nBlockStart + (GetBudgetPaymentCycleBlocks() * nPaymentCount); // End must be AFTER current cycle + if (nBlockEnd < pindexPrev->nHeight) strError = "Invalid ending block, starting block + (payment_cycle*payments) must be more than current height."; + + std::string address = ui->addressEdit->text().toStdString(); + if (!IsValidDestinationString(address)) strError = "Invalid ODIN address"; + + if (!strError.empty()) + { + QMessageBox::critical(this, tr("Submit Proposal Error"), QString::fromStdString(strError)); + return false; + } + + return true; +} + +void ProposalDialog::checkProposalTX() +{ + if (mode != SubmitProposal) return; + + int nConf = Params().BudgetFeeConfirmations(); + int nDepth = (chainActive.Tip()->nHeight + 1) - counter; + if (nDepth > nConf) + { + ui->acceptButton->setDisabled(false); + ui->acceptButton->setText("Finish Proposal"); + ui->confirmLabel->setText(tr("Click on Finish Proposal to complete the proposal and start voting.")); + + timer->stop(); + } + else if (nDepth == nConf) + { + ui->confirmLabel->setText(QString::fromStdString("Waiting for final confirmation...")); + } + else if (nDepth > 0) + { + ui->confirmLabel->setText(QString::fromStdString(strprintf("Currently %d of %d confirmations...", nDepth, (nConf + 1)).c_str())); + } +} + +void ProposalDialog::on_acceptButton_clicked() +{ + if (!validateProposal()) return; + + if (mode == PrepareProposal) + { + prepareProposal(); + } + else if (mode == SubmitProposal) + { + submitProposal(); + } +} + +void ProposalDialog::on_cancelButton_clicked() +{ + this->reject(); +} diff --git a/src/qt/proposaldialog.h b/src/qt/proposaldialog.h new file mode 100644 index 00000000..220fe01f --- /dev/null +++ b/src/qt/proposaldialog.h @@ -0,0 +1,64 @@ +// Copyright (c) 2017-2018 The Bulwark Developers +// Copyright (c) 2019 The Phore Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_CREATEPROPOSALDIALOG_H +#define BITCOIN_QT_CREATEPROPOSALDIALOG_H + +#include +#include +#include +#include + +#include +#include +#include +#include + +class ProposalModel; + +namespace Ui +{ + class ProposalDialog; +} + +QT_BEGIN_NAMESPACE +class QDataWidgetMapper; +QT_END_NAMESPACE + +/** + * Dialog for creating a proposal. + */ +class ProposalDialog : public QDialog +{ + Q_OBJECT + +public: + enum Mode { + PrepareProposal, + SubmitProposal + }; + + explicit ProposalDialog(Mode mode, QWidget* parent); + ~ProposalDialog(); + +public slots: + void checkProposalTX(); + void on_acceptButton_clicked(); + void on_cancelButton_clicked(); + +private: + Ui::ProposalDialog *ui; + QDataWidgetMapper *mapper; + Mode mode; + QTimer *timer; + CWalletTx wtx; + int counter; + + void prepareProposal(); + void submitProposal(); + bool validateProposal(); +}; + +#endif // BITCOIN_QT_CREATEPROPOSALDIALOG_H \ No newline at end of file From ec7680f5e173d3d84d8e537bbd5cc489c20aaa6c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:02:04 -0400 Subject: [PATCH 150/469] Add files via upload --- src/masternode-budget.cpp | 2286 +++++++++++++++++++++++++++++++++++++ src/masternode-budget.h | 622 ++++++++++ 2 files changed, 2908 insertions(+) create mode 100644 src/masternode-budget.cpp create mode 100644 src/masternode-budget.h diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp new file mode 100644 index 00000000..b544481e --- /dev/null +++ b/src/masternode-budget.cpp @@ -0,0 +1,2286 @@ +// Copyright (c) 2014-2015 The Dash developers +// Copyright (c) 2015-2017 The PIVX developers +// Copyright (c) 2017 The Phore developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "init.h" +#include "validation.h" + +#include "addrman.h" +#include "masternode-budget.h" +#include "masternode-sync.h" +#include "rpc/masternode.h" +#include "masternode-utils.h" +#include "obfuscation.h" +#include "util.h" +#include "utilmoneystr.h" +#include +#include + +CBudgetManager budget; +CCriticalSection cs_budget; + +std::map askedForSourceProposalOrBudget; +std::vector vecImmatureBudgetProposals; +std::vector vecImmatureFinalizedBudgets; + +int nSubmittedFinalBudget; + +CAmount GetBudgetSystemCollateralAmount(int nHeight) { + return (Params().GetBudgetSubmissionCollateral() * COIN); +} + +int GetBudgetPaymentCycleBlocks() +{ + // Amount of blocks in a months period of time (using 1 minutes per block) + // estimate 30 blocks an hour * hours in a day * avg. days in a month + if (Params().NetworkID() == CBaseChainParams::MAIN) + return (60 * 24 * 30); + + // for testing purposes -- every 12 hours + return (60 * 12); +} + +CAmount GetAvailableBudget(int nHeight) +{ + CAmount nSubsidy = GetBlockValue(nHeight, true); + return nSubsidy * GetBudgetPaymentCycleBlocks(); +} + +bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, std::string& strError, int64_t& nTime, int& nConf, bool fBudgetFinalization) +{ + CTransaction txCollateral; + uint256 nBlockHash; + if (!GetTransaction(nTxCollateralHash, txCollateral, nBlockHash, true)) { + strError = strprintf("Can't find collateral tx %s", txCollateral.ToString()); + LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError); + return false; + } + + if (txCollateral.vout.size() < 1) return false; + if (txCollateral.nLockTime != 0) return false; + + CScript findScript; + findScript << OP_RETURN << ToByteVector(nExpectedHash); + + bool foundOpReturn = false; + BOOST_FOREACH (const CTxOut o, txCollateral.vout) { + if (!o.scriptPubKey.IsNormalPaymentScript() && !o.scriptPubKey.IsUnspendable()) { + strError = strprintf("Invalid Script %s", txCollateral.ToString()); + LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError); + return false; + } + if (fBudgetFinalization) { + // Collateral for budget finalization + LogPrint("mnbudget", "Final Budget: o.scriptPubKey(%s) == findScript(%s) ?\n", o.scriptPubKey.ToString(), findScript.ToString()); + if (o.scriptPubKey == findScript) { + LogPrint("mnbudget", "Final Budget: o.nValue(%ld) >= BUDGET_FEE_TX(%ld) ?\n", o.nValue, GetBudgetSystemCollateralAmount(chainActive.Height())); + if(o.nValue >= GetBudgetSystemCollateralAmount(chainActive.Height())) { + foundOpReturn = true; + } + } + } + else { + // Collateral for normal budget proposal + LogPrint("mnbudget", "Normal Budget: o.scriptPubKey(%s) == findScript(%s) ?\n", o.scriptPubKey.ToString(), findScript.ToString()); + if (o.scriptPubKey == findScript) { + LogPrint("mnbudget", "Normal Budget: o.nValue(%ld) >= PROPOSAL_FEE_TX(%ld) ?\n", o.nValue, GetBudgetSystemCollateralAmount(chainActive.Height())); + if(o.nValue >= GetBudgetSystemCollateralAmount(chainActive.Height())) { + foundOpReturn = true; + } + } + } + } + if (!foundOpReturn) { + strError = strprintf("Couldn't find opReturn %s in %s", nExpectedHash.ToString(), txCollateral.ToString()); + LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError); + return false; + } + + // RETRIEVE CONFIRMATIONS AND NTIME + /* + - nTime starts as zero and is passed-by-reference out of this function and stored in the external proposal + - nTime is never validated via the hashing mechanism and comes from a full-validated source (the blockchain) + */ + + int conf = GetIXConfirmations(nTxCollateralHash); + if (nBlockHash != uint256(0)) { + BlockMap::iterator mi = mapBlockIndex.find(nBlockHash); + if (mi != mapBlockIndex.end() && (*mi).second) { + CBlockIndex* pindex = (*mi).second; + if (chainActive.Contains(pindex)) { + conf += chainActive.Height() - pindex->nHeight + 1; + nTime = pindex->nTime; + } + } + } + + nConf = conf; + + //if we're syncing we won't have swiftTX information, so accept 1 confirmation + if (conf >= Params().BudgetFeeConfirmations()) { + return true; + } else { + strError = strprintf("Collateral requires at least %d confirmations - %d confirmations", Params().BudgetFeeConfirmations(), conf); + LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s - %d confirmations\n", strError, conf); + return false; + } +} + +void CBudgetManager::CheckOrphanVotes() +{ + LOCK(cs); + + + std::string strError = ""; + std::map::iterator it1 = mapOrphanMasternodeBudgetVotes.begin(); + while (it1 != mapOrphanMasternodeBudgetVotes.end()) { + if (budget.UpdateProposal(((*it1).second), NULL, strError)) { + LogPrint("mnbudget","CBudgetManager::CheckOrphanVotes - Proposal/Budget is known, activating and removing orphan vote\n"); + mapOrphanMasternodeBudgetVotes.erase(it1++); + } else { + ++it1; + } + } + std::map::iterator it2 = mapOrphanFinalizedBudgetVotes.begin(); + while (it2 != mapOrphanFinalizedBudgetVotes.end()) { + if (budget.UpdateFinalizedBudget(((*it2).second), NULL, strError)) { + LogPrint("mnbudget","CBudgetManager::CheckOrphanVotes - Proposal/Budget is known, activating and removing orphan vote\n"); + mapOrphanFinalizedBudgetVotes.erase(it2++); + } else { + ++it2; + } + } + LogPrint("mnbudget","CBudgetManager::CheckOrphanVotes - Done\n"); +} + +void CBudgetManager::SubmitFinalBudget() +{ + static int nSubmittedHeight = 0; // height at which final budget was submitted last time + int nCurrentHeight; + + { + TRY_LOCK(cs_main, locked); + if (!locked) return; + if (!chainActive.Tip()) return; + nCurrentHeight = chainActive.Height(); + } + + int nBlockStart = nCurrentHeight - nCurrentHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); + if (nSubmittedHeight >= nBlockStart){ + LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - nSubmittedHeight(=%ld) < nBlockStart(=%ld) condition not fulfilled.\n", nSubmittedHeight, nBlockStart); + return; + } + + // Submit final budget during the last 2 days (2880 blocks) before payment for Mainnet + int finalizationWindow = ((GetBudgetPaymentCycleBlocks() / 30) * 2); + + // Testnet -- set window 2 hours before payment (120 blocks) + if (Params().NetworkID() == CBaseChainParams::TESTNET) { + // NOTE: votes are only submitted/relayed once every 56 blocks in CFinalizedBudget::AutoCheck() + finalizationWindow = (60 * 2); + } + + int nFinalizationStart = nBlockStart - finalizationWindow; + int nOffsetToStart = nFinalizationStart - nCurrentHeight; + + if (nBlockStart - nCurrentHeight > finalizationWindow){ + LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Too early for finalization. Current block is %ld, next Superblock is %ld.\n", nCurrentHeight, nBlockStart); + LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - First possible block for finalization: %ld. Last possible block for finalization: %ld. You have to wait for %ld block(s) until Budget finalization will be possible\n", nFinalizationStart, nBlockStart, nOffsetToStart); + + return; + } + + std::vector vBudgetProposals = budget.GetBudget(); + std::string strBudgetName = "main"; + std::vector vecTxBudgetPayments; + + for (unsigned int i = 0; i < vBudgetProposals.size(); i++) { + CTxBudgetPayment txBudgetPayment; + txBudgetPayment.nProposalHash = vBudgetProposals[i]->GetHash(); + txBudgetPayment.payee = vBudgetProposals[i]->GetPayee(); + txBudgetPayment.nAmount = vBudgetProposals[i]->GetAllotted(); + vecTxBudgetPayments.push_back(txBudgetPayment); + } + + if (vecTxBudgetPayments.size() < 1) { + LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Found No Proposals For Period\n"); + return; + } + + CFinalizedBudgetBroadcast tempBudget(strBudgetName, nBlockStart, vecTxBudgetPayments, 0); + if (mapSeenFinalizedBudgets.count(tempBudget.GetHash())) { + LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Budget already exists - %s\n", tempBudget.GetHash().ToString()); + nSubmittedHeight = nCurrentHeight; + return; //already exists + } + + //create fee tx + CTransaction tx; + uint256 txidCollateral; + + if (!mapCollateralTxids.count(tempBudget.GetHash())) { + CWalletTx wtx; + if (!pwalletMain->GetBudgetSystemCollateralTX(wtx, tempBudget.GetHash(), false)) { + LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Can't make collateral transaction\n"); + return; + } + + // Get our change address + CReserveKey reservekey(pwalletMain); + // Send the tx to the network. Do NOT use SwiftTx, locking might need too much time to propagate, especially for testnet + pwalletMain->CommitTransaction(wtx, reservekey, "NO-ix"); + tx = (CTransaction)wtx; + txidCollateral = tx.GetHash(); + mapCollateralTxids.insert(make_pair(tempBudget.GetHash(), txidCollateral)); + } else { + txidCollateral = mapCollateralTxids[tempBudget.GetHash()]; + } + + int conf = GetIXConfirmations(txidCollateral); + CTransaction txCollateral; + uint256 nBlockHash; + + if (!GetTransaction(txidCollateral, txCollateral, nBlockHash, true)) { + LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Can't find collateral tx %s", txidCollateral.ToString()); + return; + } + + if (nBlockHash != uint256(0)) { + BlockMap::iterator mi = mapBlockIndex.find(nBlockHash); + if (mi != mapBlockIndex.end() && (*mi).second) { + CBlockIndex* pindex = (*mi).second; + if (chainActive.Contains(pindex)) { + conf += chainActive.Height() - pindex->nHeight + 1; + } + } + } + + /* + Wait will we have 1 extra confirmation, otherwise some clients might reject this feeTX + -- This function is tied to NewBlock, so we will propagate this budget while the block is also propagating + */ + if (conf < Params().BudgetFeeConfirmations() + 1) { + LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Collateral requires at least %d confirmations - %s - %d confirmations\n", Params().BudgetFeeConfirmations() + 1, txidCollateral.ToString(), conf); + return; + } + + //create the proposal incase we're the first to make it + CFinalizedBudgetBroadcast finalizedBudgetBroadcast(strBudgetName, nBlockStart, vecTxBudgetPayments, txidCollateral); + + std::string strError = ""; + if (!finalizedBudgetBroadcast.IsValid(strError)) { + LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Invalid finalized budget - %s \n", strError); + return; + } + + LOCK(cs); + mapSeenFinalizedBudgets.insert(make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast)); + finalizedBudgetBroadcast.Relay(); + budget.AddFinalizedBudget(finalizedBudgetBroadcast); + nSubmittedHeight = nCurrentHeight; + LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Done! %s\n", finalizedBudgetBroadcast.GetHash().ToString()); +} + +// +// CBudgetDB +// + +CBudgetDB::CBudgetDB() +{ + pathDB = GetDataDir() / "budget.dat"; + strMagicMessage = "MasternodeBudget"; +} + +bool CBudgetDB::Write(const CBudgetManager& objToSave) +{ + LOCK(objToSave.cs); + + int64_t nStart = GetTimeMillis(); + + // serialize, checksum data up to that point, then append checksum + CDataStream ssObj(SER_DISK, CLIENT_VERSION); + ssObj << strMagicMessage; // masternode cache file specific magic message + ssObj << FLATDATA(Params().MessageStart()); // network specific magic number + ssObj << objToSave; + uint256 hash = Hash(ssObj.begin(), ssObj.end()); + ssObj << hash; + + // open output file, and associate with CAutoFile + FILE* file = fopen(pathDB.string().c_str(), "wb"); + CAutoFile fileout(file, SER_DISK, CLIENT_VERSION); + if (fileout.IsNull()) + return error("%s : Failed to open file %s", __func__, pathDB.string()); + + // Write and commit header, data + try { + fileout << ssObj; + } catch (std::exception& e) { + return error("%s : Serialize or I/O error - %s", __func__, e.what()); + } + fileout.fclose(); + + LogPrint("mnbudget","Written info to budget.dat %dms\n", GetTimeMillis() - nStart); + + return true; +} + +CBudgetDB::ReadResult CBudgetDB::Read(CBudgetManager& objToLoad, bool fDryRun) +{ + LOCK(objToLoad.cs); + + int64_t nStart = GetTimeMillis(); + // open input file, and associate with CAutoFile + FILE* file = fopen(pathDB.string().c_str(), "rb"); + CAutoFile filein(file, SER_DISK, CLIENT_VERSION); + if (filein.IsNull()) { + error("%s : Failed to open file %s", __func__, pathDB.string()); + return FileError; + } + + // use file size to size memory buffer + int fileSize = boost::filesystem::file_size(pathDB); + int dataSize = fileSize - sizeof(uint256); + // Don't try to resize to a negative number if file is small + if (dataSize < 0) + dataSize = 0; + vector vchData; + vchData.resize(dataSize); + uint256 hashIn; + + // read data and checksum from file + try { + filein.read((char*)&vchData[0], dataSize); + filein >> hashIn; + } catch (std::exception& e) { + error("%s : Deserialize or I/O error - %s", __func__, e.what()); + return HashReadError; + } + filein.fclose(); + + CDataStream ssObj(vchData, SER_DISK, CLIENT_VERSION); + + // verify stored checksum matches input data + uint256 hashTmp = Hash(ssObj.begin(), ssObj.end()); + if (hashIn != hashTmp) { + error("%s : Checksum mismatch, data corrupted", __func__); + return IncorrectHash; + } + + + unsigned char pchMsgTmp[4]; + std::string strMagicMessageTmp; + try { + // de-serialize file header (masternode cache file specific magic message) and .. + ssObj >> strMagicMessageTmp; + + // ... verify the message matches predefined one + if (strMagicMessage != strMagicMessageTmp) { + error("%s : Invalid masternode cache magic message", __func__); + return IncorrectMagicMessage; + } + + + // de-serialize file header (network specific magic number) and .. + ssObj >> FLATDATA(pchMsgTmp); + + // ... verify the network matches ours + if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp))) { + error("%s : Invalid network magic number", __func__); + return IncorrectMagicNumber; + } + + // de-serialize data into CBudgetManager object + ssObj >> objToLoad; + } catch (std::exception& e) { + objToLoad.Clear(); + error("%s : Deserialize or I/O error - %s", __func__, e.what()); + return IncorrectFormat; + } + + LogPrint("mnbudget","Loaded info from budget.dat %dms\n", GetTimeMillis() - nStart); + LogPrint("mnbudget"," %s\n", objToLoad.ToString()); + if (!fDryRun) { + LogPrint("mnbudget","Budget manager - cleaning....\n"); + objToLoad.CheckAndRemove(); + LogPrint("mnbudget","Budget manager - result:\n"); + LogPrint("mnbudget"," %s\n", objToLoad.ToString()); + } + + return Ok; +} + +void DumpBudgets() +{ + int64_t nStart = GetTimeMillis(); + + CBudgetDB budgetdb; + CBudgetManager tempBudget; + + LogPrint("mnbudget","Verifying budget.dat format...\n"); + CBudgetDB::ReadResult readResult = budgetdb.Read(tempBudget, true); + // there was an error and it was not an error on file opening => do not proceed + if (readResult == CBudgetDB::FileError) + LogPrint("mnbudget","Missing budgets file - budget.dat, will try to recreate\n"); + else if (readResult != CBudgetDB::Ok) { + LogPrint("mnbudget","Error reading budget.dat: "); + if (readResult == CBudgetDB::IncorrectFormat) + LogPrint("mnbudget","magic is ok but data has invalid format, will try to recreate\n"); + else { + LogPrint("mnbudget","file format is unknown or invalid, please fix it manually\n"); + return; + } + } + LogPrint("mnbudget","Writting info to budget.dat...\n"); + budgetdb.Write(budget); + + LogPrint("mnbudget","Budget dump finished %dms\n", GetTimeMillis() - nStart); +} + +bool CBudgetManager::AddFinalizedBudget(CFinalizedBudget& finalizedBudget) +{ + std::string strError = ""; + if (!finalizedBudget.IsValid(strError)) return false; + + if (mapFinalizedBudgets.count(finalizedBudget.GetHash())) { + return false; + } + + mapFinalizedBudgets.insert(make_pair(finalizedBudget.GetHash(), finalizedBudget)); + return true; +} + +bool CBudgetManager::AddProposal(CBudgetProposal& budgetProposal) +{ + LOCK(cs); + std::string strError = ""; + if (!budgetProposal.IsValid(strError)) { + LogPrint("mnbudget","CBudgetManager::AddProposal - invalid budget proposal - %s\n", strError); + return false; + } + + if (mapProposals.count(budgetProposal.GetHash())) { + return false; + } + + mapProposals.insert(make_pair(budgetProposal.GetHash(), budgetProposal)); + LogPrint("mnbudget","CBudgetManager::AddProposal - proposal %s added\n", budgetProposal.GetName ().c_str ()); + return true; +} + +void CBudgetManager::CheckAndRemove() +{ + int nHeight = 0; + + // Add some verbosity once loading blocks from files has finished + { + TRY_LOCK(cs_main, locked); + if ((locked) && (chainActive.Tip() != NULL)) { + CBlockIndex* pindexPrev = chainActive.Tip(); + if (pindexPrev) { + nHeight = pindexPrev->nHeight; + } + } + } + + LogPrint("mnbudget", "CBudgetManager::CheckAndRemove at Height=%d\n", nHeight); + + map tmpMapFinalizedBudgets; + map tmpMapProposals; + + std::string strError = ""; + + LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapFinalizedBudgets cleanup - size before: %d\n", mapFinalizedBudgets.size()); + std::map::iterator it = mapFinalizedBudgets.begin(); + while (it != mapFinalizedBudgets.end()) { + CFinalizedBudget* pfinalizedBudget = &((*it).second); + + pfinalizedBudget->fValid = pfinalizedBudget->IsValid(strError); + if (!strError.empty ()) { + LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Invalid finalized budget: %s\n", strError); + } + else { + LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Found valid finalized budget: %s %s\n", + pfinalizedBudget->strBudgetName.c_str(), pfinalizedBudget->nFeeTXHash.ToString().c_str()); + } + + if (pfinalizedBudget->fValid) { + pfinalizedBudget->AutoCheck(); + tmpMapFinalizedBudgets.insert(make_pair(pfinalizedBudget->GetHash(), *pfinalizedBudget)); + } + + ++it; + } + + LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapProposals cleanup - size before: %d\n", mapProposals.size()); + std::map::iterator it2 = mapProposals.begin(); + while (it2 != mapProposals.end()) { + CBudgetProposal* pbudgetProposal = &((*it2).second); + pbudgetProposal->fValid = pbudgetProposal->IsValid(strError); + if (!strError.empty ()) { + LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Invalid budget proposal - %s\n", strError); + strError = ""; + } + else { + LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Found valid budget proposal: %s %s\n", + pbudgetProposal->strProposalName.c_str(), pbudgetProposal->nFeeTXHash.ToString().c_str()); + } + if (pbudgetProposal->fValid) { + tmpMapProposals.insert(make_pair(pbudgetProposal->GetHash(), *pbudgetProposal)); + } + + ++it2; + } + // Remove invalid entries by overwriting complete map + mapFinalizedBudgets.swap(tmpMapFinalizedBudgets); + mapProposals.swap(tmpMapProposals); + + LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapFinalizedBudgets cleanup - size after: %d\n", mapFinalizedBudgets.size()); + LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapProposals cleanup - size after: %d\n", mapProposals.size()); + LogPrint("mnbudget","CBudgetManager::CheckAndRemove - PASSED\n"); + +} + +void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, bool fProofOfStake) +{ + LOCK(cs); + + CBlockIndex* pindexPrev = chainActive.Tip(); + if (!pindexPrev) return; + + int nHighestCount = 0; + CScript payee; + CAmount nAmount = 0; + + // ------- Grab The Highest Count + + std::map::iterator it = mapFinalizedBudgets.begin(); + while (it != mapFinalizedBudgets.end()) { + CFinalizedBudget* pfinalizedBudget = &((*it).second); + if (pfinalizedBudget->GetVoteCount() > nHighestCount && + pindexPrev->nHeight + 1 >= pfinalizedBudget->GetBlockStart() && + pindexPrev->nHeight + 1 <= pfinalizedBudget->GetBlockEnd() && + pfinalizedBudget->GetPayeeAndAmount(pindexPrev->nHeight + 1, payee, nAmount)) { + nHighestCount = pfinalizedBudget->GetVoteCount(); + } + + ++it; + } + + CAmount blockValue = GetBlockValue(pindexPrev->nHeight); + + if (fProofOfStake) { + if (nHighestCount > 0) { + unsigned int i = txNew.vout.size(); + txNew.vout.resize(i + 1); + txNew.vout[i].scriptPubKey = payee; + txNew.vout[i].nValue = nAmount; + + CTxDestination address1; + ExtractDestination(payee, address1); + LogPrint("mnbudget","CBudgetManager::FillBlockPayee - Budget payment to %s for %lld, nHighestCount = %d\n", EncodeDestination(address1), nAmount, nHighestCount); + } + else { + LogPrint("mnbudget","CBudgetManager::FillBlockPayee - No Budget payment, nHighestCount = %d\n", nHighestCount); + } + } else { + //miners get the full amount on these blocks + txNew.vout[0].nValue = blockValue; + + if (nHighestCount > 0) { + txNew.vout.resize(2); + + //these are super blocks, so their value can be much larger than normal + txNew.vout[1].scriptPubKey = payee; + txNew.vout[1].nValue = nAmount; + + CTxDestination address1; + ExtractDestination(payee, address1); + + LogPrint("mnbudget","CBudgetManager::FillBlockPayee - Budget payment to %s for %lld\n", EncodeDestination(address1), nAmount); + } + } +} + +CFinalizedBudget* CBudgetManager::FindFinalizedBudget(uint256 nHash) +{ + if (mapFinalizedBudgets.count(nHash)) + return &mapFinalizedBudgets[nHash]; + + return NULL; +} + +CBudgetProposal* CBudgetManager::FindProposal(const std::string& strProposalName) +{ + //find the prop with the highest yes count + + int nYesCount = -99999; + CBudgetProposal* pbudgetProposal = NULL; + + std::map::iterator it = mapProposals.begin(); + while (it != mapProposals.end()) { + if ((*it).second.strProposalName == strProposalName && (*it).second.GetYeas() > nYesCount) { + pbudgetProposal = &((*it).second); + nYesCount = pbudgetProposal->GetYeas(); + } + ++it; + } + + if (nYesCount == -99999) return NULL; + + return pbudgetProposal; +} + +CBudgetProposal* CBudgetManager::FindProposal(uint256 nHash) +{ + LOCK(cs); + + if (mapProposals.count(nHash)) + return &mapProposals[nHash]; + + return NULL; +} + +bool CBudgetManager::IsBudgetPaymentBlock(int nBlockHeight) +{ + int nHighestCount = -1; + int nFivePercent = mnodeman.CountEnabled(ActiveProtocol()) / 20; + + std::map::iterator it = mapFinalizedBudgets.begin(); + while (it != mapFinalizedBudgets.end()) { + CFinalizedBudget* pfinalizedBudget = &((*it).second); + if (pfinalizedBudget->GetVoteCount() > nHighestCount && + nBlockHeight >= pfinalizedBudget->GetBlockStart() && + nBlockHeight <= pfinalizedBudget->GetBlockEnd()) { + nHighestCount = pfinalizedBudget->GetVoteCount(); + } + + ++it; + } + + LogPrint("mnbudget","CBudgetManager::IsBudgetPaymentBlock() - nHighestCount: %lli, 5%% of Masternodes: %lli. Number of budgets: %lli\n", + nHighestCount, nFivePercent, mapFinalizedBudgets.size()); + + // If budget doesn't have 5% of the network votes, then we should pay a masternode instead + if (nHighestCount > nFivePercent) return true; + + return false; +} + +TrxValidationStatus CBudgetManager::IsTransactionValid(const CTransaction& txNew, int nBlockHeight) +{ + LOCK(cs); + + + TrxValidationStatus transactionStatus = TrxValidationStatus::Invalid; + int nHighestCount = 0; + int nFivePercent = mnodeman.CountEnabled(ActiveProtocol()) / 20; + std::vector ret; + + // ------- Grab The Highest Count + + std::map::iterator it = mapFinalizedBudgets.begin(); + while (it != mapFinalizedBudgets.end()) { + CFinalizedBudget* pfinalizedBudget = &((*it).second); + + if (pfinalizedBudget->GetVoteCount() > nHighestCount && + nBlockHeight >= pfinalizedBudget->GetBlockStart() && + nBlockHeight <= pfinalizedBudget->GetBlockEnd()) { + nHighestCount = pfinalizedBudget->GetVoteCount(); + } + + ++it; + } + + LogPrint("mnbudget","CBudgetManager::IsTransactionValid() - nHighestCount: %lli, 5%% of Masternodes: %lli mapFinalizedBudgets.size(): %ld\n", + nHighestCount, nFivePercent, mapFinalizedBudgets.size()); + /* + If budget doesn't have 5% of the network votes, then we should pay a masternode instead + */ + if (nHighestCount < nFivePercent) return TrxValidationStatus::Invalid; + + // check the highest finalized budgets (+/- 10% to assist in consensus) + + std::string strProposals = ""; + int nCountThreshold = nHighestCount - mnodeman.CountEnabled(ActiveProtocol()) / 10; + bool fThreshold = false; + it = mapFinalizedBudgets.begin(); + while (it != mapFinalizedBudgets.end()) { + CFinalizedBudget* pfinalizedBudget = &((*it).second); + strProposals = pfinalizedBudget->GetProposals(); + + LogPrint("mnbudget","CBudgetManager::IsTransactionValid - checking budget (%s) with blockstart %lli, blockend %lli, nBlockHeight %lli, votes %lli, nCountThreshold %lli\n", + strProposals.c_str(), pfinalizedBudget->GetBlockStart(), pfinalizedBudget->GetBlockEnd(), + nBlockHeight, pfinalizedBudget->GetVoteCount(), nCountThreshold); + + if (pfinalizedBudget->GetVoteCount() > nCountThreshold) { + fThreshold = true; + if (nBlockHeight >= pfinalizedBudget->GetBlockStart() && nBlockHeight <= pfinalizedBudget->GetBlockEnd()) { + LogPrint("mnbudget","CBudgetManager::IsTransactionValid - GetBlockStart() passed\n"); + transactionStatus = pfinalizedBudget->IsTransactionValid(txNew, nBlockHeight); + if (transactionStatus == TrxValidationStatus::Valid) { + LogPrint("mnbudget","CBudgetManager::IsTransactionValid - pfinalizedBudget->IsTransactionValid() passed\n"); + return TrxValidationStatus::Valid; + } else { + LogPrint("mnbudget","CBudgetManager::IsTransactionValid - pfinalizedBudget->IsTransactionValid() error\n"); + } + } else { + LogPrint("mnbudget","CBudgetManager::IsTransactionValid - GetBlockStart() failed, budget is outside current payment cycle and will be ignored.\n"); + } + } + ++it; + } + + // If not enough masternodes autovoted for any of the finalized budgets pay a masternode instead + if (!fThreshold) { + transactionStatus = TrxValidationStatus::VoteThreshold; + } + + // We looked through all of the known budgets + return transactionStatus; +} + +std::vector CBudgetManager::GetAllProposals() +{ + LOCK(cs); + + std::vector vBudgetProposalRet; + + std::map::iterator it = mapProposals.begin(); + while (it != mapProposals.end()) { + (*it).second.CleanAndRemove(false); + + CBudgetProposal* pbudgetProposal = &((*it).second); + vBudgetProposalRet.push_back(pbudgetProposal); + + ++it; + } + + return vBudgetProposalRet; +} + +// +// Sort by votes, if there's a tie sort by their feeHash TX +// +struct sortProposalsByVotes { + bool operator()(const std::pair& left, const std::pair& right) + { + if (left.second != right.second) + return (left.second > right.second); + return (left.first->nFeeTXHash > right.first->nFeeTXHash); + } +}; + +//Need to review this function +std::vector CBudgetManager::GetBudget() +{ + LOCK(cs); + + // ------- Sort budgets by Yes Count + + std::vector > vBudgetPorposalsSort; + + std::map::iterator it = mapProposals.begin(); + while (it != mapProposals.end()) { + (*it).second.CleanAndRemove(false); + vBudgetPorposalsSort.push_back(make_pair(&((*it).second), (*it).second.GetYeas() - (*it).second.GetNays())); + ++it; + } + + std::sort(vBudgetPorposalsSort.begin(), vBudgetPorposalsSort.end(), sortProposalsByVotes()); + + // ------- Grab The Budgets In Order + + std::vector vBudgetProposalsRet; + + CAmount nBudgetAllocated = 0; + CBlockIndex* pindexPrev = chainActive.Tip(); + if (pindexPrev == NULL) return vBudgetProposalsRet; + + int nBlockStart = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); + int nBlockEnd = nBlockStart + GetBudgetPaymentCycleBlocks() - 1; + CAmount nTotalBudget = GetTotalBudget(nBlockStart); + + + std::vector >::iterator it2 = vBudgetPorposalsSort.begin(); + while (it2 != vBudgetPorposalsSort.end()) { + CBudgetProposal* pbudgetProposal = (*it2).first; + + LogPrint("mnbudget","CBudgetManager::GetBudget() - Processing Budget %s\n", pbudgetProposal->strProposalName.c_str()); + //prop start/end should be inside this period + if (pbudgetProposal->fValid && pbudgetProposal->nBlockStart <= nBlockStart && + pbudgetProposal->nBlockEnd >= nBlockEnd && + pbudgetProposal->GetYeas() - pbudgetProposal->GetNays() > mnodeman.CountEnabled(ActiveProtocol()) / 10 && + pbudgetProposal->IsEstablished()) { + + LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 1 passed: valid=%d | %ld <= %ld | %ld >= %ld | Yeas=%d Nays=%d Count=%d | established=%d\n", + pbudgetProposal->fValid, pbudgetProposal->nBlockStart, nBlockStart, pbudgetProposal->nBlockEnd, + nBlockEnd, pbudgetProposal->GetYeas(), pbudgetProposal->GetNays(), mnodeman.CountEnabled(ActiveProtocol()) / 10, + pbudgetProposal->IsEstablished()); + + if (pbudgetProposal->GetAmount() + nBudgetAllocated <= nTotalBudget) { + pbudgetProposal->SetAllotted(pbudgetProposal->GetAmount()); + nBudgetAllocated += pbudgetProposal->GetAmount(); + vBudgetProposalsRet.push_back(pbudgetProposal); + LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 2 passed: Budget added\n"); + } else { + pbudgetProposal->SetAllotted(0); + LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 2 failed: no amount allotted\n"); + } + } + else { + LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 1 failed: valid=%d | %ld <= %ld | %ld >= %ld | Yeas=%d Nays=%d Count=%d | established=%d\n", + pbudgetProposal->fValid, pbudgetProposal->nBlockStart, nBlockStart, pbudgetProposal->nBlockEnd, + nBlockEnd, pbudgetProposal->GetYeas(), pbudgetProposal->GetNays(), mnodeman.CountEnabled(ActiveProtocol()) / 10, + pbudgetProposal->IsEstablished()); + } + + ++it2; + } + + return vBudgetProposalsRet; +} + +struct sortFinalizedBudgetsByVotes { + bool operator()(const std::pair& left, const std::pair& right) + { + if (left.second != right.second) + return left.second > right.second; + return (left.first->nFeeTXHash > right.first->nFeeTXHash); + } +}; + +std::vector CBudgetManager::GetFinalizedBudgets() +{ + LOCK(cs); + + std::vector vFinalizedBudgetsRet; + std::vector > vFinalizedBudgetsSort; + + // ------- Grab The Budgets In Order + + std::map::iterator it = mapFinalizedBudgets.begin(); + while (it != mapFinalizedBudgets.end()) { + CFinalizedBudget* pfinalizedBudget = &((*it).second); + + vFinalizedBudgetsSort.push_back(make_pair(pfinalizedBudget, pfinalizedBudget->GetVoteCount())); + ++it; + } + std::sort(vFinalizedBudgetsSort.begin(), vFinalizedBudgetsSort.end(), sortFinalizedBudgetsByVotes()); + + std::vector >::iterator it2 = vFinalizedBudgetsSort.begin(); + while (it2 != vFinalizedBudgetsSort.end()) { + vFinalizedBudgetsRet.push_back((*it2).first); + ++it2; + } + + return vFinalizedBudgetsRet; +} + +std::string CBudgetManager::GetRequiredPaymentsString(int nBlockHeight) +{ + LOCK(cs); + + std::string ret = "unknown-budget"; + + std::map::iterator it = mapFinalizedBudgets.begin(); + while (it != mapFinalizedBudgets.end()) { + CFinalizedBudget* pfinalizedBudget = &((*it).second); + if (nBlockHeight >= pfinalizedBudget->GetBlockStart() && nBlockHeight <= pfinalizedBudget->GetBlockEnd()) { + CTxBudgetPayment payment; + if (pfinalizedBudget->GetBudgetPaymentByBlock(nBlockHeight, payment)) { + if (ret == "unknown-budget") { + ret = payment.nProposalHash.ToString(); + } else { + ret += ","; + ret += payment.nProposalHash.ToString(); + } + } else { + LogPrint("mnbudget","CBudgetManager::GetRequiredPaymentsString - Couldn't find budget payment for block %d\n", nBlockHeight); + } + } + + ++it; + } + + return ret; +} + +CAmount CBudgetManager::GetTotalBudget(int nHeight) +{ + if (chainActive.Tip() == NULL) return 0; + + CAmount nSubsidy = GetBlockValue(nHeight, true); + + return nSubsidy * GetBudgetPaymentCycleBlocks(); +} + +void CBudgetManager::NewBlock() +{ + TRY_LOCK(cs, fBudgetNewBlock); + if (!fBudgetNewBlock) return; + + if (masternodeSync.RequestedMasternodeAssets <= MASTERNODE_SYNC_BUDGET) return; + + if (strBudgetMode == "suggest") { //suggest the budget we see + SubmitFinalBudget(); + } + + //this function should be called 1/14 blocks, allowing up to 100 votes per day on all proposals + if (chainActive.Height() % 14 != 0) return; + + // incremental sync with our peers + if (masternodeSync.IsSynced()) { + LogPrint("mnbudget","CBudgetManager::NewBlock - incremental sync started\n"); + if (chainActive.Height() % 1440 == rand() % 1440) { + ClearSeen(); + ResetSync(); + } + + LOCK(cs_vNodes); + BOOST_FOREACH (CNode* pnode, vNodes) + if (pnode->nVersion >= ActiveProtocol()) + Sync(pnode, 0, true); + + MarkSynced(); + } + + + CheckAndRemove(); + + //remove invalid votes once in a while (we have to check the signatures and validity of every vote, somewhat CPU intensive) + + LogPrint("mnbudget","CBudgetManager::NewBlock - askedForSourceProposalOrBudget cleanup - size: %d\n", askedForSourceProposalOrBudget.size()); + std::map::iterator it = askedForSourceProposalOrBudget.begin(); + while (it != askedForSourceProposalOrBudget.end()) { + if ((*it).second > GetTime() - (60 * 60 * 24)) { + ++it; + } else { + askedForSourceProposalOrBudget.erase(it++); + } + } + + LogPrint("mnbudget","CBudgetManager::NewBlock - mapProposals cleanup - size: %d\n", mapProposals.size()); + std::map::iterator it2 = mapProposals.begin(); + while (it2 != mapProposals.end()) { + (*it2).second.CleanAndRemove(false); + ++it2; + } + + LogPrint("mnbudget","CBudgetManager::NewBlock - mapFinalizedBudgets cleanup - size: %d\n", mapFinalizedBudgets.size()); + std::map::iterator it3 = mapFinalizedBudgets.begin(); + while (it3 != mapFinalizedBudgets.end()) { + (*it3).second.CleanAndRemove(false); + ++it3; + } + + LogPrint("mnbudget","CBudgetManager::NewBlock - vecImmatureBudgetProposals cleanup - size: %d\n", vecImmatureBudgetProposals.size()); + std::vector::iterator it4 = vecImmatureBudgetProposals.begin(); + while (it4 != vecImmatureBudgetProposals.end()) { + std::string strError = ""; + int nConf = 0; + if (!IsBudgetCollateralValid((*it4).nFeeTXHash, (*it4).GetHash(), strError, (*it4).nTime, nConf, true)) { + ++it4; + continue; + } + + if (!(*it4).IsValid(strError)) { + LogPrint("mnbudget","mprop (immature) - invalid budget proposal - %s\n", strError); + it4 = vecImmatureBudgetProposals.erase(it4); + continue; + } + + CBudgetProposal budgetProposal((*it4)); + if (AddProposal(budgetProposal)) { + (*it4).Relay(); + } + + LogPrint("mnbudget","mprop (immature) - new budget - %s\n", (*it4).GetHash().ToString()); + it4 = vecImmatureBudgetProposals.erase(it4); + } + + LogPrint("mnbudget","CBudgetManager::NewBlock - vecImmatureFinalizedBudgets cleanup - size: %d\n", vecImmatureFinalizedBudgets.size()); + std::vector::iterator it5 = vecImmatureFinalizedBudgets.begin(); + while (it5 != vecImmatureFinalizedBudgets.end()) { + std::string strError = ""; + int nConf = 0; + if (!IsBudgetCollateralValid((*it5).nFeeTXHash, (*it5).GetHash(), strError, (*it5).nTime, nConf, true)) { + ++it5; + continue; + } + + if (!(*it5).IsValid(strError)) { + LogPrint("mnbudget","fbs (immature) - invalid finalized budget - %s\n", strError); + it5 = vecImmatureFinalizedBudgets.erase(it5); + continue; + } + + LogPrint("mnbudget","fbs (immature) - new finalized budget - %s\n", (*it5).GetHash().ToString()); + + CFinalizedBudget finalizedBudget((*it5)); + if (AddFinalizedBudget(finalizedBudget)) { + (*it5).Relay(); + } + + it5 = vecImmatureFinalizedBudgets.erase(it5); + } + LogPrint("mnbudget","CBudgetManager::NewBlock - PASSED\n"); +} + +void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv) +{ + // lite mode is not supported + if (fLiteMode) return; + if (!masternodeSync.IsBlockchainSynced()) return; + + LOCK(cs_budget); + + if (strCommand == NetMsgType::MNVS) { //Masternode vote sync + uint256 nProp; + vRecv >> nProp; + + if (Params().NetworkID() == CBaseChainParams::MAIN) { + if (nProp == 0) { + if (pfrom->HasFulfilledRequest(NetMsgType::MNVS)) { + LogPrint("mnbudget","mnvs - peer already asked me for the list\n"); + // TODO: Determine why this happens often and is bannable offense + // LogPrintf("Misbehaving: ASKED FOR LIST\n"); + // Misbehaving(pfrom->GetId(), 20); + return; + } + pfrom->FulfilledRequest(NetMsgType::MNVS); + } + } + + Sync(pfrom, nProp); + LogPrint("mnbudget", "mnvs - Sent Masternode votes to peer %i\n", pfrom->GetId()); + } + + if (strCommand == NetMsgType::MPROP) { //Masternode Proposal + CBudgetProposalBroadcast budgetProposalBroadcast; + vRecv >> budgetProposalBroadcast; + + if (mapSeenMasternodeBudgetProposals.count(budgetProposalBroadcast.GetHash())) { + masternodeSync.AddedBudgetItem(budgetProposalBroadcast.GetHash()); + return; + } + + std::string strError = ""; + int nConf = 0; + if (!IsBudgetCollateralValid(budgetProposalBroadcast.nFeeTXHash, budgetProposalBroadcast.GetHash(), strError, budgetProposalBroadcast.nTime, nConf)) { + LogPrint("mnbudget","Proposal FeeTX is not valid - %s - %s\n", budgetProposalBroadcast.nFeeTXHash.ToString(), strError); + if (nConf >= 1) vecImmatureBudgetProposals.push_back(budgetProposalBroadcast); + return; + } + + mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast)); + + if (!budgetProposalBroadcast.IsValid(strError)) { + LogPrint("mnbudget","mprop - invalid budget proposal - %s\n", strError); + return; + } + + CBudgetProposal budgetProposal(budgetProposalBroadcast); + if (AddProposal(budgetProposal)) { + budgetProposalBroadcast.Relay(); + } + masternodeSync.AddedBudgetItem(budgetProposalBroadcast.GetHash()); + + LogPrint("mnbudget","mprop - new budget - %s\n", budgetProposalBroadcast.GetHash().ToString()); + + //We might have active votes for this proposal that are valid now + CheckOrphanVotes(); + } + + if (strCommand == NetMsgType::MVOTE) { //Masternode Vote + CBudgetVote vote; + vRecv >> vote; + vote.fValid = true; + + if (mapSeenMasternodeBudgetVotes.count(vote.GetHash())) { + masternodeSync.AddedBudgetItem(vote.GetHash()); + return; + } + + CMasternode* pmn = mnodeman.Find(vote.vin); + if (pmn == NULL) { + LogPrint("mnbudget","mvote - unknown masternode - vin: %s\n", vote.vin.prevout.hash.ToString()); + mnodeman.AskForMN(pfrom, vote.vin); + return; + } + + + mapSeenMasternodeBudgetVotes.insert(make_pair(vote.GetHash(), vote)); + if (!vote.SignatureValid(true)) { + LogPrint("mnbudget","mvote - signature invalid\n"); + if (masternodeSync.IsSynced()) { + LogPrintf("Misbehaving: SYNCED VOTES INSERTT\n"); + Misbehaving(pfrom->GetId(), 20); + } + // it could just be a non-synced masternode + mnodeman.AskForMN(pfrom, vote.vin); + return; + } + + std::string strError = ""; + if (UpdateProposal(vote, pfrom, strError)) { + vote.Relay(); + masternodeSync.AddedBudgetItem(vote.GetHash()); + } + + LogPrint("mnbudget","mvote - new budget vote for budget %s - %s\n", vote.nProposalHash.ToString(), vote.GetHash().ToString()); + } + + if (strCommand == NetMsgType::FBS) { //Finalized Budget Suggestion + CFinalizedBudgetBroadcast finalizedBudgetBroadcast; + vRecv >> finalizedBudgetBroadcast; + + if (mapSeenFinalizedBudgets.count(finalizedBudgetBroadcast.GetHash())) { + masternodeSync.AddedBudgetItem(finalizedBudgetBroadcast.GetHash()); + return; + } + + std::string strError = ""; + int nConf = 0; + if (!IsBudgetCollateralValid(finalizedBudgetBroadcast.nFeeTXHash, finalizedBudgetBroadcast.GetHash(), strError, finalizedBudgetBroadcast.nTime, nConf, true)) { + LogPrint("mnbudget","fbs - Finalized Budget FeeTX is not valid - %s - %s\n", finalizedBudgetBroadcast.nFeeTXHash.ToString(), strError); + + if (nConf >= 1) vecImmatureFinalizedBudgets.push_back(finalizedBudgetBroadcast); + return; + } + + mapSeenFinalizedBudgets.insert(make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast)); + + if (!finalizedBudgetBroadcast.IsValid(strError)) { + LogPrint("mnbudget","fbs - invalid finalized budget - %s\n", strError); + return; + } + + LogPrint("mnbudget","fbs - new finalized budget - %s\n", finalizedBudgetBroadcast.GetHash().ToString()); + + CFinalizedBudget finalizedBudget(finalizedBudgetBroadcast); + if (AddFinalizedBudget(finalizedBudget)) { + finalizedBudgetBroadcast.Relay(); + } + masternodeSync.AddedBudgetItem(finalizedBudgetBroadcast.GetHash()); + + //we might have active votes for this budget that are now valid + CheckOrphanVotes(); + } + + if (strCommand == NetMsgType::FBVOTE) { //Finalized Budget Vote + CFinalizedBudgetVote vote; + vRecv >> vote; + vote.fValid = true; + + if (mapSeenFinalizedBudgetVotes.count(vote.GetHash())) { + masternodeSync.AddedBudgetItem(vote.GetHash()); + return; + } + + CMasternode* pmn = mnodeman.Find(vote.vin); + if (pmn == NULL) { + LogPrint("mnbudget", "fbvote - unknown masternode - vin: %s\n", vote.vin.prevout.hash.ToString()); + mnodeman.AskForMN(pfrom, vote.vin); + return; + } + + mapSeenFinalizedBudgetVotes.insert(make_pair(vote.GetHash(), vote)); + if (!vote.SignatureValid(true)) { + LogPrint("mnbudget","fbvote - signature invalid\n"); + if (masternodeSync.IsSynced()) { + LogPrintf("Misbehaving: SYNCED SIG INVALID\n"); + Misbehaving(pfrom->GetId(), 20); + } + // it could just be a non-synced masternode + mnodeman.AskForMN(pfrom, vote.vin); + return; + } + + std::string strError = ""; + if (UpdateFinalizedBudget(vote, pfrom, strError)) { + vote.Relay(); + masternodeSync.AddedBudgetItem(vote.GetHash()); + + LogPrint("mnbudget","fbvote - new finalized budget vote - %s\n", vote.GetHash().ToString()); + } else { + LogPrint("mnbudget","fbvote - rejected finalized budget vote - %s - %s\n", vote.GetHash().ToString(), strError); + } + } +} + +bool CBudgetManager::PropExists(uint256 nHash) +{ + if (mapProposals.count(nHash)) return true; + return false; +} + +//mark that a full sync is needed +void CBudgetManager::ResetSync() +{ + LOCK(cs); + + + std::map::iterator it1 = mapSeenMasternodeBudgetProposals.begin(); + while (it1 != mapSeenMasternodeBudgetProposals.end()) { + CBudgetProposal* pbudgetProposal = FindProposal((*it1).first); + if (pbudgetProposal && pbudgetProposal->fValid) { + //mark votes + std::map::iterator it2 = pbudgetProposal->mapVotes.begin(); + while (it2 != pbudgetProposal->mapVotes.end()) { + (*it2).second.fSynced = false; + ++it2; + } + } + ++it1; + } + + std::map::iterator it3 = mapSeenFinalizedBudgets.begin(); + while (it3 != mapSeenFinalizedBudgets.end()) { + CFinalizedBudget* pfinalizedBudget = FindFinalizedBudget((*it3).first); + if (pfinalizedBudget && pfinalizedBudget->fValid) { + //send votes + std::map::iterator it4 = pfinalizedBudget->mapVotes.begin(); + while (it4 != pfinalizedBudget->mapVotes.end()) { + (*it4).second.fSynced = false; + ++it4; + } + } + ++it3; + } +} + +void CBudgetManager::MarkSynced() +{ + LOCK(cs); + + /* + Mark that we've sent all valid items + */ + + std::map::iterator it1 = mapSeenMasternodeBudgetProposals.begin(); + while (it1 != mapSeenMasternodeBudgetProposals.end()) { + CBudgetProposal* pbudgetProposal = FindProposal((*it1).first); + if (pbudgetProposal && pbudgetProposal->fValid) { + //mark votes + std::map::iterator it2 = pbudgetProposal->mapVotes.begin(); + while (it2 != pbudgetProposal->mapVotes.end()) { + if ((*it2).second.fValid) + (*it2).second.fSynced = true; + ++it2; + } + } + ++it1; + } + + std::map::iterator it3 = mapSeenFinalizedBudgets.begin(); + while (it3 != mapSeenFinalizedBudgets.end()) { + CFinalizedBudget* pfinalizedBudget = FindFinalizedBudget((*it3).first); + if (pfinalizedBudget && pfinalizedBudget->fValid) { + //mark votes + std::map::iterator it4 = pfinalizedBudget->mapVotes.begin(); + while (it4 != pfinalizedBudget->mapVotes.end()) { + if ((*it4).second.fValid) + (*it4).second.fSynced = true; + ++it4; + } + } + ++it3; + } +} + + +void CBudgetManager::Sync(CNode* pfrom, uint256 nProp, bool fPartial) +{ + LOCK(cs); + + /* + Sync with a client on the network + -- + This code checks each of the hash maps for all known budget proposals and finalized budget proposals, then checks them against the + budget object to see if they're OK. If all checks pass, we'll send it to the peer. + */ + + int nInvCount = 0; + + std::map::iterator it1 = mapSeenMasternodeBudgetProposals.begin(); + while (it1 != mapSeenMasternodeBudgetProposals.end()) { + CBudgetProposal* pbudgetProposal = FindProposal((*it1).first); + if (pbudgetProposal && pbudgetProposal->fValid && (nProp == 0 || (*it1).first == nProp)) { + pfrom->PushInventory(CInv(MSG_BUDGET_PROPOSAL, (*it1).second.GetHash())); + nInvCount++; + + //send votes + std::map::iterator it2 = pbudgetProposal->mapVotes.begin(); + while (it2 != pbudgetProposal->mapVotes.end()) { + if ((*it2).second.fValid) { + if ((fPartial && !(*it2).second.fSynced) || !fPartial) { + pfrom->PushInventory(CInv(MSG_BUDGET_VOTE, (*it2).second.GetHash())); + nInvCount++; + } + } + ++it2; + } + } + ++it1; + } + + pfrom->PushMessage(NetMsgType::SSC, MASTERNODE_SYNC_BUDGET_PROP, nInvCount); + + LogPrint("mnbudget", "CBudgetManager::Sync - sent %d items\n", nInvCount); + + nInvCount = 0; + + std::map::iterator it3 = mapSeenFinalizedBudgets.begin(); + while (it3 != mapSeenFinalizedBudgets.end()) { + CFinalizedBudget* pfinalizedBudget = FindFinalizedBudget((*it3).first); + if (pfinalizedBudget && pfinalizedBudget->fValid && (nProp == 0 || (*it3).first == nProp)) { + pfrom->PushInventory(CInv(MSG_BUDGET_FINALIZED, (*it3).second.GetHash())); + nInvCount++; + + //send votes + std::map::iterator it4 = pfinalizedBudget->mapVotes.begin(); + while (it4 != pfinalizedBudget->mapVotes.end()) { + if ((*it4).second.fValid) { + if ((fPartial && !(*it4).second.fSynced) || !fPartial) { + pfrom->PushInventory(CInv(MSG_BUDGET_FINALIZED_VOTE, (*it4).second.GetHash())); + nInvCount++; + } + } + ++it4; + } + } + ++it3; + } + + pfrom->PushMessage(NetMsgType::SSC, MASTERNODE_SYNC_BUDGET_FIN, nInvCount); + LogPrint("mnbudget", "CBudgetManager::Sync - sent %d items\n", nInvCount); +} + +bool CBudgetManager::UpdateProposal(CBudgetVote& vote, CNode* pfrom, std::string& strError) +{ + LOCK(cs); + + if (!mapProposals.count(vote.nProposalHash)) { + if (pfrom) { + // only ask for missing items after our syncing process is complete -- + // otherwise we'll think a full sync succeeded when they return a result + if (!masternodeSync.IsSynced()) return false; + + LogPrint("mnbudget","CBudgetManager::UpdateProposal - Unknown proposal %d, asking for source proposal\n", vote.nProposalHash.ToString()); + mapOrphanMasternodeBudgetVotes[vote.nProposalHash] = vote; + + if (!askedForSourceProposalOrBudget.count(vote.nProposalHash)) { + pfrom->PushMessage(NetMsgType::MNVS, vote.nProposalHash); + askedForSourceProposalOrBudget[vote.nProposalHash] = GetTime(); + } + } + + strError = "Proposal not found!"; + return false; + } + + + return mapProposals[vote.nProposalHash].AddOrUpdateVote(vote, strError); +} + +bool CBudgetManager::UpdateFinalizedBudget(CFinalizedBudgetVote& vote, CNode* pfrom, std::string& strError) +{ + LOCK(cs); + + if (!mapFinalizedBudgets.count(vote.nBudgetHash)) { + if (pfrom) { + // only ask for missing items after our syncing process is complete -- + // otherwise we'll think a full sync succeeded when they return a result + if (!masternodeSync.IsSynced()) return false; + + LogPrint("mnbudget","CBudgetManager::UpdateFinalizedBudget - Unknown Finalized Proposal %s, asking for source budget\n", vote.nBudgetHash.ToString()); + mapOrphanFinalizedBudgetVotes[vote.nBudgetHash] = vote; + + if (!askedForSourceProposalOrBudget.count(vote.nBudgetHash)) { + pfrom->PushMessage(NetMsgType::MNVS, vote.nBudgetHash); + askedForSourceProposalOrBudget[vote.nBudgetHash] = GetTime(); + } + } + + strError = "Finalized Budget " + vote.nBudgetHash.ToString() + " not found!"; + return false; + } + LogPrint("mnbudget","CBudgetManager::UpdateFinalizedBudget - Finalized Proposal %s added\n", vote.nBudgetHash.ToString()); + return mapFinalizedBudgets[vote.nBudgetHash].AddOrUpdateVote(vote, strError); +} + +CBudgetProposal::CBudgetProposal() +{ + strProposalName = "unknown"; + nBlockStart = 0; + nBlockEnd = 0; + nAmount = 0; + nTime = 0; + fValid = true; +} + +CBudgetProposal::CBudgetProposal(std::string strProposalNameIn, std::string strURLIn, int nBlockStartIn, int nBlockEndIn, CScript addressIn, CAmount nAmountIn, uint256 nFeeTXHashIn) +{ + strProposalName = strProposalNameIn; + strURL = strURLIn; + nBlockStart = nBlockStartIn; + nBlockEnd = nBlockEndIn; + address = addressIn; + nAmount = nAmountIn; + nFeeTXHash = nFeeTXHashIn; + fValid = true; +} + +CBudgetProposal::CBudgetProposal(const CBudgetProposal& other) +{ + strProposalName = other.strProposalName; + strURL = other.strURL; + nBlockStart = other.nBlockStart; + nBlockEnd = other.nBlockEnd; + address = other.address; + nAmount = other.nAmount; + nTime = other.nTime; + nFeeTXHash = other.nFeeTXHash; + mapVotes = other.mapVotes; + fValid = true; +} + +bool CBudgetProposal::IsValid(std::string& strError, bool fCheckCollateral) +{ + if (GetNays() - GetYeas() > mnodeman.CountEnabled(ActiveProtocol()) / 10) { + strError = "Proposal " + strProposalName + ": Active removal"; + return false; + } + + if (nBlockStart < 0) { + strError = "Invalid Proposal"; + return false; + } + + if (nBlockEnd < nBlockStart) { + strError = "Proposal " + strProposalName + ": Invalid nBlockEnd (end before start)"; + return false; + } + + if (nAmount < 10 * COIN) { + strError = "Proposal " + strProposalName + ": Invalid nAmount"; + return false; + } + + if (address == CScript()) { + strError = "Proposal " + strProposalName + ": Invalid Payment Address"; + return false; + } + + if (fCheckCollateral) { + int nConf = 0; + if (!IsBudgetCollateralValid(nFeeTXHash, GetHash(), strError, nTime, nConf)) { + strError = "Proposal " + strProposalName + ": Invalid collateral"; + return false; + } + } + + /* + TODO: There might be an issue with multisig in the coinbase on mainnet, we will add support for it in a future release. + */ + if (address.IsPayToScriptHash()) { + strError = "Proposal " + strProposalName + ": Multisig is not currently supported."; + return false; + } + + //if proposal doesn't gain traction within 2 weeks, remove it + // nTime not being saved correctly + // -- TODO: We should keep track of the last time the proposal was valid, if it's invalid for 2 weeks, erase it + // if(nTime + (60*60*24*2) < GetAdjustedTime()) { + // if(GetYeas()-GetNays() < (mnodeman.CountEnabled(ActiveProtocol())/10)) { + // strError = "Not enough support"; + // return false; + // } + // } + + CAmount totalBudget = budget.GetTotalBudget(nBlockStart); + + // can only pay out 10% of the possible coins (min value of coins) + if (nAmount > totalBudget) { + strError = "Proposal " + + strProposalName + + ": Payment more than max for cycle. (" + + FormatMoney(totalBudget) + + " ODIN)"; + return false; + } + + CBlockIndex* pindexPrev = chainActive.Tip(); + if (pindexPrev == NULL) { + strError = "Proposal " + strProposalName + ": Tip is NULL"; + return true; + } + + // Calculate maximum block this proposal will be valid, which is start of proposal + (number of payments * cycle) + int nProposalEnd = GetBlockStart() + (GetBudgetPaymentCycleBlocks() * GetTotalPaymentCount()); + + // if (GetBlockEnd() < pindexPrev->nHeight - GetBudgetPaymentCycleBlocks() / 2) { + if(nProposalEnd < pindexPrev->nHeight){ + strError = "Proposal " + strProposalName + ": Invalid nBlockEnd (" + std::to_string(nProposalEnd) + ") < current height (" + std::to_string(pindexPrev->nHeight) + ")"; + return false; + } + + return true; +} + +bool CBudgetProposal::AddOrUpdateVote(CBudgetVote& vote, std::string& strError) +{ + std::string strAction = "New vote inserted:"; + LOCK(cs); + + uint256 hash = vote.vin.prevout.GetHash(); + + if (mapVotes.count(hash)) { + if (mapVotes[hash].nTime > vote.nTime) { + strError = strprintf("new vote older than existing vote - %s\n", vote.GetHash().ToString()); + LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s\n", strError); + return false; + } + if (vote.nTime - mapVotes[hash].nTime < BUDGET_VOTE_UPDATE_MIN) { + strError = strprintf("time between votes is too soon - %s - %lli sec < %lli sec\n", vote.GetHash().ToString(), vote.nTime - mapVotes[hash].nTime,BUDGET_VOTE_UPDATE_MIN); + LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s\n", strError); + return false; + } + strAction = "Existing vote updated:"; + } + + if (vote.nTime > GetTime() + (60 * 60)) { + strError = strprintf("new vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", vote.GetHash().ToString(), vote.nTime, GetTime() + (60 * 60)); + LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s\n", strError); + return false; + } + + mapVotes[hash] = vote; + LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s %s\n", strAction.c_str(), vote.GetHash().ToString().c_str()); + + return true; +} + +// If masternode voted for a proposal, but is now invalid -- remove the vote +void CBudgetProposal::CleanAndRemove(bool fSignatureCheck) +{ + std::map::iterator it = mapVotes.begin(); + + while (it != mapVotes.end()) { + (*it).second.fValid = (*it).second.SignatureValid(fSignatureCheck); + ++it; + } +} + +double CBudgetProposal::GetRatio() +{ + int yeas = 0; + int nays = 0; + + std::map::iterator it = mapVotes.begin(); + + while (it != mapVotes.end()) { + if ((*it).second.nVote == VOTE_YES) yeas++; + if ((*it).second.nVote == VOTE_NO) nays++; + ++it; + } + + if (yeas + nays == 0) return 0.0f; + + return ((double)(yeas) / (double)(yeas + nays)); +} + +int CBudgetProposal::GetYeas() +{ + int ret = 0; + + std::map::iterator it = mapVotes.begin(); + while (it != mapVotes.end()) { + if ((*it).second.nVote == VOTE_YES && (*it).second.fValid) ret++; + ++it; + } + + return ret; +} + +int CBudgetProposal::GetNays() +{ + int ret = 0; + + std::map::iterator it = mapVotes.begin(); + while (it != mapVotes.end()) { + if ((*it).second.nVote == VOTE_NO && (*it).second.fValid) ret++; + ++it; + } + + return ret; +} + +int CBudgetProposal::GetAbstains() +{ + int ret = 0; + + std::map::iterator it = mapVotes.begin(); + while (it != mapVotes.end()) { + if ((*it).second.nVote == VOTE_ABSTAIN && (*it).second.fValid) ret++; + ++it; + } + + return ret; +} + +int CBudgetProposal::GetBlockStartCycle() +{ + //end block is half way through the next cycle (so the proposal will be removed much after the payment is sent) + + return nBlockStart - nBlockStart % GetBudgetPaymentCycleBlocks(); +} + +int CBudgetProposal::GetBlockCurrentCycle() +{ + CBlockIndex* pindexPrev = chainActive.Tip(); + if (pindexPrev == NULL) return -1; + + if (pindexPrev->nHeight >= GetBlockEndCycle()) return -1; + + return pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks(); +} + +int CBudgetProposal::GetBlockEndCycle() +{ + // Right now single payment proposals have nBlockEnd have a cycle too early! + // switch back if it break something else + // end block is half way through the next cycle (so the proposal will be removed much after the payment is sent) + // return nBlockEnd - GetBudgetPaymentCycleBlocks() / 2; + + // End block is half way through the next cycle (so the proposal will be removed much after the payment is sent) + return nBlockEnd; + +} + +int CBudgetProposal::GetTotalPaymentCount() +{ + return (GetBlockEndCycle() - GetBlockStartCycle()) / GetBudgetPaymentCycleBlocks(); +} + +int CBudgetProposal::GetRemainingPaymentCount() +{ + // If this budget starts in the future, this value will be wrong + int nPayments = (GetBlockEndCycle() - GetBlockCurrentCycle()) / GetBudgetPaymentCycleBlocks() - 1; + // Take the lowest value + return std::min(nPayments, GetTotalPaymentCount()); +} + +CBudgetProposalBroadcast::CBudgetProposalBroadcast(std::string strProposalNameIn, std::string strURLIn, int nPaymentCount, CScript addressIn, CAmount nAmountIn, int nBlockStartIn, uint256 nFeeTXHashIn) +{ + strProposalName = strProposalNameIn; + strURL = strURLIn; + + nBlockStart = nBlockStartIn; + + int nCycleStart = nBlockStart - nBlockStart % GetBudgetPaymentCycleBlocks(); + + // Right now single payment proposals have nBlockEnd have a cycle too early! + // switch back if it break something else + // calculate the end of the cycle for this vote, add half a cycle (vote will be deleted after that block) + // nBlockEnd = nCycleStart + GetBudgetPaymentCycleBlocks() * nPaymentCount + GetBudgetPaymentCycleBlocks() / 2; + + // Calculate the end of the cycle for this vote, vote will be deleted after next cycle + nBlockEnd = nCycleStart + (GetBudgetPaymentCycleBlocks() + 1) * nPaymentCount; + + address = addressIn; + nAmount = nAmountIn; + + nFeeTXHash = nFeeTXHashIn; +} + +void CBudgetProposalBroadcast::Relay() +{ + CInv inv(MSG_BUDGET_PROPOSAL, GetHash()); + RelayInv(inv); +} + +CBudgetVote::CBudgetVote() +{ + vin = CTxIn(); + nProposalHash = 0; + nVote = VOTE_ABSTAIN; + nTime = 0; + fValid = true; + fSynced = false; +} + +CBudgetVote::CBudgetVote(CTxIn vinIn, uint256 nProposalHashIn, int nVoteIn) +{ + vin = vinIn; + nProposalHash = nProposalHashIn; + nVote = nVoteIn; + nTime = GetAdjustedTime(); + fValid = true; + fSynced = false; +} + +void CBudgetVote::Relay() +{ + CInv inv(MSG_BUDGET_VOTE, GetHash()); + RelayInv(inv); +} + +bool CBudgetVote::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode) +{ + // Choose coins to use + CPubKey pubKeyCollateralAddress; + CKey keyCollateralAddress; + + std::string errorMessage; + std::string strMessage = vin.prevout.ToStringShort() + nProposalHash.ToString() + boost::lexical_cast(nVote) + boost::lexical_cast(nTime); + + if (!obfuScationSigner.SignMessage(strMessage, errorMessage, vchSig, keyMasternode)) { + LogPrint("mnbudget","CBudgetVote::Sign - Error upon calling SignMessage"); + return false; + } + + if (!obfuScationSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, errorMessage)) { + LogPrint("mnbudget","CBudgetVote::Sign - Error upon calling VerifyMessage"); + return false; + } + + return true; +} + +bool CBudgetVote::SignatureValid(bool fSignatureCheck) +{ + std::string errorMessage; + std::string strMessage = vin.prevout.ToStringShort() + nProposalHash.ToString() + boost::lexical_cast(nVote) + boost::lexical_cast(nTime); + + CMasternode* pmn = mnodeman.Find(vin); + + if (pmn == NULL) { + if (fDebug){ + LogPrint("mnbudget","CBudgetVote::SignatureValid() - Unknown Masternode - %s\n", vin.prevout.hash.ToString()); + } + return false; + } + + if (!fSignatureCheck) return true; + + if (!obfuScationSigner.VerifyMessage(pmn->pubKeyMasternode, vchSig, strMessage, errorMessage)) { + LogPrint("mnbudget","CBudgetVote::SignatureValid() - Verify message failed\n"); + return false; + } + + return true; +} + +CFinalizedBudget::CFinalizedBudget() +{ + strBudgetName = ""; + nBlockStart = 0; + vecBudgetPayments.clear(); + mapVotes.clear(); + nFeeTXHash = 0; + nTime = 0; + fValid = true; + fAutoChecked = false; +} + +CFinalizedBudget::CFinalizedBudget(const CFinalizedBudget& other) +{ + strBudgetName = other.strBudgetName; + nBlockStart = other.nBlockStart; + vecBudgetPayments = other.vecBudgetPayments; + mapVotes = other.mapVotes; + nFeeTXHash = other.nFeeTXHash; + nTime = other.nTime; + fValid = true; + fAutoChecked = false; +} + +bool CFinalizedBudget::AddOrUpdateVote(CFinalizedBudgetVote& vote, std::string& strError) +{ + LOCK(cs); + + uint256 hash = vote.vin.prevout.GetHash(); + std::string strAction = "New vote inserted:"; + + if (mapVotes.count(hash)) { + if (mapVotes[hash].nTime > vote.nTime) { + strError = strprintf("new vote older than existing vote - %s\n", vote.GetHash().ToString()); + LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError); + return false; + } + if (vote.nTime - mapVotes[hash].nTime < BUDGET_VOTE_UPDATE_MIN) { + strError = strprintf("time between votes is too soon - %s - %lli sec < %lli sec\n", vote.GetHash().ToString(), vote.nTime - mapVotes[hash].nTime,BUDGET_VOTE_UPDATE_MIN); + LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError); + return false; + } + strAction = "Existing vote updated:"; + } + + if (vote.nTime > GetTime() + (60 * 60)) { + strError = strprintf("new vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", vote.GetHash().ToString(), vote.nTime, GetTime() + (60 * 60)); + LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError); + return false; + } + + mapVotes[hash] = vote; + LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s %s\n", strAction.c_str(), vote.GetHash().ToString().c_str()); + return true; +} + +//evaluate if we should vote for this. Masternode only +void CFinalizedBudget::AutoCheck() +{ + LOCK(cs); + + CBlockIndex* pindexPrev = chainActive.Tip(); + if (!pindexPrev) return; + + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - %lli - %d\n", pindexPrev->nHeight, fAutoChecked); + + if (!fMasterNode || fAutoChecked) { + LogPrint("mnbudget","CFinalizedBudget::AutoCheck fMasterNode=%d fAutoChecked=%d\n", fMasterNode, fAutoChecked); + return; + } + + // Do this 1 in 4 blocks -- spread out the voting activity on mainnet + // -- this function is only called every fourteenth block, so this is really 1 in 56 blocks + if (rand() % 4 != 0) { + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - waiting\n"); + return; + } + + fAutoChecked = true; //we only need to check this once + + + if (strBudgetMode == "auto") //only vote for exact matches + { + std::vector vBudgetProposals = budget.GetBudget(); + + + for (unsigned int i = 0; i < vecBudgetPayments.size(); i++) { + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - nProp %d %s\n", i, vecBudgetPayments[i].nProposalHash.ToString()); + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Payee %d %s\n", i, vecBudgetPayments[i].payee.ToString()); + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - nAmount %d %lli\n", i, vecBudgetPayments[i].nAmount); + } + + for (unsigned int i = 0; i < vBudgetProposals.size(); i++) { + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - nProp %d %s\n", i, vBudgetProposals[i]->GetHash().ToString()); + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Payee %d %s\n", i, vBudgetProposals[i]->GetPayee().ToString()); + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - nAmount %d %lli\n", i, vBudgetProposals[i]->GetAmount()); + } + + if (vBudgetProposals.size() == 0) { + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Can't get Budget, aborting\n"); + return; + } + + if (vBudgetProposals.size() != vecBudgetPayments.size()) { + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Budget length doesn't match. vBudgetProposals.size()=%ld != vecBudgetPayments.size()=%ld\n", + vBudgetProposals.size(), vecBudgetPayments.size()); + return; + } + + + for (unsigned int i = 0; i < vecBudgetPayments.size(); i++) { + if (i > vBudgetProposals.size() - 1) { + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Proposal size mismatch, i=%d > (vBudgetProposals.size() - 1)=%d\n", i, vBudgetProposals.size() - 1); + return; + } + + if (vecBudgetPayments[i].nProposalHash != vBudgetProposals[i]->GetHash()) { + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - item #%d doesn't match %s %s\n", i, vecBudgetPayments[i].nProposalHash.ToString(), vBudgetProposals[i]->GetHash().ToString()); + return; + } + + // if(vecBudgetPayments[i].payee != vBudgetProposals[i]->GetPayee()){ -- triggered with false positive + if (vecBudgetPayments[i].payee.ToString() != vBudgetProposals[i]->GetPayee().ToString()) { + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - item #%d payee doesn't match %s %s\n", i, vecBudgetPayments[i].payee.ToString(), vBudgetProposals[i]->GetPayee().ToString()); + return; + } + + if (vecBudgetPayments[i].nAmount != vBudgetProposals[i]->GetAmount()) { + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - item #%d payee doesn't match %lli %lli\n", i, vecBudgetPayments[i].nAmount, vBudgetProposals[i]->GetAmount()); + return; + } + } + + LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Finalized Budget Matches! Submitting Vote.\n"); + SubmitVote(); + } +} +// If masternode voted for a proposal, but is now invalid -- remove the vote +void CFinalizedBudget::CleanAndRemove(bool fSignatureCheck) +{ + std::map::iterator it = mapVotes.begin(); + + while (it != mapVotes.end()) { + (*it).second.fValid = (*it).second.SignatureValid(fSignatureCheck); + ++it; + } +} + + +CAmount CFinalizedBudget::GetTotalPayout() +{ + CAmount ret = 0; + + for (unsigned int i = 0; i < vecBudgetPayments.size(); i++) { + ret += vecBudgetPayments[i].nAmount; + } + + return ret; +} + +std::string CFinalizedBudget::GetProposals() +{ + LOCK(cs); + std::string ret = ""; + + BOOST_FOREACH (CTxBudgetPayment& budgetPayment, vecBudgetPayments) { + CBudgetProposal* pbudgetProposal = budget.FindProposal(budgetPayment.nProposalHash); + + std::string token = budgetPayment.nProposalHash.ToString(); + + if (pbudgetProposal) token = pbudgetProposal->GetName(); + if (ret == "") { + ret = token; + } else { + ret += "," + token; + } + } + return ret; +} + +std::string CFinalizedBudget::GetStatus() +{ + std::string retBadHashes = ""; + std::string retBadPayeeOrAmount = ""; + + for (int nBlockHeight = GetBlockStart(); nBlockHeight <= GetBlockEnd(); nBlockHeight++) { + CTxBudgetPayment budgetPayment; + if (!GetBudgetPaymentByBlock(nBlockHeight, budgetPayment)) { + LogPrint("mnbudget","CFinalizedBudget::GetStatus - Couldn't find budget payment for block %lld\n", nBlockHeight); + continue; + } + + CBudgetProposal* pbudgetProposal = budget.FindProposal(budgetPayment.nProposalHash); + if (!pbudgetProposal) { + if (retBadHashes == "") { + retBadHashes = "Unknown proposal hash! Check this proposal before voting: " + budgetPayment.nProposalHash.ToString(); + } else { + retBadHashes += "," + budgetPayment.nProposalHash.ToString(); + } + } else { + if (pbudgetProposal->GetPayee() != budgetPayment.payee || pbudgetProposal->GetAmount() != budgetPayment.nAmount) { + if (retBadPayeeOrAmount == "") { + retBadPayeeOrAmount = "Budget payee/nAmount doesn't match our proposal! " + budgetPayment.nProposalHash.ToString(); + } else { + retBadPayeeOrAmount += "," + budgetPayment.nProposalHash.ToString(); + } + } + } + } + + if (retBadHashes == "" && retBadPayeeOrAmount == "") return "OK"; + + return retBadHashes + retBadPayeeOrAmount; +} + +bool CFinalizedBudget::IsValid(std::string& strError, bool fCheckCollateral) +{ + // All(!) finalized budgets have the name "main", so get some additional information about them + std::string strProposals = GetProposals(); + + // Must be the correct block for payment to happen (once a month) + if (nBlockStart % GetBudgetPaymentCycleBlocks() != 0) { + strError = "Invalid BlockStart"; + return false; + } + + // The following 2 checks check the same (basically if vecBudgetPayments.size() > 100) + if (GetBlockEnd() - nBlockStart > 100) { + strError = "Invalid BlockEnd"; + return false; + } + if ((int)vecBudgetPayments.size() > 100) { + strError = "Invalid budget payments count (too many)"; + return false; + } + if (strBudgetName == "") { + strError = "Invalid Budget Name"; + return false; + } + if (nBlockStart == 0) { + strError = "Budget " + strBudgetName + " (" + strProposals + ") Invalid BlockStart == 0"; + return false; + } + if (nFeeTXHash == 0) { + strError = "Budget " + strBudgetName + " (" + strProposals + ") Invalid FeeTx == 0"; + return false; + } + + // Can only pay out 10% of the possible coins (min value of coins) + if (GetTotalPayout() > budget.GetTotalBudget(nBlockStart)) { + strError = "Budget " + strBudgetName + " (" + strProposals + ") Invalid Payout (more than max)"; + return false; + } + + std::string strError2 = ""; + if (fCheckCollateral) { + int nConf = 0; + if (!IsBudgetCollateralValid(nFeeTXHash, GetHash(), strError2, nTime, nConf, true)) { + { + strError = "Budget " + strBudgetName + " Invalid Collateral : " + strError2; + return false; + } + } + } + + // Remove obsolete finalized budgets after some time + + CBlockIndex* pindexPrev = chainActive.Tip(); + if (pindexPrev == NULL) return true; + + // Get start of current budget-cycle + int nCurrentHeight = chainActive.Height(); + int nBlockStart = nCurrentHeight - nCurrentHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); + + // Remove budgets where the last payment (from max. 100) ends before 2 budget-cycles before the current one + int nMaxAge = nBlockStart - (2 * GetBudgetPaymentCycleBlocks()); + + if (GetBlockEnd() < nMaxAge) { + strError = strprintf("Budget " + strBudgetName + " (" + strProposals + ") (ends at block %ld) too old and obsolete", GetBlockEnd()); + return false; + } + + return true; +} + +bool CFinalizedBudget::IsPaidAlready(uint256 nProposalHash, int nBlockHeight) +{ + // Remove budget-payments from former/future payment cycles + map::iterator it = mapPayment_History.begin(); + int nPaidBlockHeight = 0; + uint256 nOldProposalHash; + + for(it = mapPayment_History.begin(); it != mapPayment_History.end(); /* No incrementation needed */ ) { + nPaidBlockHeight = (*it).second; + if((nPaidBlockHeight < GetBlockStart()) || (nPaidBlockHeight > GetBlockEnd())) { + nOldProposalHash = (*it).first; + LogPrint("mnbudget", "CFinalizedBudget::IsPaidAlready - Budget Proposal %s, Block %d from old cycle deleted\n", + nOldProposalHash.ToString().c_str(), nPaidBlockHeight); + mapPayment_History.erase(it++); + } + else { + ++it; + } + } + + // Now that we only have payments from the current payment cycle check if this budget was paid already + if(mapPayment_History.count(nProposalHash) == 0) { + // New proposal payment, insert into map for checks with later blocks from this cycle + mapPayment_History.insert(std::pair(nProposalHash, nBlockHeight)); + LogPrint("mnbudget", "CFinalizedBudget::IsPaidAlready - Budget Proposal %s, Block %d added to payment history\n", + nProposalHash.ToString().c_str(), nBlockHeight); + return false; + } + // This budget was paid already -> reject transaction so it gets paid to a masternode instead + return true; +} + +TrxValidationStatus CFinalizedBudget::IsTransactionValid(const CTransaction& txNew, int nBlockHeight) +{ + TrxValidationStatus transactionStatus = TrxValidationStatus::Invalid; + int nCurrentBudgetPayment = nBlockHeight - GetBlockStart(); + if (nCurrentBudgetPayment < 0) { + LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Invalid block - height: %d start: %d\n", nBlockHeight, GetBlockStart()); + return TrxValidationStatus::Invalid; + } + + if (nCurrentBudgetPayment > (int)vecBudgetPayments.size() - 1) { + LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Invalid block - current budget payment: %d of %d\n", nCurrentBudgetPayment + 1, (int)vecBudgetPayments.size()); + return TrxValidationStatus::Invalid; + } + + bool paid = false; + BOOST_FOREACH (CTxOut out, txNew.vout) { + LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - nCurrentBudgetPayment=%d, payee=%s == out.scriptPubKey=%s, amount=%ld == out.nValue=%ld\n", + nCurrentBudgetPayment, vecBudgetPayments[nCurrentBudgetPayment].payee.ToString().c_str(), out.scriptPubKey.ToString().c_str(), + vecBudgetPayments[nCurrentBudgetPayment].nAmount, out.nValue); + + if (vecBudgetPayments[nCurrentBudgetPayment].payee == out.scriptPubKey && vecBudgetPayments[nCurrentBudgetPayment].nAmount == out.nValue) { + // Check if this proposal was paid already. If so, pay a masternode instead + paid = IsPaidAlready(vecBudgetPayments[nCurrentBudgetPayment].nProposalHash, nBlockHeight); + if(paid) { + LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Double Budget Payment of %d for proposal %d detected. Paying a masternode instead.\n", + vecBudgetPayments[nCurrentBudgetPayment].nAmount, vecBudgetPayments[nCurrentBudgetPayment].nProposalHash.Get32()); + // No matter what we've found before, stop all checks here. In future releases there might be more than one budget payment + // per block, so even if the first one was not paid yet this one disables all budget payments for this block. + transactionStatus = TrxValidationStatus::DoublePayment; + break; + } + else { + transactionStatus = TrxValidationStatus::Valid; + LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Found valid Budget Payment of %d for proposal %d\n", + vecBudgetPayments[nCurrentBudgetPayment].nAmount, vecBudgetPayments[nCurrentBudgetPayment].nProposalHash.Get32()); + } + } + } + + if (transactionStatus == TrxValidationStatus::Invalid) { + CTxDestination address1; + ExtractDestination(vecBudgetPayments[nCurrentBudgetPayment].payee, address1); + + LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Missing required payment - %s: %d c: %d\n", + EncodeDestination(address1), vecBudgetPayments[nCurrentBudgetPayment].nAmount, nCurrentBudgetPayment); + } + + return transactionStatus; +} + +void CFinalizedBudget::SubmitVote() +{ + CPubKey pubKeyMasternode; + CKey keyMasternode; + std::string errorMessage; + + if (!obfuScationSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode)) { + LogPrint("mnbudget","CFinalizedBudget::SubmitVote - Error upon calling SetKey\n"); + return; + } + + CFinalizedBudgetVote vote(activeMasternode.vin, GetHash()); + if (!vote.Sign(keyMasternode, pubKeyMasternode)) { + LogPrint("mnbudget","CFinalizedBudget::SubmitVote - Failure to sign."); + return; + } + + std::string strError = ""; + if (budget.UpdateFinalizedBudget(vote, NULL, strError)) { + LogPrint("mnbudget","CFinalizedBudget::SubmitVote - new finalized budget vote - %s\n", vote.GetHash().ToString()); + + budget.mapSeenFinalizedBudgetVotes.insert(make_pair(vote.GetHash(), vote)); + vote.Relay(); + } else { + LogPrint("mnbudget","CFinalizedBudget::SubmitVote : Error submitting vote - %s\n", strError); + } +} + +CFinalizedBudgetBroadcast::CFinalizedBudgetBroadcast() +{ + strBudgetName = ""; + nBlockStart = 0; + vecBudgetPayments.clear(); + mapVotes.clear(); + vchSig.clear(); + nFeeTXHash = 0; +} + +CFinalizedBudgetBroadcast::CFinalizedBudgetBroadcast(const CFinalizedBudget& other) +{ + strBudgetName = other.strBudgetName; + nBlockStart = other.nBlockStart; + BOOST_FOREACH (CTxBudgetPayment out, other.vecBudgetPayments) + vecBudgetPayments.push_back(out); + mapVotes = other.mapVotes; + nFeeTXHash = other.nFeeTXHash; +} + +CFinalizedBudgetBroadcast::CFinalizedBudgetBroadcast(std::string strBudgetNameIn, int nBlockStartIn, std::vector vecBudgetPaymentsIn, uint256 nFeeTXHashIn) +{ + strBudgetName = strBudgetNameIn; + nBlockStart = nBlockStartIn; + BOOST_FOREACH (CTxBudgetPayment out, vecBudgetPaymentsIn) + vecBudgetPayments.push_back(out); + mapVotes.clear(); + nFeeTXHash = nFeeTXHashIn; +} + +void CFinalizedBudgetBroadcast::Relay() +{ + CInv inv(MSG_BUDGET_FINALIZED, GetHash()); + RelayInv(inv); +} + +CFinalizedBudgetVote::CFinalizedBudgetVote() +{ + vin = CTxIn(); + nBudgetHash = 0; + nTime = 0; + vchSig.clear(); + fValid = true; + fSynced = false; +} + +CFinalizedBudgetVote::CFinalizedBudgetVote(CTxIn vinIn, uint256 nBudgetHashIn) +{ + vin = vinIn; + nBudgetHash = nBudgetHashIn; + nTime = GetAdjustedTime(); + vchSig.clear(); + fValid = true; + fSynced = false; +} + +void CFinalizedBudgetVote::Relay() +{ + CInv inv(MSG_BUDGET_FINALIZED_VOTE, GetHash()); + RelayInv(inv); +} + +bool CFinalizedBudgetVote::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode) +{ + // Choose coins to use + CPubKey pubKeyCollateralAddress; + CKey keyCollateralAddress; + + std::string errorMessage; + std::string strMessage = vin.prevout.ToStringShort() + nBudgetHash.ToString() + boost::lexical_cast(nTime); + + if (!obfuScationSigner.SignMessage(strMessage, errorMessage, vchSig, keyMasternode)) { + LogPrint("mnbudget","CFinalizedBudgetVote::Sign - Error upon calling SignMessage"); + return false; + } + + if (!obfuScationSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, errorMessage)) { + LogPrint("mnbudget","CFinalizedBudgetVote::Sign - Error upon calling VerifyMessage"); + return false; + } + + return true; +} + +bool CFinalizedBudgetVote::SignatureValid(bool fSignatureCheck) +{ + std::string errorMessage; + + std::string strMessage = vin.prevout.ToStringShort() + nBudgetHash.ToString() + boost::lexical_cast(nTime); + + CMasternode* pmn = mnodeman.Find(vin); + + if (pmn == NULL) { + LogPrint("mnbudget","CFinalizedBudgetVote::SignatureValid() - Unknown Masternode %s\n", strMessage); + return false; + } + + if (!fSignatureCheck) return true; + + if (!obfuScationSigner.VerifyMessage(pmn->pubKeyMasternode, vchSig, strMessage, errorMessage)) { + LogPrint("mnbudget","CFinalizedBudgetVote::SignatureValid() - Verify message failed %s %s\n", strMessage, errorMessage); + return false; + } + + return true; +} + +std::string CBudgetManager::ToString() const +{ + std::ostringstream info; + + info << "Proposals: " << (int)mapProposals.size() << ", Budgets: " << (int)mapFinalizedBudgets.size() << ", Seen Budgets: " << (int)mapSeenMasternodeBudgetProposals.size() << ", Seen Budget Votes: " << (int)mapSeenMasternodeBudgetVotes.size() << ", Seen Final Budgets: " << (int)mapSeenFinalizedBudgets.size() << ", Seen Final Budget Votes: " << (int)mapSeenFinalizedBudgetVotes.size(); + + return info.str(); +} \ No newline at end of file diff --git a/src/masternode-budget.h b/src/masternode-budget.h new file mode 100644 index 00000000..7e95ed10 --- /dev/null +++ b/src/masternode-budget.h @@ -0,0 +1,622 @@ +// Copyright (c) 2014-2015 The Dash developers +// Copyright (c) 2015-2017 The PIVX developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef MASTERNODE_BUDGET_H +#define MASTERNODE_BUDGET_H + +#include "base58.h" +#include "init.h" +#include "key.h" +#include "main.h" +#include "masternode.h" +#include "net.h" +#include "sync.h" +#include "util.h" +#include + +using namespace std; + +extern CCriticalSection cs_budget; + +class CBudgetManager; +class CFinalizedBudgetBroadcast; +class CFinalizedBudget; +class CBudgetProposal; +class CBudgetProposalBroadcast; +class CTxBudgetPayment; + +#define VOTE_ABSTAIN 0 +#define VOTE_YES 1 +#define VOTE_NO 2 + +enum class TrxValidationStatus { + Invalid, /** Transaction verification failed */ + Valid, /** Transaction successfully verified */ + DoublePayment, /** Transaction successfully verified, but includes a double-budget-payment */ + VoteThreshold /** If not enough masternodes have voted on a finalized budget */ +}; + +static const int64_t BUDGET_VOTE_UPDATE_MIN = 60 * 60; + +extern std::vector vecImmatureBudgetProposals; +extern std::vector vecImmatureFinalizedBudgets; + +static map mapPayment_History; + +extern CBudgetManager budget; +void DumpBudgets(); + +// Define amount of blocks in budget payment cycle +int GetBudgetPaymentCycleBlocks(); + +// Determine available allocation for a given superblock +CAmount GetAvailableBudget(int nHeight); + +//Check the collateral transaction for the budget proposal/finalized budget +bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, std::string& strError, int64_t& nTime, int& nConf, bool fBudgetFinalization = false); + +// Get the budget collateral amount for a block height +CAmount GetBudgetSystemCollateralAmount(int nHeight); + +// +// CBudgetVote - Allow a masternode node to vote and broadcast throughout the network +// + +class CBudgetVote +{ +public: + bool fValid; //if the vote is currently valid / counted + bool fSynced; //if we've sent this to our peers + CTxIn vin; + uint256 nProposalHash; + int nVote; + int64_t nTime; + std::vector vchSig; + + CBudgetVote(); + CBudgetVote(CTxIn vin, uint256 nProposalHash, int nVoteIn); + + bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode); + bool SignatureValid(bool fSignatureCheck); + void Relay(); + + std::string GetVoteString() + { + std::string ret = "ABSTAIN"; + if (nVote == VOTE_YES) ret = "YES"; + if (nVote == VOTE_NO) ret = "NO"; + return ret; + } + + uint256 GetHash() + { + CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); + ss << vin; + ss << nProposalHash; + ss << nVote; + ss << nTime; + return ss.GetHash(); + } + + ADD_SERIALIZE_METHODS; + + template + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) + { + READWRITE(vin); + READWRITE(nProposalHash); + READWRITE(nVote); + READWRITE(nTime); + READWRITE(vchSig); + } +}; + +// +// CFinalizedBudgetVote - Allow a masternode node to vote and broadcast throughout the network +// + +class CFinalizedBudgetVote +{ +public: + bool fValid; //if the vote is currently valid / counted + bool fSynced; //if we've sent this to our peers + CTxIn vin; + uint256 nBudgetHash; + int64_t nTime; + std::vector vchSig; + + CFinalizedBudgetVote(); + CFinalizedBudgetVote(CTxIn vinIn, uint256 nBudgetHashIn); + + bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode); + bool SignatureValid(bool fSignatureCheck); + void Relay(); + + uint256 GetHash() + { + CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); + ss << vin; + ss << nBudgetHash; + ss << nTime; + return ss.GetHash(); + } + + ADD_SERIALIZE_METHODS; + + template + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) + { + READWRITE(vin); + READWRITE(nBudgetHash); + READWRITE(nTime); + READWRITE(vchSig); + } +}; + +/** Save Budget Manager (budget.dat) + */ +class CBudgetDB +{ +private: + boost::filesystem::path pathDB; + std::string strMagicMessage; + +public: + enum ReadResult { + Ok, + FileError, + HashReadError, + IncorrectHash, + IncorrectMagicMessage, + IncorrectMagicNumber, + IncorrectFormat + }; + + CBudgetDB(); + bool Write(const CBudgetManager& objToSave); + ReadResult Read(CBudgetManager& objToLoad, bool fDryRun = false); +}; + + +// +// Budget Manager : Contains all proposals for the budget +// +class CBudgetManager +{ +private: + //hold txes until they mature enough to use + // XX42 map mapCollateral; + map mapCollateralTxids; + +public: + // critical section to protect the inner data structures + mutable CCriticalSection cs; + + // keep track of the scanning errors I've seen + map mapProposals; + map mapFinalizedBudgets; + + std::map mapSeenMasternodeBudgetProposals; + std::map mapSeenMasternodeBudgetVotes; + std::map mapOrphanMasternodeBudgetVotes; + std::map mapSeenFinalizedBudgets; + std::map mapSeenFinalizedBudgetVotes; + std::map mapOrphanFinalizedBudgetVotes; + + CBudgetManager() + { + mapProposals.clear(); + mapFinalizedBudgets.clear(); + } + + void ClearSeen() + { + mapSeenMasternodeBudgetProposals.clear(); + mapSeenMasternodeBudgetVotes.clear(); + mapSeenFinalizedBudgets.clear(); + mapSeenFinalizedBudgetVotes.clear(); + } + + int sizeFinalized() { return (int)mapFinalizedBudgets.size(); } + int sizeProposals() { return (int)mapProposals.size(); } + + void ResetSync(); + void MarkSynced(); + void Sync(CNode* node, uint256 nProp, bool fPartial = false); + + void Calculate(); + void ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv); + void NewBlock(); + CBudgetProposal* FindProposal(const std::string& strProposalName); + CBudgetProposal* FindProposal(uint256 nHash); + CFinalizedBudget* FindFinalizedBudget(uint256 nHash); + std::pair GetVotes(std::string strProposalName); + + CAmount GetTotalBudget(int nHeight); + std::vector GetBudget(); + std::vector GetAllProposals(); + std::vector GetFinalizedBudgets(); + bool IsBudgetPaymentBlock(int nBlockHeight); + bool AddProposal(CBudgetProposal& budgetProposal); + bool AddFinalizedBudget(CFinalizedBudget& finalizedBudget); + void SubmitFinalBudget(); + + bool UpdateProposal(CBudgetVote& vote, CNode* pfrom, std::string& strError); + bool UpdateFinalizedBudget(CFinalizedBudgetVote& vote, CNode* pfrom, std::string& strError); + bool PropExists(uint256 nHash); + TrxValidationStatus IsTransactionValid(const CTransaction& txNew, int nBlockHeight); + bool IsPaidAlready(uint256 nProposalHash, int nBlockHeight); + std::string GetRequiredPaymentsString(int nBlockHeight); + void FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, bool fProofOfStake); + + void CheckOrphanVotes(); + void Clear() + { + LOCK(cs); + + LogPrintf("Budget object cleared\n"); + mapProposals.clear(); + mapFinalizedBudgets.clear(); + mapSeenMasternodeBudgetProposals.clear(); + mapSeenMasternodeBudgetVotes.clear(); + mapSeenFinalizedBudgets.clear(); + mapSeenFinalizedBudgetVotes.clear(); + mapOrphanMasternodeBudgetVotes.clear(); + mapOrphanFinalizedBudgetVotes.clear(); + } + void CheckAndRemove(); + std::string ToString() const; + + + ADD_SERIALIZE_METHODS; + + template + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) + { + READWRITE(mapSeenMasternodeBudgetProposals); + READWRITE(mapSeenMasternodeBudgetVotes); + READWRITE(mapSeenFinalizedBudgets); + READWRITE(mapSeenFinalizedBudgetVotes); + READWRITE(mapOrphanMasternodeBudgetVotes); + READWRITE(mapOrphanFinalizedBudgetVotes); + + READWRITE(mapProposals); + READWRITE(mapFinalizedBudgets); + } +}; + + +class CTxBudgetPayment +{ +public: + uint256 nProposalHash; + CScript payee; + CAmount nAmount; + + CTxBudgetPayment() + { + payee = CScript(); + nAmount = 0; + nProposalHash = 0; + } + + ADD_SERIALIZE_METHODS; + + //for saving to the serialized db + template + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) + { + READWRITE(payee); + READWRITE(nAmount); + READWRITE(nProposalHash); + } +}; + +// +// Finalized Budget : Contains the suggested proposals to pay on a given block +// + +class CFinalizedBudget +{ +private: + // critical section to protect the inner data structures + mutable CCriticalSection cs; + bool fAutoChecked; //If it matches what we see, we'll auto vote for it (masternode only) + +public: + bool fValid; + std::string strBudgetName; + int nBlockStart; + std::vector vecBudgetPayments; + map mapVotes; + uint256 nFeeTXHash; + int64_t nTime; + + CFinalizedBudget(); + CFinalizedBudget(const CFinalizedBudget& other); + + void CleanAndRemove(bool fSignatureCheck); + bool AddOrUpdateVote(CFinalizedBudgetVote& vote, std::string& strError); + double GetScore(); + bool HasMinimumRequiredSupport(); + + bool IsValid(std::string& strError, bool fCheckCollateral = true); + + std::string GetName() { return strBudgetName; } + std::string GetProposals(); + int GetBlockStart() { return nBlockStart; } + int GetBlockEnd() { return nBlockStart + (int)(vecBudgetPayments.size() - 1); } + int GetVoteCount() { return (int)mapVotes.size(); } + bool IsPaidAlready(uint256 nProposalHash, int nBlockHeight); + TrxValidationStatus IsTransactionValid(const CTransaction& txNew, int nBlockHeight); + bool GetBudgetPaymentByBlock(int64_t nBlockHeight, CTxBudgetPayment& payment) + { + LOCK(cs); + + int i = nBlockHeight - GetBlockStart(); + if (i < 0) return false; + if (i > (int)vecBudgetPayments.size() - 1) return false; + payment = vecBudgetPayments[i]; + return true; + } + bool GetPayeeAndAmount(int64_t nBlockHeight, CScript& payee, CAmount& nAmount) + { + LOCK(cs); + + int i = nBlockHeight - GetBlockStart(); + if (i < 0) return false; + if (i > (int)vecBudgetPayments.size() - 1) return false; + payee = vecBudgetPayments[i].payee; + nAmount = vecBudgetPayments[i].nAmount; + return true; + } + + //check to see if we should vote on this + void AutoCheck(); + //total odin paid out by this budget + CAmount GetTotalPayout(); + //vote on this finalized budget as a masternode + void SubmitVote(); + + //checks the hashes to make sure we know about them + string GetStatus(); + + uint256 GetHash() + { + CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); + ss << strBudgetName; + ss << nBlockStart; + ss << vecBudgetPayments; + + uint256 h1 = ss.GetHash(); + return h1; + } + + ADD_SERIALIZE_METHODS; + + //for saving to the serialized db + template + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) + { + READWRITE(LIMITED_STRING(strBudgetName, 20)); + READWRITE(nFeeTXHash); + READWRITE(nTime); + READWRITE(nBlockStart); + READWRITE(vecBudgetPayments); + READWRITE(fAutoChecked); + + READWRITE(mapVotes); + } +}; + +// FinalizedBudget are cast then sent to peers with this object, which leaves the votes out +class CFinalizedBudgetBroadcast : public CFinalizedBudget +{ +private: + std::vector vchSig; + +public: + CFinalizedBudgetBroadcast(); + CFinalizedBudgetBroadcast(const CFinalizedBudget& other); + CFinalizedBudgetBroadcast(std::string strBudgetNameIn, int nBlockStartIn, std::vector vecBudgetPaymentsIn, uint256 nFeeTXHashIn); + + void swap(CFinalizedBudgetBroadcast& first, CFinalizedBudgetBroadcast& second) // nothrow + { + // enable ADL (not necessary in our case, but good practice) + using std::swap; + + // by swapping the members of two classes, + // the two classes are effectively swapped + swap(first.strBudgetName, second.strBudgetName); + swap(first.nBlockStart, second.nBlockStart); + first.mapVotes.swap(second.mapVotes); + first.vecBudgetPayments.swap(second.vecBudgetPayments); + swap(first.nFeeTXHash, second.nFeeTXHash); + swap(first.nTime, second.nTime); + } + + CFinalizedBudgetBroadcast& operator=(CFinalizedBudgetBroadcast from) + { + swap(*this, from); + return *this; + } + + void Relay(); + + ADD_SERIALIZE_METHODS; + + //for propagating messages + template + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) + { + //for syncing with other clients + READWRITE(LIMITED_STRING(strBudgetName, 20)); + READWRITE(nBlockStart); + READWRITE(vecBudgetPayments); + READWRITE(nFeeTXHash); + } +}; + + +// +// Budget Proposal : Contains the masternode votes for each budget +// + +class CBudgetProposal +{ +private: + // critical section to protect the inner data structures + mutable CCriticalSection cs; + CAmount nAlloted; + +public: + bool fValid; + std::string strProposalName; + + /* + json object with name, short-description, long-description, pdf-url and any other info + This allows the proposal website to stay 100% decentralized + */ + std::string strURL; + int nBlockStart; + int nBlockEnd; + CAmount nAmount; + CScript address; + int64_t nTime; + uint256 nFeeTXHash; + + map mapVotes; + //cache object + + CBudgetProposal(); + CBudgetProposal(const CBudgetProposal& other); + CBudgetProposal(std::string strProposalNameIn, std::string strURLIn, int nBlockStartIn, int nBlockEndIn, CScript addressIn, CAmount nAmountIn, uint256 nFeeTXHashIn); + + void Calculate(); + bool AddOrUpdateVote(CBudgetVote& vote, std::string& strError); + bool HasMinimumRequiredSupport(); + std::pair GetVotes(); + + bool IsValid(std::string& strError, bool fCheckCollateral = true); + + bool IsEstablished() + { + // Proposals must be at least a day old to make it into a budget + if (Params().NetworkID() == CBaseChainParams::MAIN) return (nTime < GetTime() - (60 * 60 * 24)); + + // For testing purposes - 5 minutes + return (nTime < GetTime() - (60 * 5)); + } + + std::string GetName() { return strProposalName; } + std::string GetURL() { return strURL; } + int GetBlockStart() { return nBlockStart; } + int GetBlockEnd() { return nBlockEnd; } + CScript GetPayee() { return address; } + int GetTotalPaymentCount(); + int GetRemainingPaymentCount(); + int GetBlockStartCycle(); + int GetBlockCurrentCycle(); + int GetBlockEndCycle(); + double GetRatio(); + int GetYeas(); + int GetNays(); + int GetAbstains(); + CAmount GetAmount() { return nAmount; } + void SetAllotted(CAmount nAllotedIn) { nAlloted = nAllotedIn; } + CAmount GetAllotted() { return nAlloted; } + + void CleanAndRemove(bool fSignatureCheck); + + uint256 GetHash() + { + CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); + ss << strProposalName; + ss << strURL; + ss << nBlockStart; + ss << nBlockEnd; + ss << nAmount; + ss << address; + uint256 h1 = ss.GetHash(); + + return h1; + } + + ADD_SERIALIZE_METHODS; + + template + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) + { + //for syncing with other clients + READWRITE(LIMITED_STRING(strProposalName, 20)); + READWRITE(LIMITED_STRING(strURL, 64)); + READWRITE(nTime); + READWRITE(nBlockStart); + READWRITE(nBlockEnd); + READWRITE(nAmount); + READWRITE(address); + READWRITE(nTime); + READWRITE(nFeeTXHash); + + //for saving to the serialized db + READWRITE(mapVotes); + } +}; + +// Proposals are cast then sent to peers with this object, which leaves the votes out +class CBudgetProposalBroadcast : public CBudgetProposal +{ +public: + CBudgetProposalBroadcast() : CBudgetProposal() {} + CBudgetProposalBroadcast(const CBudgetProposal& other) : CBudgetProposal(other) {} + CBudgetProposalBroadcast(const CBudgetProposalBroadcast& other) : CBudgetProposal(other) {} + CBudgetProposalBroadcast(std::string strProposalNameIn, std::string strURLIn, int nPaymentCount, CScript addressIn, CAmount nAmountIn, int nBlockStartIn, uint256 nFeeTXHashIn); + + void swap(CBudgetProposalBroadcast& first, CBudgetProposalBroadcast& second) // nothrow + { + // enable ADL (not necessary in our case, but good practice) + using std::swap; + + // by swapping the members of two classes, + // the two classes are effectively swapped + swap(first.strProposalName, second.strProposalName); + swap(first.nBlockStart, second.nBlockStart); + swap(first.strURL, second.strURL); + swap(first.nBlockEnd, second.nBlockEnd); + swap(first.nAmount, second.nAmount); + swap(first.address, second.address); + swap(first.nTime, second.nTime); + swap(first.nFeeTXHash, second.nFeeTXHash); + first.mapVotes.swap(second.mapVotes); + } + + CBudgetProposalBroadcast& operator=(CBudgetProposalBroadcast from) + { + swap(*this, from); + return *this; + } + + void Relay(); + + ADD_SERIALIZE_METHODS; + + template + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) + { + //for syncing with other clients + + READWRITE(LIMITED_STRING(strProposalName, 20)); + READWRITE(LIMITED_STRING(strURL, 64)); + READWRITE(nTime); + READWRITE(nBlockStart); + READWRITE(nBlockEnd); + READWRITE(nAmount); + READWRITE(address); + READWRITE(nFeeTXHash); + } +}; + + +#endif \ No newline at end of file From 54228548a81fa93ba42f36d7a466bafc0ccf8e8e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:03:10 -0400 Subject: [PATCH 151/469] Update masternode-budget.cpp --- src/masternode-budget.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index b544481e..a9c10420 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -12,7 +12,6 @@ #include "masternode-sync.h" #include "rpc/masternode.h" #include "masternode-utils.h" -#include "obfuscation.h" #include "util.h" #include "utilmoneystr.h" #include @@ -2283,4 +2282,4 @@ std::string CBudgetManager::ToString() const info << "Proposals: " << (int)mapProposals.size() << ", Budgets: " << (int)mapFinalizedBudgets.size() << ", Seen Budgets: " << (int)mapSeenMasternodeBudgetProposals.size() << ", Seen Budget Votes: " << (int)mapSeenMasternodeBudgetVotes.size() << ", Seen Final Budgets: " << (int)mapSeenFinalizedBudgets.size() << ", Seen Final Budget Votes: " << (int)mapSeenFinalizedBudgetVotes.size(); return info.str(); -} \ No newline at end of file +} From f017f85ed8e6e4b015ab8ca3776b9328c7c07f25 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:05:11 -0400 Subject: [PATCH 152/469] Update Makefile.qt.include --- src/Makefile.qt.include | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 49c453a9..6ce7f963 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -46,6 +46,7 @@ QT_FORMS_UI = \ qt/forms/optionsdialog.ui \ qt/forms/overviewpage.ui \ qt/forms/privatesendpage.ui \ + qt/forms/proposaldialog.ui \ qt/forms/receivecoinsdialog.ui \ qt/forms/receiverequestdialog.ui \ qt/forms/debugwindow.ui \ @@ -82,6 +83,7 @@ QT_MOC_CPP = \ qt/moc_optionsmodel.cpp \ qt/moc_overviewpage.cpp \ qt/moc_privatesendpage.cpp \ + qt/moc_proposaldialog.cpp \ qt/moc_peertablemodel.cpp \ qt/moc_paymentserver.cpp \ qt/moc_qrdialog.cpp \ @@ -163,6 +165,7 @@ BITCOIN_QT_H = \ qt/paymentserver.h \ qt/peertablemodel.h \ qt/platformstyle.h \ + qt/proposaldialog.h \ qt/qrdialog.h \ qt/qvalidatedlineedit.h \ qt/qvaluecombobox.h \ @@ -484,6 +487,7 @@ BITCOIN_QT_BASE_CPP = \ qt/optionsmodel.cpp \ qt/peertablemodel.cpp \ qt/platformstyle.cpp \ + qt/proposaldialog.cpp \ qt/qvalidatedlineedit.cpp \ qt/qvaluecombobox.cpp \ qt/rpcconsole.cpp \ @@ -507,6 +511,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/openuridialog.cpp \ qt/overviewpage.cpp \ qt/privatesendpage.cpp \ + qt/proposaldialog.cpp \ qt/paymentrequestplus.cpp \ qt/paymentserver.cpp \ qt/qrdialog.cpp \ From 9a0eb790a6d86da43db0a100bd5bb9c841adc9ca Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:07:30 -0400 Subject: [PATCH 153/469] Update Makefile.am --- src/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Makefile.am b/src/Makefile.am index ac252b97..9a02f301 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -178,6 +178,7 @@ BITCOIN_CORE_H = \ llmq/quorums_signing.h \ llmq/quorums_signing_shares.h \ llmq/quorums_utils.h \ + masternode-budget.h \ masternode-meta.h \ masternode-payments.h \ masternode-sync.h \ @@ -298,6 +299,7 @@ libhelpthehomeless_server_a_SOURCES = \ llmq/quorums_signing.cpp \ llmq/quorums_signing_shares.cpp \ llmq/quorums_utils.cpp \ + masternode-budget.cpp \ masternode-meta.cpp \ masternode-payments.cpp \ masternode-sync.cpp \ From 61c8bb631e28a42e322e846e64de0e55e74cfeb0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:13:03 -0400 Subject: [PATCH 154/469] Update masternode-budget.h --- src/masternode-budget.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/masternode-budget.h b/src/masternode-budget.h index 7e95ed10..9048dee2 100644 --- a/src/masternode-budget.h +++ b/src/masternode-budget.h @@ -9,8 +9,8 @@ #include "base58.h" #include "init.h" #include "key.h" -#include "main.h" -#include "masternode.h" +#include "validation.h" +#include "governance.h" #include "net.h" #include "sync.h" #include "util.h" @@ -619,4 +619,4 @@ class CBudgetProposalBroadcast : public CBudgetProposal }; -#endif \ No newline at end of file +#endif From df2fd10d9aa3a7b72683641d1f81ec09d19eb656 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:27:08 -0400 Subject: [PATCH 155/469] Update masternode-budget.cpp --- src/masternode-budget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index a9c10420..3faccd87 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -10,7 +10,7 @@ #include "addrman.h" #include "masternode-budget.h" #include "masternode-sync.h" -#include "rpc/masternode.h" +#include "governance.h" #include "masternode-utils.h" #include "util.h" #include "utilmoneystr.h" From e9a590cf9ee61591b3a74c2a3bd4738534eafc03 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:28:07 -0400 Subject: [PATCH 156/469] Add files via upload --- src/qt/forms/proposaldialog.ui | 224 +++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 src/qt/forms/proposaldialog.ui diff --git a/src/qt/forms/proposaldialog.ui b/src/qt/forms/proposaldialog.ui new file mode 100644 index 00000000..03599202 --- /dev/null +++ b/src/qt/forms/proposaldialog.ui @@ -0,0 +1,224 @@ + + + ProposalDialog + + + + 0 + 0 + 640 + 126 + + + + Budget Proposal + + + + 11 + + + 11 + + + 11 + + + 11 + + + 11 + + + + + Fill out the form below to create a budget proposal. Before beginning, make sure your wallet is unlocked to pay the budget proposal fee of 50 ODIN. After the proposal is submitted, wait for the transaction confirmations to complete, and then click Finish Proposal to submit the proposal for voting. The screen will update to help guide you. Do not close the dialog after paying the transaction fee + --it will close automatically once the proposal is submitted. + + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + 11 + + + 11 + + + 11 + + + 11 + + + 11 + + + + + &Proposal Name: + + + nameEdit + + + + + + + + + + + &Proposal URL: + + + urlEdit + + + + + + + + + + + &Payments (Months): + + + paymentsEdit + + + + + + + + + + + &Super Block: + + + blockEdit + + + + + + + + + + + &Payment Address: + + + addressEdit + + + + + + + + + + + &Payment Amount (Month): + + + amountEdit + + + + + + + + + + + &Proposal TXID: + + + hashEdit + + + + + + + + + + + + + + + + + + + + + + Submit Proposal + + + + + + + Cancel + + + + + + + + + + + + + buttonBox + accepted() + ProposalDialog + accept() + + + 20 + 20 + + + 20 + 20 + + + + + buttonBox + rejected() + ProposalDialog + reject() + + + 20 + 20 + + + 20 + 20 + + + + + \ No newline at end of file From 79578bb9ef686bb28a272c6360521e577c8fabf4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:29:27 -0400 Subject: [PATCH 157/469] Update proposaldialog.h --- src/qt/proposaldialog.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/proposaldialog.h b/src/qt/proposaldialog.h index 220fe01f..b975e184 100644 --- a/src/qt/proposaldialog.h +++ b/src/qt/proposaldialog.h @@ -6,7 +6,7 @@ #ifndef BITCOIN_QT_CREATEPROPOSALDIALOG_H #define BITCOIN_QT_CREATEPROPOSALDIALOG_H -#include +#include #include #include #include @@ -61,4 +61,4 @@ public slots: bool validateProposal(); }; -#endif // BITCOIN_QT_CREATEPROPOSALDIALOG_H \ No newline at end of file +#endif // BITCOIN_QT_CREATEPROPOSALDIALOG_H From 03f2d76c7002116dc0499540d1a3b31b0e04fd21 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:30:35 -0400 Subject: [PATCH 158/469] Update proposaldialog.h --- src/qt/proposaldialog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/proposaldialog.h b/src/qt/proposaldialog.h index b975e184..ee55c65f 100644 --- a/src/qt/proposaldialog.h +++ b/src/qt/proposaldialog.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include From 9a991b7f5839254cff6c834bf9c34cb57256dfc2 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:31:03 -0400 Subject: [PATCH 159/469] Update proposaldialog.cpp --- src/qt/proposaldialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/proposaldialog.cpp b/src/qt/proposaldialog.cpp index 943bf952..0fb1600f 100644 --- a/src/qt/proposaldialog.cpp +++ b/src/qt/proposaldialog.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include From 53228754581e569a2745d97d119efd0525e9007d Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:34:45 -0400 Subject: [PATCH 160/469] Delete proposaldialog.cpp --- src/qt/proposaldialog.cpp | 297 -------------------------------------- 1 file changed, 297 deletions(-) delete mode 100644 src/qt/proposaldialog.cpp diff --git a/src/qt/proposaldialog.cpp b/src/qt/proposaldialog.cpp deleted file mode 100644 index 0fb1600f..00000000 --- a/src/qt/proposaldialog.cpp +++ /dev/null @@ -1,297 +0,0 @@ -// Copyright (c) 2017-2018 The Bulwark Developers -// Copyright (c) 2019 The Phore Developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#if defined(HAVE_CONFIG_H) -#include -#endif - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -ProposalDialog::ProposalDialog(Mode mode, QWidget* parent) : QDialog(parent), ui(new Ui::ProposalDialog), mapper(0), mode(mode), counter(0) -{ - ui->setupUi(this); - - switch (mode) { - case PrepareProposal: - setWindowTitle(tr("Prepare Proposal")); - ui->confirmLabel->setVisible(false); - ui->hashEdit->setVisible(false); - ui->hashLabel->setVisible(false); - break; - case SubmitProposal: - setWindowTitle(tr("Submit Proposal")); - ui->confirmLabel->setVisible(true); - ui->hashEdit->setVisible(true); - ui->hashLabel->setVisible(true); - break; - } - - ui->nameEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->nameEdit->setPlaceholderText(tr("Provide a proposal name, keep it short")); - ui->nameEdit->setToolTip(tr("Provide a proposal name, keep it short")); - - ui->urlEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->urlEdit->setPlaceholderText(tr("Valid http or https URL (include http:// or https://")); - ui->urlEdit->setToolTip(tr("Valid http or https URL (include http:// or https://")); - - ui->paymentsEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->paymentsEdit->setPlaceholderText(tr("How many monthly payments, 1 per budget cycle")); - ui->paymentsEdit->setToolTip(tr("How many monthly payments, 1 per budget cycle")); - ui->paymentsEdit->setValidator(new QIntValidator(1, 100)); - - ui->blockEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->blockEdit->setPlaceholderText(tr("The governance budget block for the desired cycle (default to next)")); - ui->blockEdit->setToolTip(tr("The governance budget block for the desired cycle (default to next)")); - ui->blockEdit->setValidator(new QIntValidator(1, INT_MAX)); - - ui->addressEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->addressEdit->setPlaceholderText(tr("The public ODIN address that will receive the funds")); - ui->addressEdit->setToolTip(tr("The public ODIN address that will receive the funds")); - - ui->amountEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->amountEdit->setPlaceholderText(tr("The amount to be paid per month or cycle")); - ui->amountEdit->setToolTip(tr("The amount to be paid per month or cycle")); - ui->amountEdit->setValidator(new QIntValidator(10, INT_MAX)); - - ui->hashEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->hashEdit->setPlaceholderText(tr("The TXID of the proposal hash, must be confirmed before use")); - ui->hashEdit->setToolTip(tr("The TXID of the proposal hash, must be confirmed before use")); - - ui->confirmLabel->setWordWrap(true); - ui->infoLabel->setWordWrap(true); - - // Load next superblock number. - CBlockIndex* pindexPrev = chainActive.Tip(); - if (!pindexPrev) return; - int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); - ui->blockEdit->setText(QString::number(nNext)); - - // Start periodic updates to handle submit block depth validation. - timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(checkProposalTX())); -} - -ProposalDialog::~ProposalDialog() -{ - delete ui; -} - -void ProposalDialog::prepareProposal() -{ - std::string strError = ""; - - if (pwalletMain->IsLocked()) - { - strError = "Error: Please enter the wallet passphrase with walletpassphrase first."; - QMessageBox::critical(this, "Prepare Proposal Error", QString::fromStdString(strError)); - return; - } - - std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); - std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); - int nPaymentCount = ui->paymentsEdit->text().toInt(); - int nBlockStart = ui->blockEdit->text().toInt(); - std::string address = ui->addressEdit->text().toStdString(); - CScript scriptPubKey = GetScriptForDestination(DecodeDestination(address)); - CAmount nAmount = AmountFromValue(ui->amountEdit->text().toInt()); - - //************************************************************************* - - // create the proposal incase we're the first to make it - CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, 0); - std::string err; - if (!budgetProposalBroadcast.IsValid(err, false)) strError = "Proposal is not valid - " + budgetProposalBroadcast.GetHash().ToString() + " - " + err; - - bool useIX = false; - if (strError.empty() && !pwalletMain->GetBudgetSystemCollateralTX(wtx, budgetProposalBroadcast.GetHash(), useIX)) - { - strError = "Error making collateral transaction for proposal. Please check your wallet balance."; - } - - // make our change address - CReserveKey reservekey(pwalletMain); - // send the tx to the network - if (strError.empty() && !pwalletMain->CommitTransaction(wtx, reservekey, useIX ? "ix" : "tx")) - { - strError = "Unable to commit proposal transaction."; - } - - if (!strError.empty()) - { - std::cout << strError << std::endl; - QMessageBox::critical(this, "Prepare Proposal Error", QString::fromStdString(strError)); - return; - } - - // update the local view with submit view - ui->cancelButton->setDisabled(true); - ui->nameEdit->setDisabled(true); - ui->urlEdit->setDisabled(true); - ui->paymentsEdit->setDisabled(true); - ui->blockEdit->setDisabled(true); - ui->addressEdit->setDisabled(true); - ui->amountEdit->setDisabled(true); - ui->hashEdit->setDisabled(true); - - ui->acceptButton->setDisabled(true); - ui->acceptButton->setText(tr("Waiting...")); - - ui->confirmLabel->setVisible(true); - ui->confirmLabel->setText(QString::fromStdString("Waiting for confirmations...")); - - ui->hashEdit->setText(QString::fromStdString(wtx.GetHash().ToString())); - ui->hashEdit->setVisible(true); - ui->hashLabel->setVisible(true); - - mode = SubmitProposal; - setWindowTitle(tr("Submit Proposal")); - - timer->start(1000); - counter = chainActive.Tip()->nHeight + 1; -} - -void ProposalDialog::submitProposal() -{ - std::string strError = ""; - - std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); - std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); - int nPaymentCount = ui->paymentsEdit->text().toInt(); - int nBlockStart = ui->blockEdit->text().toInt(); - std::string address = ui->addressEdit->text().toStdString(); - CScript scriptPubKey = GetScriptForDestination(DecodeDestination(address)); - CAmount nAmount = AmountFromValue(ui->amountEdit->text().toInt()); - uint256 hash = ParseHashV(ui->hashEdit->text().toStdString(), "parameter 1"); - - //************************************************************************* - - // create the proposal incase we're the first to make it - int nConf = 0; - std::string err = ""; - CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, hash); - if (!IsBudgetCollateralValid(hash, budgetProposalBroadcast.GetHash(), err, budgetProposalBroadcast.nTime, nConf)) - { - strError = "Proposal FeeTX is not valid - " + hash.ToString() + " - " + err; - } - - if (strError.empty() && !budget.AddProposal(budgetProposalBroadcast)) strError = "Invalid proposal, see debug.log for details."; - - if (!strError.empty()) - { - std::cout << strError << std::endl; - QMessageBox::critical(this, tr("Submit Proposal Error"), QString::fromStdString(strError)); - return; - } - - budget.mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast)); - budgetProposalBroadcast.Relay(); - - this->accept(); -} - -bool ProposalDialog::validateProposal() -{ - std::string strError = ""; - - if (!masternodeSync.IsBlockchainSynced()) strError = "Must wait for client to sync with masternode network. Try again in a minute or so."; - - std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); - if (strProposalName.size() > 20) strError = "Invalid proposal name, limit of 20 characters."; - - std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); - if (strURL.size() > 64) strError = "Invalid url, limit of 64 characters."; - - int nPaymentCount = ui->paymentsEdit->text().toInt(); - if (nPaymentCount < 1) strError = "Invalid payment count, must be more than zero."; - - // Start must be in the next budget cycle - int nBlockMin = 0; - CBlockIndex* pindexPrev = chainActive.Tip(); - if (pindexPrev != NULL) nBlockMin = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); - - int nBlockStart = ui->blockEdit->text().toInt(); - if (nBlockStart < nBlockMin) strError = "Invalid block start, must be more than current height."; - if (nBlockStart % GetBudgetPaymentCycleBlocks() != 0) - { - int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); - strError = strprintf("Invalid block start - must be a budget cycle block. Next valid block: %d", nNext); - } - - int nBlockEnd = nBlockStart + (GetBudgetPaymentCycleBlocks() * nPaymentCount); // End must be AFTER current cycle - if (nBlockEnd < pindexPrev->nHeight) strError = "Invalid ending block, starting block + (payment_cycle*payments) must be more than current height."; - - std::string address = ui->addressEdit->text().toStdString(); - if (!IsValidDestinationString(address)) strError = "Invalid ODIN address"; - - if (!strError.empty()) - { - QMessageBox::critical(this, tr("Submit Proposal Error"), QString::fromStdString(strError)); - return false; - } - - return true; -} - -void ProposalDialog::checkProposalTX() -{ - if (mode != SubmitProposal) return; - - int nConf = Params().BudgetFeeConfirmations(); - int nDepth = (chainActive.Tip()->nHeight + 1) - counter; - if (nDepth > nConf) - { - ui->acceptButton->setDisabled(false); - ui->acceptButton->setText("Finish Proposal"); - ui->confirmLabel->setText(tr("Click on Finish Proposal to complete the proposal and start voting.")); - - timer->stop(); - } - else if (nDepth == nConf) - { - ui->confirmLabel->setText(QString::fromStdString("Waiting for final confirmation...")); - } - else if (nDepth > 0) - { - ui->confirmLabel->setText(QString::fromStdString(strprintf("Currently %d of %d confirmations...", nDepth, (nConf + 1)).c_str())); - } -} - -void ProposalDialog::on_acceptButton_clicked() -{ - if (!validateProposal()) return; - - if (mode == PrepareProposal) - { - prepareProposal(); - } - else if (mode == SubmitProposal) - { - submitProposal(); - } -} - -void ProposalDialog::on_cancelButton_clicked() -{ - this->reject(); -} From 35c5919283e1c68a191a63df1ef5d4e1db8b4186 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:35:00 -0400 Subject: [PATCH 161/469] Delete proposaldialog.h --- src/qt/proposaldialog.h | 64 ----------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 src/qt/proposaldialog.h diff --git a/src/qt/proposaldialog.h b/src/qt/proposaldialog.h deleted file mode 100644 index ee55c65f..00000000 --- a/src/qt/proposaldialog.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2017-2018 The Bulwark Developers -// Copyright (c) 2019 The Phore Developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_QT_CREATEPROPOSALDIALOG_H -#define BITCOIN_QT_CREATEPROPOSALDIALOG_H - -#include -#include -#include -#include - -#include -#include -#include -#include - -class ProposalModel; - -namespace Ui -{ - class ProposalDialog; -} - -QT_BEGIN_NAMESPACE -class QDataWidgetMapper; -QT_END_NAMESPACE - -/** - * Dialog for creating a proposal. - */ -class ProposalDialog : public QDialog -{ - Q_OBJECT - -public: - enum Mode { - PrepareProposal, - SubmitProposal - }; - - explicit ProposalDialog(Mode mode, QWidget* parent); - ~ProposalDialog(); - -public slots: - void checkProposalTX(); - void on_acceptButton_clicked(); - void on_cancelButton_clicked(); - -private: - Ui::ProposalDialog *ui; - QDataWidgetMapper *mapper; - Mode mode; - QTimer *timer; - CWalletTx wtx; - int counter; - - void prepareProposal(); - void submitProposal(); - bool validateProposal(); -}; - -#endif // BITCOIN_QT_CREATEPROPOSALDIALOG_H From f282d2ab66a3236fc862350a1b950f58134ce4ba Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:35:09 -0400 Subject: [PATCH 162/469] Delete proposaldialog.ui --- src/qt/forms/proposaldialog.ui | 224 --------------------------------- 1 file changed, 224 deletions(-) delete mode 100644 src/qt/forms/proposaldialog.ui diff --git a/src/qt/forms/proposaldialog.ui b/src/qt/forms/proposaldialog.ui deleted file mode 100644 index 03599202..00000000 --- a/src/qt/forms/proposaldialog.ui +++ /dev/null @@ -1,224 +0,0 @@ - - - ProposalDialog - - - - 0 - 0 - 640 - 126 - - - - Budget Proposal - - - - 11 - - - 11 - - - 11 - - - 11 - - - 11 - - - - - Fill out the form below to create a budget proposal. Before beginning, make sure your wallet is unlocked to pay the budget proposal fee of 50 ODIN. After the proposal is submitted, wait for the transaction confirmations to complete, and then click Finish Proposal to submit the proposal for voting. The screen will update to help guide you. Do not close the dialog after paying the transaction fee - --it will close automatically once the proposal is submitted. - - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - 11 - - - 11 - - - 11 - - - 11 - - - 11 - - - - - &Proposal Name: - - - nameEdit - - - - - - - - - - - &Proposal URL: - - - urlEdit - - - - - - - - - - - &Payments (Months): - - - paymentsEdit - - - - - - - - - - - &Super Block: - - - blockEdit - - - - - - - - - - - &Payment Address: - - - addressEdit - - - - - - - - - - - &Payment Amount (Month): - - - amountEdit - - - - - - - - - - - &Proposal TXID: - - - hashEdit - - - - - - - - - - - - - - - - - - - - - - Submit Proposal - - - - - - - Cancel - - - - - - - - - - - - - buttonBox - accepted() - ProposalDialog - accept() - - - 20 - 20 - - - 20 - 20 - - - - - buttonBox - rejected() - ProposalDialog - reject() - - - 20 - 20 - - - 20 - 20 - - - - - \ No newline at end of file From e572d9773db4046249bfe13c75ea68496de702f7 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:35:28 -0400 Subject: [PATCH 163/469] Delete masternode-budget.cpp --- src/masternode-budget.cpp | 2285 ------------------------------------- 1 file changed, 2285 deletions(-) delete mode 100644 src/masternode-budget.cpp diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp deleted file mode 100644 index 3faccd87..00000000 --- a/src/masternode-budget.cpp +++ /dev/null @@ -1,2285 +0,0 @@ -// Copyright (c) 2014-2015 The Dash developers -// Copyright (c) 2015-2017 The PIVX developers -// Copyright (c) 2017 The Phore developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "init.h" -#include "validation.h" - -#include "addrman.h" -#include "masternode-budget.h" -#include "masternode-sync.h" -#include "governance.h" -#include "masternode-utils.h" -#include "util.h" -#include "utilmoneystr.h" -#include -#include - -CBudgetManager budget; -CCriticalSection cs_budget; - -std::map askedForSourceProposalOrBudget; -std::vector vecImmatureBudgetProposals; -std::vector vecImmatureFinalizedBudgets; - -int nSubmittedFinalBudget; - -CAmount GetBudgetSystemCollateralAmount(int nHeight) { - return (Params().GetBudgetSubmissionCollateral() * COIN); -} - -int GetBudgetPaymentCycleBlocks() -{ - // Amount of blocks in a months period of time (using 1 minutes per block) - // estimate 30 blocks an hour * hours in a day * avg. days in a month - if (Params().NetworkID() == CBaseChainParams::MAIN) - return (60 * 24 * 30); - - // for testing purposes -- every 12 hours - return (60 * 12); -} - -CAmount GetAvailableBudget(int nHeight) -{ - CAmount nSubsidy = GetBlockValue(nHeight, true); - return nSubsidy * GetBudgetPaymentCycleBlocks(); -} - -bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, std::string& strError, int64_t& nTime, int& nConf, bool fBudgetFinalization) -{ - CTransaction txCollateral; - uint256 nBlockHash; - if (!GetTransaction(nTxCollateralHash, txCollateral, nBlockHash, true)) { - strError = strprintf("Can't find collateral tx %s", txCollateral.ToString()); - LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError); - return false; - } - - if (txCollateral.vout.size() < 1) return false; - if (txCollateral.nLockTime != 0) return false; - - CScript findScript; - findScript << OP_RETURN << ToByteVector(nExpectedHash); - - bool foundOpReturn = false; - BOOST_FOREACH (const CTxOut o, txCollateral.vout) { - if (!o.scriptPubKey.IsNormalPaymentScript() && !o.scriptPubKey.IsUnspendable()) { - strError = strprintf("Invalid Script %s", txCollateral.ToString()); - LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError); - return false; - } - if (fBudgetFinalization) { - // Collateral for budget finalization - LogPrint("mnbudget", "Final Budget: o.scriptPubKey(%s) == findScript(%s) ?\n", o.scriptPubKey.ToString(), findScript.ToString()); - if (o.scriptPubKey == findScript) { - LogPrint("mnbudget", "Final Budget: o.nValue(%ld) >= BUDGET_FEE_TX(%ld) ?\n", o.nValue, GetBudgetSystemCollateralAmount(chainActive.Height())); - if(o.nValue >= GetBudgetSystemCollateralAmount(chainActive.Height())) { - foundOpReturn = true; - } - } - } - else { - // Collateral for normal budget proposal - LogPrint("mnbudget", "Normal Budget: o.scriptPubKey(%s) == findScript(%s) ?\n", o.scriptPubKey.ToString(), findScript.ToString()); - if (o.scriptPubKey == findScript) { - LogPrint("mnbudget", "Normal Budget: o.nValue(%ld) >= PROPOSAL_FEE_TX(%ld) ?\n", o.nValue, GetBudgetSystemCollateralAmount(chainActive.Height())); - if(o.nValue >= GetBudgetSystemCollateralAmount(chainActive.Height())) { - foundOpReturn = true; - } - } - } - } - if (!foundOpReturn) { - strError = strprintf("Couldn't find opReturn %s in %s", nExpectedHash.ToString(), txCollateral.ToString()); - LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s\n", strError); - return false; - } - - // RETRIEVE CONFIRMATIONS AND NTIME - /* - - nTime starts as zero and is passed-by-reference out of this function and stored in the external proposal - - nTime is never validated via the hashing mechanism and comes from a full-validated source (the blockchain) - */ - - int conf = GetIXConfirmations(nTxCollateralHash); - if (nBlockHash != uint256(0)) { - BlockMap::iterator mi = mapBlockIndex.find(nBlockHash); - if (mi != mapBlockIndex.end() && (*mi).second) { - CBlockIndex* pindex = (*mi).second; - if (chainActive.Contains(pindex)) { - conf += chainActive.Height() - pindex->nHeight + 1; - nTime = pindex->nTime; - } - } - } - - nConf = conf; - - //if we're syncing we won't have swiftTX information, so accept 1 confirmation - if (conf >= Params().BudgetFeeConfirmations()) { - return true; - } else { - strError = strprintf("Collateral requires at least %d confirmations - %d confirmations", Params().BudgetFeeConfirmations(), conf); - LogPrint("mnbudget","CBudgetProposalBroadcast::IsBudgetCollateralValid - %s - %d confirmations\n", strError, conf); - return false; - } -} - -void CBudgetManager::CheckOrphanVotes() -{ - LOCK(cs); - - - std::string strError = ""; - std::map::iterator it1 = mapOrphanMasternodeBudgetVotes.begin(); - while (it1 != mapOrphanMasternodeBudgetVotes.end()) { - if (budget.UpdateProposal(((*it1).second), NULL, strError)) { - LogPrint("mnbudget","CBudgetManager::CheckOrphanVotes - Proposal/Budget is known, activating and removing orphan vote\n"); - mapOrphanMasternodeBudgetVotes.erase(it1++); - } else { - ++it1; - } - } - std::map::iterator it2 = mapOrphanFinalizedBudgetVotes.begin(); - while (it2 != mapOrphanFinalizedBudgetVotes.end()) { - if (budget.UpdateFinalizedBudget(((*it2).second), NULL, strError)) { - LogPrint("mnbudget","CBudgetManager::CheckOrphanVotes - Proposal/Budget is known, activating and removing orphan vote\n"); - mapOrphanFinalizedBudgetVotes.erase(it2++); - } else { - ++it2; - } - } - LogPrint("mnbudget","CBudgetManager::CheckOrphanVotes - Done\n"); -} - -void CBudgetManager::SubmitFinalBudget() -{ - static int nSubmittedHeight = 0; // height at which final budget was submitted last time - int nCurrentHeight; - - { - TRY_LOCK(cs_main, locked); - if (!locked) return; - if (!chainActive.Tip()) return; - nCurrentHeight = chainActive.Height(); - } - - int nBlockStart = nCurrentHeight - nCurrentHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); - if (nSubmittedHeight >= nBlockStart){ - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - nSubmittedHeight(=%ld) < nBlockStart(=%ld) condition not fulfilled.\n", nSubmittedHeight, nBlockStart); - return; - } - - // Submit final budget during the last 2 days (2880 blocks) before payment for Mainnet - int finalizationWindow = ((GetBudgetPaymentCycleBlocks() / 30) * 2); - - // Testnet -- set window 2 hours before payment (120 blocks) - if (Params().NetworkID() == CBaseChainParams::TESTNET) { - // NOTE: votes are only submitted/relayed once every 56 blocks in CFinalizedBudget::AutoCheck() - finalizationWindow = (60 * 2); - } - - int nFinalizationStart = nBlockStart - finalizationWindow; - int nOffsetToStart = nFinalizationStart - nCurrentHeight; - - if (nBlockStart - nCurrentHeight > finalizationWindow){ - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Too early for finalization. Current block is %ld, next Superblock is %ld.\n", nCurrentHeight, nBlockStart); - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - First possible block for finalization: %ld. Last possible block for finalization: %ld. You have to wait for %ld block(s) until Budget finalization will be possible\n", nFinalizationStart, nBlockStart, nOffsetToStart); - - return; - } - - std::vector vBudgetProposals = budget.GetBudget(); - std::string strBudgetName = "main"; - std::vector vecTxBudgetPayments; - - for (unsigned int i = 0; i < vBudgetProposals.size(); i++) { - CTxBudgetPayment txBudgetPayment; - txBudgetPayment.nProposalHash = vBudgetProposals[i]->GetHash(); - txBudgetPayment.payee = vBudgetProposals[i]->GetPayee(); - txBudgetPayment.nAmount = vBudgetProposals[i]->GetAllotted(); - vecTxBudgetPayments.push_back(txBudgetPayment); - } - - if (vecTxBudgetPayments.size() < 1) { - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Found No Proposals For Period\n"); - return; - } - - CFinalizedBudgetBroadcast tempBudget(strBudgetName, nBlockStart, vecTxBudgetPayments, 0); - if (mapSeenFinalizedBudgets.count(tempBudget.GetHash())) { - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Budget already exists - %s\n", tempBudget.GetHash().ToString()); - nSubmittedHeight = nCurrentHeight; - return; //already exists - } - - //create fee tx - CTransaction tx; - uint256 txidCollateral; - - if (!mapCollateralTxids.count(tempBudget.GetHash())) { - CWalletTx wtx; - if (!pwalletMain->GetBudgetSystemCollateralTX(wtx, tempBudget.GetHash(), false)) { - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Can't make collateral transaction\n"); - return; - } - - // Get our change address - CReserveKey reservekey(pwalletMain); - // Send the tx to the network. Do NOT use SwiftTx, locking might need too much time to propagate, especially for testnet - pwalletMain->CommitTransaction(wtx, reservekey, "NO-ix"); - tx = (CTransaction)wtx; - txidCollateral = tx.GetHash(); - mapCollateralTxids.insert(make_pair(tempBudget.GetHash(), txidCollateral)); - } else { - txidCollateral = mapCollateralTxids[tempBudget.GetHash()]; - } - - int conf = GetIXConfirmations(txidCollateral); - CTransaction txCollateral; - uint256 nBlockHash; - - if (!GetTransaction(txidCollateral, txCollateral, nBlockHash, true)) { - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Can't find collateral tx %s", txidCollateral.ToString()); - return; - } - - if (nBlockHash != uint256(0)) { - BlockMap::iterator mi = mapBlockIndex.find(nBlockHash); - if (mi != mapBlockIndex.end() && (*mi).second) { - CBlockIndex* pindex = (*mi).second; - if (chainActive.Contains(pindex)) { - conf += chainActive.Height() - pindex->nHeight + 1; - } - } - } - - /* - Wait will we have 1 extra confirmation, otherwise some clients might reject this feeTX - -- This function is tied to NewBlock, so we will propagate this budget while the block is also propagating - */ - if (conf < Params().BudgetFeeConfirmations() + 1) { - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Collateral requires at least %d confirmations - %s - %d confirmations\n", Params().BudgetFeeConfirmations() + 1, txidCollateral.ToString(), conf); - return; - } - - //create the proposal incase we're the first to make it - CFinalizedBudgetBroadcast finalizedBudgetBroadcast(strBudgetName, nBlockStart, vecTxBudgetPayments, txidCollateral); - - std::string strError = ""; - if (!finalizedBudgetBroadcast.IsValid(strError)) { - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Invalid finalized budget - %s \n", strError); - return; - } - - LOCK(cs); - mapSeenFinalizedBudgets.insert(make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast)); - finalizedBudgetBroadcast.Relay(); - budget.AddFinalizedBudget(finalizedBudgetBroadcast); - nSubmittedHeight = nCurrentHeight; - LogPrint("mnbudget","CBudgetManager::SubmitFinalBudget - Done! %s\n", finalizedBudgetBroadcast.GetHash().ToString()); -} - -// -// CBudgetDB -// - -CBudgetDB::CBudgetDB() -{ - pathDB = GetDataDir() / "budget.dat"; - strMagicMessage = "MasternodeBudget"; -} - -bool CBudgetDB::Write(const CBudgetManager& objToSave) -{ - LOCK(objToSave.cs); - - int64_t nStart = GetTimeMillis(); - - // serialize, checksum data up to that point, then append checksum - CDataStream ssObj(SER_DISK, CLIENT_VERSION); - ssObj << strMagicMessage; // masternode cache file specific magic message - ssObj << FLATDATA(Params().MessageStart()); // network specific magic number - ssObj << objToSave; - uint256 hash = Hash(ssObj.begin(), ssObj.end()); - ssObj << hash; - - // open output file, and associate with CAutoFile - FILE* file = fopen(pathDB.string().c_str(), "wb"); - CAutoFile fileout(file, SER_DISK, CLIENT_VERSION); - if (fileout.IsNull()) - return error("%s : Failed to open file %s", __func__, pathDB.string()); - - // Write and commit header, data - try { - fileout << ssObj; - } catch (std::exception& e) { - return error("%s : Serialize or I/O error - %s", __func__, e.what()); - } - fileout.fclose(); - - LogPrint("mnbudget","Written info to budget.dat %dms\n", GetTimeMillis() - nStart); - - return true; -} - -CBudgetDB::ReadResult CBudgetDB::Read(CBudgetManager& objToLoad, bool fDryRun) -{ - LOCK(objToLoad.cs); - - int64_t nStart = GetTimeMillis(); - // open input file, and associate with CAutoFile - FILE* file = fopen(pathDB.string().c_str(), "rb"); - CAutoFile filein(file, SER_DISK, CLIENT_VERSION); - if (filein.IsNull()) { - error("%s : Failed to open file %s", __func__, pathDB.string()); - return FileError; - } - - // use file size to size memory buffer - int fileSize = boost::filesystem::file_size(pathDB); - int dataSize = fileSize - sizeof(uint256); - // Don't try to resize to a negative number if file is small - if (dataSize < 0) - dataSize = 0; - vector vchData; - vchData.resize(dataSize); - uint256 hashIn; - - // read data and checksum from file - try { - filein.read((char*)&vchData[0], dataSize); - filein >> hashIn; - } catch (std::exception& e) { - error("%s : Deserialize or I/O error - %s", __func__, e.what()); - return HashReadError; - } - filein.fclose(); - - CDataStream ssObj(vchData, SER_DISK, CLIENT_VERSION); - - // verify stored checksum matches input data - uint256 hashTmp = Hash(ssObj.begin(), ssObj.end()); - if (hashIn != hashTmp) { - error("%s : Checksum mismatch, data corrupted", __func__); - return IncorrectHash; - } - - - unsigned char pchMsgTmp[4]; - std::string strMagicMessageTmp; - try { - // de-serialize file header (masternode cache file specific magic message) and .. - ssObj >> strMagicMessageTmp; - - // ... verify the message matches predefined one - if (strMagicMessage != strMagicMessageTmp) { - error("%s : Invalid masternode cache magic message", __func__); - return IncorrectMagicMessage; - } - - - // de-serialize file header (network specific magic number) and .. - ssObj >> FLATDATA(pchMsgTmp); - - // ... verify the network matches ours - if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp))) { - error("%s : Invalid network magic number", __func__); - return IncorrectMagicNumber; - } - - // de-serialize data into CBudgetManager object - ssObj >> objToLoad; - } catch (std::exception& e) { - objToLoad.Clear(); - error("%s : Deserialize or I/O error - %s", __func__, e.what()); - return IncorrectFormat; - } - - LogPrint("mnbudget","Loaded info from budget.dat %dms\n", GetTimeMillis() - nStart); - LogPrint("mnbudget"," %s\n", objToLoad.ToString()); - if (!fDryRun) { - LogPrint("mnbudget","Budget manager - cleaning....\n"); - objToLoad.CheckAndRemove(); - LogPrint("mnbudget","Budget manager - result:\n"); - LogPrint("mnbudget"," %s\n", objToLoad.ToString()); - } - - return Ok; -} - -void DumpBudgets() -{ - int64_t nStart = GetTimeMillis(); - - CBudgetDB budgetdb; - CBudgetManager tempBudget; - - LogPrint("mnbudget","Verifying budget.dat format...\n"); - CBudgetDB::ReadResult readResult = budgetdb.Read(tempBudget, true); - // there was an error and it was not an error on file opening => do not proceed - if (readResult == CBudgetDB::FileError) - LogPrint("mnbudget","Missing budgets file - budget.dat, will try to recreate\n"); - else if (readResult != CBudgetDB::Ok) { - LogPrint("mnbudget","Error reading budget.dat: "); - if (readResult == CBudgetDB::IncorrectFormat) - LogPrint("mnbudget","magic is ok but data has invalid format, will try to recreate\n"); - else { - LogPrint("mnbudget","file format is unknown or invalid, please fix it manually\n"); - return; - } - } - LogPrint("mnbudget","Writting info to budget.dat...\n"); - budgetdb.Write(budget); - - LogPrint("mnbudget","Budget dump finished %dms\n", GetTimeMillis() - nStart); -} - -bool CBudgetManager::AddFinalizedBudget(CFinalizedBudget& finalizedBudget) -{ - std::string strError = ""; - if (!finalizedBudget.IsValid(strError)) return false; - - if (mapFinalizedBudgets.count(finalizedBudget.GetHash())) { - return false; - } - - mapFinalizedBudgets.insert(make_pair(finalizedBudget.GetHash(), finalizedBudget)); - return true; -} - -bool CBudgetManager::AddProposal(CBudgetProposal& budgetProposal) -{ - LOCK(cs); - std::string strError = ""; - if (!budgetProposal.IsValid(strError)) { - LogPrint("mnbudget","CBudgetManager::AddProposal - invalid budget proposal - %s\n", strError); - return false; - } - - if (mapProposals.count(budgetProposal.GetHash())) { - return false; - } - - mapProposals.insert(make_pair(budgetProposal.GetHash(), budgetProposal)); - LogPrint("mnbudget","CBudgetManager::AddProposal - proposal %s added\n", budgetProposal.GetName ().c_str ()); - return true; -} - -void CBudgetManager::CheckAndRemove() -{ - int nHeight = 0; - - // Add some verbosity once loading blocks from files has finished - { - TRY_LOCK(cs_main, locked); - if ((locked) && (chainActive.Tip() != NULL)) { - CBlockIndex* pindexPrev = chainActive.Tip(); - if (pindexPrev) { - nHeight = pindexPrev->nHeight; - } - } - } - - LogPrint("mnbudget", "CBudgetManager::CheckAndRemove at Height=%d\n", nHeight); - - map tmpMapFinalizedBudgets; - map tmpMapProposals; - - std::string strError = ""; - - LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapFinalizedBudgets cleanup - size before: %d\n", mapFinalizedBudgets.size()); - std::map::iterator it = mapFinalizedBudgets.begin(); - while (it != mapFinalizedBudgets.end()) { - CFinalizedBudget* pfinalizedBudget = &((*it).second); - - pfinalizedBudget->fValid = pfinalizedBudget->IsValid(strError); - if (!strError.empty ()) { - LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Invalid finalized budget: %s\n", strError); - } - else { - LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Found valid finalized budget: %s %s\n", - pfinalizedBudget->strBudgetName.c_str(), pfinalizedBudget->nFeeTXHash.ToString().c_str()); - } - - if (pfinalizedBudget->fValid) { - pfinalizedBudget->AutoCheck(); - tmpMapFinalizedBudgets.insert(make_pair(pfinalizedBudget->GetHash(), *pfinalizedBudget)); - } - - ++it; - } - - LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapProposals cleanup - size before: %d\n", mapProposals.size()); - std::map::iterator it2 = mapProposals.begin(); - while (it2 != mapProposals.end()) { - CBudgetProposal* pbudgetProposal = &((*it2).second); - pbudgetProposal->fValid = pbudgetProposal->IsValid(strError); - if (!strError.empty ()) { - LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Invalid budget proposal - %s\n", strError); - strError = ""; - } - else { - LogPrint("mnbudget","CBudgetManager::CheckAndRemove - Found valid budget proposal: %s %s\n", - pbudgetProposal->strProposalName.c_str(), pbudgetProposal->nFeeTXHash.ToString().c_str()); - } - if (pbudgetProposal->fValid) { - tmpMapProposals.insert(make_pair(pbudgetProposal->GetHash(), *pbudgetProposal)); - } - - ++it2; - } - // Remove invalid entries by overwriting complete map - mapFinalizedBudgets.swap(tmpMapFinalizedBudgets); - mapProposals.swap(tmpMapProposals); - - LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapFinalizedBudgets cleanup - size after: %d\n", mapFinalizedBudgets.size()); - LogPrint("mnbudget", "CBudgetManager::CheckAndRemove - mapProposals cleanup - size after: %d\n", mapProposals.size()); - LogPrint("mnbudget","CBudgetManager::CheckAndRemove - PASSED\n"); - -} - -void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, bool fProofOfStake) -{ - LOCK(cs); - - CBlockIndex* pindexPrev = chainActive.Tip(); - if (!pindexPrev) return; - - int nHighestCount = 0; - CScript payee; - CAmount nAmount = 0; - - // ------- Grab The Highest Count - - std::map::iterator it = mapFinalizedBudgets.begin(); - while (it != mapFinalizedBudgets.end()) { - CFinalizedBudget* pfinalizedBudget = &((*it).second); - if (pfinalizedBudget->GetVoteCount() > nHighestCount && - pindexPrev->nHeight + 1 >= pfinalizedBudget->GetBlockStart() && - pindexPrev->nHeight + 1 <= pfinalizedBudget->GetBlockEnd() && - pfinalizedBudget->GetPayeeAndAmount(pindexPrev->nHeight + 1, payee, nAmount)) { - nHighestCount = pfinalizedBudget->GetVoteCount(); - } - - ++it; - } - - CAmount blockValue = GetBlockValue(pindexPrev->nHeight); - - if (fProofOfStake) { - if (nHighestCount > 0) { - unsigned int i = txNew.vout.size(); - txNew.vout.resize(i + 1); - txNew.vout[i].scriptPubKey = payee; - txNew.vout[i].nValue = nAmount; - - CTxDestination address1; - ExtractDestination(payee, address1); - LogPrint("mnbudget","CBudgetManager::FillBlockPayee - Budget payment to %s for %lld, nHighestCount = %d\n", EncodeDestination(address1), nAmount, nHighestCount); - } - else { - LogPrint("mnbudget","CBudgetManager::FillBlockPayee - No Budget payment, nHighestCount = %d\n", nHighestCount); - } - } else { - //miners get the full amount on these blocks - txNew.vout[0].nValue = blockValue; - - if (nHighestCount > 0) { - txNew.vout.resize(2); - - //these are super blocks, so their value can be much larger than normal - txNew.vout[1].scriptPubKey = payee; - txNew.vout[1].nValue = nAmount; - - CTxDestination address1; - ExtractDestination(payee, address1); - - LogPrint("mnbudget","CBudgetManager::FillBlockPayee - Budget payment to %s for %lld\n", EncodeDestination(address1), nAmount); - } - } -} - -CFinalizedBudget* CBudgetManager::FindFinalizedBudget(uint256 nHash) -{ - if (mapFinalizedBudgets.count(nHash)) - return &mapFinalizedBudgets[nHash]; - - return NULL; -} - -CBudgetProposal* CBudgetManager::FindProposal(const std::string& strProposalName) -{ - //find the prop with the highest yes count - - int nYesCount = -99999; - CBudgetProposal* pbudgetProposal = NULL; - - std::map::iterator it = mapProposals.begin(); - while (it != mapProposals.end()) { - if ((*it).second.strProposalName == strProposalName && (*it).second.GetYeas() > nYesCount) { - pbudgetProposal = &((*it).second); - nYesCount = pbudgetProposal->GetYeas(); - } - ++it; - } - - if (nYesCount == -99999) return NULL; - - return pbudgetProposal; -} - -CBudgetProposal* CBudgetManager::FindProposal(uint256 nHash) -{ - LOCK(cs); - - if (mapProposals.count(nHash)) - return &mapProposals[nHash]; - - return NULL; -} - -bool CBudgetManager::IsBudgetPaymentBlock(int nBlockHeight) -{ - int nHighestCount = -1; - int nFivePercent = mnodeman.CountEnabled(ActiveProtocol()) / 20; - - std::map::iterator it = mapFinalizedBudgets.begin(); - while (it != mapFinalizedBudgets.end()) { - CFinalizedBudget* pfinalizedBudget = &((*it).second); - if (pfinalizedBudget->GetVoteCount() > nHighestCount && - nBlockHeight >= pfinalizedBudget->GetBlockStart() && - nBlockHeight <= pfinalizedBudget->GetBlockEnd()) { - nHighestCount = pfinalizedBudget->GetVoteCount(); - } - - ++it; - } - - LogPrint("mnbudget","CBudgetManager::IsBudgetPaymentBlock() - nHighestCount: %lli, 5%% of Masternodes: %lli. Number of budgets: %lli\n", - nHighestCount, nFivePercent, mapFinalizedBudgets.size()); - - // If budget doesn't have 5% of the network votes, then we should pay a masternode instead - if (nHighestCount > nFivePercent) return true; - - return false; -} - -TrxValidationStatus CBudgetManager::IsTransactionValid(const CTransaction& txNew, int nBlockHeight) -{ - LOCK(cs); - - - TrxValidationStatus transactionStatus = TrxValidationStatus::Invalid; - int nHighestCount = 0; - int nFivePercent = mnodeman.CountEnabled(ActiveProtocol()) / 20; - std::vector ret; - - // ------- Grab The Highest Count - - std::map::iterator it = mapFinalizedBudgets.begin(); - while (it != mapFinalizedBudgets.end()) { - CFinalizedBudget* pfinalizedBudget = &((*it).second); - - if (pfinalizedBudget->GetVoteCount() > nHighestCount && - nBlockHeight >= pfinalizedBudget->GetBlockStart() && - nBlockHeight <= pfinalizedBudget->GetBlockEnd()) { - nHighestCount = pfinalizedBudget->GetVoteCount(); - } - - ++it; - } - - LogPrint("mnbudget","CBudgetManager::IsTransactionValid() - nHighestCount: %lli, 5%% of Masternodes: %lli mapFinalizedBudgets.size(): %ld\n", - nHighestCount, nFivePercent, mapFinalizedBudgets.size()); - /* - If budget doesn't have 5% of the network votes, then we should pay a masternode instead - */ - if (nHighestCount < nFivePercent) return TrxValidationStatus::Invalid; - - // check the highest finalized budgets (+/- 10% to assist in consensus) - - std::string strProposals = ""; - int nCountThreshold = nHighestCount - mnodeman.CountEnabled(ActiveProtocol()) / 10; - bool fThreshold = false; - it = mapFinalizedBudgets.begin(); - while (it != mapFinalizedBudgets.end()) { - CFinalizedBudget* pfinalizedBudget = &((*it).second); - strProposals = pfinalizedBudget->GetProposals(); - - LogPrint("mnbudget","CBudgetManager::IsTransactionValid - checking budget (%s) with blockstart %lli, blockend %lli, nBlockHeight %lli, votes %lli, nCountThreshold %lli\n", - strProposals.c_str(), pfinalizedBudget->GetBlockStart(), pfinalizedBudget->GetBlockEnd(), - nBlockHeight, pfinalizedBudget->GetVoteCount(), nCountThreshold); - - if (pfinalizedBudget->GetVoteCount() > nCountThreshold) { - fThreshold = true; - if (nBlockHeight >= pfinalizedBudget->GetBlockStart() && nBlockHeight <= pfinalizedBudget->GetBlockEnd()) { - LogPrint("mnbudget","CBudgetManager::IsTransactionValid - GetBlockStart() passed\n"); - transactionStatus = pfinalizedBudget->IsTransactionValid(txNew, nBlockHeight); - if (transactionStatus == TrxValidationStatus::Valid) { - LogPrint("mnbudget","CBudgetManager::IsTransactionValid - pfinalizedBudget->IsTransactionValid() passed\n"); - return TrxValidationStatus::Valid; - } else { - LogPrint("mnbudget","CBudgetManager::IsTransactionValid - pfinalizedBudget->IsTransactionValid() error\n"); - } - } else { - LogPrint("mnbudget","CBudgetManager::IsTransactionValid - GetBlockStart() failed, budget is outside current payment cycle and will be ignored.\n"); - } - } - ++it; - } - - // If not enough masternodes autovoted for any of the finalized budgets pay a masternode instead - if (!fThreshold) { - transactionStatus = TrxValidationStatus::VoteThreshold; - } - - // We looked through all of the known budgets - return transactionStatus; -} - -std::vector CBudgetManager::GetAllProposals() -{ - LOCK(cs); - - std::vector vBudgetProposalRet; - - std::map::iterator it = mapProposals.begin(); - while (it != mapProposals.end()) { - (*it).second.CleanAndRemove(false); - - CBudgetProposal* pbudgetProposal = &((*it).second); - vBudgetProposalRet.push_back(pbudgetProposal); - - ++it; - } - - return vBudgetProposalRet; -} - -// -// Sort by votes, if there's a tie sort by their feeHash TX -// -struct sortProposalsByVotes { - bool operator()(const std::pair& left, const std::pair& right) - { - if (left.second != right.second) - return (left.second > right.second); - return (left.first->nFeeTXHash > right.first->nFeeTXHash); - } -}; - -//Need to review this function -std::vector CBudgetManager::GetBudget() -{ - LOCK(cs); - - // ------- Sort budgets by Yes Count - - std::vector > vBudgetPorposalsSort; - - std::map::iterator it = mapProposals.begin(); - while (it != mapProposals.end()) { - (*it).second.CleanAndRemove(false); - vBudgetPorposalsSort.push_back(make_pair(&((*it).second), (*it).second.GetYeas() - (*it).second.GetNays())); - ++it; - } - - std::sort(vBudgetPorposalsSort.begin(), vBudgetPorposalsSort.end(), sortProposalsByVotes()); - - // ------- Grab The Budgets In Order - - std::vector vBudgetProposalsRet; - - CAmount nBudgetAllocated = 0; - CBlockIndex* pindexPrev = chainActive.Tip(); - if (pindexPrev == NULL) return vBudgetProposalsRet; - - int nBlockStart = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); - int nBlockEnd = nBlockStart + GetBudgetPaymentCycleBlocks() - 1; - CAmount nTotalBudget = GetTotalBudget(nBlockStart); - - - std::vector >::iterator it2 = vBudgetPorposalsSort.begin(); - while (it2 != vBudgetPorposalsSort.end()) { - CBudgetProposal* pbudgetProposal = (*it2).first; - - LogPrint("mnbudget","CBudgetManager::GetBudget() - Processing Budget %s\n", pbudgetProposal->strProposalName.c_str()); - //prop start/end should be inside this period - if (pbudgetProposal->fValid && pbudgetProposal->nBlockStart <= nBlockStart && - pbudgetProposal->nBlockEnd >= nBlockEnd && - pbudgetProposal->GetYeas() - pbudgetProposal->GetNays() > mnodeman.CountEnabled(ActiveProtocol()) / 10 && - pbudgetProposal->IsEstablished()) { - - LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 1 passed: valid=%d | %ld <= %ld | %ld >= %ld | Yeas=%d Nays=%d Count=%d | established=%d\n", - pbudgetProposal->fValid, pbudgetProposal->nBlockStart, nBlockStart, pbudgetProposal->nBlockEnd, - nBlockEnd, pbudgetProposal->GetYeas(), pbudgetProposal->GetNays(), mnodeman.CountEnabled(ActiveProtocol()) / 10, - pbudgetProposal->IsEstablished()); - - if (pbudgetProposal->GetAmount() + nBudgetAllocated <= nTotalBudget) { - pbudgetProposal->SetAllotted(pbudgetProposal->GetAmount()); - nBudgetAllocated += pbudgetProposal->GetAmount(); - vBudgetProposalsRet.push_back(pbudgetProposal); - LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 2 passed: Budget added\n"); - } else { - pbudgetProposal->SetAllotted(0); - LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 2 failed: no amount allotted\n"); - } - } - else { - LogPrint("mnbudget","CBudgetManager::GetBudget() - Check 1 failed: valid=%d | %ld <= %ld | %ld >= %ld | Yeas=%d Nays=%d Count=%d | established=%d\n", - pbudgetProposal->fValid, pbudgetProposal->nBlockStart, nBlockStart, pbudgetProposal->nBlockEnd, - nBlockEnd, pbudgetProposal->GetYeas(), pbudgetProposal->GetNays(), mnodeman.CountEnabled(ActiveProtocol()) / 10, - pbudgetProposal->IsEstablished()); - } - - ++it2; - } - - return vBudgetProposalsRet; -} - -struct sortFinalizedBudgetsByVotes { - bool operator()(const std::pair& left, const std::pair& right) - { - if (left.second != right.second) - return left.second > right.second; - return (left.first->nFeeTXHash > right.first->nFeeTXHash); - } -}; - -std::vector CBudgetManager::GetFinalizedBudgets() -{ - LOCK(cs); - - std::vector vFinalizedBudgetsRet; - std::vector > vFinalizedBudgetsSort; - - // ------- Grab The Budgets In Order - - std::map::iterator it = mapFinalizedBudgets.begin(); - while (it != mapFinalizedBudgets.end()) { - CFinalizedBudget* pfinalizedBudget = &((*it).second); - - vFinalizedBudgetsSort.push_back(make_pair(pfinalizedBudget, pfinalizedBudget->GetVoteCount())); - ++it; - } - std::sort(vFinalizedBudgetsSort.begin(), vFinalizedBudgetsSort.end(), sortFinalizedBudgetsByVotes()); - - std::vector >::iterator it2 = vFinalizedBudgetsSort.begin(); - while (it2 != vFinalizedBudgetsSort.end()) { - vFinalizedBudgetsRet.push_back((*it2).first); - ++it2; - } - - return vFinalizedBudgetsRet; -} - -std::string CBudgetManager::GetRequiredPaymentsString(int nBlockHeight) -{ - LOCK(cs); - - std::string ret = "unknown-budget"; - - std::map::iterator it = mapFinalizedBudgets.begin(); - while (it != mapFinalizedBudgets.end()) { - CFinalizedBudget* pfinalizedBudget = &((*it).second); - if (nBlockHeight >= pfinalizedBudget->GetBlockStart() && nBlockHeight <= pfinalizedBudget->GetBlockEnd()) { - CTxBudgetPayment payment; - if (pfinalizedBudget->GetBudgetPaymentByBlock(nBlockHeight, payment)) { - if (ret == "unknown-budget") { - ret = payment.nProposalHash.ToString(); - } else { - ret += ","; - ret += payment.nProposalHash.ToString(); - } - } else { - LogPrint("mnbudget","CBudgetManager::GetRequiredPaymentsString - Couldn't find budget payment for block %d\n", nBlockHeight); - } - } - - ++it; - } - - return ret; -} - -CAmount CBudgetManager::GetTotalBudget(int nHeight) -{ - if (chainActive.Tip() == NULL) return 0; - - CAmount nSubsidy = GetBlockValue(nHeight, true); - - return nSubsidy * GetBudgetPaymentCycleBlocks(); -} - -void CBudgetManager::NewBlock() -{ - TRY_LOCK(cs, fBudgetNewBlock); - if (!fBudgetNewBlock) return; - - if (masternodeSync.RequestedMasternodeAssets <= MASTERNODE_SYNC_BUDGET) return; - - if (strBudgetMode == "suggest") { //suggest the budget we see - SubmitFinalBudget(); - } - - //this function should be called 1/14 blocks, allowing up to 100 votes per day on all proposals - if (chainActive.Height() % 14 != 0) return; - - // incremental sync with our peers - if (masternodeSync.IsSynced()) { - LogPrint("mnbudget","CBudgetManager::NewBlock - incremental sync started\n"); - if (chainActive.Height() % 1440 == rand() % 1440) { - ClearSeen(); - ResetSync(); - } - - LOCK(cs_vNodes); - BOOST_FOREACH (CNode* pnode, vNodes) - if (pnode->nVersion >= ActiveProtocol()) - Sync(pnode, 0, true); - - MarkSynced(); - } - - - CheckAndRemove(); - - //remove invalid votes once in a while (we have to check the signatures and validity of every vote, somewhat CPU intensive) - - LogPrint("mnbudget","CBudgetManager::NewBlock - askedForSourceProposalOrBudget cleanup - size: %d\n", askedForSourceProposalOrBudget.size()); - std::map::iterator it = askedForSourceProposalOrBudget.begin(); - while (it != askedForSourceProposalOrBudget.end()) { - if ((*it).second > GetTime() - (60 * 60 * 24)) { - ++it; - } else { - askedForSourceProposalOrBudget.erase(it++); - } - } - - LogPrint("mnbudget","CBudgetManager::NewBlock - mapProposals cleanup - size: %d\n", mapProposals.size()); - std::map::iterator it2 = mapProposals.begin(); - while (it2 != mapProposals.end()) { - (*it2).second.CleanAndRemove(false); - ++it2; - } - - LogPrint("mnbudget","CBudgetManager::NewBlock - mapFinalizedBudgets cleanup - size: %d\n", mapFinalizedBudgets.size()); - std::map::iterator it3 = mapFinalizedBudgets.begin(); - while (it3 != mapFinalizedBudgets.end()) { - (*it3).second.CleanAndRemove(false); - ++it3; - } - - LogPrint("mnbudget","CBudgetManager::NewBlock - vecImmatureBudgetProposals cleanup - size: %d\n", vecImmatureBudgetProposals.size()); - std::vector::iterator it4 = vecImmatureBudgetProposals.begin(); - while (it4 != vecImmatureBudgetProposals.end()) { - std::string strError = ""; - int nConf = 0; - if (!IsBudgetCollateralValid((*it4).nFeeTXHash, (*it4).GetHash(), strError, (*it4).nTime, nConf, true)) { - ++it4; - continue; - } - - if (!(*it4).IsValid(strError)) { - LogPrint("mnbudget","mprop (immature) - invalid budget proposal - %s\n", strError); - it4 = vecImmatureBudgetProposals.erase(it4); - continue; - } - - CBudgetProposal budgetProposal((*it4)); - if (AddProposal(budgetProposal)) { - (*it4).Relay(); - } - - LogPrint("mnbudget","mprop (immature) - new budget - %s\n", (*it4).GetHash().ToString()); - it4 = vecImmatureBudgetProposals.erase(it4); - } - - LogPrint("mnbudget","CBudgetManager::NewBlock - vecImmatureFinalizedBudgets cleanup - size: %d\n", vecImmatureFinalizedBudgets.size()); - std::vector::iterator it5 = vecImmatureFinalizedBudgets.begin(); - while (it5 != vecImmatureFinalizedBudgets.end()) { - std::string strError = ""; - int nConf = 0; - if (!IsBudgetCollateralValid((*it5).nFeeTXHash, (*it5).GetHash(), strError, (*it5).nTime, nConf, true)) { - ++it5; - continue; - } - - if (!(*it5).IsValid(strError)) { - LogPrint("mnbudget","fbs (immature) - invalid finalized budget - %s\n", strError); - it5 = vecImmatureFinalizedBudgets.erase(it5); - continue; - } - - LogPrint("mnbudget","fbs (immature) - new finalized budget - %s\n", (*it5).GetHash().ToString()); - - CFinalizedBudget finalizedBudget((*it5)); - if (AddFinalizedBudget(finalizedBudget)) { - (*it5).Relay(); - } - - it5 = vecImmatureFinalizedBudgets.erase(it5); - } - LogPrint("mnbudget","CBudgetManager::NewBlock - PASSED\n"); -} - -void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv) -{ - // lite mode is not supported - if (fLiteMode) return; - if (!masternodeSync.IsBlockchainSynced()) return; - - LOCK(cs_budget); - - if (strCommand == NetMsgType::MNVS) { //Masternode vote sync - uint256 nProp; - vRecv >> nProp; - - if (Params().NetworkID() == CBaseChainParams::MAIN) { - if (nProp == 0) { - if (pfrom->HasFulfilledRequest(NetMsgType::MNVS)) { - LogPrint("mnbudget","mnvs - peer already asked me for the list\n"); - // TODO: Determine why this happens often and is bannable offense - // LogPrintf("Misbehaving: ASKED FOR LIST\n"); - // Misbehaving(pfrom->GetId(), 20); - return; - } - pfrom->FulfilledRequest(NetMsgType::MNVS); - } - } - - Sync(pfrom, nProp); - LogPrint("mnbudget", "mnvs - Sent Masternode votes to peer %i\n", pfrom->GetId()); - } - - if (strCommand == NetMsgType::MPROP) { //Masternode Proposal - CBudgetProposalBroadcast budgetProposalBroadcast; - vRecv >> budgetProposalBroadcast; - - if (mapSeenMasternodeBudgetProposals.count(budgetProposalBroadcast.GetHash())) { - masternodeSync.AddedBudgetItem(budgetProposalBroadcast.GetHash()); - return; - } - - std::string strError = ""; - int nConf = 0; - if (!IsBudgetCollateralValid(budgetProposalBroadcast.nFeeTXHash, budgetProposalBroadcast.GetHash(), strError, budgetProposalBroadcast.nTime, nConf)) { - LogPrint("mnbudget","Proposal FeeTX is not valid - %s - %s\n", budgetProposalBroadcast.nFeeTXHash.ToString(), strError); - if (nConf >= 1) vecImmatureBudgetProposals.push_back(budgetProposalBroadcast); - return; - } - - mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast)); - - if (!budgetProposalBroadcast.IsValid(strError)) { - LogPrint("mnbudget","mprop - invalid budget proposal - %s\n", strError); - return; - } - - CBudgetProposal budgetProposal(budgetProposalBroadcast); - if (AddProposal(budgetProposal)) { - budgetProposalBroadcast.Relay(); - } - masternodeSync.AddedBudgetItem(budgetProposalBroadcast.GetHash()); - - LogPrint("mnbudget","mprop - new budget - %s\n", budgetProposalBroadcast.GetHash().ToString()); - - //We might have active votes for this proposal that are valid now - CheckOrphanVotes(); - } - - if (strCommand == NetMsgType::MVOTE) { //Masternode Vote - CBudgetVote vote; - vRecv >> vote; - vote.fValid = true; - - if (mapSeenMasternodeBudgetVotes.count(vote.GetHash())) { - masternodeSync.AddedBudgetItem(vote.GetHash()); - return; - } - - CMasternode* pmn = mnodeman.Find(vote.vin); - if (pmn == NULL) { - LogPrint("mnbudget","mvote - unknown masternode - vin: %s\n", vote.vin.prevout.hash.ToString()); - mnodeman.AskForMN(pfrom, vote.vin); - return; - } - - - mapSeenMasternodeBudgetVotes.insert(make_pair(vote.GetHash(), vote)); - if (!vote.SignatureValid(true)) { - LogPrint("mnbudget","mvote - signature invalid\n"); - if (masternodeSync.IsSynced()) { - LogPrintf("Misbehaving: SYNCED VOTES INSERTT\n"); - Misbehaving(pfrom->GetId(), 20); - } - // it could just be a non-synced masternode - mnodeman.AskForMN(pfrom, vote.vin); - return; - } - - std::string strError = ""; - if (UpdateProposal(vote, pfrom, strError)) { - vote.Relay(); - masternodeSync.AddedBudgetItem(vote.GetHash()); - } - - LogPrint("mnbudget","mvote - new budget vote for budget %s - %s\n", vote.nProposalHash.ToString(), vote.GetHash().ToString()); - } - - if (strCommand == NetMsgType::FBS) { //Finalized Budget Suggestion - CFinalizedBudgetBroadcast finalizedBudgetBroadcast; - vRecv >> finalizedBudgetBroadcast; - - if (mapSeenFinalizedBudgets.count(finalizedBudgetBroadcast.GetHash())) { - masternodeSync.AddedBudgetItem(finalizedBudgetBroadcast.GetHash()); - return; - } - - std::string strError = ""; - int nConf = 0; - if (!IsBudgetCollateralValid(finalizedBudgetBroadcast.nFeeTXHash, finalizedBudgetBroadcast.GetHash(), strError, finalizedBudgetBroadcast.nTime, nConf, true)) { - LogPrint("mnbudget","fbs - Finalized Budget FeeTX is not valid - %s - %s\n", finalizedBudgetBroadcast.nFeeTXHash.ToString(), strError); - - if (nConf >= 1) vecImmatureFinalizedBudgets.push_back(finalizedBudgetBroadcast); - return; - } - - mapSeenFinalizedBudgets.insert(make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast)); - - if (!finalizedBudgetBroadcast.IsValid(strError)) { - LogPrint("mnbudget","fbs - invalid finalized budget - %s\n", strError); - return; - } - - LogPrint("mnbudget","fbs - new finalized budget - %s\n", finalizedBudgetBroadcast.GetHash().ToString()); - - CFinalizedBudget finalizedBudget(finalizedBudgetBroadcast); - if (AddFinalizedBudget(finalizedBudget)) { - finalizedBudgetBroadcast.Relay(); - } - masternodeSync.AddedBudgetItem(finalizedBudgetBroadcast.GetHash()); - - //we might have active votes for this budget that are now valid - CheckOrphanVotes(); - } - - if (strCommand == NetMsgType::FBVOTE) { //Finalized Budget Vote - CFinalizedBudgetVote vote; - vRecv >> vote; - vote.fValid = true; - - if (mapSeenFinalizedBudgetVotes.count(vote.GetHash())) { - masternodeSync.AddedBudgetItem(vote.GetHash()); - return; - } - - CMasternode* pmn = mnodeman.Find(vote.vin); - if (pmn == NULL) { - LogPrint("mnbudget", "fbvote - unknown masternode - vin: %s\n", vote.vin.prevout.hash.ToString()); - mnodeman.AskForMN(pfrom, vote.vin); - return; - } - - mapSeenFinalizedBudgetVotes.insert(make_pair(vote.GetHash(), vote)); - if (!vote.SignatureValid(true)) { - LogPrint("mnbudget","fbvote - signature invalid\n"); - if (masternodeSync.IsSynced()) { - LogPrintf("Misbehaving: SYNCED SIG INVALID\n"); - Misbehaving(pfrom->GetId(), 20); - } - // it could just be a non-synced masternode - mnodeman.AskForMN(pfrom, vote.vin); - return; - } - - std::string strError = ""; - if (UpdateFinalizedBudget(vote, pfrom, strError)) { - vote.Relay(); - masternodeSync.AddedBudgetItem(vote.GetHash()); - - LogPrint("mnbudget","fbvote - new finalized budget vote - %s\n", vote.GetHash().ToString()); - } else { - LogPrint("mnbudget","fbvote - rejected finalized budget vote - %s - %s\n", vote.GetHash().ToString(), strError); - } - } -} - -bool CBudgetManager::PropExists(uint256 nHash) -{ - if (mapProposals.count(nHash)) return true; - return false; -} - -//mark that a full sync is needed -void CBudgetManager::ResetSync() -{ - LOCK(cs); - - - std::map::iterator it1 = mapSeenMasternodeBudgetProposals.begin(); - while (it1 != mapSeenMasternodeBudgetProposals.end()) { - CBudgetProposal* pbudgetProposal = FindProposal((*it1).first); - if (pbudgetProposal && pbudgetProposal->fValid) { - //mark votes - std::map::iterator it2 = pbudgetProposal->mapVotes.begin(); - while (it2 != pbudgetProposal->mapVotes.end()) { - (*it2).second.fSynced = false; - ++it2; - } - } - ++it1; - } - - std::map::iterator it3 = mapSeenFinalizedBudgets.begin(); - while (it3 != mapSeenFinalizedBudgets.end()) { - CFinalizedBudget* pfinalizedBudget = FindFinalizedBudget((*it3).first); - if (pfinalizedBudget && pfinalizedBudget->fValid) { - //send votes - std::map::iterator it4 = pfinalizedBudget->mapVotes.begin(); - while (it4 != pfinalizedBudget->mapVotes.end()) { - (*it4).second.fSynced = false; - ++it4; - } - } - ++it3; - } -} - -void CBudgetManager::MarkSynced() -{ - LOCK(cs); - - /* - Mark that we've sent all valid items - */ - - std::map::iterator it1 = mapSeenMasternodeBudgetProposals.begin(); - while (it1 != mapSeenMasternodeBudgetProposals.end()) { - CBudgetProposal* pbudgetProposal = FindProposal((*it1).first); - if (pbudgetProposal && pbudgetProposal->fValid) { - //mark votes - std::map::iterator it2 = pbudgetProposal->mapVotes.begin(); - while (it2 != pbudgetProposal->mapVotes.end()) { - if ((*it2).second.fValid) - (*it2).second.fSynced = true; - ++it2; - } - } - ++it1; - } - - std::map::iterator it3 = mapSeenFinalizedBudgets.begin(); - while (it3 != mapSeenFinalizedBudgets.end()) { - CFinalizedBudget* pfinalizedBudget = FindFinalizedBudget((*it3).first); - if (pfinalizedBudget && pfinalizedBudget->fValid) { - //mark votes - std::map::iterator it4 = pfinalizedBudget->mapVotes.begin(); - while (it4 != pfinalizedBudget->mapVotes.end()) { - if ((*it4).second.fValid) - (*it4).second.fSynced = true; - ++it4; - } - } - ++it3; - } -} - - -void CBudgetManager::Sync(CNode* pfrom, uint256 nProp, bool fPartial) -{ - LOCK(cs); - - /* - Sync with a client on the network - -- - This code checks each of the hash maps for all known budget proposals and finalized budget proposals, then checks them against the - budget object to see if they're OK. If all checks pass, we'll send it to the peer. - */ - - int nInvCount = 0; - - std::map::iterator it1 = mapSeenMasternodeBudgetProposals.begin(); - while (it1 != mapSeenMasternodeBudgetProposals.end()) { - CBudgetProposal* pbudgetProposal = FindProposal((*it1).first); - if (pbudgetProposal && pbudgetProposal->fValid && (nProp == 0 || (*it1).first == nProp)) { - pfrom->PushInventory(CInv(MSG_BUDGET_PROPOSAL, (*it1).second.GetHash())); - nInvCount++; - - //send votes - std::map::iterator it2 = pbudgetProposal->mapVotes.begin(); - while (it2 != pbudgetProposal->mapVotes.end()) { - if ((*it2).second.fValid) { - if ((fPartial && !(*it2).second.fSynced) || !fPartial) { - pfrom->PushInventory(CInv(MSG_BUDGET_VOTE, (*it2).second.GetHash())); - nInvCount++; - } - } - ++it2; - } - } - ++it1; - } - - pfrom->PushMessage(NetMsgType::SSC, MASTERNODE_SYNC_BUDGET_PROP, nInvCount); - - LogPrint("mnbudget", "CBudgetManager::Sync - sent %d items\n", nInvCount); - - nInvCount = 0; - - std::map::iterator it3 = mapSeenFinalizedBudgets.begin(); - while (it3 != mapSeenFinalizedBudgets.end()) { - CFinalizedBudget* pfinalizedBudget = FindFinalizedBudget((*it3).first); - if (pfinalizedBudget && pfinalizedBudget->fValid && (nProp == 0 || (*it3).first == nProp)) { - pfrom->PushInventory(CInv(MSG_BUDGET_FINALIZED, (*it3).second.GetHash())); - nInvCount++; - - //send votes - std::map::iterator it4 = pfinalizedBudget->mapVotes.begin(); - while (it4 != pfinalizedBudget->mapVotes.end()) { - if ((*it4).second.fValid) { - if ((fPartial && !(*it4).second.fSynced) || !fPartial) { - pfrom->PushInventory(CInv(MSG_BUDGET_FINALIZED_VOTE, (*it4).second.GetHash())); - nInvCount++; - } - } - ++it4; - } - } - ++it3; - } - - pfrom->PushMessage(NetMsgType::SSC, MASTERNODE_SYNC_BUDGET_FIN, nInvCount); - LogPrint("mnbudget", "CBudgetManager::Sync - sent %d items\n", nInvCount); -} - -bool CBudgetManager::UpdateProposal(CBudgetVote& vote, CNode* pfrom, std::string& strError) -{ - LOCK(cs); - - if (!mapProposals.count(vote.nProposalHash)) { - if (pfrom) { - // only ask for missing items after our syncing process is complete -- - // otherwise we'll think a full sync succeeded when they return a result - if (!masternodeSync.IsSynced()) return false; - - LogPrint("mnbudget","CBudgetManager::UpdateProposal - Unknown proposal %d, asking for source proposal\n", vote.nProposalHash.ToString()); - mapOrphanMasternodeBudgetVotes[vote.nProposalHash] = vote; - - if (!askedForSourceProposalOrBudget.count(vote.nProposalHash)) { - pfrom->PushMessage(NetMsgType::MNVS, vote.nProposalHash); - askedForSourceProposalOrBudget[vote.nProposalHash] = GetTime(); - } - } - - strError = "Proposal not found!"; - return false; - } - - - return mapProposals[vote.nProposalHash].AddOrUpdateVote(vote, strError); -} - -bool CBudgetManager::UpdateFinalizedBudget(CFinalizedBudgetVote& vote, CNode* pfrom, std::string& strError) -{ - LOCK(cs); - - if (!mapFinalizedBudgets.count(vote.nBudgetHash)) { - if (pfrom) { - // only ask for missing items after our syncing process is complete -- - // otherwise we'll think a full sync succeeded when they return a result - if (!masternodeSync.IsSynced()) return false; - - LogPrint("mnbudget","CBudgetManager::UpdateFinalizedBudget - Unknown Finalized Proposal %s, asking for source budget\n", vote.nBudgetHash.ToString()); - mapOrphanFinalizedBudgetVotes[vote.nBudgetHash] = vote; - - if (!askedForSourceProposalOrBudget.count(vote.nBudgetHash)) { - pfrom->PushMessage(NetMsgType::MNVS, vote.nBudgetHash); - askedForSourceProposalOrBudget[vote.nBudgetHash] = GetTime(); - } - } - - strError = "Finalized Budget " + vote.nBudgetHash.ToString() + " not found!"; - return false; - } - LogPrint("mnbudget","CBudgetManager::UpdateFinalizedBudget - Finalized Proposal %s added\n", vote.nBudgetHash.ToString()); - return mapFinalizedBudgets[vote.nBudgetHash].AddOrUpdateVote(vote, strError); -} - -CBudgetProposal::CBudgetProposal() -{ - strProposalName = "unknown"; - nBlockStart = 0; - nBlockEnd = 0; - nAmount = 0; - nTime = 0; - fValid = true; -} - -CBudgetProposal::CBudgetProposal(std::string strProposalNameIn, std::string strURLIn, int nBlockStartIn, int nBlockEndIn, CScript addressIn, CAmount nAmountIn, uint256 nFeeTXHashIn) -{ - strProposalName = strProposalNameIn; - strURL = strURLIn; - nBlockStart = nBlockStartIn; - nBlockEnd = nBlockEndIn; - address = addressIn; - nAmount = nAmountIn; - nFeeTXHash = nFeeTXHashIn; - fValid = true; -} - -CBudgetProposal::CBudgetProposal(const CBudgetProposal& other) -{ - strProposalName = other.strProposalName; - strURL = other.strURL; - nBlockStart = other.nBlockStart; - nBlockEnd = other.nBlockEnd; - address = other.address; - nAmount = other.nAmount; - nTime = other.nTime; - nFeeTXHash = other.nFeeTXHash; - mapVotes = other.mapVotes; - fValid = true; -} - -bool CBudgetProposal::IsValid(std::string& strError, bool fCheckCollateral) -{ - if (GetNays() - GetYeas() > mnodeman.CountEnabled(ActiveProtocol()) / 10) { - strError = "Proposal " + strProposalName + ": Active removal"; - return false; - } - - if (nBlockStart < 0) { - strError = "Invalid Proposal"; - return false; - } - - if (nBlockEnd < nBlockStart) { - strError = "Proposal " + strProposalName + ": Invalid nBlockEnd (end before start)"; - return false; - } - - if (nAmount < 10 * COIN) { - strError = "Proposal " + strProposalName + ": Invalid nAmount"; - return false; - } - - if (address == CScript()) { - strError = "Proposal " + strProposalName + ": Invalid Payment Address"; - return false; - } - - if (fCheckCollateral) { - int nConf = 0; - if (!IsBudgetCollateralValid(nFeeTXHash, GetHash(), strError, nTime, nConf)) { - strError = "Proposal " + strProposalName + ": Invalid collateral"; - return false; - } - } - - /* - TODO: There might be an issue with multisig in the coinbase on mainnet, we will add support for it in a future release. - */ - if (address.IsPayToScriptHash()) { - strError = "Proposal " + strProposalName + ": Multisig is not currently supported."; - return false; - } - - //if proposal doesn't gain traction within 2 weeks, remove it - // nTime not being saved correctly - // -- TODO: We should keep track of the last time the proposal was valid, if it's invalid for 2 weeks, erase it - // if(nTime + (60*60*24*2) < GetAdjustedTime()) { - // if(GetYeas()-GetNays() < (mnodeman.CountEnabled(ActiveProtocol())/10)) { - // strError = "Not enough support"; - // return false; - // } - // } - - CAmount totalBudget = budget.GetTotalBudget(nBlockStart); - - // can only pay out 10% of the possible coins (min value of coins) - if (nAmount > totalBudget) { - strError = "Proposal " + - strProposalName + - ": Payment more than max for cycle. (" + - FormatMoney(totalBudget) + - " ODIN)"; - return false; - } - - CBlockIndex* pindexPrev = chainActive.Tip(); - if (pindexPrev == NULL) { - strError = "Proposal " + strProposalName + ": Tip is NULL"; - return true; - } - - // Calculate maximum block this proposal will be valid, which is start of proposal + (number of payments * cycle) - int nProposalEnd = GetBlockStart() + (GetBudgetPaymentCycleBlocks() * GetTotalPaymentCount()); - - // if (GetBlockEnd() < pindexPrev->nHeight - GetBudgetPaymentCycleBlocks() / 2) { - if(nProposalEnd < pindexPrev->nHeight){ - strError = "Proposal " + strProposalName + ": Invalid nBlockEnd (" + std::to_string(nProposalEnd) + ") < current height (" + std::to_string(pindexPrev->nHeight) + ")"; - return false; - } - - return true; -} - -bool CBudgetProposal::AddOrUpdateVote(CBudgetVote& vote, std::string& strError) -{ - std::string strAction = "New vote inserted:"; - LOCK(cs); - - uint256 hash = vote.vin.prevout.GetHash(); - - if (mapVotes.count(hash)) { - if (mapVotes[hash].nTime > vote.nTime) { - strError = strprintf("new vote older than existing vote - %s\n", vote.GetHash().ToString()); - LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s\n", strError); - return false; - } - if (vote.nTime - mapVotes[hash].nTime < BUDGET_VOTE_UPDATE_MIN) { - strError = strprintf("time between votes is too soon - %s - %lli sec < %lli sec\n", vote.GetHash().ToString(), vote.nTime - mapVotes[hash].nTime,BUDGET_VOTE_UPDATE_MIN); - LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s\n", strError); - return false; - } - strAction = "Existing vote updated:"; - } - - if (vote.nTime > GetTime() + (60 * 60)) { - strError = strprintf("new vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", vote.GetHash().ToString(), vote.nTime, GetTime() + (60 * 60)); - LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s\n", strError); - return false; - } - - mapVotes[hash] = vote; - LogPrint("mnbudget", "CBudgetProposal::AddOrUpdateVote - %s %s\n", strAction.c_str(), vote.GetHash().ToString().c_str()); - - return true; -} - -// If masternode voted for a proposal, but is now invalid -- remove the vote -void CBudgetProposal::CleanAndRemove(bool fSignatureCheck) -{ - std::map::iterator it = mapVotes.begin(); - - while (it != mapVotes.end()) { - (*it).second.fValid = (*it).second.SignatureValid(fSignatureCheck); - ++it; - } -} - -double CBudgetProposal::GetRatio() -{ - int yeas = 0; - int nays = 0; - - std::map::iterator it = mapVotes.begin(); - - while (it != mapVotes.end()) { - if ((*it).second.nVote == VOTE_YES) yeas++; - if ((*it).second.nVote == VOTE_NO) nays++; - ++it; - } - - if (yeas + nays == 0) return 0.0f; - - return ((double)(yeas) / (double)(yeas + nays)); -} - -int CBudgetProposal::GetYeas() -{ - int ret = 0; - - std::map::iterator it = mapVotes.begin(); - while (it != mapVotes.end()) { - if ((*it).second.nVote == VOTE_YES && (*it).second.fValid) ret++; - ++it; - } - - return ret; -} - -int CBudgetProposal::GetNays() -{ - int ret = 0; - - std::map::iterator it = mapVotes.begin(); - while (it != mapVotes.end()) { - if ((*it).second.nVote == VOTE_NO && (*it).second.fValid) ret++; - ++it; - } - - return ret; -} - -int CBudgetProposal::GetAbstains() -{ - int ret = 0; - - std::map::iterator it = mapVotes.begin(); - while (it != mapVotes.end()) { - if ((*it).second.nVote == VOTE_ABSTAIN && (*it).second.fValid) ret++; - ++it; - } - - return ret; -} - -int CBudgetProposal::GetBlockStartCycle() -{ - //end block is half way through the next cycle (so the proposal will be removed much after the payment is sent) - - return nBlockStart - nBlockStart % GetBudgetPaymentCycleBlocks(); -} - -int CBudgetProposal::GetBlockCurrentCycle() -{ - CBlockIndex* pindexPrev = chainActive.Tip(); - if (pindexPrev == NULL) return -1; - - if (pindexPrev->nHeight >= GetBlockEndCycle()) return -1; - - return pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks(); -} - -int CBudgetProposal::GetBlockEndCycle() -{ - // Right now single payment proposals have nBlockEnd have a cycle too early! - // switch back if it break something else - // end block is half way through the next cycle (so the proposal will be removed much after the payment is sent) - // return nBlockEnd - GetBudgetPaymentCycleBlocks() / 2; - - // End block is half way through the next cycle (so the proposal will be removed much after the payment is sent) - return nBlockEnd; - -} - -int CBudgetProposal::GetTotalPaymentCount() -{ - return (GetBlockEndCycle() - GetBlockStartCycle()) / GetBudgetPaymentCycleBlocks(); -} - -int CBudgetProposal::GetRemainingPaymentCount() -{ - // If this budget starts in the future, this value will be wrong - int nPayments = (GetBlockEndCycle() - GetBlockCurrentCycle()) / GetBudgetPaymentCycleBlocks() - 1; - // Take the lowest value - return std::min(nPayments, GetTotalPaymentCount()); -} - -CBudgetProposalBroadcast::CBudgetProposalBroadcast(std::string strProposalNameIn, std::string strURLIn, int nPaymentCount, CScript addressIn, CAmount nAmountIn, int nBlockStartIn, uint256 nFeeTXHashIn) -{ - strProposalName = strProposalNameIn; - strURL = strURLIn; - - nBlockStart = nBlockStartIn; - - int nCycleStart = nBlockStart - nBlockStart % GetBudgetPaymentCycleBlocks(); - - // Right now single payment proposals have nBlockEnd have a cycle too early! - // switch back if it break something else - // calculate the end of the cycle for this vote, add half a cycle (vote will be deleted after that block) - // nBlockEnd = nCycleStart + GetBudgetPaymentCycleBlocks() * nPaymentCount + GetBudgetPaymentCycleBlocks() / 2; - - // Calculate the end of the cycle for this vote, vote will be deleted after next cycle - nBlockEnd = nCycleStart + (GetBudgetPaymentCycleBlocks() + 1) * nPaymentCount; - - address = addressIn; - nAmount = nAmountIn; - - nFeeTXHash = nFeeTXHashIn; -} - -void CBudgetProposalBroadcast::Relay() -{ - CInv inv(MSG_BUDGET_PROPOSAL, GetHash()); - RelayInv(inv); -} - -CBudgetVote::CBudgetVote() -{ - vin = CTxIn(); - nProposalHash = 0; - nVote = VOTE_ABSTAIN; - nTime = 0; - fValid = true; - fSynced = false; -} - -CBudgetVote::CBudgetVote(CTxIn vinIn, uint256 nProposalHashIn, int nVoteIn) -{ - vin = vinIn; - nProposalHash = nProposalHashIn; - nVote = nVoteIn; - nTime = GetAdjustedTime(); - fValid = true; - fSynced = false; -} - -void CBudgetVote::Relay() -{ - CInv inv(MSG_BUDGET_VOTE, GetHash()); - RelayInv(inv); -} - -bool CBudgetVote::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode) -{ - // Choose coins to use - CPubKey pubKeyCollateralAddress; - CKey keyCollateralAddress; - - std::string errorMessage; - std::string strMessage = vin.prevout.ToStringShort() + nProposalHash.ToString() + boost::lexical_cast(nVote) + boost::lexical_cast(nTime); - - if (!obfuScationSigner.SignMessage(strMessage, errorMessage, vchSig, keyMasternode)) { - LogPrint("mnbudget","CBudgetVote::Sign - Error upon calling SignMessage"); - return false; - } - - if (!obfuScationSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, errorMessage)) { - LogPrint("mnbudget","CBudgetVote::Sign - Error upon calling VerifyMessage"); - return false; - } - - return true; -} - -bool CBudgetVote::SignatureValid(bool fSignatureCheck) -{ - std::string errorMessage; - std::string strMessage = vin.prevout.ToStringShort() + nProposalHash.ToString() + boost::lexical_cast(nVote) + boost::lexical_cast(nTime); - - CMasternode* pmn = mnodeman.Find(vin); - - if (pmn == NULL) { - if (fDebug){ - LogPrint("mnbudget","CBudgetVote::SignatureValid() - Unknown Masternode - %s\n", vin.prevout.hash.ToString()); - } - return false; - } - - if (!fSignatureCheck) return true; - - if (!obfuScationSigner.VerifyMessage(pmn->pubKeyMasternode, vchSig, strMessage, errorMessage)) { - LogPrint("mnbudget","CBudgetVote::SignatureValid() - Verify message failed\n"); - return false; - } - - return true; -} - -CFinalizedBudget::CFinalizedBudget() -{ - strBudgetName = ""; - nBlockStart = 0; - vecBudgetPayments.clear(); - mapVotes.clear(); - nFeeTXHash = 0; - nTime = 0; - fValid = true; - fAutoChecked = false; -} - -CFinalizedBudget::CFinalizedBudget(const CFinalizedBudget& other) -{ - strBudgetName = other.strBudgetName; - nBlockStart = other.nBlockStart; - vecBudgetPayments = other.vecBudgetPayments; - mapVotes = other.mapVotes; - nFeeTXHash = other.nFeeTXHash; - nTime = other.nTime; - fValid = true; - fAutoChecked = false; -} - -bool CFinalizedBudget::AddOrUpdateVote(CFinalizedBudgetVote& vote, std::string& strError) -{ - LOCK(cs); - - uint256 hash = vote.vin.prevout.GetHash(); - std::string strAction = "New vote inserted:"; - - if (mapVotes.count(hash)) { - if (mapVotes[hash].nTime > vote.nTime) { - strError = strprintf("new vote older than existing vote - %s\n", vote.GetHash().ToString()); - LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError); - return false; - } - if (vote.nTime - mapVotes[hash].nTime < BUDGET_VOTE_UPDATE_MIN) { - strError = strprintf("time between votes is too soon - %s - %lli sec < %lli sec\n", vote.GetHash().ToString(), vote.nTime - mapVotes[hash].nTime,BUDGET_VOTE_UPDATE_MIN); - LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError); - return false; - } - strAction = "Existing vote updated:"; - } - - if (vote.nTime > GetTime() + (60 * 60)) { - strError = strprintf("new vote is too far ahead of current time - %s - nTime %lli - Max Time %lli\n", vote.GetHash().ToString(), vote.nTime, GetTime() + (60 * 60)); - LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s\n", strError); - return false; - } - - mapVotes[hash] = vote; - LogPrint("mnbudget", "CFinalizedBudget::AddOrUpdateVote - %s %s\n", strAction.c_str(), vote.GetHash().ToString().c_str()); - return true; -} - -//evaluate if we should vote for this. Masternode only -void CFinalizedBudget::AutoCheck() -{ - LOCK(cs); - - CBlockIndex* pindexPrev = chainActive.Tip(); - if (!pindexPrev) return; - - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - %lli - %d\n", pindexPrev->nHeight, fAutoChecked); - - if (!fMasterNode || fAutoChecked) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck fMasterNode=%d fAutoChecked=%d\n", fMasterNode, fAutoChecked); - return; - } - - // Do this 1 in 4 blocks -- spread out the voting activity on mainnet - // -- this function is only called every fourteenth block, so this is really 1 in 56 blocks - if (rand() % 4 != 0) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - waiting\n"); - return; - } - - fAutoChecked = true; //we only need to check this once - - - if (strBudgetMode == "auto") //only vote for exact matches - { - std::vector vBudgetProposals = budget.GetBudget(); - - - for (unsigned int i = 0; i < vecBudgetPayments.size(); i++) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - nProp %d %s\n", i, vecBudgetPayments[i].nProposalHash.ToString()); - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Payee %d %s\n", i, vecBudgetPayments[i].payee.ToString()); - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - nAmount %d %lli\n", i, vecBudgetPayments[i].nAmount); - } - - for (unsigned int i = 0; i < vBudgetProposals.size(); i++) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - nProp %d %s\n", i, vBudgetProposals[i]->GetHash().ToString()); - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Payee %d %s\n", i, vBudgetProposals[i]->GetPayee().ToString()); - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - nAmount %d %lli\n", i, vBudgetProposals[i]->GetAmount()); - } - - if (vBudgetProposals.size() == 0) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Can't get Budget, aborting\n"); - return; - } - - if (vBudgetProposals.size() != vecBudgetPayments.size()) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Budget length doesn't match. vBudgetProposals.size()=%ld != vecBudgetPayments.size()=%ld\n", - vBudgetProposals.size(), vecBudgetPayments.size()); - return; - } - - - for (unsigned int i = 0; i < vecBudgetPayments.size(); i++) { - if (i > vBudgetProposals.size() - 1) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Proposal size mismatch, i=%d > (vBudgetProposals.size() - 1)=%d\n", i, vBudgetProposals.size() - 1); - return; - } - - if (vecBudgetPayments[i].nProposalHash != vBudgetProposals[i]->GetHash()) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - item #%d doesn't match %s %s\n", i, vecBudgetPayments[i].nProposalHash.ToString(), vBudgetProposals[i]->GetHash().ToString()); - return; - } - - // if(vecBudgetPayments[i].payee != vBudgetProposals[i]->GetPayee()){ -- triggered with false positive - if (vecBudgetPayments[i].payee.ToString() != vBudgetProposals[i]->GetPayee().ToString()) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - item #%d payee doesn't match %s %s\n", i, vecBudgetPayments[i].payee.ToString(), vBudgetProposals[i]->GetPayee().ToString()); - return; - } - - if (vecBudgetPayments[i].nAmount != vBudgetProposals[i]->GetAmount()) { - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - item #%d payee doesn't match %lli %lli\n", i, vecBudgetPayments[i].nAmount, vBudgetProposals[i]->GetAmount()); - return; - } - } - - LogPrint("mnbudget","CFinalizedBudget::AutoCheck - Finalized Budget Matches! Submitting Vote.\n"); - SubmitVote(); - } -} -// If masternode voted for a proposal, but is now invalid -- remove the vote -void CFinalizedBudget::CleanAndRemove(bool fSignatureCheck) -{ - std::map::iterator it = mapVotes.begin(); - - while (it != mapVotes.end()) { - (*it).second.fValid = (*it).second.SignatureValid(fSignatureCheck); - ++it; - } -} - - -CAmount CFinalizedBudget::GetTotalPayout() -{ - CAmount ret = 0; - - for (unsigned int i = 0; i < vecBudgetPayments.size(); i++) { - ret += vecBudgetPayments[i].nAmount; - } - - return ret; -} - -std::string CFinalizedBudget::GetProposals() -{ - LOCK(cs); - std::string ret = ""; - - BOOST_FOREACH (CTxBudgetPayment& budgetPayment, vecBudgetPayments) { - CBudgetProposal* pbudgetProposal = budget.FindProposal(budgetPayment.nProposalHash); - - std::string token = budgetPayment.nProposalHash.ToString(); - - if (pbudgetProposal) token = pbudgetProposal->GetName(); - if (ret == "") { - ret = token; - } else { - ret += "," + token; - } - } - return ret; -} - -std::string CFinalizedBudget::GetStatus() -{ - std::string retBadHashes = ""; - std::string retBadPayeeOrAmount = ""; - - for (int nBlockHeight = GetBlockStart(); nBlockHeight <= GetBlockEnd(); nBlockHeight++) { - CTxBudgetPayment budgetPayment; - if (!GetBudgetPaymentByBlock(nBlockHeight, budgetPayment)) { - LogPrint("mnbudget","CFinalizedBudget::GetStatus - Couldn't find budget payment for block %lld\n", nBlockHeight); - continue; - } - - CBudgetProposal* pbudgetProposal = budget.FindProposal(budgetPayment.nProposalHash); - if (!pbudgetProposal) { - if (retBadHashes == "") { - retBadHashes = "Unknown proposal hash! Check this proposal before voting: " + budgetPayment.nProposalHash.ToString(); - } else { - retBadHashes += "," + budgetPayment.nProposalHash.ToString(); - } - } else { - if (pbudgetProposal->GetPayee() != budgetPayment.payee || pbudgetProposal->GetAmount() != budgetPayment.nAmount) { - if (retBadPayeeOrAmount == "") { - retBadPayeeOrAmount = "Budget payee/nAmount doesn't match our proposal! " + budgetPayment.nProposalHash.ToString(); - } else { - retBadPayeeOrAmount += "," + budgetPayment.nProposalHash.ToString(); - } - } - } - } - - if (retBadHashes == "" && retBadPayeeOrAmount == "") return "OK"; - - return retBadHashes + retBadPayeeOrAmount; -} - -bool CFinalizedBudget::IsValid(std::string& strError, bool fCheckCollateral) -{ - // All(!) finalized budgets have the name "main", so get some additional information about them - std::string strProposals = GetProposals(); - - // Must be the correct block for payment to happen (once a month) - if (nBlockStart % GetBudgetPaymentCycleBlocks() != 0) { - strError = "Invalid BlockStart"; - return false; - } - - // The following 2 checks check the same (basically if vecBudgetPayments.size() > 100) - if (GetBlockEnd() - nBlockStart > 100) { - strError = "Invalid BlockEnd"; - return false; - } - if ((int)vecBudgetPayments.size() > 100) { - strError = "Invalid budget payments count (too many)"; - return false; - } - if (strBudgetName == "") { - strError = "Invalid Budget Name"; - return false; - } - if (nBlockStart == 0) { - strError = "Budget " + strBudgetName + " (" + strProposals + ") Invalid BlockStart == 0"; - return false; - } - if (nFeeTXHash == 0) { - strError = "Budget " + strBudgetName + " (" + strProposals + ") Invalid FeeTx == 0"; - return false; - } - - // Can only pay out 10% of the possible coins (min value of coins) - if (GetTotalPayout() > budget.GetTotalBudget(nBlockStart)) { - strError = "Budget " + strBudgetName + " (" + strProposals + ") Invalid Payout (more than max)"; - return false; - } - - std::string strError2 = ""; - if (fCheckCollateral) { - int nConf = 0; - if (!IsBudgetCollateralValid(nFeeTXHash, GetHash(), strError2, nTime, nConf, true)) { - { - strError = "Budget " + strBudgetName + " Invalid Collateral : " + strError2; - return false; - } - } - } - - // Remove obsolete finalized budgets after some time - - CBlockIndex* pindexPrev = chainActive.Tip(); - if (pindexPrev == NULL) return true; - - // Get start of current budget-cycle - int nCurrentHeight = chainActive.Height(); - int nBlockStart = nCurrentHeight - nCurrentHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); - - // Remove budgets where the last payment (from max. 100) ends before 2 budget-cycles before the current one - int nMaxAge = nBlockStart - (2 * GetBudgetPaymentCycleBlocks()); - - if (GetBlockEnd() < nMaxAge) { - strError = strprintf("Budget " + strBudgetName + " (" + strProposals + ") (ends at block %ld) too old and obsolete", GetBlockEnd()); - return false; - } - - return true; -} - -bool CFinalizedBudget::IsPaidAlready(uint256 nProposalHash, int nBlockHeight) -{ - // Remove budget-payments from former/future payment cycles - map::iterator it = mapPayment_History.begin(); - int nPaidBlockHeight = 0; - uint256 nOldProposalHash; - - for(it = mapPayment_History.begin(); it != mapPayment_History.end(); /* No incrementation needed */ ) { - nPaidBlockHeight = (*it).second; - if((nPaidBlockHeight < GetBlockStart()) || (nPaidBlockHeight > GetBlockEnd())) { - nOldProposalHash = (*it).first; - LogPrint("mnbudget", "CFinalizedBudget::IsPaidAlready - Budget Proposal %s, Block %d from old cycle deleted\n", - nOldProposalHash.ToString().c_str(), nPaidBlockHeight); - mapPayment_History.erase(it++); - } - else { - ++it; - } - } - - // Now that we only have payments from the current payment cycle check if this budget was paid already - if(mapPayment_History.count(nProposalHash) == 0) { - // New proposal payment, insert into map for checks with later blocks from this cycle - mapPayment_History.insert(std::pair(nProposalHash, nBlockHeight)); - LogPrint("mnbudget", "CFinalizedBudget::IsPaidAlready - Budget Proposal %s, Block %d added to payment history\n", - nProposalHash.ToString().c_str(), nBlockHeight); - return false; - } - // This budget was paid already -> reject transaction so it gets paid to a masternode instead - return true; -} - -TrxValidationStatus CFinalizedBudget::IsTransactionValid(const CTransaction& txNew, int nBlockHeight) -{ - TrxValidationStatus transactionStatus = TrxValidationStatus::Invalid; - int nCurrentBudgetPayment = nBlockHeight - GetBlockStart(); - if (nCurrentBudgetPayment < 0) { - LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Invalid block - height: %d start: %d\n", nBlockHeight, GetBlockStart()); - return TrxValidationStatus::Invalid; - } - - if (nCurrentBudgetPayment > (int)vecBudgetPayments.size() - 1) { - LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Invalid block - current budget payment: %d of %d\n", nCurrentBudgetPayment + 1, (int)vecBudgetPayments.size()); - return TrxValidationStatus::Invalid; - } - - bool paid = false; - BOOST_FOREACH (CTxOut out, txNew.vout) { - LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - nCurrentBudgetPayment=%d, payee=%s == out.scriptPubKey=%s, amount=%ld == out.nValue=%ld\n", - nCurrentBudgetPayment, vecBudgetPayments[nCurrentBudgetPayment].payee.ToString().c_str(), out.scriptPubKey.ToString().c_str(), - vecBudgetPayments[nCurrentBudgetPayment].nAmount, out.nValue); - - if (vecBudgetPayments[nCurrentBudgetPayment].payee == out.scriptPubKey && vecBudgetPayments[nCurrentBudgetPayment].nAmount == out.nValue) { - // Check if this proposal was paid already. If so, pay a masternode instead - paid = IsPaidAlready(vecBudgetPayments[nCurrentBudgetPayment].nProposalHash, nBlockHeight); - if(paid) { - LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Double Budget Payment of %d for proposal %d detected. Paying a masternode instead.\n", - vecBudgetPayments[nCurrentBudgetPayment].nAmount, vecBudgetPayments[nCurrentBudgetPayment].nProposalHash.Get32()); - // No matter what we've found before, stop all checks here. In future releases there might be more than one budget payment - // per block, so even if the first one was not paid yet this one disables all budget payments for this block. - transactionStatus = TrxValidationStatus::DoublePayment; - break; - } - else { - transactionStatus = TrxValidationStatus::Valid; - LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Found valid Budget Payment of %d for proposal %d\n", - vecBudgetPayments[nCurrentBudgetPayment].nAmount, vecBudgetPayments[nCurrentBudgetPayment].nProposalHash.Get32()); - } - } - } - - if (transactionStatus == TrxValidationStatus::Invalid) { - CTxDestination address1; - ExtractDestination(vecBudgetPayments[nCurrentBudgetPayment].payee, address1); - - LogPrint("mnbudget","CFinalizedBudget::IsTransactionValid - Missing required payment - %s: %d c: %d\n", - EncodeDestination(address1), vecBudgetPayments[nCurrentBudgetPayment].nAmount, nCurrentBudgetPayment); - } - - return transactionStatus; -} - -void CFinalizedBudget::SubmitVote() -{ - CPubKey pubKeyMasternode; - CKey keyMasternode; - std::string errorMessage; - - if (!obfuScationSigner.SetKey(strMasterNodePrivKey, errorMessage, keyMasternode, pubKeyMasternode)) { - LogPrint("mnbudget","CFinalizedBudget::SubmitVote - Error upon calling SetKey\n"); - return; - } - - CFinalizedBudgetVote vote(activeMasternode.vin, GetHash()); - if (!vote.Sign(keyMasternode, pubKeyMasternode)) { - LogPrint("mnbudget","CFinalizedBudget::SubmitVote - Failure to sign."); - return; - } - - std::string strError = ""; - if (budget.UpdateFinalizedBudget(vote, NULL, strError)) { - LogPrint("mnbudget","CFinalizedBudget::SubmitVote - new finalized budget vote - %s\n", vote.GetHash().ToString()); - - budget.mapSeenFinalizedBudgetVotes.insert(make_pair(vote.GetHash(), vote)); - vote.Relay(); - } else { - LogPrint("mnbudget","CFinalizedBudget::SubmitVote : Error submitting vote - %s\n", strError); - } -} - -CFinalizedBudgetBroadcast::CFinalizedBudgetBroadcast() -{ - strBudgetName = ""; - nBlockStart = 0; - vecBudgetPayments.clear(); - mapVotes.clear(); - vchSig.clear(); - nFeeTXHash = 0; -} - -CFinalizedBudgetBroadcast::CFinalizedBudgetBroadcast(const CFinalizedBudget& other) -{ - strBudgetName = other.strBudgetName; - nBlockStart = other.nBlockStart; - BOOST_FOREACH (CTxBudgetPayment out, other.vecBudgetPayments) - vecBudgetPayments.push_back(out); - mapVotes = other.mapVotes; - nFeeTXHash = other.nFeeTXHash; -} - -CFinalizedBudgetBroadcast::CFinalizedBudgetBroadcast(std::string strBudgetNameIn, int nBlockStartIn, std::vector vecBudgetPaymentsIn, uint256 nFeeTXHashIn) -{ - strBudgetName = strBudgetNameIn; - nBlockStart = nBlockStartIn; - BOOST_FOREACH (CTxBudgetPayment out, vecBudgetPaymentsIn) - vecBudgetPayments.push_back(out); - mapVotes.clear(); - nFeeTXHash = nFeeTXHashIn; -} - -void CFinalizedBudgetBroadcast::Relay() -{ - CInv inv(MSG_BUDGET_FINALIZED, GetHash()); - RelayInv(inv); -} - -CFinalizedBudgetVote::CFinalizedBudgetVote() -{ - vin = CTxIn(); - nBudgetHash = 0; - nTime = 0; - vchSig.clear(); - fValid = true; - fSynced = false; -} - -CFinalizedBudgetVote::CFinalizedBudgetVote(CTxIn vinIn, uint256 nBudgetHashIn) -{ - vin = vinIn; - nBudgetHash = nBudgetHashIn; - nTime = GetAdjustedTime(); - vchSig.clear(); - fValid = true; - fSynced = false; -} - -void CFinalizedBudgetVote::Relay() -{ - CInv inv(MSG_BUDGET_FINALIZED_VOTE, GetHash()); - RelayInv(inv); -} - -bool CFinalizedBudgetVote::Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode) -{ - // Choose coins to use - CPubKey pubKeyCollateralAddress; - CKey keyCollateralAddress; - - std::string errorMessage; - std::string strMessage = vin.prevout.ToStringShort() + nBudgetHash.ToString() + boost::lexical_cast(nTime); - - if (!obfuScationSigner.SignMessage(strMessage, errorMessage, vchSig, keyMasternode)) { - LogPrint("mnbudget","CFinalizedBudgetVote::Sign - Error upon calling SignMessage"); - return false; - } - - if (!obfuScationSigner.VerifyMessage(pubKeyMasternode, vchSig, strMessage, errorMessage)) { - LogPrint("mnbudget","CFinalizedBudgetVote::Sign - Error upon calling VerifyMessage"); - return false; - } - - return true; -} - -bool CFinalizedBudgetVote::SignatureValid(bool fSignatureCheck) -{ - std::string errorMessage; - - std::string strMessage = vin.prevout.ToStringShort() + nBudgetHash.ToString() + boost::lexical_cast(nTime); - - CMasternode* pmn = mnodeman.Find(vin); - - if (pmn == NULL) { - LogPrint("mnbudget","CFinalizedBudgetVote::SignatureValid() - Unknown Masternode %s\n", strMessage); - return false; - } - - if (!fSignatureCheck) return true; - - if (!obfuScationSigner.VerifyMessage(pmn->pubKeyMasternode, vchSig, strMessage, errorMessage)) { - LogPrint("mnbudget","CFinalizedBudgetVote::SignatureValid() - Verify message failed %s %s\n", strMessage, errorMessage); - return false; - } - - return true; -} - -std::string CBudgetManager::ToString() const -{ - std::ostringstream info; - - info << "Proposals: " << (int)mapProposals.size() << ", Budgets: " << (int)mapFinalizedBudgets.size() << ", Seen Budgets: " << (int)mapSeenMasternodeBudgetProposals.size() << ", Seen Budget Votes: " << (int)mapSeenMasternodeBudgetVotes.size() << ", Seen Final Budgets: " << (int)mapSeenFinalizedBudgets.size() << ", Seen Final Budget Votes: " << (int)mapSeenFinalizedBudgetVotes.size(); - - return info.str(); -} From 158ed8ac8cf20f4b92f056f0c37c4fdac7989317 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:35:40 -0400 Subject: [PATCH 164/469] Delete masternode-budget.h --- src/masternode-budget.h | 622 ---------------------------------------- 1 file changed, 622 deletions(-) delete mode 100644 src/masternode-budget.h diff --git a/src/masternode-budget.h b/src/masternode-budget.h deleted file mode 100644 index 9048dee2..00000000 --- a/src/masternode-budget.h +++ /dev/null @@ -1,622 +0,0 @@ -// Copyright (c) 2014-2015 The Dash developers -// Copyright (c) 2015-2017 The PIVX developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef MASTERNODE_BUDGET_H -#define MASTERNODE_BUDGET_H - -#include "base58.h" -#include "init.h" -#include "key.h" -#include "validation.h" -#include "governance.h" -#include "net.h" -#include "sync.h" -#include "util.h" -#include - -using namespace std; - -extern CCriticalSection cs_budget; - -class CBudgetManager; -class CFinalizedBudgetBroadcast; -class CFinalizedBudget; -class CBudgetProposal; -class CBudgetProposalBroadcast; -class CTxBudgetPayment; - -#define VOTE_ABSTAIN 0 -#define VOTE_YES 1 -#define VOTE_NO 2 - -enum class TrxValidationStatus { - Invalid, /** Transaction verification failed */ - Valid, /** Transaction successfully verified */ - DoublePayment, /** Transaction successfully verified, but includes a double-budget-payment */ - VoteThreshold /** If not enough masternodes have voted on a finalized budget */ -}; - -static const int64_t BUDGET_VOTE_UPDATE_MIN = 60 * 60; - -extern std::vector vecImmatureBudgetProposals; -extern std::vector vecImmatureFinalizedBudgets; - -static map mapPayment_History; - -extern CBudgetManager budget; -void DumpBudgets(); - -// Define amount of blocks in budget payment cycle -int GetBudgetPaymentCycleBlocks(); - -// Determine available allocation for a given superblock -CAmount GetAvailableBudget(int nHeight); - -//Check the collateral transaction for the budget proposal/finalized budget -bool IsBudgetCollateralValid(uint256 nTxCollateralHash, uint256 nExpectedHash, std::string& strError, int64_t& nTime, int& nConf, bool fBudgetFinalization = false); - -// Get the budget collateral amount for a block height -CAmount GetBudgetSystemCollateralAmount(int nHeight); - -// -// CBudgetVote - Allow a masternode node to vote and broadcast throughout the network -// - -class CBudgetVote -{ -public: - bool fValid; //if the vote is currently valid / counted - bool fSynced; //if we've sent this to our peers - CTxIn vin; - uint256 nProposalHash; - int nVote; - int64_t nTime; - std::vector vchSig; - - CBudgetVote(); - CBudgetVote(CTxIn vin, uint256 nProposalHash, int nVoteIn); - - bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode); - bool SignatureValid(bool fSignatureCheck); - void Relay(); - - std::string GetVoteString() - { - std::string ret = "ABSTAIN"; - if (nVote == VOTE_YES) ret = "YES"; - if (nVote == VOTE_NO) ret = "NO"; - return ret; - } - - uint256 GetHash() - { - CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); - ss << vin; - ss << nProposalHash; - ss << nVote; - ss << nTime; - return ss.GetHash(); - } - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) - { - READWRITE(vin); - READWRITE(nProposalHash); - READWRITE(nVote); - READWRITE(nTime); - READWRITE(vchSig); - } -}; - -// -// CFinalizedBudgetVote - Allow a masternode node to vote and broadcast throughout the network -// - -class CFinalizedBudgetVote -{ -public: - bool fValid; //if the vote is currently valid / counted - bool fSynced; //if we've sent this to our peers - CTxIn vin; - uint256 nBudgetHash; - int64_t nTime; - std::vector vchSig; - - CFinalizedBudgetVote(); - CFinalizedBudgetVote(CTxIn vinIn, uint256 nBudgetHashIn); - - bool Sign(CKey& keyMasternode, CPubKey& pubKeyMasternode); - bool SignatureValid(bool fSignatureCheck); - void Relay(); - - uint256 GetHash() - { - CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); - ss << vin; - ss << nBudgetHash; - ss << nTime; - return ss.GetHash(); - } - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) - { - READWRITE(vin); - READWRITE(nBudgetHash); - READWRITE(nTime); - READWRITE(vchSig); - } -}; - -/** Save Budget Manager (budget.dat) - */ -class CBudgetDB -{ -private: - boost::filesystem::path pathDB; - std::string strMagicMessage; - -public: - enum ReadResult { - Ok, - FileError, - HashReadError, - IncorrectHash, - IncorrectMagicMessage, - IncorrectMagicNumber, - IncorrectFormat - }; - - CBudgetDB(); - bool Write(const CBudgetManager& objToSave); - ReadResult Read(CBudgetManager& objToLoad, bool fDryRun = false); -}; - - -// -// Budget Manager : Contains all proposals for the budget -// -class CBudgetManager -{ -private: - //hold txes until they mature enough to use - // XX42 map mapCollateral; - map mapCollateralTxids; - -public: - // critical section to protect the inner data structures - mutable CCriticalSection cs; - - // keep track of the scanning errors I've seen - map mapProposals; - map mapFinalizedBudgets; - - std::map mapSeenMasternodeBudgetProposals; - std::map mapSeenMasternodeBudgetVotes; - std::map mapOrphanMasternodeBudgetVotes; - std::map mapSeenFinalizedBudgets; - std::map mapSeenFinalizedBudgetVotes; - std::map mapOrphanFinalizedBudgetVotes; - - CBudgetManager() - { - mapProposals.clear(); - mapFinalizedBudgets.clear(); - } - - void ClearSeen() - { - mapSeenMasternodeBudgetProposals.clear(); - mapSeenMasternodeBudgetVotes.clear(); - mapSeenFinalizedBudgets.clear(); - mapSeenFinalizedBudgetVotes.clear(); - } - - int sizeFinalized() { return (int)mapFinalizedBudgets.size(); } - int sizeProposals() { return (int)mapProposals.size(); } - - void ResetSync(); - void MarkSynced(); - void Sync(CNode* node, uint256 nProp, bool fPartial = false); - - void Calculate(); - void ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv); - void NewBlock(); - CBudgetProposal* FindProposal(const std::string& strProposalName); - CBudgetProposal* FindProposal(uint256 nHash); - CFinalizedBudget* FindFinalizedBudget(uint256 nHash); - std::pair GetVotes(std::string strProposalName); - - CAmount GetTotalBudget(int nHeight); - std::vector GetBudget(); - std::vector GetAllProposals(); - std::vector GetFinalizedBudgets(); - bool IsBudgetPaymentBlock(int nBlockHeight); - bool AddProposal(CBudgetProposal& budgetProposal); - bool AddFinalizedBudget(CFinalizedBudget& finalizedBudget); - void SubmitFinalBudget(); - - bool UpdateProposal(CBudgetVote& vote, CNode* pfrom, std::string& strError); - bool UpdateFinalizedBudget(CFinalizedBudgetVote& vote, CNode* pfrom, std::string& strError); - bool PropExists(uint256 nHash); - TrxValidationStatus IsTransactionValid(const CTransaction& txNew, int nBlockHeight); - bool IsPaidAlready(uint256 nProposalHash, int nBlockHeight); - std::string GetRequiredPaymentsString(int nBlockHeight); - void FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, bool fProofOfStake); - - void CheckOrphanVotes(); - void Clear() - { - LOCK(cs); - - LogPrintf("Budget object cleared\n"); - mapProposals.clear(); - mapFinalizedBudgets.clear(); - mapSeenMasternodeBudgetProposals.clear(); - mapSeenMasternodeBudgetVotes.clear(); - mapSeenFinalizedBudgets.clear(); - mapSeenFinalizedBudgetVotes.clear(); - mapOrphanMasternodeBudgetVotes.clear(); - mapOrphanFinalizedBudgetVotes.clear(); - } - void CheckAndRemove(); - std::string ToString() const; - - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) - { - READWRITE(mapSeenMasternodeBudgetProposals); - READWRITE(mapSeenMasternodeBudgetVotes); - READWRITE(mapSeenFinalizedBudgets); - READWRITE(mapSeenFinalizedBudgetVotes); - READWRITE(mapOrphanMasternodeBudgetVotes); - READWRITE(mapOrphanFinalizedBudgetVotes); - - READWRITE(mapProposals); - READWRITE(mapFinalizedBudgets); - } -}; - - -class CTxBudgetPayment -{ -public: - uint256 nProposalHash; - CScript payee; - CAmount nAmount; - - CTxBudgetPayment() - { - payee = CScript(); - nAmount = 0; - nProposalHash = 0; - } - - ADD_SERIALIZE_METHODS; - - //for saving to the serialized db - template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) - { - READWRITE(payee); - READWRITE(nAmount); - READWRITE(nProposalHash); - } -}; - -// -// Finalized Budget : Contains the suggested proposals to pay on a given block -// - -class CFinalizedBudget -{ -private: - // critical section to protect the inner data structures - mutable CCriticalSection cs; - bool fAutoChecked; //If it matches what we see, we'll auto vote for it (masternode only) - -public: - bool fValid; - std::string strBudgetName; - int nBlockStart; - std::vector vecBudgetPayments; - map mapVotes; - uint256 nFeeTXHash; - int64_t nTime; - - CFinalizedBudget(); - CFinalizedBudget(const CFinalizedBudget& other); - - void CleanAndRemove(bool fSignatureCheck); - bool AddOrUpdateVote(CFinalizedBudgetVote& vote, std::string& strError); - double GetScore(); - bool HasMinimumRequiredSupport(); - - bool IsValid(std::string& strError, bool fCheckCollateral = true); - - std::string GetName() { return strBudgetName; } - std::string GetProposals(); - int GetBlockStart() { return nBlockStart; } - int GetBlockEnd() { return nBlockStart + (int)(vecBudgetPayments.size() - 1); } - int GetVoteCount() { return (int)mapVotes.size(); } - bool IsPaidAlready(uint256 nProposalHash, int nBlockHeight); - TrxValidationStatus IsTransactionValid(const CTransaction& txNew, int nBlockHeight); - bool GetBudgetPaymentByBlock(int64_t nBlockHeight, CTxBudgetPayment& payment) - { - LOCK(cs); - - int i = nBlockHeight - GetBlockStart(); - if (i < 0) return false; - if (i > (int)vecBudgetPayments.size() - 1) return false; - payment = vecBudgetPayments[i]; - return true; - } - bool GetPayeeAndAmount(int64_t nBlockHeight, CScript& payee, CAmount& nAmount) - { - LOCK(cs); - - int i = nBlockHeight - GetBlockStart(); - if (i < 0) return false; - if (i > (int)vecBudgetPayments.size() - 1) return false; - payee = vecBudgetPayments[i].payee; - nAmount = vecBudgetPayments[i].nAmount; - return true; - } - - //check to see if we should vote on this - void AutoCheck(); - //total odin paid out by this budget - CAmount GetTotalPayout(); - //vote on this finalized budget as a masternode - void SubmitVote(); - - //checks the hashes to make sure we know about them - string GetStatus(); - - uint256 GetHash() - { - CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); - ss << strBudgetName; - ss << nBlockStart; - ss << vecBudgetPayments; - - uint256 h1 = ss.GetHash(); - return h1; - } - - ADD_SERIALIZE_METHODS; - - //for saving to the serialized db - template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) - { - READWRITE(LIMITED_STRING(strBudgetName, 20)); - READWRITE(nFeeTXHash); - READWRITE(nTime); - READWRITE(nBlockStart); - READWRITE(vecBudgetPayments); - READWRITE(fAutoChecked); - - READWRITE(mapVotes); - } -}; - -// FinalizedBudget are cast then sent to peers with this object, which leaves the votes out -class CFinalizedBudgetBroadcast : public CFinalizedBudget -{ -private: - std::vector vchSig; - -public: - CFinalizedBudgetBroadcast(); - CFinalizedBudgetBroadcast(const CFinalizedBudget& other); - CFinalizedBudgetBroadcast(std::string strBudgetNameIn, int nBlockStartIn, std::vector vecBudgetPaymentsIn, uint256 nFeeTXHashIn); - - void swap(CFinalizedBudgetBroadcast& first, CFinalizedBudgetBroadcast& second) // nothrow - { - // enable ADL (not necessary in our case, but good practice) - using std::swap; - - // by swapping the members of two classes, - // the two classes are effectively swapped - swap(first.strBudgetName, second.strBudgetName); - swap(first.nBlockStart, second.nBlockStart); - first.mapVotes.swap(second.mapVotes); - first.vecBudgetPayments.swap(second.vecBudgetPayments); - swap(first.nFeeTXHash, second.nFeeTXHash); - swap(first.nTime, second.nTime); - } - - CFinalizedBudgetBroadcast& operator=(CFinalizedBudgetBroadcast from) - { - swap(*this, from); - return *this; - } - - void Relay(); - - ADD_SERIALIZE_METHODS; - - //for propagating messages - template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) - { - //for syncing with other clients - READWRITE(LIMITED_STRING(strBudgetName, 20)); - READWRITE(nBlockStart); - READWRITE(vecBudgetPayments); - READWRITE(nFeeTXHash); - } -}; - - -// -// Budget Proposal : Contains the masternode votes for each budget -// - -class CBudgetProposal -{ -private: - // critical section to protect the inner data structures - mutable CCriticalSection cs; - CAmount nAlloted; - -public: - bool fValid; - std::string strProposalName; - - /* - json object with name, short-description, long-description, pdf-url and any other info - This allows the proposal website to stay 100% decentralized - */ - std::string strURL; - int nBlockStart; - int nBlockEnd; - CAmount nAmount; - CScript address; - int64_t nTime; - uint256 nFeeTXHash; - - map mapVotes; - //cache object - - CBudgetProposal(); - CBudgetProposal(const CBudgetProposal& other); - CBudgetProposal(std::string strProposalNameIn, std::string strURLIn, int nBlockStartIn, int nBlockEndIn, CScript addressIn, CAmount nAmountIn, uint256 nFeeTXHashIn); - - void Calculate(); - bool AddOrUpdateVote(CBudgetVote& vote, std::string& strError); - bool HasMinimumRequiredSupport(); - std::pair GetVotes(); - - bool IsValid(std::string& strError, bool fCheckCollateral = true); - - bool IsEstablished() - { - // Proposals must be at least a day old to make it into a budget - if (Params().NetworkID() == CBaseChainParams::MAIN) return (nTime < GetTime() - (60 * 60 * 24)); - - // For testing purposes - 5 minutes - return (nTime < GetTime() - (60 * 5)); - } - - std::string GetName() { return strProposalName; } - std::string GetURL() { return strURL; } - int GetBlockStart() { return nBlockStart; } - int GetBlockEnd() { return nBlockEnd; } - CScript GetPayee() { return address; } - int GetTotalPaymentCount(); - int GetRemainingPaymentCount(); - int GetBlockStartCycle(); - int GetBlockCurrentCycle(); - int GetBlockEndCycle(); - double GetRatio(); - int GetYeas(); - int GetNays(); - int GetAbstains(); - CAmount GetAmount() { return nAmount; } - void SetAllotted(CAmount nAllotedIn) { nAlloted = nAllotedIn; } - CAmount GetAllotted() { return nAlloted; } - - void CleanAndRemove(bool fSignatureCheck); - - uint256 GetHash() - { - CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); - ss << strProposalName; - ss << strURL; - ss << nBlockStart; - ss << nBlockEnd; - ss << nAmount; - ss << address; - uint256 h1 = ss.GetHash(); - - return h1; - } - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) - { - //for syncing with other clients - READWRITE(LIMITED_STRING(strProposalName, 20)); - READWRITE(LIMITED_STRING(strURL, 64)); - READWRITE(nTime); - READWRITE(nBlockStart); - READWRITE(nBlockEnd); - READWRITE(nAmount); - READWRITE(address); - READWRITE(nTime); - READWRITE(nFeeTXHash); - - //for saving to the serialized db - READWRITE(mapVotes); - } -}; - -// Proposals are cast then sent to peers with this object, which leaves the votes out -class CBudgetProposalBroadcast : public CBudgetProposal -{ -public: - CBudgetProposalBroadcast() : CBudgetProposal() {} - CBudgetProposalBroadcast(const CBudgetProposal& other) : CBudgetProposal(other) {} - CBudgetProposalBroadcast(const CBudgetProposalBroadcast& other) : CBudgetProposal(other) {} - CBudgetProposalBroadcast(std::string strProposalNameIn, std::string strURLIn, int nPaymentCount, CScript addressIn, CAmount nAmountIn, int nBlockStartIn, uint256 nFeeTXHashIn); - - void swap(CBudgetProposalBroadcast& first, CBudgetProposalBroadcast& second) // nothrow - { - // enable ADL (not necessary in our case, but good practice) - using std::swap; - - // by swapping the members of two classes, - // the two classes are effectively swapped - swap(first.strProposalName, second.strProposalName); - swap(first.nBlockStart, second.nBlockStart); - swap(first.strURL, second.strURL); - swap(first.nBlockEnd, second.nBlockEnd); - swap(first.nAmount, second.nAmount); - swap(first.address, second.address); - swap(first.nTime, second.nTime); - swap(first.nFeeTXHash, second.nFeeTXHash); - first.mapVotes.swap(second.mapVotes); - } - - CBudgetProposalBroadcast& operator=(CBudgetProposalBroadcast from) - { - swap(*this, from); - return *this; - } - - void Relay(); - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) - { - //for syncing with other clients - - READWRITE(LIMITED_STRING(strProposalName, 20)); - READWRITE(LIMITED_STRING(strURL, 64)); - READWRITE(nTime); - READWRITE(nBlockStart); - READWRITE(nBlockEnd); - READWRITE(nAmount); - READWRITE(address); - READWRITE(nFeeTXHash); - } -}; - - -#endif From 8ad1e7767742115c8d975694e409116fb204db96 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:36:37 -0400 Subject: [PATCH 165/469] Update Makefile.am --- src/Makefile.am | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 9a02f301..ac252b97 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -178,7 +178,6 @@ BITCOIN_CORE_H = \ llmq/quorums_signing.h \ llmq/quorums_signing_shares.h \ llmq/quorums_utils.h \ - masternode-budget.h \ masternode-meta.h \ masternode-payments.h \ masternode-sync.h \ @@ -299,7 +298,6 @@ libhelpthehomeless_server_a_SOURCES = \ llmq/quorums_signing.cpp \ llmq/quorums_signing_shares.cpp \ llmq/quorums_utils.cpp \ - masternode-budget.cpp \ masternode-meta.cpp \ masternode-payments.cpp \ masternode-sync.cpp \ From bd6c28ab72299906462c5a8a6baec334f021322e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:37:27 -0400 Subject: [PATCH 166/469] Update Makefile.qt.include --- src/Makefile.qt.include | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 6ce7f963..49c453a9 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -46,7 +46,6 @@ QT_FORMS_UI = \ qt/forms/optionsdialog.ui \ qt/forms/overviewpage.ui \ qt/forms/privatesendpage.ui \ - qt/forms/proposaldialog.ui \ qt/forms/receivecoinsdialog.ui \ qt/forms/receiverequestdialog.ui \ qt/forms/debugwindow.ui \ @@ -83,7 +82,6 @@ QT_MOC_CPP = \ qt/moc_optionsmodel.cpp \ qt/moc_overviewpage.cpp \ qt/moc_privatesendpage.cpp \ - qt/moc_proposaldialog.cpp \ qt/moc_peertablemodel.cpp \ qt/moc_paymentserver.cpp \ qt/moc_qrdialog.cpp \ @@ -165,7 +163,6 @@ BITCOIN_QT_H = \ qt/paymentserver.h \ qt/peertablemodel.h \ qt/platformstyle.h \ - qt/proposaldialog.h \ qt/qrdialog.h \ qt/qvalidatedlineedit.h \ qt/qvaluecombobox.h \ @@ -487,7 +484,6 @@ BITCOIN_QT_BASE_CPP = \ qt/optionsmodel.cpp \ qt/peertablemodel.cpp \ qt/platformstyle.cpp \ - qt/proposaldialog.cpp \ qt/qvalidatedlineedit.cpp \ qt/qvaluecombobox.cpp \ qt/rpcconsole.cpp \ @@ -511,7 +507,6 @@ BITCOIN_QT_WALLET_CPP = \ qt/openuridialog.cpp \ qt/overviewpage.cpp \ qt/privatesendpage.cpp \ - qt/proposaldialog.cpp \ qt/paymentrequestplus.cpp \ qt/paymentserver.cpp \ qt/qrdialog.cpp \ From f3d57c9a4adff1ca8852fa73ecbf4e8b912daeea Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:38:53 -0400 Subject: [PATCH 167/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index a6f02cb7..379c7ced 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1049,15 +1049,6 @@ void BitcoinGUI::openClicked() } } -void BitcoinGUI::createProposal() -{ - ProposalDialog dlg(ProposalDialog::PrepareProposal, this); - if (QDialog::Accepted == dlg.exec()) - { - refreshProposals(true); - } -} - void BitcoinGUI::openDonate() { openExternalURL("https://helpthehomelessworldwide.org/donate"); From 3c7cfe43f2d3b80b74c7d46762919aa8bc40661b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:39:19 -0400 Subject: [PATCH 168/469] Update bitcoingui.h --- src/qt/bitcoingui.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 683d660c..6332b864 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -264,7 +264,6 @@ private Q_SLOTS: /** Open external URL */ void openDonate(); void openExternalURL(QString url = ""); - void createProposal(); /** Show debug window and set focus to the appropriate tab */ void showInfo(); From 9ba72c9ebde11cd242808549c1cbde3f14e47100 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:55:04 -0400 Subject: [PATCH 169/469] Create proposaldialog.cpp --- src/qt/proposaldialog.cpp | 297 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 297 insertions(+) create mode 100644 src/qt/proposaldialog.cpp diff --git a/src/qt/proposaldialog.cpp b/src/qt/proposaldialog.cpp new file mode 100644 index 00000000..b34986e5 --- /dev/null +++ b/src/qt/proposaldialog.cpp @@ -0,0 +1,297 @@ +// Copyright (c) 2017-2018 The Bulwark Developers +// Copyright (c) 2019 The Phore Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#if defined(HAVE_CONFIG_H) +#include +#endif + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +ProposalDialog::ProposalDialog(Mode mode, QWidget* parent) : QDialog(parent), ui(new Ui::ProposalDialog), mapper(0), mode(mode), counter(0) +{ + ui->setupUi(this); + + switch (mode) { + case PrepareProposal: + setWindowTitle(tr("Prepare Proposal")); + ui->confirmLabel->setVisible(false); + ui->hashEdit->setVisible(false); + ui->hashLabel->setVisible(false); + break; + case SubmitProposal: + setWindowTitle(tr("Submit Proposal")); + ui->confirmLabel->setVisible(true); + ui->hashEdit->setVisible(true); + ui->hashLabel->setVisible(true); + break; + } + + ui->nameEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->nameEdit->setPlaceholderText(tr("Provide a proposal name, keep it short")); + ui->nameEdit->setToolTip(tr("Provide a proposal name, keep it short")); + + ui->urlEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->urlEdit->setPlaceholderText(tr("Valid http or https URL (include http:// or https://")); + ui->urlEdit->setToolTip(tr("Valid http or https URL (include http:// or https://")); + + ui->paymentsEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->paymentsEdit->setPlaceholderText(tr("How many monthly payments, 1 per budget cycle")); + ui->paymentsEdit->setToolTip(tr("How many monthly payments, 1 per budget cycle")); + ui->paymentsEdit->setValidator(new QIntValidator(1, 100)); + + ui->blockEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->blockEdit->setPlaceholderText(tr("The governance budget block for the desired cycle (default to next)")); + ui->blockEdit->setToolTip(tr("The governance budget block for the desired cycle (default to next)")); + ui->blockEdit->setValidator(new QIntValidator(1, INT_MAX)); + + ui->addressEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->addressEdit->setPlaceholderText(tr("The public ODIN address that will receive the funds")); + ui->addressEdit->setToolTip(tr("The public ODIN address that will receive the funds")); + + ui->amountEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->amountEdit->setPlaceholderText(tr("The amount to be paid per month or cycle")); + ui->amountEdit->setToolTip(tr("The amount to be paid per month or cycle")); + ui->amountEdit->setValidator(new QIntValidator(10, INT_MAX)); + + ui->hashEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->hashEdit->setPlaceholderText(tr("The TXID of the proposal hash, must be confirmed before use")); + ui->hashEdit->setToolTip(tr("The TXID of the proposal hash, must be confirmed before use")); + + ui->confirmLabel->setWordWrap(true); + ui->infoLabel->setWordWrap(true); + + // Load next superblock number. + CBlockIndex* pindexPrev = chainActive.Tip(); + if (!pindexPrev) return; + int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); + ui->blockEdit->setText(QString::number(nNext)); + + // Start periodic updates to handle submit block depth validation. + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(checkProposalTX())); +} + +ProposalDialog::~ProposalDialog() +{ + delete ui; +} + +void ProposalDialog::prepareProposal() +{ + std::string strError = ""; + + if (pwalletMain->IsLocked()) + { + strError = "Error: Please enter the wallet passphrase with walletpassphrase first."; + QMessageBox::critical(this, "Prepare Proposal Error", QString::fromStdString(strError)); + return; + } + + std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); + std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); + int nPaymentCount = ui->paymentsEdit->text().toInt(); + int nBlockStart = ui->blockEdit->text().toInt(); + std::string address = ui->addressEdit->text().toStdString(); + CScript scriptPubKey = GetScriptForDestination(DecodeDestination(address)); + CAmount nAmount = AmountFromValue(ui->amountEdit->text().toInt()); + + //************************************************************************* + + // create the proposal incase we're the first to make it + CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, 0); + std::string err; + if (!budgetProposalBroadcast.IsValid(err, false)) strError = "Proposal is not valid - " + budgetProposalBroadcast.GetHash().ToString() + " - " + err; + + bool useIX = false; + if (strError.empty() && !pwalletMain->GetBudgetSystemCollateralTX(wtx, budgetProposalBroadcast.GetHash(), useIX)) + { + strError = "Error making collateral transaction for proposal. Please check your wallet balance."; + } + + // make our change address + CReserveKey reservekey(pwalletMain); + // send the tx to the network + if (strError.empty() && !pwalletMain->CommitTransaction(wtx, reservekey, useIX ? "ix" : "tx")) + { + strError = "Unable to commit proposal transaction."; + } + + if (!strError.empty()) + { + std::cout << strError << std::endl; + QMessageBox::critical(this, "Prepare Proposal Error", QString::fromStdString(strError)); + return; + } + + // update the local view with submit view + ui->cancelButton->setDisabled(true); + ui->nameEdit->setDisabled(true); + ui->urlEdit->setDisabled(true); + ui->paymentsEdit->setDisabled(true); + ui->blockEdit->setDisabled(true); + ui->addressEdit->setDisabled(true); + ui->amountEdit->setDisabled(true); + ui->hashEdit->setDisabled(true); + + ui->acceptButton->setDisabled(true); + ui->acceptButton->setText(tr("Waiting...")); + + ui->confirmLabel->setVisible(true); + ui->confirmLabel->setText(QString::fromStdString("Waiting for confirmations...")); + + ui->hashEdit->setText(QString::fromStdString(wtx.GetHash().ToString())); + ui->hashEdit->setVisible(true); + ui->hashLabel->setVisible(true); + + mode = SubmitProposal; + setWindowTitle(tr("Submit Proposal")); + + timer->start(1000); + counter = chainActive.Tip()->nHeight + 1; +} + +void ProposalDialog::submitProposal() +{ + std::string strError = ""; + + std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); + std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); + int nPaymentCount = ui->paymentsEdit->text().toInt(); + int nBlockStart = ui->blockEdit->text().toInt(); + std::string address = ui->addressEdit->text().toStdString(); + CScript scriptPubKey = GetScriptForDestination(DecodeDestination(address)); + CAmount nAmount = AmountFromValue(ui->amountEdit->text().toInt()); + uint256 hash = ParseHashV(ui->hashEdit->text().toStdString(), "parameter 1"); + + //************************************************************************* + + // create the proposal incase we're the first to make it + int nConf = 0; + std::string err = ""; + CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, hash); + if (!IsBudgetCollateralValid(hash, budgetProposalBroadcast.GetHash(), err, budgetProposalBroadcast.nTime, nConf)) + { + strError = "Proposal FeeTX is not valid - " + hash.ToString() + " - " + err; + } + + if (strError.empty() && !budget.AddProposal(budgetProposalBroadcast)) strError = "Invalid proposal, see debug.log for details."; + + if (!strError.empty()) + { + std::cout << strError << std::endl; + QMessageBox::critical(this, tr("Submit Proposal Error"), QString::fromStdString(strError)); + return; + } + + budget.mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast)); + budgetProposalBroadcast.Relay(); + + this->accept(); +} + +bool ProposalDialog::validateProposal() +{ + std::string strError = ""; + + if (!masternodeSync.IsBlockchainSynced()) strError = "Must wait for client to sync with masternode network. Try again in a minute or so."; + + std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); + if (strProposalName.size() > 20) strError = "Invalid proposal name, limit of 20 characters."; + + std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); + if (strURL.size() > 64) strError = "Invalid url, limit of 64 characters."; + + int nPaymentCount = ui->paymentsEdit->text().toInt(); + if (nPaymentCount < 1) strError = "Invalid payment count, must be more than zero."; + + // Start must be in the next budget cycle + int nBlockMin = 0; + CBlockIndex* pindexPrev = chainActive.Tip(); + if (pindexPrev != NULL) nBlockMin = pindexPrev->nHeight - pindexPrev->nHeight % consensusParams.nBudgetPaymentsCycleBlocks + consensusParams.nBudgetPaymentsCycleBlocks; + + int nBlockStart = ui->blockEdit->text().toInt(); + if (nBlockStart < nBlockMin) strError = "Invalid block start, must be more than current height."; + if (nBlockStart % consensusParams.nBudgetPaymentsCycleBlocks != 0) + { + int nNext = pindexPrev->nHeight - pindexPrev->nHeight % consensusParams.nBudgetPaymentsCycleBlocks + consensusParams.nBudgetPaymentsCycleBlocks; + strError = strprintf("Invalid block start - must be a budget cycle block. Next valid block: %d", nNext); + } + + int nBlockEnd = nBlockStart + (consensusParams.nBudgetPaymentsCycleBlocks * nPaymentCount); // End must be AFTER current cycle + if (nBlockEnd < pindexPrev->nHeight) strError = "Invalid ending block, starting block + (payment_cycle*payments) must be more than current height."; + + std::string address = ui->addressEdit->text().toStdString(); + if (!IsValidDestinationString(address)) strError = "Invalid ODIN address"; + + if (!strError.empty()) + { + QMessageBox::critical(this, tr("Submit Proposal Error"), QString::fromStdString(strError)); + return false; + } + + return true; +} + +void ProposalDialog::checkProposalTX() +{ + if (mode != SubmitProposal) return; + + int nConf = Params().BudgetFeeConfirmations(); + int nDepth = (chainActive.Tip()->nHeight + 1) - counter; + if (nDepth > nConf) + { + ui->acceptButton->setDisabled(false); + ui->acceptButton->setText("Finish Proposal"); + ui->confirmLabel->setText(tr("Click on Finish Proposal to complete the proposal and start voting.")); + + timer->stop(); + } + else if (nDepth == nConf) + { + ui->confirmLabel->setText(QString::fromStdString("Waiting for final confirmation...")); + } + else if (nDepth > 0) + { + ui->confirmLabel->setText(QString::fromStdString(strprintf("Currently %d of %d confirmations...", nDepth, (nConf + 1)).c_str())); + } +} + +void ProposalDialog::on_acceptButton_clicked() +{ + if (!validateProposal()) return; + + if (mode == PrepareProposal) + { + prepareProposal(); + } + else if (mode == SubmitProposal) + { + submitProposal(); + } +} + +void ProposalDialog::on_cancelButton_clicked() +{ + this->reject(); +} From 0211e958587763aaaf998865a643573cfb4dac21 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:55:48 -0400 Subject: [PATCH 170/469] Create proposaldialog.h --- src/qt/proposaldialog.h | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/qt/proposaldialog.h diff --git a/src/qt/proposaldialog.h b/src/qt/proposaldialog.h new file mode 100644 index 00000000..8acf75a3 --- /dev/null +++ b/src/qt/proposaldialog.h @@ -0,0 +1,64 @@ +// Copyright (c) 2017-2018 The Bulwark Developers +// Copyright (c) 2019 The Phore Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_CREATEPROPOSALDIALOG_H +#define BITCOIN_QT_CREATEPROPOSALDIALOG_H + +#include +#include +#include +#include + +#include +#include +#include +#include + +class ProposalModel; + +namespace Ui +{ + class ProposalDialog; +} + +QT_BEGIN_NAMESPACE +class QDataWidgetMapper; +QT_END_NAMESPACE + +/** + * Dialog for creating a proposal. + */ +class ProposalDialog : public QDialog +{ + Q_OBJECT + +public: + enum Mode { + PrepareProposal, + SubmitProposal + }; + + explicit ProposalDialog(Mode mode, QWidget* parent); + ~ProposalDialog(); + +public slots: + void checkProposalTX(); + void on_acceptButton_clicked(); + void on_cancelButton_clicked(); + +private: + Ui::ProposalDialog *ui; + QDataWidgetMapper *mapper; + Mode mode; + QTimer *timer; + CWalletTx wtx; + int counter; + + void prepareProposal(); + void submitProposal(); + bool validateProposal(); +}; + +#endif // BITCOIN_QT_CREATEPROPOSALDIALOG_H From 54b99e46a28c281277d74ab13bfccb914afcb865 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:57:02 -0400 Subject: [PATCH 171/469] Update governancelist.cpp --- src/qt/governancelist.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/qt/governancelist.cpp b/src/qt/governancelist.cpp index b79745e7..6264347a 100644 --- a/src/qt/governancelist.cpp +++ b/src/qt/governancelist.cpp @@ -303,6 +303,29 @@ void GovernanceList::setClientModel(ClientModel *model) this->clientModel = model; } +void ProposalList::createProposal() +{ + ProposalDialog dlg(ProposalDialog::PrepareProposal, this); + if (QDialog::Accepted == dlg.exec()) + { + refreshProposals(true); + } +} + +void ProposalList::refreshProposals(bool force) { + int64_t secondsRemaining = nLastUpdate - GetTime() + PROPOSALLIST_UPDATE_SECONDS; + + QString secOrMinutes = (secondsRemaining / 60 > 1) ? tr("minute(s)") : tr("second(s)"); + secondsLabel->setText(tr("List will be updated in %1 %2").arg((secondsRemaining > 60) ? QString::number(secondsRemaining / 60) : QString::number(secondsRemaining), secOrMinutes)); + + if(secondsRemaining > 0 && !force) return; + nLastUpdate = GetTime(); + + proposalTableModel->refreshProposals(); + + secondsLabel->setText(tr("List will be updated in 0 second(s)")); +} + void GovernanceList::on_UpdateButton_clicked() { updateGobjects(); From 3fbc2edeebf086a2999e1d8b1bb3c2bf5a7c8afe Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:58:14 -0400 Subject: [PATCH 172/469] Update governancelist.h --- src/qt/governancelist.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qt/governancelist.h b/src/qt/governancelist.h index e640eede..7ce63adb 100644 --- a/src/qt/governancelist.h +++ b/src/qt/governancelist.h @@ -48,6 +48,7 @@ class GovernanceList : public QWidget public Q_SLOTS: void updateGobjects(); + void refreshProposals(bool force = false); Q_SIGNALS: @@ -72,6 +73,7 @@ private Q_SLOTS: void on_voteYesButton_clicked(); void on_voteNoButton_clicked(); void on_voteAbstainButton_clicked(); + void createProposal(); }; #endif // GOVERNANCELIST_H From af456abbecef24f8ddb0a44b6659c26564669ed3 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 20:58:36 -0400 Subject: [PATCH 173/469] Add files via upload --- src/qt/forms/proposaldialog.ui | 224 +++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 src/qt/forms/proposaldialog.ui diff --git a/src/qt/forms/proposaldialog.ui b/src/qt/forms/proposaldialog.ui new file mode 100644 index 00000000..03599202 --- /dev/null +++ b/src/qt/forms/proposaldialog.ui @@ -0,0 +1,224 @@ + + + ProposalDialog + + + + 0 + 0 + 640 + 126 + + + + Budget Proposal + + + + 11 + + + 11 + + + 11 + + + 11 + + + 11 + + + + + Fill out the form below to create a budget proposal. Before beginning, make sure your wallet is unlocked to pay the budget proposal fee of 50 ODIN. After the proposal is submitted, wait for the transaction confirmations to complete, and then click Finish Proposal to submit the proposal for voting. The screen will update to help guide you. Do not close the dialog after paying the transaction fee + --it will close automatically once the proposal is submitted. + + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + 11 + + + 11 + + + 11 + + + 11 + + + 11 + + + + + &Proposal Name: + + + nameEdit + + + + + + + + + + + &Proposal URL: + + + urlEdit + + + + + + + + + + + &Payments (Months): + + + paymentsEdit + + + + + + + + + + + &Super Block: + + + blockEdit + + + + + + + + + + + &Payment Address: + + + addressEdit + + + + + + + + + + + &Payment Amount (Month): + + + amountEdit + + + + + + + + + + + &Proposal TXID: + + + hashEdit + + + + + + + + + + + + + + + + + + + + + + Submit Proposal + + + + + + + Cancel + + + + + + + + + + + + + buttonBox + accepted() + ProposalDialog + accept() + + + 20 + 20 + + + 20 + 20 + + + + + buttonBox + rejected() + ProposalDialog + reject() + + + 20 + 20 + + + 20 + 20 + + + + + \ No newline at end of file From 0bcfc2cd3185513ec095ee5e4255adde668c3ac8 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:01:08 -0400 Subject: [PATCH 174/469] Update governancelist.cpp --- src/qt/governancelist.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/governancelist.cpp b/src/qt/governancelist.cpp index 6264347a..486723f5 100644 --- a/src/qt/governancelist.cpp +++ b/src/qt/governancelist.cpp @@ -303,7 +303,7 @@ void GovernanceList::setClientModel(ClientModel *model) this->clientModel = model; } -void ProposalList::createProposal() +void GovernanceList::createProposal() { ProposalDialog dlg(ProposalDialog::PrepareProposal, this); if (QDialog::Accepted == dlg.exec()) @@ -312,7 +312,7 @@ void ProposalList::createProposal() } } -void ProposalList::refreshProposals(bool force) { +void GovernanceList::refreshProposals(bool force) { int64_t secondsRemaining = nLastUpdate - GetTime() + PROPOSALLIST_UPDATE_SECONDS; QString secOrMinutes = (secondsRemaining / 60 > 1) ? tr("minute(s)") : tr("second(s)"); From 4abdff1ead2a3d4cbf9f01abe1d22016aeff54a6 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:02:32 -0400 Subject: [PATCH 175/469] Update Makefile.qt.include --- src/Makefile.qt.include | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 49c453a9..49119940 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -46,6 +46,7 @@ QT_FORMS_UI = \ qt/forms/optionsdialog.ui \ qt/forms/overviewpage.ui \ qt/forms/privatesendpage.ui \ + qt/forms/proposaldialog.ui \ qt/forms/receivecoinsdialog.ui \ qt/forms/receiverequestdialog.ui \ qt/forms/debugwindow.ui \ @@ -82,6 +83,7 @@ QT_MOC_CPP = \ qt/moc_optionsmodel.cpp \ qt/moc_overviewpage.cpp \ qt/moc_privatesendpage.cpp \ + qt/moc_proposaldialog.cpp \ qt/moc_peertablemodel.cpp \ qt/moc_paymentserver.cpp \ qt/moc_qrdialog.cpp \ @@ -163,6 +165,7 @@ BITCOIN_QT_H = \ qt/paymentserver.h \ qt/peertablemodel.h \ qt/platformstyle.h \ + qt/proposaldialog.h \ qt/qrdialog.h \ qt/qvalidatedlineedit.h \ qt/qvaluecombobox.h \ @@ -507,6 +510,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/openuridialog.cpp \ qt/overviewpage.cpp \ qt/privatesendpage.cpp \ + qt/proposaldialog.cpp \ qt/paymentrequestplus.cpp \ qt/paymentserver.cpp \ qt/qrdialog.cpp \ From 13ef4c12f4da6448dc62cc34855de703078a14dd Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:11:24 -0400 Subject: [PATCH 176/469] Update proposaldialog.h --- src/qt/proposaldialog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/proposaldialog.h b/src/qt/proposaldialog.h index 8acf75a3..010dfcf4 100644 --- a/src/qt/proposaldialog.h +++ b/src/qt/proposaldialog.h @@ -43,7 +43,7 @@ class ProposalDialog : public QDialog explicit ProposalDialog(Mode mode, QWidget* parent); ~ProposalDialog(); -public slots: +public Q_SLOTS: void checkProposalTX(); void on_acceptButton_clicked(); void on_cancelButton_clicked(); From e13c26d2a6541ba8e737738390ea5404adedfe04 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:14:26 -0400 Subject: [PATCH 177/469] Update governancelist.cpp --- src/qt/governancelist.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/governancelist.cpp b/src/qt/governancelist.cpp index 486723f5..68c29401 100644 --- a/src/qt/governancelist.cpp +++ b/src/qt/governancelist.cpp @@ -1,4 +1,5 @@ #include "governancelist.h" +#include "proposaldialog.h" #include "ui_governancelist.h" #include #include From cf52389d72d8d56bc489d9e71d05b53ab43cb4e3 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:20:30 -0400 Subject: [PATCH 178/469] Update governancelist.cpp --- src/qt/governancelist.cpp | 62 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/src/qt/governancelist.cpp b/src/qt/governancelist.cpp index 68c29401..5d99b401 100644 --- a/src/qt/governancelist.cpp +++ b/src/qt/governancelist.cpp @@ -313,6 +313,66 @@ void GovernanceList::createProposal() } } +void GovernanceList::refreshProposals() +{ + beginResetModel(); + proposalRecords.clear(); + + int mnCount = mnodeman.CountEnabled(); + std::vector bObj; + + if (proposalType == 0) + { + bObj = budget.GetAllProposals(); + } + else + { + bObj = budget.GetBudget(); + } + + + for (CBudgetProposal* pbudgetProposal : bObj) + { + UniValue o(UniValue::VOBJ); + budgetToST(pbudgetProposal, o); + + //UniValue objResult(UniValue::VOBJ); + //UniValue dataObj(UniValue::VOBJ); + //objResult.read(pbudgetProposal->GetDataAsPlainString()); // not need as time being + + //std::vector arr1 = objResult.getValues(); + //std::vector arr2 = arr1.at( 0 ).getValues(); + //dataObj = arr2.at( 1 ); + + UniValue bObj(UniValue::VOBJ); + budgetToST(pbudgetProposal, bObj); + + int votesNeeded = 0; + int voteGap = 0; + + if(mnCount > 0) { + voteGap = ceil( (mnCount / 10) - (pbudgetProposal->GetYeas() - pbudgetProposal->GetNays()) ); + votesNeeded = (voteGap < 0) ? 0 : voteGap; + }; + + proposalRecords.append(new ProposalRecord( + QString::fromStdString(pbudgetProposal->GetHash().ToString()), + pbudgetProposal->GetBlockStart(), + pbudgetProposal->GetBlockEnd(), + pbudgetProposal->GetTotalPaymentCount(), + pbudgetProposal->GetRemainingPaymentCount(), + QString::fromStdString(pbudgetProposal->GetURL()), + QString::fromStdString(pbudgetProposal->GetName()), + (long long)pbudgetProposal->GetYeas(), + (long long)pbudgetProposal->GetNays(), + (long long)pbudgetProposal->GetAbstains(), + (long long)pbudgetProposal->GetAmount(), + (long long)votesNeeded)); + } + endResetModel(); +} + + void GovernanceList::refreshProposals(bool force) { int64_t secondsRemaining = nLastUpdate - GetTime() + PROPOSALLIST_UPDATE_SECONDS; @@ -322,7 +382,7 @@ void GovernanceList::refreshProposals(bool force) { if(secondsRemaining > 0 && !force) return; nLastUpdate = GetTime(); - proposalTableModel->refreshProposals(); + governanceLi->refreshProposals(); secondsLabel->setText(tr("List will be updated in 0 second(s)")); } From 3b827a1196d8411ad85e40c06f246a3022b51036 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:21:49 -0400 Subject: [PATCH 179/469] Update governancelist.h --- src/qt/governancelist.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/governancelist.h b/src/qt/governancelist.h index 7ce63adb..922ce8b9 100644 --- a/src/qt/governancelist.h +++ b/src/qt/governancelist.h @@ -48,6 +48,7 @@ class GovernanceList : public QWidget public Q_SLOTS: void updateGobjects(); + void refreshProposals(); void refreshProposals(bool force = false); From df8bff522d73f13f6f2a5b2b782259e95d43bf69 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:25:02 -0400 Subject: [PATCH 180/469] Update governancelist.cpp --- src/qt/governancelist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/governancelist.cpp b/src/qt/governancelist.cpp index 5d99b401..b5f0d6c1 100644 --- a/src/qt/governancelist.cpp +++ b/src/qt/governancelist.cpp @@ -315,7 +315,7 @@ void GovernanceList::createProposal() void GovernanceList::refreshProposals() { - beginResetModel(); + setClientModel(); proposalRecords.clear(); int mnCount = mnodeman.CountEnabled(); From bab00e1f2feaa31e101234d83439ed6f8f9fff71 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:25:39 -0400 Subject: [PATCH 181/469] Create proposalrecord.h --- src/qt/proposalrecord.h | 66 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/qt/proposalrecord.h diff --git a/src/qt/proposalrecord.h b/src/qt/proposalrecord.h new file mode 100644 index 00000000..7306e5ea --- /dev/null +++ b/src/qt/proposalrecord.h @@ -0,0 +1,66 @@ +// Copyright (c) 2017-2018 The Bulwark Developers +// Copyright (c) 2018 The Curium developers +// Copyright (c) 2018-2018 The Phore developers +// Copyright (c) 2019 The ODIN developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_PROPOSALRECORD_H +#define BITCOIN_QT_PROPOSALRECORD_H + +#include "amount.h" +#include "uint256.h" + +#include +#include + +class CWallet; + +class ProposalRecord +{ +public: + ProposalRecord() : + hash(""), + start_epoch(0), + end_epoch(0), + totalPaymentCount(0), + remainingPaymentCount(0), + url(""), + name(""), + yesVotes(0), + noVotes(0), + abstainVotes(0), + amount(0), + votesNeeded(0) + {} + + ProposalRecord(QString hash, const CAmount& start_epoch, const CAmount& end_epoch, const int& totalPaymentCount, const int& remainingPaymentCount, QString url, QString name, const int yesVotes, const int noVotes, const int abstainVotes, const CAmount amount, const int votesNeeded) : + hash(hash), + start_epoch(start_epoch), + end_epoch(end_epoch), + totalPaymentCount(totalPaymentCount), + remainingPaymentCount(remainingPaymentCount), + url(url), + name(name), + yesVotes(yesVotes), + noVotes(noVotes), + abstainVotes(abstainVotes), + amount(amount), + votesNeeded(votesNeeded) + {} + + QString hash; + int start_epoch; + int end_epoch; + int totalPaymentCount; + int remainingPaymentCount; + QString url; + QString name; + int yesVotes; + int noVotes; + int abstainVotes; + CAmount amount; + int votesNeeded; +}; + +#endif // BITCOIN_QT_PROPOSALRECORD_H From abb6bfc55192bab5342d0064a096b005734392e8 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:25:59 -0400 Subject: [PATCH 182/469] Create proposalrecord.cpp --- src/qt/proposalrecord.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/qt/proposalrecord.cpp diff --git a/src/qt/proposalrecord.cpp b/src/qt/proposalrecord.cpp new file mode 100644 index 00000000..0ac0fedd --- /dev/null +++ b/src/qt/proposalrecord.cpp @@ -0,0 +1,8 @@ +// Copyright (c) 2017-2018 The Bulwark Developers +// Copyright (c) 2018 The Curium developers +// Copyright (c) 2018-2018 The Phore developers +// Copyright (c) 2019 The ODIN developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "proposalrecord.h" From c5eff8ad8cdcd307facce61759b8403e9919980e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:26:31 -0400 Subject: [PATCH 183/469] Update governancelist.cpp --- src/qt/governancelist.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/governancelist.cpp b/src/qt/governancelist.cpp index b5f0d6c1..f4989a77 100644 --- a/src/qt/governancelist.cpp +++ b/src/qt/governancelist.cpp @@ -1,5 +1,6 @@ #include "governancelist.h" #include "proposaldialog.h" +#include "proposalrecord.h" #include "ui_governancelist.h" #include #include From 65a254f8b3136fc1940933bdb5a039df807ee150 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:28:29 -0400 Subject: [PATCH 184/469] Update Makefile.qt.include --- src/Makefile.qt.include | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 49119940..f7dbf2bd 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -166,6 +166,7 @@ BITCOIN_QT_H = \ qt/peertablemodel.h \ qt/platformstyle.h \ qt/proposaldialog.h \ + qt/proposalrecord.h \ qt/qrdialog.h \ qt/qvalidatedlineedit.h \ qt/qvaluecombobox.h \ @@ -511,6 +512,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/overviewpage.cpp \ qt/privatesendpage.cpp \ qt/proposaldialog.cpp \ + qt/proposalrecord.cpp \ qt/paymentrequestplus.cpp \ qt/paymentserver.cpp \ qt/qrdialog.cpp \ From c528c96bf392e698bc8880c643c80d93a8235414 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:30:37 -0400 Subject: [PATCH 185/469] Update governancelist.h --- src/qt/governancelist.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt/governancelist.h b/src/qt/governancelist.h index 922ce8b9..7ce63adb 100644 --- a/src/qt/governancelist.h +++ b/src/qt/governancelist.h @@ -48,7 +48,6 @@ class GovernanceList : public QWidget public Q_SLOTS: void updateGobjects(); - void refreshProposals(); void refreshProposals(bool force = false); From 4ff856fb70279a25a619f153587fcbfcfc278378 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:33:42 -0400 Subject: [PATCH 186/469] Update governancelist.cpp --- src/qt/governancelist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/governancelist.cpp b/src/qt/governancelist.cpp index f4989a77..0b43b079 100644 --- a/src/qt/governancelist.cpp +++ b/src/qt/governancelist.cpp @@ -383,7 +383,7 @@ void GovernanceList::refreshProposals(bool force) { if(secondsRemaining > 0 && !force) return; nLastUpdate = GetTime(); - governanceLi->refreshProposals(); + governanceList->refreshProposals(); secondsLabel->setText(tr("List will be updated in 0 second(s)")); } From 2f4b9bcecbdcfbaa6714965d0f7f07167311b2e0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:35:01 -0400 Subject: [PATCH 187/469] Update governancelist.cpp --- src/qt/governancelist.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qt/governancelist.cpp b/src/qt/governancelist.cpp index 0b43b079..55c4fecb 100644 --- a/src/qt/governancelist.cpp +++ b/src/qt/governancelist.cpp @@ -49,6 +49,10 @@ GovernanceList::GovernanceList(const PlatformStyle *platformStyle, QWidget *pare timer->start(1000); fFilterUpdated = false; nTimeFilterUpdated = GetTime(); + + secondsLabel = new QLabel(); + actionBar->addWidget(secondsLabel); + actionBar->addStretch(); } void GovernanceList::on_voteYesButton_clicked() From 33075ad7fa03afd83e5ab586ba36d8007460baf8 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:36:32 -0400 Subject: [PATCH 188/469] Update governancelist.h --- src/qt/governancelist.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qt/governancelist.h b/src/qt/governancelist.h index 7ce63adb..e59dd048 100644 --- a/src/qt/governancelist.h +++ b/src/qt/governancelist.h @@ -13,6 +13,7 @@ #define GOBJECT_UPDATE_SECONDS 15 #define GOBJECT_COOLDOWN_SECONDS 3 +#define PROPOSALLIST_UPDATE_SECONDS 30 namespace Ui { class GovernanceList; @@ -45,6 +46,7 @@ class GovernanceList : public QWidget QMenu *contextMenu; int64_t nTimeFilterUpdated; bool fFilterUpdated; + QLabel *secondsLabel; public Q_SLOTS: void updateGobjects(); From c97223587a109dd123fee1c3a1ba8f2be291d801 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:37:46 -0400 Subject: [PATCH 189/469] Update governancelist.h --- src/qt/governancelist.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/governancelist.h b/src/qt/governancelist.h index e59dd048..ee81b8d2 100644 --- a/src/qt/governancelist.h +++ b/src/qt/governancelist.h @@ -10,6 +10,7 @@ #include #include #include +#include #define GOBJECT_UPDATE_SECONDS 15 #define GOBJECT_COOLDOWN_SECONDS 3 From 014fc6a211e2773fd82a3e0cc2003d516125a097 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:41:47 -0400 Subject: [PATCH 190/469] Update governancelist.cpp --- src/qt/governancelist.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qt/governancelist.cpp b/src/qt/governancelist.cpp index 55c4fecb..29f8c809 100644 --- a/src/qt/governancelist.cpp +++ b/src/qt/governancelist.cpp @@ -49,6 +49,11 @@ GovernanceList::GovernanceList(const PlatformStyle *platformStyle, QWidget *pare timer->start(1000); fFilterUpdated = false; nTimeFilterUpdated = GetTime(); + + + QHBoxLayout *actionBar = new QHBoxLayout(); + actionBar->setSpacing(11); + actionBar->setContentsMargins(0,20,0,4); secondsLabel = new QLabel(); actionBar->addWidget(secondsLabel); From 9332d7ff4f72fceeff6f8f66948e00fe20f978f1 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:43:42 -0400 Subject: [PATCH 191/469] Update governancelist.cpp --- src/qt/governancelist.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/qt/governancelist.cpp b/src/qt/governancelist.cpp index 29f8c809..6d6d586e 100644 --- a/src/qt/governancelist.cpp +++ b/src/qt/governancelist.cpp @@ -49,8 +49,18 @@ GovernanceList::GovernanceList(const PlatformStyle *platformStyle, QWidget *pare timer->start(1000); fFilterUpdated = false; nTimeFilterUpdated = GetTime(); - + nLastUpdate = GetTime(); + + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(refreshProposals())); + timer->start(1000); + + + QVBoxLayout *vlayout = new QVBoxLayout(this); + vlayout->setSpacing(0); + vlayout->addLayout(actionBar); + QHBoxLayout *actionBar = new QHBoxLayout(); actionBar->setSpacing(11); actionBar->setContentsMargins(0,20,0,4); From 284c2dd21d0cf05777e033e094c56a2025b1e015 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 21:45:00 -0400 Subject: [PATCH 192/469] Update governancelist.h --- src/qt/governancelist.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/governancelist.h b/src/qt/governancelist.h index ee81b8d2..34025276 100644 --- a/src/qt/governancelist.h +++ b/src/qt/governancelist.h @@ -48,6 +48,7 @@ class GovernanceList : public QWidget int64_t nTimeFilterUpdated; bool fFilterUpdated; QLabel *secondsLabel; + int64_t nLastUpdate = 0; public Q_SLOTS: void updateGobjects(); From 994e4d5397740c3460701ab044ff29bc3128e4c5 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 22:03:22 -0400 Subject: [PATCH 193/469] Delete proposalrecord.h --- src/qt/proposalrecord.h | 66 ----------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 src/qt/proposalrecord.h diff --git a/src/qt/proposalrecord.h b/src/qt/proposalrecord.h deleted file mode 100644 index 7306e5ea..00000000 --- a/src/qt/proposalrecord.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2017-2018 The Bulwark Developers -// Copyright (c) 2018 The Curium developers -// Copyright (c) 2018-2018 The Phore developers -// Copyright (c) 2019 The ODIN developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_QT_PROPOSALRECORD_H -#define BITCOIN_QT_PROPOSALRECORD_H - -#include "amount.h" -#include "uint256.h" - -#include -#include - -class CWallet; - -class ProposalRecord -{ -public: - ProposalRecord() : - hash(""), - start_epoch(0), - end_epoch(0), - totalPaymentCount(0), - remainingPaymentCount(0), - url(""), - name(""), - yesVotes(0), - noVotes(0), - abstainVotes(0), - amount(0), - votesNeeded(0) - {} - - ProposalRecord(QString hash, const CAmount& start_epoch, const CAmount& end_epoch, const int& totalPaymentCount, const int& remainingPaymentCount, QString url, QString name, const int yesVotes, const int noVotes, const int abstainVotes, const CAmount amount, const int votesNeeded) : - hash(hash), - start_epoch(start_epoch), - end_epoch(end_epoch), - totalPaymentCount(totalPaymentCount), - remainingPaymentCount(remainingPaymentCount), - url(url), - name(name), - yesVotes(yesVotes), - noVotes(noVotes), - abstainVotes(abstainVotes), - amount(amount), - votesNeeded(votesNeeded) - {} - - QString hash; - int start_epoch; - int end_epoch; - int totalPaymentCount; - int remainingPaymentCount; - QString url; - QString name; - int yesVotes; - int noVotes; - int abstainVotes; - CAmount amount; - int votesNeeded; -}; - -#endif // BITCOIN_QT_PROPOSALRECORD_H From 8eed7a3301534c5f170a0c3fef249d981bc872d7 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 22:03:30 -0400 Subject: [PATCH 194/469] Delete proposalrecord.cpp --- src/qt/proposalrecord.cpp | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 src/qt/proposalrecord.cpp diff --git a/src/qt/proposalrecord.cpp b/src/qt/proposalrecord.cpp deleted file mode 100644 index 0ac0fedd..00000000 --- a/src/qt/proposalrecord.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2017-2018 The Bulwark Developers -// Copyright (c) 2018 The Curium developers -// Copyright (c) 2018-2018 The Phore developers -// Copyright (c) 2019 The ODIN developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "proposalrecord.h" From 14e15a56570e5812e06ed1d9872f37d79ab33194 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 22:03:39 -0400 Subject: [PATCH 195/469] Delete proposaldialog.h --- src/qt/proposaldialog.h | 64 ----------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 src/qt/proposaldialog.h diff --git a/src/qt/proposaldialog.h b/src/qt/proposaldialog.h deleted file mode 100644 index 010dfcf4..00000000 --- a/src/qt/proposaldialog.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2017-2018 The Bulwark Developers -// Copyright (c) 2019 The Phore Developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_QT_CREATEPROPOSALDIALOG_H -#define BITCOIN_QT_CREATEPROPOSALDIALOG_H - -#include -#include -#include -#include - -#include -#include -#include -#include - -class ProposalModel; - -namespace Ui -{ - class ProposalDialog; -} - -QT_BEGIN_NAMESPACE -class QDataWidgetMapper; -QT_END_NAMESPACE - -/** - * Dialog for creating a proposal. - */ -class ProposalDialog : public QDialog -{ - Q_OBJECT - -public: - enum Mode { - PrepareProposal, - SubmitProposal - }; - - explicit ProposalDialog(Mode mode, QWidget* parent); - ~ProposalDialog(); - -public Q_SLOTS: - void checkProposalTX(); - void on_acceptButton_clicked(); - void on_cancelButton_clicked(); - -private: - Ui::ProposalDialog *ui; - QDataWidgetMapper *mapper; - Mode mode; - QTimer *timer; - CWalletTx wtx; - int counter; - - void prepareProposal(); - void submitProposal(); - bool validateProposal(); -}; - -#endif // BITCOIN_QT_CREATEPROPOSALDIALOG_H From b83b043155e840fb4c05cf0036301fa54cd7675b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 22:03:48 -0400 Subject: [PATCH 196/469] Delete proposaldialog.cpp --- src/qt/proposaldialog.cpp | 297 -------------------------------------- 1 file changed, 297 deletions(-) delete mode 100644 src/qt/proposaldialog.cpp diff --git a/src/qt/proposaldialog.cpp b/src/qt/proposaldialog.cpp deleted file mode 100644 index b34986e5..00000000 --- a/src/qt/proposaldialog.cpp +++ /dev/null @@ -1,297 +0,0 @@ -// Copyright (c) 2017-2018 The Bulwark Developers -// Copyright (c) 2019 The Phore Developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#if defined(HAVE_CONFIG_H) -#include -#endif - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -ProposalDialog::ProposalDialog(Mode mode, QWidget* parent) : QDialog(parent), ui(new Ui::ProposalDialog), mapper(0), mode(mode), counter(0) -{ - ui->setupUi(this); - - switch (mode) { - case PrepareProposal: - setWindowTitle(tr("Prepare Proposal")); - ui->confirmLabel->setVisible(false); - ui->hashEdit->setVisible(false); - ui->hashLabel->setVisible(false); - break; - case SubmitProposal: - setWindowTitle(tr("Submit Proposal")); - ui->confirmLabel->setVisible(true); - ui->hashEdit->setVisible(true); - ui->hashLabel->setVisible(true); - break; - } - - ui->nameEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->nameEdit->setPlaceholderText(tr("Provide a proposal name, keep it short")); - ui->nameEdit->setToolTip(tr("Provide a proposal name, keep it short")); - - ui->urlEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->urlEdit->setPlaceholderText(tr("Valid http or https URL (include http:// or https://")); - ui->urlEdit->setToolTip(tr("Valid http or https URL (include http:// or https://")); - - ui->paymentsEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->paymentsEdit->setPlaceholderText(tr("How many monthly payments, 1 per budget cycle")); - ui->paymentsEdit->setToolTip(tr("How many monthly payments, 1 per budget cycle")); - ui->paymentsEdit->setValidator(new QIntValidator(1, 100)); - - ui->blockEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->blockEdit->setPlaceholderText(tr("The governance budget block for the desired cycle (default to next)")); - ui->blockEdit->setToolTip(tr("The governance budget block for the desired cycle (default to next)")); - ui->blockEdit->setValidator(new QIntValidator(1, INT_MAX)); - - ui->addressEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->addressEdit->setPlaceholderText(tr("The public ODIN address that will receive the funds")); - ui->addressEdit->setToolTip(tr("The public ODIN address that will receive the funds")); - - ui->amountEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->amountEdit->setPlaceholderText(tr("The amount to be paid per month or cycle")); - ui->amountEdit->setToolTip(tr("The amount to be paid per month or cycle")); - ui->amountEdit->setValidator(new QIntValidator(10, INT_MAX)); - - ui->hashEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->hashEdit->setPlaceholderText(tr("The TXID of the proposal hash, must be confirmed before use")); - ui->hashEdit->setToolTip(tr("The TXID of the proposal hash, must be confirmed before use")); - - ui->confirmLabel->setWordWrap(true); - ui->infoLabel->setWordWrap(true); - - // Load next superblock number. - CBlockIndex* pindexPrev = chainActive.Tip(); - if (!pindexPrev) return; - int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); - ui->blockEdit->setText(QString::number(nNext)); - - // Start periodic updates to handle submit block depth validation. - timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(checkProposalTX())); -} - -ProposalDialog::~ProposalDialog() -{ - delete ui; -} - -void ProposalDialog::prepareProposal() -{ - std::string strError = ""; - - if (pwalletMain->IsLocked()) - { - strError = "Error: Please enter the wallet passphrase with walletpassphrase first."; - QMessageBox::critical(this, "Prepare Proposal Error", QString::fromStdString(strError)); - return; - } - - std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); - std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); - int nPaymentCount = ui->paymentsEdit->text().toInt(); - int nBlockStart = ui->blockEdit->text().toInt(); - std::string address = ui->addressEdit->text().toStdString(); - CScript scriptPubKey = GetScriptForDestination(DecodeDestination(address)); - CAmount nAmount = AmountFromValue(ui->amountEdit->text().toInt()); - - //************************************************************************* - - // create the proposal incase we're the first to make it - CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, 0); - std::string err; - if (!budgetProposalBroadcast.IsValid(err, false)) strError = "Proposal is not valid - " + budgetProposalBroadcast.GetHash().ToString() + " - " + err; - - bool useIX = false; - if (strError.empty() && !pwalletMain->GetBudgetSystemCollateralTX(wtx, budgetProposalBroadcast.GetHash(), useIX)) - { - strError = "Error making collateral transaction for proposal. Please check your wallet balance."; - } - - // make our change address - CReserveKey reservekey(pwalletMain); - // send the tx to the network - if (strError.empty() && !pwalletMain->CommitTransaction(wtx, reservekey, useIX ? "ix" : "tx")) - { - strError = "Unable to commit proposal transaction."; - } - - if (!strError.empty()) - { - std::cout << strError << std::endl; - QMessageBox::critical(this, "Prepare Proposal Error", QString::fromStdString(strError)); - return; - } - - // update the local view with submit view - ui->cancelButton->setDisabled(true); - ui->nameEdit->setDisabled(true); - ui->urlEdit->setDisabled(true); - ui->paymentsEdit->setDisabled(true); - ui->blockEdit->setDisabled(true); - ui->addressEdit->setDisabled(true); - ui->amountEdit->setDisabled(true); - ui->hashEdit->setDisabled(true); - - ui->acceptButton->setDisabled(true); - ui->acceptButton->setText(tr("Waiting...")); - - ui->confirmLabel->setVisible(true); - ui->confirmLabel->setText(QString::fromStdString("Waiting for confirmations...")); - - ui->hashEdit->setText(QString::fromStdString(wtx.GetHash().ToString())); - ui->hashEdit->setVisible(true); - ui->hashLabel->setVisible(true); - - mode = SubmitProposal; - setWindowTitle(tr("Submit Proposal")); - - timer->start(1000); - counter = chainActive.Tip()->nHeight + 1; -} - -void ProposalDialog::submitProposal() -{ - std::string strError = ""; - - std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); - std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); - int nPaymentCount = ui->paymentsEdit->text().toInt(); - int nBlockStart = ui->blockEdit->text().toInt(); - std::string address = ui->addressEdit->text().toStdString(); - CScript scriptPubKey = GetScriptForDestination(DecodeDestination(address)); - CAmount nAmount = AmountFromValue(ui->amountEdit->text().toInt()); - uint256 hash = ParseHashV(ui->hashEdit->text().toStdString(), "parameter 1"); - - //************************************************************************* - - // create the proposal incase we're the first to make it - int nConf = 0; - std::string err = ""; - CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, hash); - if (!IsBudgetCollateralValid(hash, budgetProposalBroadcast.GetHash(), err, budgetProposalBroadcast.nTime, nConf)) - { - strError = "Proposal FeeTX is not valid - " + hash.ToString() + " - " + err; - } - - if (strError.empty() && !budget.AddProposal(budgetProposalBroadcast)) strError = "Invalid proposal, see debug.log for details."; - - if (!strError.empty()) - { - std::cout << strError << std::endl; - QMessageBox::critical(this, tr("Submit Proposal Error"), QString::fromStdString(strError)); - return; - } - - budget.mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast)); - budgetProposalBroadcast.Relay(); - - this->accept(); -} - -bool ProposalDialog::validateProposal() -{ - std::string strError = ""; - - if (!masternodeSync.IsBlockchainSynced()) strError = "Must wait for client to sync with masternode network. Try again in a minute or so."; - - std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); - if (strProposalName.size() > 20) strError = "Invalid proposal name, limit of 20 characters."; - - std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); - if (strURL.size() > 64) strError = "Invalid url, limit of 64 characters."; - - int nPaymentCount = ui->paymentsEdit->text().toInt(); - if (nPaymentCount < 1) strError = "Invalid payment count, must be more than zero."; - - // Start must be in the next budget cycle - int nBlockMin = 0; - CBlockIndex* pindexPrev = chainActive.Tip(); - if (pindexPrev != NULL) nBlockMin = pindexPrev->nHeight - pindexPrev->nHeight % consensusParams.nBudgetPaymentsCycleBlocks + consensusParams.nBudgetPaymentsCycleBlocks; - - int nBlockStart = ui->blockEdit->text().toInt(); - if (nBlockStart < nBlockMin) strError = "Invalid block start, must be more than current height."; - if (nBlockStart % consensusParams.nBudgetPaymentsCycleBlocks != 0) - { - int nNext = pindexPrev->nHeight - pindexPrev->nHeight % consensusParams.nBudgetPaymentsCycleBlocks + consensusParams.nBudgetPaymentsCycleBlocks; - strError = strprintf("Invalid block start - must be a budget cycle block. Next valid block: %d", nNext); - } - - int nBlockEnd = nBlockStart + (consensusParams.nBudgetPaymentsCycleBlocks * nPaymentCount); // End must be AFTER current cycle - if (nBlockEnd < pindexPrev->nHeight) strError = "Invalid ending block, starting block + (payment_cycle*payments) must be more than current height."; - - std::string address = ui->addressEdit->text().toStdString(); - if (!IsValidDestinationString(address)) strError = "Invalid ODIN address"; - - if (!strError.empty()) - { - QMessageBox::critical(this, tr("Submit Proposal Error"), QString::fromStdString(strError)); - return false; - } - - return true; -} - -void ProposalDialog::checkProposalTX() -{ - if (mode != SubmitProposal) return; - - int nConf = Params().BudgetFeeConfirmations(); - int nDepth = (chainActive.Tip()->nHeight + 1) - counter; - if (nDepth > nConf) - { - ui->acceptButton->setDisabled(false); - ui->acceptButton->setText("Finish Proposal"); - ui->confirmLabel->setText(tr("Click on Finish Proposal to complete the proposal and start voting.")); - - timer->stop(); - } - else if (nDepth == nConf) - { - ui->confirmLabel->setText(QString::fromStdString("Waiting for final confirmation...")); - } - else if (nDepth > 0) - { - ui->confirmLabel->setText(QString::fromStdString(strprintf("Currently %d of %d confirmations...", nDepth, (nConf + 1)).c_str())); - } -} - -void ProposalDialog::on_acceptButton_clicked() -{ - if (!validateProposal()) return; - - if (mode == PrepareProposal) - { - prepareProposal(); - } - else if (mode == SubmitProposal) - { - submitProposal(); - } -} - -void ProposalDialog::on_cancelButton_clicked() -{ - this->reject(); -} From 5b916c2957a5b003dc6e0e9eb166b580aa2418bc Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 22:04:24 -0400 Subject: [PATCH 197/469] Update governancelist.h --- src/qt/governancelist.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/qt/governancelist.h b/src/qt/governancelist.h index 34025276..f1cce380 100644 --- a/src/qt/governancelist.h +++ b/src/qt/governancelist.h @@ -14,7 +14,7 @@ #define GOBJECT_UPDATE_SECONDS 15 #define GOBJECT_COOLDOWN_SECONDS 3 -#define PROPOSALLIST_UPDATE_SECONDS 30 + namespace Ui { class GovernanceList; @@ -47,12 +47,10 @@ class GovernanceList : public QWidget QMenu *contextMenu; int64_t nTimeFilterUpdated; bool fFilterUpdated; - QLabel *secondsLabel; - int64_t nLastUpdate = 0; + public Q_SLOTS: void updateGobjects(); - void refreshProposals(bool force = false); Q_SIGNALS: @@ -77,7 +75,6 @@ private Q_SLOTS: void on_voteYesButton_clicked(); void on_voteNoButton_clicked(); void on_voteAbstainButton_clicked(); - void createProposal(); }; #endif // GOVERNANCELIST_H From 035f872b1b9c0a6d7e7657bd8fc0b626e108492d Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 22:05:19 -0400 Subject: [PATCH 198/469] Update governancelist.cpp --- src/qt/governancelist.cpp | 103 +------------------------------------- 1 file changed, 1 insertion(+), 102 deletions(-) diff --git a/src/qt/governancelist.cpp b/src/qt/governancelist.cpp index 6d6d586e..88b1c452 100644 --- a/src/qt/governancelist.cpp +++ b/src/qt/governancelist.cpp @@ -49,25 +49,7 @@ GovernanceList::GovernanceList(const PlatformStyle *platformStyle, QWidget *pare timer->start(1000); fFilterUpdated = false; nTimeFilterUpdated = GetTime(); - - nLastUpdate = GetTime(); - - timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(refreshProposals())); - timer->start(1000); - - - QVBoxLayout *vlayout = new QVBoxLayout(this); - vlayout->setSpacing(0); - vlayout->addLayout(actionBar); - - QHBoxLayout *actionBar = new QHBoxLayout(); - actionBar->setSpacing(11); - actionBar->setContentsMargins(0,20,0,4); - - secondsLabel = new QLabel(); - actionBar->addWidget(secondsLabel); - actionBar->addStretch(); + } void GovernanceList::on_voteYesButton_clicked() @@ -324,89 +306,6 @@ void GovernanceList::setClientModel(ClientModel *model) this->clientModel = model; } -void GovernanceList::createProposal() -{ - ProposalDialog dlg(ProposalDialog::PrepareProposal, this); - if (QDialog::Accepted == dlg.exec()) - { - refreshProposals(true); - } -} - -void GovernanceList::refreshProposals() -{ - setClientModel(); - proposalRecords.clear(); - - int mnCount = mnodeman.CountEnabled(); - std::vector bObj; - - if (proposalType == 0) - { - bObj = budget.GetAllProposals(); - } - else - { - bObj = budget.GetBudget(); - } - - - for (CBudgetProposal* pbudgetProposal : bObj) - { - UniValue o(UniValue::VOBJ); - budgetToST(pbudgetProposal, o); - - //UniValue objResult(UniValue::VOBJ); - //UniValue dataObj(UniValue::VOBJ); - //objResult.read(pbudgetProposal->GetDataAsPlainString()); // not need as time being - - //std::vector arr1 = objResult.getValues(); - //std::vector arr2 = arr1.at( 0 ).getValues(); - //dataObj = arr2.at( 1 ); - - UniValue bObj(UniValue::VOBJ); - budgetToST(pbudgetProposal, bObj); - - int votesNeeded = 0; - int voteGap = 0; - - if(mnCount > 0) { - voteGap = ceil( (mnCount / 10) - (pbudgetProposal->GetYeas() - pbudgetProposal->GetNays()) ); - votesNeeded = (voteGap < 0) ? 0 : voteGap; - }; - - proposalRecords.append(new ProposalRecord( - QString::fromStdString(pbudgetProposal->GetHash().ToString()), - pbudgetProposal->GetBlockStart(), - pbudgetProposal->GetBlockEnd(), - pbudgetProposal->GetTotalPaymentCount(), - pbudgetProposal->GetRemainingPaymentCount(), - QString::fromStdString(pbudgetProposal->GetURL()), - QString::fromStdString(pbudgetProposal->GetName()), - (long long)pbudgetProposal->GetYeas(), - (long long)pbudgetProposal->GetNays(), - (long long)pbudgetProposal->GetAbstains(), - (long long)pbudgetProposal->GetAmount(), - (long long)votesNeeded)); - } - endResetModel(); -} - - -void GovernanceList::refreshProposals(bool force) { - int64_t secondsRemaining = nLastUpdate - GetTime() + PROPOSALLIST_UPDATE_SECONDS; - - QString secOrMinutes = (secondsRemaining / 60 > 1) ? tr("minute(s)") : tr("second(s)"); - secondsLabel->setText(tr("List will be updated in %1 %2").arg((secondsRemaining > 60) ? QString::number(secondsRemaining / 60) : QString::number(secondsRemaining), secOrMinutes)); - - if(secondsRemaining > 0 && !force) return; - nLastUpdate = GetTime(); - - governanceList->refreshProposals(); - - secondsLabel->setText(tr("List will be updated in 0 second(s)")); -} - void GovernanceList::on_UpdateButton_clicked() { updateGobjects(); From 717781123d8316ca908e06e3049d168c40fecbba Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 22:06:04 -0400 Subject: [PATCH 199/469] Update bitcoingui.h --- src/qt/bitcoingui.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 6332b864..9011d71d 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -103,7 +103,6 @@ class BitcoinGUI : public QMainWindow QMenuBar *appMenuBar; - QAction* createProposal; QAction* externalDonate; QAction *governanceAction; /* QAction* privatesendAction; */ From 2cffa6dfe3c47a39815975f9d033966595ff39cd Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 22:07:48 -0400 Subject: [PATCH 200/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 379c7ced..c039a629 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -601,10 +601,6 @@ void BitcoinGUI::createActions() externalDonate = new QAction(QIcon(":/icons/" + theme + "/about"), tr("Donate To HTHW"), this); externalDonate->setStatusTip(tr("Donate to Help The Homeless Worldwide")); - // HTH Create Proposal - createProposal = new QAction(QIcon(":/icons/" + theme + "/about"), tr("Create Proposals"), this); - createProposal->setStatusTip(tr("Create a HTH Proposal")); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked())); @@ -617,11 +613,7 @@ void BitcoinGUI::createActions() // HTHW Donate connect(externalDonate, SIGNAL(triggered()), this, SLOT(openDonate())); - - // HTH Create Proposal - - connect(createProposal, SIGNAL(clicked()), this, SLOT(createProposal())); - + // Jump directly to tabs in RPC-console connect(openInfoAction, SIGNAL(triggered()), this, SLOT(showInfo())); connect(openRPCConsoleAction, SIGNAL(triggered()), this, SLOT(showConsole())); @@ -720,10 +712,7 @@ void BitcoinGUI::createMenuBar() help->addAction(aboutQtAction); QMenu* donate = appMenuBar->addMenu(tr("&Donate")); - donate->addAction(externalDonate); - - QMenu* proposals = appMenuBar->addMenu(tr("&Create Proposals")); - proposals->addAction(createProposal); + donate->addAction(externalDonate); } From d38bc93a5fa329301ea07f275dd4c3cef0386fa8 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 22:08:00 -0400 Subject: [PATCH 201/469] Delete proposaldialog.ui --- src/qt/forms/proposaldialog.ui | 224 --------------------------------- 1 file changed, 224 deletions(-) delete mode 100644 src/qt/forms/proposaldialog.ui diff --git a/src/qt/forms/proposaldialog.ui b/src/qt/forms/proposaldialog.ui deleted file mode 100644 index 03599202..00000000 --- a/src/qt/forms/proposaldialog.ui +++ /dev/null @@ -1,224 +0,0 @@ - - - ProposalDialog - - - - 0 - 0 - 640 - 126 - - - - Budget Proposal - - - - 11 - - - 11 - - - 11 - - - 11 - - - 11 - - - - - Fill out the form below to create a budget proposal. Before beginning, make sure your wallet is unlocked to pay the budget proposal fee of 50 ODIN. After the proposal is submitted, wait for the transaction confirmations to complete, and then click Finish Proposal to submit the proposal for voting. The screen will update to help guide you. Do not close the dialog after paying the transaction fee - --it will close automatically once the proposal is submitted. - - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - 11 - - - 11 - - - 11 - - - 11 - - - 11 - - - - - &Proposal Name: - - - nameEdit - - - - - - - - - - - &Proposal URL: - - - urlEdit - - - - - - - - - - - &Payments (Months): - - - paymentsEdit - - - - - - - - - - - &Super Block: - - - blockEdit - - - - - - - - - - - &Payment Address: - - - addressEdit - - - - - - - - - - - &Payment Amount (Month): - - - amountEdit - - - - - - - - - - - &Proposal TXID: - - - hashEdit - - - - - - - - - - - - - - - - - - - - - - Submit Proposal - - - - - - - Cancel - - - - - - - - - - - - - buttonBox - accepted() - ProposalDialog - accept() - - - 20 - 20 - - - 20 - 20 - - - - - buttonBox - rejected() - ProposalDialog - reject() - - - 20 - 20 - - - 20 - 20 - - - - - \ No newline at end of file From ea70f0c68ab2b1c2b9dc7029dcc0ed9b5a6a251e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 22:08:48 -0400 Subject: [PATCH 202/469] Update Makefile.qt.include --- src/Makefile.qt.include | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index f7dbf2bd..49c453a9 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -46,7 +46,6 @@ QT_FORMS_UI = \ qt/forms/optionsdialog.ui \ qt/forms/overviewpage.ui \ qt/forms/privatesendpage.ui \ - qt/forms/proposaldialog.ui \ qt/forms/receivecoinsdialog.ui \ qt/forms/receiverequestdialog.ui \ qt/forms/debugwindow.ui \ @@ -83,7 +82,6 @@ QT_MOC_CPP = \ qt/moc_optionsmodel.cpp \ qt/moc_overviewpage.cpp \ qt/moc_privatesendpage.cpp \ - qt/moc_proposaldialog.cpp \ qt/moc_peertablemodel.cpp \ qt/moc_paymentserver.cpp \ qt/moc_qrdialog.cpp \ @@ -165,8 +163,6 @@ BITCOIN_QT_H = \ qt/paymentserver.h \ qt/peertablemodel.h \ qt/platformstyle.h \ - qt/proposaldialog.h \ - qt/proposalrecord.h \ qt/qrdialog.h \ qt/qvalidatedlineedit.h \ qt/qvaluecombobox.h \ @@ -511,8 +507,6 @@ BITCOIN_QT_WALLET_CPP = \ qt/openuridialog.cpp \ qt/overviewpage.cpp \ qt/privatesendpage.cpp \ - qt/proposaldialog.cpp \ - qt/proposalrecord.cpp \ qt/paymentrequestplus.cpp \ qt/paymentserver.cpp \ qt/qrdialog.cpp \ From 92f9dda7ce4975dd120fa4d4cdae7eb3f16ecb7f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Fri, 29 May 2020 22:09:44 -0400 Subject: [PATCH 203/469] Update governancelist.cpp --- src/qt/governancelist.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qt/governancelist.cpp b/src/qt/governancelist.cpp index 88b1c452..d91077a3 100644 --- a/src/qt/governancelist.cpp +++ b/src/qt/governancelist.cpp @@ -1,6 +1,4 @@ #include "governancelist.h" -#include "proposaldialog.h" -#include "proposalrecord.h" #include "ui_governancelist.h" #include #include From 9e8f71d5cece3456ef98213589945749ff447292 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 19:56:46 -0400 Subject: [PATCH 204/469] Add files via upload --- src/qt/proposaldialog.cpp | 297 ++++++++++++++++++++++++++++++++++++++ src/qt/proposaldialog.h | 64 ++++++++ 2 files changed, 361 insertions(+) create mode 100644 src/qt/proposaldialog.cpp create mode 100644 src/qt/proposaldialog.h diff --git a/src/qt/proposaldialog.cpp b/src/qt/proposaldialog.cpp new file mode 100644 index 00000000..943bf952 --- /dev/null +++ b/src/qt/proposaldialog.cpp @@ -0,0 +1,297 @@ +// Copyright (c) 2017-2018 The Bulwark Developers +// Copyright (c) 2019 The Phore Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#if defined(HAVE_CONFIG_H) +#include +#endif + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +ProposalDialog::ProposalDialog(Mode mode, QWidget* parent) : QDialog(parent), ui(new Ui::ProposalDialog), mapper(0), mode(mode), counter(0) +{ + ui->setupUi(this); + + switch (mode) { + case PrepareProposal: + setWindowTitle(tr("Prepare Proposal")); + ui->confirmLabel->setVisible(false); + ui->hashEdit->setVisible(false); + ui->hashLabel->setVisible(false); + break; + case SubmitProposal: + setWindowTitle(tr("Submit Proposal")); + ui->confirmLabel->setVisible(true); + ui->hashEdit->setVisible(true); + ui->hashLabel->setVisible(true); + break; + } + + ui->nameEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->nameEdit->setPlaceholderText(tr("Provide a proposal name, keep it short")); + ui->nameEdit->setToolTip(tr("Provide a proposal name, keep it short")); + + ui->urlEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->urlEdit->setPlaceholderText(tr("Valid http or https URL (include http:// or https://")); + ui->urlEdit->setToolTip(tr("Valid http or https URL (include http:// or https://")); + + ui->paymentsEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->paymentsEdit->setPlaceholderText(tr("How many monthly payments, 1 per budget cycle")); + ui->paymentsEdit->setToolTip(tr("How many monthly payments, 1 per budget cycle")); + ui->paymentsEdit->setValidator(new QIntValidator(1, 100)); + + ui->blockEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->blockEdit->setPlaceholderText(tr("The governance budget block for the desired cycle (default to next)")); + ui->blockEdit->setToolTip(tr("The governance budget block for the desired cycle (default to next)")); + ui->blockEdit->setValidator(new QIntValidator(1, INT_MAX)); + + ui->addressEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->addressEdit->setPlaceholderText(tr("The public ODIN address that will receive the funds")); + ui->addressEdit->setToolTip(tr("The public ODIN address that will receive the funds")); + + ui->amountEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->amountEdit->setPlaceholderText(tr("The amount to be paid per month or cycle")); + ui->amountEdit->setToolTip(tr("The amount to be paid per month or cycle")); + ui->amountEdit->setValidator(new QIntValidator(10, INT_MAX)); + + ui->hashEdit->setFont(GUIUtil::bitcoinAddressFont()); + ui->hashEdit->setPlaceholderText(tr("The TXID of the proposal hash, must be confirmed before use")); + ui->hashEdit->setToolTip(tr("The TXID of the proposal hash, must be confirmed before use")); + + ui->confirmLabel->setWordWrap(true); + ui->infoLabel->setWordWrap(true); + + // Load next superblock number. + CBlockIndex* pindexPrev = chainActive.Tip(); + if (!pindexPrev) return; + int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); + ui->blockEdit->setText(QString::number(nNext)); + + // Start periodic updates to handle submit block depth validation. + timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(checkProposalTX())); +} + +ProposalDialog::~ProposalDialog() +{ + delete ui; +} + +void ProposalDialog::prepareProposal() +{ + std::string strError = ""; + + if (pwalletMain->IsLocked()) + { + strError = "Error: Please enter the wallet passphrase with walletpassphrase first."; + QMessageBox::critical(this, "Prepare Proposal Error", QString::fromStdString(strError)); + return; + } + + std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); + std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); + int nPaymentCount = ui->paymentsEdit->text().toInt(); + int nBlockStart = ui->blockEdit->text().toInt(); + std::string address = ui->addressEdit->text().toStdString(); + CScript scriptPubKey = GetScriptForDestination(DecodeDestination(address)); + CAmount nAmount = AmountFromValue(ui->amountEdit->text().toInt()); + + //************************************************************************* + + // create the proposal incase we're the first to make it + CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, 0); + std::string err; + if (!budgetProposalBroadcast.IsValid(err, false)) strError = "Proposal is not valid - " + budgetProposalBroadcast.GetHash().ToString() + " - " + err; + + bool useIX = false; + if (strError.empty() && !pwalletMain->GetBudgetSystemCollateralTX(wtx, budgetProposalBroadcast.GetHash(), useIX)) + { + strError = "Error making collateral transaction for proposal. Please check your wallet balance."; + } + + // make our change address + CReserveKey reservekey(pwalletMain); + // send the tx to the network + if (strError.empty() && !pwalletMain->CommitTransaction(wtx, reservekey, useIX ? "ix" : "tx")) + { + strError = "Unable to commit proposal transaction."; + } + + if (!strError.empty()) + { + std::cout << strError << std::endl; + QMessageBox::critical(this, "Prepare Proposal Error", QString::fromStdString(strError)); + return; + } + + // update the local view with submit view + ui->cancelButton->setDisabled(true); + ui->nameEdit->setDisabled(true); + ui->urlEdit->setDisabled(true); + ui->paymentsEdit->setDisabled(true); + ui->blockEdit->setDisabled(true); + ui->addressEdit->setDisabled(true); + ui->amountEdit->setDisabled(true); + ui->hashEdit->setDisabled(true); + + ui->acceptButton->setDisabled(true); + ui->acceptButton->setText(tr("Waiting...")); + + ui->confirmLabel->setVisible(true); + ui->confirmLabel->setText(QString::fromStdString("Waiting for confirmations...")); + + ui->hashEdit->setText(QString::fromStdString(wtx.GetHash().ToString())); + ui->hashEdit->setVisible(true); + ui->hashLabel->setVisible(true); + + mode = SubmitProposal; + setWindowTitle(tr("Submit Proposal")); + + timer->start(1000); + counter = chainActive.Tip()->nHeight + 1; +} + +void ProposalDialog::submitProposal() +{ + std::string strError = ""; + + std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); + std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); + int nPaymentCount = ui->paymentsEdit->text().toInt(); + int nBlockStart = ui->blockEdit->text().toInt(); + std::string address = ui->addressEdit->text().toStdString(); + CScript scriptPubKey = GetScriptForDestination(DecodeDestination(address)); + CAmount nAmount = AmountFromValue(ui->amountEdit->text().toInt()); + uint256 hash = ParseHashV(ui->hashEdit->text().toStdString(), "parameter 1"); + + //************************************************************************* + + // create the proposal incase we're the first to make it + int nConf = 0; + std::string err = ""; + CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, hash); + if (!IsBudgetCollateralValid(hash, budgetProposalBroadcast.GetHash(), err, budgetProposalBroadcast.nTime, nConf)) + { + strError = "Proposal FeeTX is not valid - " + hash.ToString() + " - " + err; + } + + if (strError.empty() && !budget.AddProposal(budgetProposalBroadcast)) strError = "Invalid proposal, see debug.log for details."; + + if (!strError.empty()) + { + std::cout << strError << std::endl; + QMessageBox::critical(this, tr("Submit Proposal Error"), QString::fromStdString(strError)); + return; + } + + budget.mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast)); + budgetProposalBroadcast.Relay(); + + this->accept(); +} + +bool ProposalDialog::validateProposal() +{ + std::string strError = ""; + + if (!masternodeSync.IsBlockchainSynced()) strError = "Must wait for client to sync with masternode network. Try again in a minute or so."; + + std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); + if (strProposalName.size() > 20) strError = "Invalid proposal name, limit of 20 characters."; + + std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); + if (strURL.size() > 64) strError = "Invalid url, limit of 64 characters."; + + int nPaymentCount = ui->paymentsEdit->text().toInt(); + if (nPaymentCount < 1) strError = "Invalid payment count, must be more than zero."; + + // Start must be in the next budget cycle + int nBlockMin = 0; + CBlockIndex* pindexPrev = chainActive.Tip(); + if (pindexPrev != NULL) nBlockMin = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); + + int nBlockStart = ui->blockEdit->text().toInt(); + if (nBlockStart < nBlockMin) strError = "Invalid block start, must be more than current height."; + if (nBlockStart % GetBudgetPaymentCycleBlocks() != 0) + { + int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); + strError = strprintf("Invalid block start - must be a budget cycle block. Next valid block: %d", nNext); + } + + int nBlockEnd = nBlockStart + (GetBudgetPaymentCycleBlocks() * nPaymentCount); // End must be AFTER current cycle + if (nBlockEnd < pindexPrev->nHeight) strError = "Invalid ending block, starting block + (payment_cycle*payments) must be more than current height."; + + std::string address = ui->addressEdit->text().toStdString(); + if (!IsValidDestinationString(address)) strError = "Invalid ODIN address"; + + if (!strError.empty()) + { + QMessageBox::critical(this, tr("Submit Proposal Error"), QString::fromStdString(strError)); + return false; + } + + return true; +} + +void ProposalDialog::checkProposalTX() +{ + if (mode != SubmitProposal) return; + + int nConf = Params().BudgetFeeConfirmations(); + int nDepth = (chainActive.Tip()->nHeight + 1) - counter; + if (nDepth > nConf) + { + ui->acceptButton->setDisabled(false); + ui->acceptButton->setText("Finish Proposal"); + ui->confirmLabel->setText(tr("Click on Finish Proposal to complete the proposal and start voting.")); + + timer->stop(); + } + else if (nDepth == nConf) + { + ui->confirmLabel->setText(QString::fromStdString("Waiting for final confirmation...")); + } + else if (nDepth > 0) + { + ui->confirmLabel->setText(QString::fromStdString(strprintf("Currently %d of %d confirmations...", nDepth, (nConf + 1)).c_str())); + } +} + +void ProposalDialog::on_acceptButton_clicked() +{ + if (!validateProposal()) return; + + if (mode == PrepareProposal) + { + prepareProposal(); + } + else if (mode == SubmitProposal) + { + submitProposal(); + } +} + +void ProposalDialog::on_cancelButton_clicked() +{ + this->reject(); +} diff --git a/src/qt/proposaldialog.h b/src/qt/proposaldialog.h new file mode 100644 index 00000000..220fe01f --- /dev/null +++ b/src/qt/proposaldialog.h @@ -0,0 +1,64 @@ +// Copyright (c) 2017-2018 The Bulwark Developers +// Copyright (c) 2019 The Phore Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_CREATEPROPOSALDIALOG_H +#define BITCOIN_QT_CREATEPROPOSALDIALOG_H + +#include +#include +#include +#include + +#include +#include +#include +#include + +class ProposalModel; + +namespace Ui +{ + class ProposalDialog; +} + +QT_BEGIN_NAMESPACE +class QDataWidgetMapper; +QT_END_NAMESPACE + +/** + * Dialog for creating a proposal. + */ +class ProposalDialog : public QDialog +{ + Q_OBJECT + +public: + enum Mode { + PrepareProposal, + SubmitProposal + }; + + explicit ProposalDialog(Mode mode, QWidget* parent); + ~ProposalDialog(); + +public slots: + void checkProposalTX(); + void on_acceptButton_clicked(); + void on_cancelButton_clicked(); + +private: + Ui::ProposalDialog *ui; + QDataWidgetMapper *mapper; + Mode mode; + QTimer *timer; + CWalletTx wtx; + int counter; + + void prepareProposal(); + void submitProposal(); + bool validateProposal(); +}; + +#endif // BITCOIN_QT_CREATEPROPOSALDIALOG_H \ No newline at end of file From a2a2abeeb8a81a0afaa8e090e50555075d987c6a Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 19:58:40 -0400 Subject: [PATCH 205/469] Update proposaldialog.cpp --- src/qt/proposaldialog.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qt/proposaldialog.cpp b/src/qt/proposaldialog.cpp index 943bf952..b41bf903 100644 --- a/src/qt/proposaldialog.cpp +++ b/src/qt/proposaldialog.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -84,7 +84,7 @@ ProposalDialog::ProposalDialog(Mode mode, QWidget* parent) : QDialog(parent), ui // Load next superblock number. CBlockIndex* pindexPrev = chainActive.Tip(); if (!pindexPrev) return; - int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); + int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetNearestSuperblocksHeights() + GetNearestSuperblocksHeights(); ui->blockEdit->setText(QString::number(nNext)); // Start periodic updates to handle submit block depth validation. @@ -228,17 +228,17 @@ bool ProposalDialog::validateProposal() // Start must be in the next budget cycle int nBlockMin = 0; CBlockIndex* pindexPrev = chainActive.Tip(); - if (pindexPrev != NULL) nBlockMin = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); + if (pindexPrev != NULL) nBlockMin = pindexPrev->nHeight - pindexPrev->nHeight % GetNearestSuperblocksHeights() + GetNearestSuperblocksHeights(); int nBlockStart = ui->blockEdit->text().toInt(); if (nBlockStart < nBlockMin) strError = "Invalid block start, must be more than current height."; - if (nBlockStart % GetBudgetPaymentCycleBlocks() != 0) + if (nBlockStart % GetNearestSuperblocksHeights() != 0) { - int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetBudgetPaymentCycleBlocks() + GetBudgetPaymentCycleBlocks(); + int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetNearestSuperblocksHeights() + GetNearestSuperblocksHeights(); strError = strprintf("Invalid block start - must be a budget cycle block. Next valid block: %d", nNext); } - int nBlockEnd = nBlockStart + (GetBudgetPaymentCycleBlocks() * nPaymentCount); // End must be AFTER current cycle + int nBlockEnd = nBlockStart + (GetNearestSuperblocksHeights() * nPaymentCount); // End must be AFTER current cycle if (nBlockEnd < pindexPrev->nHeight) strError = "Invalid ending block, starting block + (payment_cycle*payments) must be more than current height."; std::string address = ui->addressEdit->text().toStdString(); From 4c4554e7ce783d5bc02007502fcc0278f96bf260 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 19:59:24 -0400 Subject: [PATCH 206/469] Update proposaldialog.h --- src/qt/proposaldialog.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/proposaldialog.h b/src/qt/proposaldialog.h index 220fe01f..b975e184 100644 --- a/src/qt/proposaldialog.h +++ b/src/qt/proposaldialog.h @@ -6,7 +6,7 @@ #ifndef BITCOIN_QT_CREATEPROPOSALDIALOG_H #define BITCOIN_QT_CREATEPROPOSALDIALOG_H -#include +#include #include #include #include @@ -61,4 +61,4 @@ public slots: bool validateProposal(); }; -#endif // BITCOIN_QT_CREATEPROPOSALDIALOG_H \ No newline at end of file +#endif // BITCOIN_QT_CREATEPROPOSALDIALOG_H From 55f74ecba58ce6959fb85a0aca26f7552c336e10 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 19:59:45 -0400 Subject: [PATCH 207/469] Add files via upload --- src/qt/forms/proposaldialog.ui | 224 +++++++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 src/qt/forms/proposaldialog.ui diff --git a/src/qt/forms/proposaldialog.ui b/src/qt/forms/proposaldialog.ui new file mode 100644 index 00000000..03599202 --- /dev/null +++ b/src/qt/forms/proposaldialog.ui @@ -0,0 +1,224 @@ + + + ProposalDialog + + + + 0 + 0 + 640 + 126 + + + + Budget Proposal + + + + 11 + + + 11 + + + 11 + + + 11 + + + 11 + + + + + Fill out the form below to create a budget proposal. Before beginning, make sure your wallet is unlocked to pay the budget proposal fee of 50 ODIN. After the proposal is submitted, wait for the transaction confirmations to complete, and then click Finish Proposal to submit the proposal for voting. The screen will update to help guide you. Do not close the dialog after paying the transaction fee + --it will close automatically once the proposal is submitted. + + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + 11 + + + 11 + + + 11 + + + 11 + + + 11 + + + + + &Proposal Name: + + + nameEdit + + + + + + + + + + + &Proposal URL: + + + urlEdit + + + + + + + + + + + &Payments (Months): + + + paymentsEdit + + + + + + + + + + + &Super Block: + + + blockEdit + + + + + + + + + + + &Payment Address: + + + addressEdit + + + + + + + + + + + &Payment Amount (Month): + + + amountEdit + + + + + + + + + + + &Proposal TXID: + + + hashEdit + + + + + + + + + + + + + + + + + + + + + + Submit Proposal + + + + + + + Cancel + + + + + + + + + + + + + buttonBox + accepted() + ProposalDialog + accept() + + + 20 + 20 + + + 20 + 20 + + + + + buttonBox + rejected() + ProposalDialog + reject() + + + 20 + 20 + + + 20 + 20 + + + + + \ No newline at end of file From 95bad80fc963f3fa6c4583bbb8e39c67a1988361 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:02:01 -0400 Subject: [PATCH 208/469] Update Makefile.qt.include --- src/Makefile.qt.include | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 49c453a9..65aa1183 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -46,6 +46,7 @@ QT_FORMS_UI = \ qt/forms/optionsdialog.ui \ qt/forms/overviewpage.ui \ qt/forms/privatesendpage.ui \ + qt/forms/proposaldialog.ui \ qt/forms/receivecoinsdialog.ui \ qt/forms/receiverequestdialog.ui \ qt/forms/debugwindow.ui \ @@ -82,6 +83,7 @@ QT_MOC_CPP = \ qt/moc_optionsmodel.cpp \ qt/moc_overviewpage.cpp \ qt/moc_privatesendpage.cpp \ + qt/moc_proposaldialog.cpp \ qt/moc_peertablemodel.cpp \ qt/moc_paymentserver.cpp \ qt/moc_qrdialog.cpp \ @@ -159,6 +161,7 @@ BITCOIN_QT_H = \ qt/optionsmodel.h \ qt/overviewpage.h \ qt/privatesendpage.h \ + qt/proposaldialog.h \ qt/paymentrequestplus.h \ qt/paymentserver.h \ qt/peertablemodel.h \ @@ -507,6 +510,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/openuridialog.cpp \ qt/overviewpage.cpp \ qt/privatesendpage.cpp \ + qt/proposaldialog.cpp \ qt/paymentrequestplus.cpp \ qt/paymentserver.cpp \ qt/qrdialog.cpp \ From a90cfe98c321369aa79546c4d5b7bf9eaab0cc16 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:03:17 -0400 Subject: [PATCH 209/469] Update proposaldialog.cpp --- src/qt/proposaldialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/proposaldialog.cpp b/src/qt/proposaldialog.cpp index b41bf903..06cf83b6 100644 --- a/src/qt/proposaldialog.cpp +++ b/src/qt/proposaldialog.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include From 2a19c1cdbc8edf6e571c1ae6f7f0dd6a22388929 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:03:37 -0400 Subject: [PATCH 210/469] Update proposaldialog.h --- src/qt/proposaldialog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/proposaldialog.h b/src/qt/proposaldialog.h index b975e184..ee55c65f 100644 --- a/src/qt/proposaldialog.h +++ b/src/qt/proposaldialog.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include From 6a34584122133c053de83095efc66c485ace9d66 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:05:50 -0400 Subject: [PATCH 211/469] Update proposaldialog.h --- src/qt/proposaldialog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/proposaldialog.h b/src/qt/proposaldialog.h index ee55c65f..ed99bb9f 100644 --- a/src/qt/proposaldialog.h +++ b/src/qt/proposaldialog.h @@ -43,7 +43,7 @@ class ProposalDialog : public QDialog explicit ProposalDialog(Mode mode, QWidget* parent); ~ProposalDialog(); -public slots: +public Q_SLOTS: void checkProposalTX(); void on_acceptButton_clicked(); void on_cancelButton_clicked(); From 604e05eb042f5d186d415de7fc5556b0e1b70775 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:08:49 -0400 Subject: [PATCH 212/469] Update guiutil.cpp --- src/qt/guiutil.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index d6a314ac..7707c836 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -89,6 +89,17 @@ namespace GUIUtil { { return dateTimeStr(QDateTime::fromTime_t((qint32)nTime)); } + + QFont bitcoinAddressFont() +{ + QFont font("Monospace"); +#if QT_VERSION >= 0x040800 + font.setStyleHint(QFont::Monospace); +#else + font.setStyleHint(QFont::TypeWriter); +#endif + return font; +} QFont fixedPitchFont() { From c3a9caa5f13f8882ed16c1e498545dbf04e79bc1 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:09:56 -0400 Subject: [PATCH 213/469] Update guiutil.cpp --- src/qt/guiutil.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 7707c836..240994d8 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -99,6 +99,80 @@ namespace GUIUtil { font.setStyleHint(QFont::TypeWriter); #endif return font; +} + + void setupAddressWidget(QValidatedLineEdit* widget, QWidget* parent) +{ + parent->setFocusProxy(widget); + + widget->setFont(bitcoinAddressFont()); +#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 an ODIN address (e.g. %1)").arg("oRBrSswefQ6aqQqgZ3New6Ws5QYSCXdqgL")); +#endif + widget->setValidator(new BitcoinAddressEntryValidator(parent)); + widget->setCheckValidator(new BitcoinAddressCheckValidator(parent)); +} + +void setupAliasWidget(QValidatedLineEdit* widget, QWidget* parent) +{ + parent->setFocusProxy(widget); + + widget->setFont(bitcoinAddressFont()); +#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 Masternode Alias (e.g. %1)").arg("mn1")); +#endif +} + +void setupIPWidget(QValidatedLineEdit* widget, QWidget* parent) +{ + parent->setFocusProxy(widget); + + widget->setFont(bitcoinAddressFont()); +#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 VPS IP (e.g. %1)").arg("127.0.0.2:11771")); +#endif +} + +void setupPrivKeyWidget(QValidatedLineEdit* widget, QWidget* parent) +{ + parent->setFocusProxy(widget); + + widget->setFont(bitcoinAddressFont()); +#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 Private Key (e.g. %1)").arg("93HaYBVUCYjEMeeH1Y4sBGLALQZE1Yc1K64xiqgX37tGBDQL8Xt")); +#endif +} + +void setupTXIDWidget(QValidatedLineEdit* widget, QWidget* parent) +{ + parent->setFocusProxy(widget); + + widget->setFont(bitcoinAddressFont()); +#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 TX Output (e.g. %1)").arg("2bcd3c84c84f87eaa86e4e56834c92937a07f9e18718810b92e0d0324456a57c")); +#endif +} + +void setupTXIDIndexWidget(QValidatedLineEdit* widget, QWidget* parent) +{ + parent->setFocusProxy(widget); + + widget->setFont(bitcoinAddressFont()); +#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 TX Index (e.g. %1)").arg("1")); +#endif } QFont fixedPitchFont() From 46416f6a3bd7bbd3dfd3fc48e921524fec502db2 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:11:03 -0400 Subject: [PATCH 214/469] Update guiutil.h --- src/qt/guiutil.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 24aaf89a..ea646a69 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -39,6 +39,18 @@ namespace GUIUtil QString TOQS(std::string s); std::string FROMQS(QString qs); + // Render ODIN addresses in monospace font +QFont bitcoinAddressFont(); + +// Set up widgets for address and amounts + +void setupAliasWidget(QValidatedLineEdit* widget, QWidget* parent); +void setupIPWidget(QValidatedLineEdit* widget, QWidget* parent); +void setupPrivKeyWidget(QValidatedLineEdit* widget, QWidget* parent); +void setupTXIDWidget(QValidatedLineEdit* widget, QWidget* parent); +void setupTXIDIndexWidget(QValidatedLineEdit* widget, QWidget* parent); + + // Create human-readable string from date QString dateTimeStr(const QDateTime &datetime); QString dateTimeStr(qint64 nTime); From 9e3d2f93079a82ce367e89b02b8d2ffa0cd2c770 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:13:29 -0400 Subject: [PATCH 215/469] Update guiutil.cpp --- src/qt/guiutil.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 240994d8..2a54b7ae 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -206,12 +206,7 @@ void setupTXIDIndexWidget(QValidatedLineEdit* widget, QWidget* parent) } return ""; } - - void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent) - { - parent->setFocusProxy(widget); - - widget->setFont(fixedPitchFont()); + #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. From 2d76b8a563202579cc46ca946f78dd331cb92ae9 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:20:22 -0400 Subject: [PATCH 216/469] Update guiutil.h --- src/qt/guiutil.h | 105 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 75 insertions(+), 30 deletions(-) diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index ea646a69..0431e235 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -80,13 +80,43 @@ void setupTXIDIndexWidget(QValidatedLineEdit* widget, QWidget* parent); @param[in] role Data role to extract from the model @see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress */ - void copyEntryData(QAbstractItemView *view, int column, int role=Qt::EditRole); + void copyEntryData(QAbstractItemView* view, int column, int role = Qt::EditRole); - /** Return a field of the currently selected entry as a QString. Does nothing if nothing +/** Return a field of the currently selected entry as a QString. Does nothing if nothing is selected. @param[in] column Data column to extract from the model + @param[in] role Data role to extract from the model @see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress */ +QString getEntryData(QAbstractItemView *view, int column, int role); + +void setClipboard(const QString& str); + +/** Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix + when no suffix is provided by the user. + @param[in] parent Parent window (or 0) + @param[in] caption Window caption (or empty, for default) + @param[in] dir Starting directory (or empty, to default to documents directory) + @param[in] filter Filter specification such as "Comma Separated Files (*.csv)" + @param[out] selectedSuffixOut Pointer to return the suffix (file type) that was selected (or 0). + Can be useful when choosing the save file format based on suffix. + */ +QString getSaveFileName(QWidget* parent, const QString& caption, const QString& dir, const QString& filter, QString* selectedSuffixOut); + +/** Get open filename, convenience wrapper for QFileDialog::getOpenFileName. + @param[in] parent Parent window (or 0) + @param[in] caption Window caption (or empty, for default) + @param[in] dir Starting directory (or empty, to default to documents directory) + @param[in] filter Filter specification such as "Comma Separated Files (*.csv)" + @param[out] selectedSuffixOut Pointer to return the suffix (file type) that was selected (or 0). + Can be useful when choosing the save file format based on suffix. + */ +QString getOpenFileName(QWidget* parent, const QString& caption, const QString& dir, const QString& filter, QString* selectedSuffixOut); + +/** Get connection type to call object slot in GUI thread with invokeMethod. The call will be blocking. + @returns If called from the GUI thread, return a Qt::DirectConnection. + If called from another thread, return a Qt::BlockingQueuedConnection. + */ QList getEntryData(QAbstractItemView *view, int column); void setClipboard(const QString& str); @@ -168,34 +198,49 @@ void setupTXIDIndexWidget(QValidatedLineEdit* widget, QWidget* parent); * This helper object takes care of this issue. * */ - class TableViewLastColumnResizingFixer: public QObject - { - Q_OBJECT - - public: - TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth, QObject *parent); - void stretchColumnWidth(int column); - - private: - QTableView* tableView; - int lastColumnMinimumWidth; - int allColumnsMinimumWidth; - int lastColumnIndex; - int columnCount; - int secondToLastColumnIndex; - - void adjustTableColumnsWidth(); - int getAvailableWidthForColumn(int column); - int getColumnsWidth(); - void connectViewHeadersSignals(); - void disconnectViewHeadersSignals(); - void setViewHeaderResizeMode(int logicalIndex, QHeaderView::ResizeMode resizeMode); - void resizeColumn(int nColumnIndex, int width); - - private Q_SLOTS: - void on_sectionResized(int logicalIndex, int oldSize, int newSize); - void on_geometriesChanged(); - }; + class TableViewLastColumnResizingFixer : public QObject +{ + Q_OBJECT + +public: + TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth); + void stretchColumnWidth(int column); + +private: + QTableView* tableView; + int lastColumnMinimumWidth; + int allColumnsMinimumWidth; + int lastColumnIndex; + int columnCount; + int secondToLastColumnIndex; + + void adjustTableColumnsWidth(); + int getAvailableWidthForColumn(int column); + int getColumnsWidth(); + void connectViewHeadersSignals(); + void disconnectViewHeadersSignals(); + void setViewHeaderResizeMode(int logicalIndex, QHeaderView::ResizeMode resizeMode); + void resizeColumn(int nColumnIndex, int width); + +private Q_SLOTS: + void on_sectionResized(int logicalIndex, int oldSize, int newSize); + void on_geometriesChanged(); +}; + +/** + * Extension to QTableWidgetItem that facilitates proper ordering for "DHMS" + * strings (primarily used in the masternode's "active" listing). + */ +class DHMSTableWidgetItem : public QTableWidgetItem +{ +public: + DHMSTableWidgetItem(const int64_t seconds); + virtual bool operator<(QTableWidgetItem const& item) const; + +private: + // Private backing value for DHMS string, used for sorting. + int64_t value; +}; bool GetStartOnSystemStartup(); bool SetStartOnSystemStartup(bool fAutoStart); From 7ca1f6e81ac033cc2e644a0f6aa8534fb34a951d Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:21:10 -0400 Subject: [PATCH 217/469] Update guiutil.h --- src/qt/guiutil.h | 122 +++++++++++------------------------------------ 1 file changed, 29 insertions(+), 93 deletions(-) diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 0431e235..4f37ef7c 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -36,21 +36,6 @@ QT_END_NAMESPACE */ namespace GUIUtil { - QString TOQS(std::string s); - std::string FROMQS(QString qs); - - // Render ODIN addresses in monospace font -QFont bitcoinAddressFont(); - -// Set up widgets for address and amounts - -void setupAliasWidget(QValidatedLineEdit* widget, QWidget* parent); -void setupIPWidget(QValidatedLineEdit* widget, QWidget* parent); -void setupPrivKeyWidget(QValidatedLineEdit* widget, QWidget* parent); -void setupTXIDWidget(QValidatedLineEdit* widget, QWidget* parent); -void setupTXIDIndexWidget(QValidatedLineEdit* widget, QWidget* parent); - - // Create human-readable string from date QString dateTimeStr(const QDateTime &datetime); QString dateTimeStr(qint64 nTime); @@ -80,50 +65,19 @@ void setupTXIDIndexWidget(QValidatedLineEdit* widget, QWidget* parent); @param[in] role Data role to extract from the model @see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress */ - void copyEntryData(QAbstractItemView* view, int column, int role = Qt::EditRole); + void copyEntryData(QAbstractItemView *view, int column, int role=Qt::EditRole); -/** Return a field of the currently selected entry as a QString. Does nothing if nothing + /** Return a field of the currently selected entry as a QString. Does nothing if nothing is selected. @param[in] column Data column to extract from the model - @param[in] role Data role to extract from the model @see TransactionView::copyLabel, TransactionView::copyAmount, TransactionView::copyAddress */ -QString getEntryData(QAbstractItemView *view, int column, int role); - -void setClipboard(const QString& str); - -/** Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix - when no suffix is provided by the user. - @param[in] parent Parent window (or 0) - @param[in] caption Window caption (or empty, for default) - @param[in] dir Starting directory (or empty, to default to documents directory) - @param[in] filter Filter specification such as "Comma Separated Files (*.csv)" - @param[out] selectedSuffixOut Pointer to return the suffix (file type) that was selected (or 0). - Can be useful when choosing the save file format based on suffix. - */ -QString getSaveFileName(QWidget* parent, const QString& caption, const QString& dir, const QString& filter, QString* selectedSuffixOut); - -/** Get open filename, convenience wrapper for QFileDialog::getOpenFileName. - @param[in] parent Parent window (or 0) - @param[in] caption Window caption (or empty, for default) - @param[in] dir Starting directory (or empty, to default to documents directory) - @param[in] filter Filter specification such as "Comma Separated Files (*.csv)" - @param[out] selectedSuffixOut Pointer to return the suffix (file type) that was selected (or 0). - Can be useful when choosing the save file format based on suffix. - */ -QString getOpenFileName(QWidget* parent, const QString& caption, const QString& dir, const QString& filter, QString* selectedSuffixOut); - -/** Get connection type to call object slot in GUI thread with invokeMethod. The call will be blocking. - @returns If called from the GUI thread, return a Qt::DirectConnection. - If called from another thread, return a Qt::BlockingQueuedConnection. - */ QList getEntryData(QAbstractItemView *view, int column); void setClipboard(const QString& str); /** Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix when no suffix is provided by the user. - @param[in] parent Parent window (or 0) @param[in] caption Window caption (or empty, for default) @param[in] dir Starting directory (or empty, to default to documents directory) @@ -136,7 +90,6 @@ QString getOpenFileName(QWidget* parent, const QString& caption, const QString& QString *selectedSuffixOut); /** Get open filename, convenience wrapper for QFileDialog::getOpenFileName. - @param[in] parent Parent window (or 0) @param[in] caption Window caption (or empty, for default) @param[in] dir Starting directory (or empty, to default to documents directory) @@ -149,7 +102,6 @@ QString getOpenFileName(QWidget* parent, const QString& caption, const QString& QString *selectedSuffixOut); /** Get connection type to call object slot in GUI thread with invokeMethod. The call will be blocking. - @returns If called from the GUI thread, return a Qt::DirectConnection. If called from another thread, return a Qt::BlockingQueuedConnection. */ @@ -198,49 +150,34 @@ QString getOpenFileName(QWidget* parent, const QString& caption, const QString& * This helper object takes care of this issue. * */ - class TableViewLastColumnResizingFixer : public QObject -{ - Q_OBJECT - -public: - TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth); - void stretchColumnWidth(int column); - -private: - QTableView* tableView; - int lastColumnMinimumWidth; - int allColumnsMinimumWidth; - int lastColumnIndex; - int columnCount; - int secondToLastColumnIndex; - - void adjustTableColumnsWidth(); - int getAvailableWidthForColumn(int column); - int getColumnsWidth(); - void connectViewHeadersSignals(); - void disconnectViewHeadersSignals(); - void setViewHeaderResizeMode(int logicalIndex, QHeaderView::ResizeMode resizeMode); - void resizeColumn(int nColumnIndex, int width); - -private Q_SLOTS: - void on_sectionResized(int logicalIndex, int oldSize, int newSize); - void on_geometriesChanged(); -}; - -/** - * Extension to QTableWidgetItem that facilitates proper ordering for "DHMS" - * strings (primarily used in the masternode's "active" listing). - */ -class DHMSTableWidgetItem : public QTableWidgetItem -{ -public: - DHMSTableWidgetItem(const int64_t seconds); - virtual bool operator<(QTableWidgetItem const& item) const; + class TableViewLastColumnResizingFixer: public QObject + { + Q_OBJECT -private: - // Private backing value for DHMS string, used for sorting. - int64_t value; -}; + public: + TableViewLastColumnResizingFixer(QTableView* table, int lastColMinimumWidth, int allColsMinimumWidth, QObject *parent); + void stretchColumnWidth(int column); + + private: + QTableView* tableView; + int lastColumnMinimumWidth; + int allColumnsMinimumWidth; + int lastColumnIndex; + int columnCount; + int secondToLastColumnIndex; + + void adjustTableColumnsWidth(); + int getAvailableWidthForColumn(int column); + int getColumnsWidth(); + void connectViewHeadersSignals(); + void disconnectViewHeadersSignals(); + void setViewHeaderResizeMode(int logicalIndex, QHeaderView::ResizeMode resizeMode); + void resizeColumn(int nColumnIndex, int width); + + private Q_SLOTS: + void on_sectionResized(int logicalIndex, int oldSize, int newSize); + void on_geometriesChanged(); + }; bool GetStartOnSystemStartup(); bool SetStartOnSystemStartup(bool fAutoStart); @@ -264,7 +201,6 @@ class DHMSTableWidgetItem : public QTableWidgetItem /* Convert OS specific boost path to QString through UTF-8 */ QString boostPathToQString(const boost::filesystem::path &path); - /* Convert seconds into a QString with days, hours, mins, secs */ QString formatDurationStr(int secs); From 38c46a1eaa71ecc272959931ff5070943686a676 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:21:34 -0400 Subject: [PATCH 218/469] Update guiutil.cpp --- src/qt/guiutil.cpp | 103 +++------------------------------------------ 1 file changed, 6 insertions(+), 97 deletions(-) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 2a54b7ae..2a4416b8 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -89,91 +89,6 @@ namespace GUIUtil { { return dateTimeStr(QDateTime::fromTime_t((qint32)nTime)); } - - QFont bitcoinAddressFont() -{ - QFont font("Monospace"); -#if QT_VERSION >= 0x040800 - font.setStyleHint(QFont::Monospace); -#else - font.setStyleHint(QFont::TypeWriter); -#endif - return font; -} - - void setupAddressWidget(QValidatedLineEdit* widget, QWidget* parent) -{ - parent->setFocusProxy(widget); - - widget->setFont(bitcoinAddressFont()); -#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 an ODIN address (e.g. %1)").arg("oRBrSswefQ6aqQqgZ3New6Ws5QYSCXdqgL")); -#endif - widget->setValidator(new BitcoinAddressEntryValidator(parent)); - widget->setCheckValidator(new BitcoinAddressCheckValidator(parent)); -} - -void setupAliasWidget(QValidatedLineEdit* widget, QWidget* parent) -{ - parent->setFocusProxy(widget); - - widget->setFont(bitcoinAddressFont()); -#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 Masternode Alias (e.g. %1)").arg("mn1")); -#endif -} - -void setupIPWidget(QValidatedLineEdit* widget, QWidget* parent) -{ - parent->setFocusProxy(widget); - - widget->setFont(bitcoinAddressFont()); -#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 VPS IP (e.g. %1)").arg("127.0.0.2:11771")); -#endif -} - -void setupPrivKeyWidget(QValidatedLineEdit* widget, QWidget* parent) -{ - parent->setFocusProxy(widget); - - widget->setFont(bitcoinAddressFont()); -#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 Private Key (e.g. %1)").arg("93HaYBVUCYjEMeeH1Y4sBGLALQZE1Yc1K64xiqgX37tGBDQL8Xt")); -#endif -} - -void setupTXIDWidget(QValidatedLineEdit* widget, QWidget* parent) -{ - parent->setFocusProxy(widget); - - widget->setFont(bitcoinAddressFont()); -#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 TX Output (e.g. %1)").arg("2bcd3c84c84f87eaa86e4e56834c92937a07f9e18718810b92e0d0324456a57c")); -#endif -} - -void setupTXIDIndexWidget(QValidatedLineEdit* widget, QWidget* parent) -{ - parent->setFocusProxy(widget); - - widget->setFont(bitcoinAddressFont()); -#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 TX Index (e.g. %1)").arg("1")); -#endif -} QFont fixedPitchFont() { @@ -206,7 +121,12 @@ void setupTXIDIndexWidget(QValidatedLineEdit* widget, QWidget* parent) } return ""; } - + + void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent) + { + parent->setFocusProxy(widget); + + widget->setFont(fixedPitchFont()); #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. @@ -1057,17 +977,6 @@ void setupTXIDIndexWidget(QValidatedLineEdit* widget, QWidget* parent) return strList.join(" "); } - std::string FROMQS(QString qs) -{ - std::string sOut = qs.toUtf8().constData(); - return sOut; -} - -QString TOQS(std::string s) -{ - QString str1 = QString::fromUtf8(s.c_str()); - return str1; -} QString formatServicesStr(quint64 mask) { From 22b8d06f4d1991e9b7c58c0ada7442f6f08c96c2 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:25:56 -0400 Subject: [PATCH 219/469] Update guiutil.cpp --- src/qt/guiutil.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 2a4416b8..56afbae2 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -90,6 +90,17 @@ namespace GUIUtil { return dateTimeStr(QDateTime::fromTime_t((qint32)nTime)); } + QFont bitcoinAddressFont() +{ + QFont font("Monospace"); +#if QT_VERSION >= 0x040800 + font.setStyleHint(QFont::Monospace); +#else + font.setStyleHint(QFont::TypeWriter); +#endif + return font; +} + QFont fixedPitchFont() { #if QT_VERSION >= 0x50200 From 02cb726459370162176dd6bfc84a7a1f61bd3242 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:26:19 -0400 Subject: [PATCH 220/469] Update guiutil.h --- src/qt/guiutil.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 4f37ef7c..af4c191a 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -40,6 +40,9 @@ namespace GUIUtil QString dateTimeStr(const QDateTime &datetime); QString dateTimeStr(qint64 nTime); + // Render ODIN addresses in monospace font + QFont bitcoinAddressFont(); + // Return a monospace font QFont fixedPitchFont(); From 242082936e72ee980de54961c755bb892417def3 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:43:03 -0400 Subject: [PATCH 221/469] Delete proposaldialog.h --- src/qt/proposaldialog.h | 64 ----------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 src/qt/proposaldialog.h diff --git a/src/qt/proposaldialog.h b/src/qt/proposaldialog.h deleted file mode 100644 index ed99bb9f..00000000 --- a/src/qt/proposaldialog.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2017-2018 The Bulwark Developers -// Copyright (c) 2019 The Phore Developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_QT_CREATEPROPOSALDIALOG_H -#define BITCOIN_QT_CREATEPROPOSALDIALOG_H - -#include -#include -#include -#include - -#include -#include -#include -#include - -class ProposalModel; - -namespace Ui -{ - class ProposalDialog; -} - -QT_BEGIN_NAMESPACE -class QDataWidgetMapper; -QT_END_NAMESPACE - -/** - * Dialog for creating a proposal. - */ -class ProposalDialog : public QDialog -{ - Q_OBJECT - -public: - enum Mode { - PrepareProposal, - SubmitProposal - }; - - explicit ProposalDialog(Mode mode, QWidget* parent); - ~ProposalDialog(); - -public Q_SLOTS: - void checkProposalTX(); - void on_acceptButton_clicked(); - void on_cancelButton_clicked(); - -private: - Ui::ProposalDialog *ui; - QDataWidgetMapper *mapper; - Mode mode; - QTimer *timer; - CWalletTx wtx; - int counter; - - void prepareProposal(); - void submitProposal(); - bool validateProposal(); -}; - -#endif // BITCOIN_QT_CREATEPROPOSALDIALOG_H From 234881988b523826df9479529b7acbeca8388202 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:43:14 -0400 Subject: [PATCH 222/469] Delete proposaldialog.cpp --- src/qt/proposaldialog.cpp | 297 -------------------------------------- 1 file changed, 297 deletions(-) delete mode 100644 src/qt/proposaldialog.cpp diff --git a/src/qt/proposaldialog.cpp b/src/qt/proposaldialog.cpp deleted file mode 100644 index 06cf83b6..00000000 --- a/src/qt/proposaldialog.cpp +++ /dev/null @@ -1,297 +0,0 @@ -// Copyright (c) 2017-2018 The Bulwark Developers -// Copyright (c) 2019 The Phore Developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#if defined(HAVE_CONFIG_H) -#include -#endif - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -ProposalDialog::ProposalDialog(Mode mode, QWidget* parent) : QDialog(parent), ui(new Ui::ProposalDialog), mapper(0), mode(mode), counter(0) -{ - ui->setupUi(this); - - switch (mode) { - case PrepareProposal: - setWindowTitle(tr("Prepare Proposal")); - ui->confirmLabel->setVisible(false); - ui->hashEdit->setVisible(false); - ui->hashLabel->setVisible(false); - break; - case SubmitProposal: - setWindowTitle(tr("Submit Proposal")); - ui->confirmLabel->setVisible(true); - ui->hashEdit->setVisible(true); - ui->hashLabel->setVisible(true); - break; - } - - ui->nameEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->nameEdit->setPlaceholderText(tr("Provide a proposal name, keep it short")); - ui->nameEdit->setToolTip(tr("Provide a proposal name, keep it short")); - - ui->urlEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->urlEdit->setPlaceholderText(tr("Valid http or https URL (include http:// or https://")); - ui->urlEdit->setToolTip(tr("Valid http or https URL (include http:// or https://")); - - ui->paymentsEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->paymentsEdit->setPlaceholderText(tr("How many monthly payments, 1 per budget cycle")); - ui->paymentsEdit->setToolTip(tr("How many monthly payments, 1 per budget cycle")); - ui->paymentsEdit->setValidator(new QIntValidator(1, 100)); - - ui->blockEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->blockEdit->setPlaceholderText(tr("The governance budget block for the desired cycle (default to next)")); - ui->blockEdit->setToolTip(tr("The governance budget block for the desired cycle (default to next)")); - ui->blockEdit->setValidator(new QIntValidator(1, INT_MAX)); - - ui->addressEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->addressEdit->setPlaceholderText(tr("The public ODIN address that will receive the funds")); - ui->addressEdit->setToolTip(tr("The public ODIN address that will receive the funds")); - - ui->amountEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->amountEdit->setPlaceholderText(tr("The amount to be paid per month or cycle")); - ui->amountEdit->setToolTip(tr("The amount to be paid per month or cycle")); - ui->amountEdit->setValidator(new QIntValidator(10, INT_MAX)); - - ui->hashEdit->setFont(GUIUtil::bitcoinAddressFont()); - ui->hashEdit->setPlaceholderText(tr("The TXID of the proposal hash, must be confirmed before use")); - ui->hashEdit->setToolTip(tr("The TXID of the proposal hash, must be confirmed before use")); - - ui->confirmLabel->setWordWrap(true); - ui->infoLabel->setWordWrap(true); - - // Load next superblock number. - CBlockIndex* pindexPrev = chainActive.Tip(); - if (!pindexPrev) return; - int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetNearestSuperblocksHeights() + GetNearestSuperblocksHeights(); - ui->blockEdit->setText(QString::number(nNext)); - - // Start periodic updates to handle submit block depth validation. - timer = new QTimer(this); - connect(timer, SIGNAL(timeout()), this, SLOT(checkProposalTX())); -} - -ProposalDialog::~ProposalDialog() -{ - delete ui; -} - -void ProposalDialog::prepareProposal() -{ - std::string strError = ""; - - if (pwalletMain->IsLocked()) - { - strError = "Error: Please enter the wallet passphrase with walletpassphrase first."; - QMessageBox::critical(this, "Prepare Proposal Error", QString::fromStdString(strError)); - return; - } - - std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); - std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); - int nPaymentCount = ui->paymentsEdit->text().toInt(); - int nBlockStart = ui->blockEdit->text().toInt(); - std::string address = ui->addressEdit->text().toStdString(); - CScript scriptPubKey = GetScriptForDestination(DecodeDestination(address)); - CAmount nAmount = AmountFromValue(ui->amountEdit->text().toInt()); - - //************************************************************************* - - // create the proposal incase we're the first to make it - CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, 0); - std::string err; - if (!budgetProposalBroadcast.IsValid(err, false)) strError = "Proposal is not valid - " + budgetProposalBroadcast.GetHash().ToString() + " - " + err; - - bool useIX = false; - if (strError.empty() && !pwalletMain->GetBudgetSystemCollateralTX(wtx, budgetProposalBroadcast.GetHash(), useIX)) - { - strError = "Error making collateral transaction for proposal. Please check your wallet balance."; - } - - // make our change address - CReserveKey reservekey(pwalletMain); - // send the tx to the network - if (strError.empty() && !pwalletMain->CommitTransaction(wtx, reservekey, useIX ? "ix" : "tx")) - { - strError = "Unable to commit proposal transaction."; - } - - if (!strError.empty()) - { - std::cout << strError << std::endl; - QMessageBox::critical(this, "Prepare Proposal Error", QString::fromStdString(strError)); - return; - } - - // update the local view with submit view - ui->cancelButton->setDisabled(true); - ui->nameEdit->setDisabled(true); - ui->urlEdit->setDisabled(true); - ui->paymentsEdit->setDisabled(true); - ui->blockEdit->setDisabled(true); - ui->addressEdit->setDisabled(true); - ui->amountEdit->setDisabled(true); - ui->hashEdit->setDisabled(true); - - ui->acceptButton->setDisabled(true); - ui->acceptButton->setText(tr("Waiting...")); - - ui->confirmLabel->setVisible(true); - ui->confirmLabel->setText(QString::fromStdString("Waiting for confirmations...")); - - ui->hashEdit->setText(QString::fromStdString(wtx.GetHash().ToString())); - ui->hashEdit->setVisible(true); - ui->hashLabel->setVisible(true); - - mode = SubmitProposal; - setWindowTitle(tr("Submit Proposal")); - - timer->start(1000); - counter = chainActive.Tip()->nHeight + 1; -} - -void ProposalDialog::submitProposal() -{ - std::string strError = ""; - - std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); - std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); - int nPaymentCount = ui->paymentsEdit->text().toInt(); - int nBlockStart = ui->blockEdit->text().toInt(); - std::string address = ui->addressEdit->text().toStdString(); - CScript scriptPubKey = GetScriptForDestination(DecodeDestination(address)); - CAmount nAmount = AmountFromValue(ui->amountEdit->text().toInt()); - uint256 hash = ParseHashV(ui->hashEdit->text().toStdString(), "parameter 1"); - - //************************************************************************* - - // create the proposal incase we're the first to make it - int nConf = 0; - std::string err = ""; - CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, hash); - if (!IsBudgetCollateralValid(hash, budgetProposalBroadcast.GetHash(), err, budgetProposalBroadcast.nTime, nConf)) - { - strError = "Proposal FeeTX is not valid - " + hash.ToString() + " - " + err; - } - - if (strError.empty() && !budget.AddProposal(budgetProposalBroadcast)) strError = "Invalid proposal, see debug.log for details."; - - if (!strError.empty()) - { - std::cout << strError << std::endl; - QMessageBox::critical(this, tr("Submit Proposal Error"), QString::fromStdString(strError)); - return; - } - - budget.mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast)); - budgetProposalBroadcast.Relay(); - - this->accept(); -} - -bool ProposalDialog::validateProposal() -{ - std::string strError = ""; - - if (!masternodeSync.IsBlockchainSynced()) strError = "Must wait for client to sync with masternode network. Try again in a minute or so."; - - std::string strProposalName = SanitizeString(ui->nameEdit->text().toStdString()); - if (strProposalName.size() > 20) strError = "Invalid proposal name, limit of 20 characters."; - - std::string strURL = SanitizeString(ui->urlEdit->text().toStdString()); - if (strURL.size() > 64) strError = "Invalid url, limit of 64 characters."; - - int nPaymentCount = ui->paymentsEdit->text().toInt(); - if (nPaymentCount < 1) strError = "Invalid payment count, must be more than zero."; - - // Start must be in the next budget cycle - int nBlockMin = 0; - CBlockIndex* pindexPrev = chainActive.Tip(); - if (pindexPrev != NULL) nBlockMin = pindexPrev->nHeight - pindexPrev->nHeight % GetNearestSuperblocksHeights() + GetNearestSuperblocksHeights(); - - int nBlockStart = ui->blockEdit->text().toInt(); - if (nBlockStart < nBlockMin) strError = "Invalid block start, must be more than current height."; - if (nBlockStart % GetNearestSuperblocksHeights() != 0) - { - int nNext = pindexPrev->nHeight - pindexPrev->nHeight % GetNearestSuperblocksHeights() + GetNearestSuperblocksHeights(); - strError = strprintf("Invalid block start - must be a budget cycle block. Next valid block: %d", nNext); - } - - int nBlockEnd = nBlockStart + (GetNearestSuperblocksHeights() * nPaymentCount); // End must be AFTER current cycle - if (nBlockEnd < pindexPrev->nHeight) strError = "Invalid ending block, starting block + (payment_cycle*payments) must be more than current height."; - - std::string address = ui->addressEdit->text().toStdString(); - if (!IsValidDestinationString(address)) strError = "Invalid ODIN address"; - - if (!strError.empty()) - { - QMessageBox::critical(this, tr("Submit Proposal Error"), QString::fromStdString(strError)); - return false; - } - - return true; -} - -void ProposalDialog::checkProposalTX() -{ - if (mode != SubmitProposal) return; - - int nConf = Params().BudgetFeeConfirmations(); - int nDepth = (chainActive.Tip()->nHeight + 1) - counter; - if (nDepth > nConf) - { - ui->acceptButton->setDisabled(false); - ui->acceptButton->setText("Finish Proposal"); - ui->confirmLabel->setText(tr("Click on Finish Proposal to complete the proposal and start voting.")); - - timer->stop(); - } - else if (nDepth == nConf) - { - ui->confirmLabel->setText(QString::fromStdString("Waiting for final confirmation...")); - } - else if (nDepth > 0) - { - ui->confirmLabel->setText(QString::fromStdString(strprintf("Currently %d of %d confirmations...", nDepth, (nConf + 1)).c_str())); - } -} - -void ProposalDialog::on_acceptButton_clicked() -{ - if (!validateProposal()) return; - - if (mode == PrepareProposal) - { - prepareProposal(); - } - else if (mode == SubmitProposal) - { - submitProposal(); - } -} - -void ProposalDialog::on_cancelButton_clicked() -{ - this->reject(); -} From 7a48e4f1886828298b1221a85ff3058c030461de Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:43:21 -0400 Subject: [PATCH 223/469] Delete proposaldialog.ui --- src/qt/forms/proposaldialog.ui | 224 --------------------------------- 1 file changed, 224 deletions(-) delete mode 100644 src/qt/forms/proposaldialog.ui diff --git a/src/qt/forms/proposaldialog.ui b/src/qt/forms/proposaldialog.ui deleted file mode 100644 index 03599202..00000000 --- a/src/qt/forms/proposaldialog.ui +++ /dev/null @@ -1,224 +0,0 @@ - - - ProposalDialog - - - - 0 - 0 - 640 - 126 - - - - Budget Proposal - - - - 11 - - - 11 - - - 11 - - - 11 - - - 11 - - - - - Fill out the form below to create a budget proposal. Before beginning, make sure your wallet is unlocked to pay the budget proposal fee of 50 ODIN. After the proposal is submitted, wait for the transaction confirmations to complete, and then click Finish Proposal to submit the proposal for voting. The screen will update to help guide you. Do not close the dialog after paying the transaction fee - --it will close automatically once the proposal is submitted. - - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - 11 - - - 11 - - - 11 - - - 11 - - - 11 - - - - - &Proposal Name: - - - nameEdit - - - - - - - - - - - &Proposal URL: - - - urlEdit - - - - - - - - - - - &Payments (Months): - - - paymentsEdit - - - - - - - - - - - &Super Block: - - - blockEdit - - - - - - - - - - - &Payment Address: - - - addressEdit - - - - - - - - - - - &Payment Amount (Month): - - - amountEdit - - - - - - - - - - - &Proposal TXID: - - - hashEdit - - - - - - - - - - - - - - - - - - - - - - Submit Proposal - - - - - - - Cancel - - - - - - - - - - - - - buttonBox - accepted() - ProposalDialog - accept() - - - 20 - 20 - - - 20 - 20 - - - - - buttonBox - rejected() - ProposalDialog - reject() - - - 20 - 20 - - - 20 - 20 - - - - - \ No newline at end of file From b2d3f3282a8d7f2ebc10b0ff4947b499d729e497 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:43:50 -0400 Subject: [PATCH 224/469] Update guiutil.cpp --- src/qt/guiutil.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 56afbae2..435cbdda 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -89,17 +89,6 @@ namespace GUIUtil { { return dateTimeStr(QDateTime::fromTime_t((qint32)nTime)); } - - QFont bitcoinAddressFont() -{ - QFont font("Monospace"); -#if QT_VERSION >= 0x040800 - font.setStyleHint(QFont::Monospace); -#else - font.setStyleHint(QFont::TypeWriter); -#endif - return font; -} QFont fixedPitchFont() { From 361a65d3eee94930573624179d56e93503611d5e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:44:11 -0400 Subject: [PATCH 225/469] Update guiutil.h --- src/qt/guiutil.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index af4c191a..6ddc5c65 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -40,8 +40,6 @@ namespace GUIUtil QString dateTimeStr(const QDateTime &datetime); QString dateTimeStr(qint64 nTime); - // Render ODIN addresses in monospace font - QFont bitcoinAddressFont(); // Return a monospace font QFont fixedPitchFont(); From 3ec9de0a33982668b22fd9c7c8368582bf0b9eaa Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:44:51 -0400 Subject: [PATCH 226/469] Update Makefile.qt.include --- src/Makefile.qt.include | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 65aa1183..49c453a9 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -46,7 +46,6 @@ QT_FORMS_UI = \ qt/forms/optionsdialog.ui \ qt/forms/overviewpage.ui \ qt/forms/privatesendpage.ui \ - qt/forms/proposaldialog.ui \ qt/forms/receivecoinsdialog.ui \ qt/forms/receiverequestdialog.ui \ qt/forms/debugwindow.ui \ @@ -83,7 +82,6 @@ QT_MOC_CPP = \ qt/moc_optionsmodel.cpp \ qt/moc_overviewpage.cpp \ qt/moc_privatesendpage.cpp \ - qt/moc_proposaldialog.cpp \ qt/moc_peertablemodel.cpp \ qt/moc_paymentserver.cpp \ qt/moc_qrdialog.cpp \ @@ -161,7 +159,6 @@ BITCOIN_QT_H = \ qt/optionsmodel.h \ qt/overviewpage.h \ qt/privatesendpage.h \ - qt/proposaldialog.h \ qt/paymentrequestplus.h \ qt/paymentserver.h \ qt/peertablemodel.h \ @@ -510,7 +507,6 @@ BITCOIN_QT_WALLET_CPP = \ qt/openuridialog.cpp \ qt/overviewpage.cpp \ qt/privatesendpage.cpp \ - qt/proposaldialog.cpp \ qt/paymentrequestplus.cpp \ qt/paymentserver.cpp \ qt/qrdialog.cpp \ From 1425c469f573e605cab7272807b0f0a8ad54d8b0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:55:07 -0400 Subject: [PATCH 227/469] Update guiutil.cpp --- src/qt/guiutil.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 435cbdda..f24d7bf9 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -958,6 +958,46 @@ namespace GUIUtil { return QString::fromStdString(path.string(utf8)); } + QString TOQS(std::string s) +{ + QString str1 = QString::fromUtf8(s.c_str()); + return str1; +} + + QString formatServicesStr(quint64 mask) + { + QStringList strList; + + // Just scan the last 8 bits for now. + for (int i = 0; i < 8; i++) { + uint64_t check = 1 << i; + if (mask & check) + { + switch (check) + { + case NODE_NETWORK: + strList.append("NETWORK"); + break; + case NODE_GETUTXO: + strList.append("GETUTXO"); + break; + case NODE_BLOOM: + strList.append("BLOOM"); + break; + case NODE_XTHIN: + strList.append("XTHIN"); + break; + default: + strList.append(QString("%1[%2]").arg("UNKNOWN").arg(check)); + } + } + } + + if (strList.size()) + return strList.join(" & "); + else + + QString formatDurationStr(int secs) { QStringList strList; From ef3baea13e2fa99756b7ffcceaeb1e14fa544e2e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:56:49 -0400 Subject: [PATCH 228/469] Update guiutil.cpp --- src/qt/guiutil.cpp | 53 ---------------------------------------------- 1 file changed, 53 deletions(-) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index f24d7bf9..7ceab147 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -964,59 +964,6 @@ namespace GUIUtil { return str1; } - QString formatServicesStr(quint64 mask) - { - QStringList strList; - - // Just scan the last 8 bits for now. - for (int i = 0; i < 8; i++) { - uint64_t check = 1 << i; - if (mask & check) - { - switch (check) - { - case NODE_NETWORK: - strList.append("NETWORK"); - break; - case NODE_GETUTXO: - strList.append("GETUTXO"); - break; - case NODE_BLOOM: - strList.append("BLOOM"); - break; - case NODE_XTHIN: - strList.append("XTHIN"); - break; - default: - strList.append(QString("%1[%2]").arg("UNKNOWN").arg(check)); - } - } - } - - if (strList.size()) - return strList.join(" & "); - else - - - QString formatDurationStr(int secs) - { - QStringList strList; - int days = secs / 86400; - int hours = (secs % 86400) / 3600; - int mins = (secs % 3600) / 60; - int seconds = secs % 60; - - if (days) - strList.append(QString(QObject::tr("%1 d")).arg(days)); - if (hours) - strList.append(QString(QObject::tr("%1 h")).arg(hours)); - if (mins) - strList.append(QString(QObject::tr("%1 m")).arg(mins)); - if (seconds || (!days && !hours && !mins)) - strList.append(QString(QObject::tr("%1 s")).arg(seconds)); - - return strList.join(" "); - } QString formatServicesStr(quint64 mask) { From ff0a1b07a10627e21ae2425a235ad8727ae2bbfa Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 20:59:18 -0400 Subject: [PATCH 229/469] Update guiutil.h --- src/qt/guiutil.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 6ddc5c65..c959f028 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -36,6 +36,10 @@ QT_END_NAMESPACE */ namespace GUIUtil { + + QString TOQS(std::string s); + std::string FROMQS(QString qs); + // Create human-readable string from date QString dateTimeStr(const QDateTime &datetime); QString dateTimeStr(qint64 nTime); From 31a5f9043da65260800084b01a60235fae93f193 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Sun, 31 May 2020 21:07:57 -0400 Subject: [PATCH 230/469] Update guiutil.cpp --- src/qt/guiutil.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 7ceab147..2f7a70ce 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -957,6 +957,26 @@ namespace GUIUtil { { return QString::fromStdString(path.string(utf8)); } + + QString formatDurationStr(int secs) + { + QStringList strList; + int days = secs / 86400; + int hours = (secs % 86400) / 3600; + int mins = (secs % 3600) / 60; + int seconds = secs % 60; + + if (days) + strList.append(QString(QObject::tr("%1 d")).arg(days)); + if (hours) + strList.append(QString(QObject::tr("%1 h")).arg(hours)); + if (mins) + strList.append(QString(QObject::tr("%1 m")).arg(mins)); + if (seconds || (!days && !hours && !mins)) + strList.append(QString(QObject::tr("%1 s")).arg(seconds)); + + return strList.join(" "); + } QString TOQS(std::string s) { From 7b5014807a48d5d38376f9de26e29693fed29fd7 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 14:39:45 -0400 Subject: [PATCH 231/469] Create chatwindow.cpp --- src/qt/chatwindow.cpp | 437 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 437 insertions(+) create mode 100644 src/qt/chatwindow.cpp diff --git a/src/qt/chatwindow.cpp b/src/qt/chatwindow.cpp new file mode 100644 index 00000000..fd955f1b --- /dev/null +++ b/src/qt/chatwindow.cpp @@ -0,0 +1,437 @@ +/* +* Copyright (C) 2016 Joe 'raizor' McChristmas +* Copyright (C) 2009 Cleriot Simon +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ + +#include "chatwindow.h" +#include "ui_chatwindow.h" + +#include +#include +#include +#include +#include + +ChatTabHolder::ChatTabHolder(QString nickname, ChatWindow* win, QWidget *parent) : QTabWidget(parent) +{ + nick = nickname; + serverName = "chat.freenode.net"; + this->setTabsClosable(true); + parentWindow = win; + connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(CloseTab(int))); +} + +void ChatTabHolder::CloseTab(int index) +{ + ChatTab* chatTab = (ChatTab*)this->widget(index); + //chatTab->ChannelTabClosed(); + servers[serverName]->sendData(servers[serverName]->parseCommande("/part "+chatTab->tabName, true) ); + if (chatTab->isServer) + { + parentWindow->disconnectFromServer(); + } + this->removeTab(index); +} + +void ChatTab::UpdateUserList() +{ + if (this->userView) + { + users.sort(); + delete modelUsers; + modelUsers = new QStandardItemModel(); + + for(int i=0; inickColorHex(username); + + QStandardItem *colorItem = new QStandardItem(username); + colorItem->setData(QBrush(QColor(col)),Qt::ForegroundRole); + modelUsers->appendRow(colorItem); + + //QModelIndex vIndex = chanTab->modelUsers->index(i, 0); + //chanTab->modelUsers->setData(vIndex, QBrush(Qt::red), Qt::ForegroundRole); + } + userView->setModel(this->modelUsers); + userView->update(); + } +} + +// find nick in userlist (with +v, @ decoration) +QString ChatTab::FormatNick(QString nick) +{ + foreach(QString s, users) + { + if (s.length() == nick.length() + 1 && s.endsWith(nick)) + return s; + } + return nick; +} + +ChatTab::ChatTab(ChatTabHolder* tabHolder, QString tabName, QWidget *parent, IrcServer* server) + : QWidget(parent) +{ + modelUsers = 0; + updateUsers = true; // always update new tab + this->tabName = tabName; + QWidget* holder = this; + QGridLayout* gridLayout = new QGridLayout(); + + // create vertical layout to hold hlayout (editor/userlist) on top and line edit chat box below + QVBoxLayout* vlayout = new QVBoxLayout(); + + // add horizontal split with channel edit on left and user list on right + QHBoxLayout* hlayout = new QHBoxLayout(); + + // add text edit to left and make it fill spare width + textEdit=new QTextEdit(); + textEdit->setReadOnly(true); + QSizePolicy spLeft(QSizePolicy::Preferred, QSizePolicy::Preferred); + spLeft.setHorizontalStretch(1); + textEdit->setSizePolicy(spLeft); + hlayout->addWidget(textEdit); + + isServer = !server; + + if (server) + { + // add userlist on right. will be auto-constrained by sizing of text edit on left + userView = new QListView(); + QFont f(userView->font()); + f.setBold(true); + userView->setFont(f); + hlayout->addWidget(userView); + } + + // add the horizontal layout to vertical layout + vlayout->addLayout(hlayout); + gridLayout->addLayout(vlayout, 0, 0, 1, 1); + + // and add the edit line to bottom of vertical layout + lineEdit = new QLineEdit(); + lineEdit->setObjectName(QLatin1String("lineEdit")); + lineEdit->setGeometry(QRect(90, 230, 701, 30)); + QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); + sizePolicy.setHorizontalStretch(1); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(lineEdit->sizePolicy().hasHeightForWidth()); + lineEdit->setSizePolicy(sizePolicy); + lineEdit->setMaximumSize(QSize(16777215, 30)); + vlayout->addWidget(lineEdit); + + holder->setLayout(gridLayout); + + if (!server) + { + // create server + server=new IrcServer(); + server->pseudo=tabHolder->nick; + server->serverName=tabHolder->serverName; + server->port=6667; + server->editor=textEdit; + server->tab=tabHolder; + server->parent=tabHolder; + + tabHolder->servers.insert(tabHolder->serverName, server); + // connect event signals + connect(server, SIGNAL(joinTab()),this, SLOT(tabJoined() )); + connect(server, SIGNAL(tabJoined()),this, SLOT(tabJoining() )); + server->connectToHost(tabHolder->serverName, 6667); + + // add server status tab to conversations + server->conversations.insert(server->serverName, this); + } + + connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(sendCommand())); + + ircServer = server; + holder = tabHolder; +} + +ChatTab* ChatTabHolder::ChannelTab(QString channelName) +{ + for (int i=0; icount(); i++) + { + ChatTab* tab = (ChatTab*)this->widget(i); + if (QString::compare(tab->tabName, channelName, Qt::CaseInsensitive) == 0) + return tab; + } + // return status tab + return (ChatTab*)this->widget(0); +} + +ChatTab::~ChatTab() +{ + // todo +} + +ChatTabHolder::~ChatTabHolder() +{ + // todo +} + + +ChatWindow::ChatWindow(QWidget *parent) + : QWidget(parent), ui(new Ui::ChatWindowClass) +{ + ui->setupUi(this); + tabsChannels = 0; + connectOptionsLayout = 0; + showConnectOptions(); +} + +void ChatWindow::showConnectOptions() +{ + this->connectOptionsLayout = new QWidget(); + + // main label + QLabel* label_2 = new QLabel(); + label_2->setObjectName(QLatin1String("label_2")); + label_2->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); + label_2->setText(QApplication::translate("ChatWindowOldClass", "

A few IRC commands :

  • /JOIN #channel Join a channel
  • /NICK nickname Change nickname
  • /PRIVMSG nickname message Send PM
  • If userlist gets buggy, switch tabs to fix
", 0)); + QSizePolicy spLeft(QSizePolicy::Preferred, QSizePolicy::Preferred); + spLeft.setHorizontalStretch(1); + label_2->setSizePolicy(spLeft); + + editPseudo = new QLineEdit(); + editPseudo->setObjectName(QLatin1String("editPseudo")); + //editPseudo->setGeometry(QRect(470, 250, 151, 22)); + + QLabel* label_5 = new QLabel(); + label_5->setObjectName(QLatin1String("label_5")); + //label_5->setGeometry(QRect(370, 250, 61, 21)); + label_5->setText(QApplication::translate("ChatWindowOldClass", "Nickname", 0)); + + QPushButton* buttonConnect = new QPushButton(); + buttonConnect->setObjectName(QLatin1String("buttonConnect")); + buttonConnect->setGeometry(QRect(470, 300, 151, 41)); + // buttonConnect->setStyleSheet(QLatin1String("border-radius:40px;border:1px solid grey")); + buttonConnect->setText(QApplication::translate("ChatWindowOldClass", "Connect to IRC", 0)); + + QLabel* label_10 = new QLabel(); + label_10->setObjectName(QLatin1String("label_10")); + //label_10->setGeometry(QRect(370, 200, 161, 21)); + label_10->setText(QApplication::translate("ChatWindowOldClass", "

Connect to IRC :

", 0)); + label_10->setAlignment(Qt::AlignTop | Qt::AlignLeft); + label_10->setMinimumHeight(30); + + // add horizontal split with channel edit on left and user list on right + QHBoxLayout* hlayout = new QHBoxLayout(); + + QWidget* gridHolder= new QWidget(); + gridHolder->setMaximumWidth(250); + + QGridLayout* glayout = new QGridLayout(); + glayout->addWidget(label_10, 0, 0, 2, 2); + glayout->addWidget(label_5, 1, 0, 1, 1); + glayout->addWidget(editPseudo, 1, 1, 1, 1); + glayout->addWidget(buttonConnect, 2, 0, 2, 2); + hlayout->setAlignment(Qt::AlignVCenter | Qt::AlignCenter); + + // add left spacer so contents are centered + QWidget* leftSpacer = new QWidget(); + leftSpacer->setSizePolicy(spLeft); + hlayout->addWidget(leftSpacer); + + hlayout->addWidget(label_2); + + gridHolder->setLayout(glayout); + hlayout->addWidget(gridHolder); + + // add right spacer so contents are centered + QWidget* rightSpacer = new QWidget(); + rightSpacer->setSizePolicy(spLeft); + hlayout->addWidget(rightSpacer); + + + connectOptionsLayout->setLayout(hlayout); + ui->verticalLayout->addWidget(connectOptionsLayout); + + connect(buttonConnect, SIGNAL(clicked()),this, SLOT(on_buttonConnect_clicked())); +} + +void ChatTab::sendCommand() +{ + if(isServer) { + ircServer->sendData(ircServer->parseCommande(lineEdit->text(), true) ); + } + else { + ircServer->sendData(ircServer->parseCommande(lineEdit->text()) ); + } + + lineEdit->clear(); + lineEdit->setFocus(); +} + +void ChatWindow::tabChanged(int index) +{ + // if(index != 0 && joining == false) + // currentTab()->updateUsersList(ui->tab->tabText(index)); +} + +void ChatWindow::tabClosing(int index) +{ + //currentTab()->leave(ui->tab->tabText(index)); +} +/*void ChatWindow::tabRemoved(int index) +{ + currentTab()->leave(ui->tab->tabText(index)); +}*/ + +void ChatWindow::disconnectFromServer() +{ + QMapIterator i(this->tabsChannels->servers); + while(i.hasNext()) + { + i.next(); + QMapIterator i2(i.value()->conversations); + + while(i2.hasNext()) { + i2.next(); + i.value()->sendData("QUIT " + i2.key() + " "); + } + } + + // remove the tab holder + ui->verticalLayout->removeWidget(tabsChannels); + + // recreate connection options + showConnectOptions(); + + //ui->splitter->hide(); + //ui->hide3->show(); + +} + +IrcServer *ChatWindow::getServer() +{ + //QString tooltip=ui->tab->tabToolTip(ui->tab->currentIndex()); + return this->tabsChannels->servers[0]; + //return ui->tab->currentWidget()->findChild(); +} + +void ChatWindow::closeTab() +{ + QString tooltip=this->tabsChannels->tabToolTip(this->tabsChannels->currentIndex()); + QString txt=this->tabsChannels->tabText(this->tabsChannels->currentIndex()); + //QString tooltip=ui->tab->tabToolTip(ui->tab->currentIndex()); + //QString txt=ui->tab->tabText(ui->tab->currentIndex()); +/* + if(txt==tooltip) { + QMapIterator i(servers[tooltip]->conversations); + int count=ui->tab->currentIndex()+1; + while(i.hasNext()) { + i.next(); + ui->tab->removeTab(count); + } + currentTab()->abort(); + ui->tab->removeTab(ui->tab->currentIndex()); + } + else { + ui->tab->removeTab(ui->tab->currentIndex()); + currentTab()->conversations.remove(txt); + }*/ +} + + +void ChatWindow::tabJoined() +{ + joining = true; +} + +void ChatWindow::tabJoining() +{ + joining = false; +} + +void ChatWindow::connectToServer() +{ + if (!this->tabsChannels) + { + this->tabsChannels = new ChatTabHolder(editPseudo->text(), this); + } + + // remove connections options + if (connectOptionsLayout) + { + /* + QLayoutItem *item; + while ((item = ui->verticalLayout->takeAt(0)) != 0) + delete item; + delete connectOptionsLayout; + */ + connectOptionsLayout->hide(); + } + + ui->verticalLayout->addWidget(tabsChannels); + + QString chan = tabsChannels->serverName; + ChatTab* tab = new ChatTab(tabsChannels, chan); + int idx = tabsChannels->currentIndex()+1; + int index=tabsChannels->insertTab(idx, tab, chan); + tabsChannels->setCurrentIndex(index); +} + +void ChatWindow::closeEvent(QCloseEvent *event) +{ + (void) event; + + QMapIterator i(tabsChannels->servers); + + while(i.hasNext()) + { + i.next(); + QMapIterator i2(i.value()->conversations); + + while(i2.hasNext()) { + i2.next(); + i.value()->sendData("QUIT " + i2.key() + " "); + } + } +} + +void ChatWindow ::setModel(ClientModel *model) +{ + this->model = model; +} + +ChatWindow::~ChatWindow() +{ + delete ui; + return; + /* + QMapIterator i(tabsChannels->servers); + while(i.hasNext()) + { + i.next(); + QMapIterator i2(i.value()->conversations); + while(i2.hasNext()) { + i2.next(); + i.value()->sendData("QUIT " + i2.key() + " "); + } + } + */ +} + +void ChatWindow::on_buttonConnect_clicked() +{ + this->connectToServer(); +} From 03c7f7a85158707c1618b97d312c794826b62289 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 14:40:55 -0400 Subject: [PATCH 232/469] Create chatwindow.h --- src/qt/chatwindow.h | 124 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 src/qt/chatwindow.h diff --git a/src/qt/chatwindow.h b/src/qt/chatwindow.h new file mode 100644 index 00000000..cfdbc690 --- /dev/null +++ b/src/qt/chatwindow.h @@ -0,0 +1,124 @@ +/*Copyright (C) 2009 Cleriot Simon +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ + +#ifndef CHATWINDOW_H +#define CHATWINDOW_H + +#include +#include +#include "clientmodel.h" +#include "serveur.h" + +namespace Ui +{ + class ChatWindowClass; +} + +enum ChatWindowTabType +{ + CHATWINDOW_UNKNOWN = 0, + CHATWINDOW_SERVER = 1, + CHATWINDOW_CHANNEL = 2 +}; + +class IrcServer; +class ChatTab; +class QHBoxLayout; +class ChatWindow; + +class ChatTabHolder : public QTabWidget +{ + Q_OBJECT + public: + ChatTabHolder(QString nickname, ChatWindow* win = 0, QWidget *parent = 0); + ~ChatTabHolder(); + + ChatTab* ChannelTab(QString channelName); // #channelname + + QMap servers; + QString nick; + QString serverName; + ChatWindow* parentWindow; + + public Q_SLOTS: + void CloseTab(int index); + +}; + +class ChatTab : public QWidget +{ + Q_OBJECT + public: + ChatTab(ChatTabHolder* tabHolder, QString tabName, QWidget *parent = 0, IrcServer* server = 0); + ~ChatTab(); + + void UpdateUserList(); + QString FormatNick(QString nick); + + QListView *userView; + QLineEdit* lineEdit; + QTextEdit *textEdit; + IrcServer* ircServer; + ChatTabHolder* holder; + QStringList users; + QStandardItemModel* modelUsers; + QString tabName; + bool updateUsers; + bool isServer; + + + public Q_SLOTS: + void sendCommand(); +}; + +class ChatWindow : public QWidget +{ + Q_OBJECT + +public: + ChatWindow(QWidget *parent = 0); + ~ChatWindow(); + void setModel(ClientModel *model); + void addNewServerTab(); + IrcServer * getServer(); + ChatTabHolder* tabsChannels; + QLineEdit* editPseudo; + QWidget* connectOptionsLayout; + +Q_SIGNALS: + void changeTab(); + +public Q_SLOTS: + void connectToServer(); + void showConnectOptions(); + void closeTab(); + void tabChanged(int index); + void tabJoined(); + void tabJoining(); + void disconnectFromServer(); + void tabClosing(int index); + +private Q_SLOTS: + void on_buttonConnect_clicked(); + +private: + Ui::ChatWindowClass *ui; + ClientModel *model; + bool joining; + void closeEvent(QCloseEvent *event); +}; + +#endif // CHATWINDOW_H From 6c7b27fd3d008dbc73d7577eb7e63f424b60a481 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 14:41:51 -0400 Subject: [PATCH 233/469] Create chatwindow.ui --- src/qt/forms/chatwindow.ui | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/qt/forms/chatwindow.ui diff --git a/src/qt/forms/chatwindow.ui b/src/qt/forms/chatwindow.ui new file mode 100644 index 00000000..929749d7 --- /dev/null +++ b/src/qt/forms/chatwindow.ui @@ -0,0 +1,35 @@ + + + ChatWindowClass + + + + 0 + 0 + 743 + 514 + + + + + + + + + + Quitter + + + Ctrl+Q + + + + + Fermer l'onglet + + + + + + + From e600cb04074ab28cc391341061eec76438f1a18d Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 14:55:20 -0400 Subject: [PATCH 234/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index c039a629..f8c97529 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -22,6 +22,7 @@ #include "platformstyle.h" #include "rpcconsole.h" #include "utilitydialog.h" +#include "chatwindow.h" #ifdef ENABLE_WALLET #include "privatesend-client.h" @@ -601,6 +602,13 @@ void BitcoinGUI::createActions() externalDonate = new QAction(QIcon(":/icons/" + theme + "/about"), tr("Donate To HTHW"), this); externalDonate->setStatusTip(tr("Donate to Help The Homeless Worldwide")); + // HTH CHAT + + chatPage = new ChatWindow(); + centralWidget->addWidget(chatPage); + + chatAction = new QAction(QIcon(":/icons/chat"), tr("&HTH Chat"), this); + chatAction->setStatusTip(tr("HTH IRC Chat")); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked())); @@ -613,6 +621,10 @@ void BitcoinGUI::createActions() // HTHW Donate connect(externalDonate, SIGNAL(triggered()), this, SLOT(openDonate())); + + // HTH CHAT + + connect(chatAction, SIGNAL(triggered()), this, SLOT(goChat())); // Jump directly to tabs in RPC-console connect(openInfoAction, SIGNAL(triggered()), this, SLOT(showInfo())); @@ -713,6 +725,9 @@ void BitcoinGUI::createMenuBar() QMenu* donate = appMenuBar->addMenu(tr("&Donate")); donate->addAction(externalDonate); + + QMenu* chat = appMenuBar->addMenu(tr("&HTH Chat")); + chat->addAction(chatAction); } @@ -1038,6 +1053,15 @@ void BitcoinGUI::openClicked() } } +void BitcoinGUI::goChat() +{ + chatAction->setChecked(true); + centralWidget->setCurrentWidget(chatPage); + + exportAction->setEnabled(false); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); +} + void BitcoinGUI::openDonate() { openExternalURL("https://helpthehomelessworldwide.org/donate"); From b4d62afa731143cc33f6f48f72f8edda3d341d85 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 14:58:05 -0400 Subject: [PATCH 235/469] Update bitcoingui.h --- src/qt/bitcoingui.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 9011d71d..f0123c38 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -38,6 +38,7 @@ class HelpMessageDialog; class ModalOverlay; class QNetworkAccessManager; class QNetworkRequest; +class ChatWindow; class CWallet; @@ -102,7 +103,8 @@ class BitcoinGUI : public QMainWindow QProgressDialog *progressDialog; QMenuBar *appMenuBar; - + ChatWindow* chatPage; + QAction *chatAction; QAction* externalDonate; QAction *governanceAction; /* QAction* privatesendAction; */ @@ -230,7 +232,7 @@ public Q_SLOTS: private Q_SLOTS: #ifdef ENABLE_WALLET - + void goChat(); /** Switch to masternode page */ void gotoGovernancePage(); /** Switch to private send page */ From 76e449a0b3cfaad0fa2ce9d55adccacb81793518 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 14:59:33 -0400 Subject: [PATCH 236/469] Update helpthehomeless.qrc --- src/qt/helpthehomeless.qrc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/helpthehomeless.qrc b/src/qt/helpthehomeless.qrc index 8bb49e70..842849b5 100644 --- a/src/qt/helpthehomeless.qrc +++ b/src/qt/helpthehomeless.qrc @@ -15,6 +15,7 @@ res/icons/github.png res/icons/coinmix.png res/icons/governance.png + res/icons/chat.png res/icons/drkblue/address-book.png From c063b1ca137a2e1c383216c3b4b912e81cbdef1d Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:01:22 -0400 Subject: [PATCH 237/469] Update Makefile.qt.include --- src/Makefile.qt.include | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 49c453a9..6cefafa7 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -33,6 +33,7 @@ QT_TS = \ QT_FORMS_UI = \ qt/forms/addressbookpage.ui \ qt/forms/askpassphrasedialog.ui \ + qt/forms/chatwindow.ui \ qt/forms/coincontroldialog.ui \ qt/forms/editaddressdialog.ui \ qt/forms/governancelist.ui \ @@ -64,6 +65,7 @@ QT_MOC_CPP = \ qt/moc_bitcoingui.cpp \ qt/moc_bitcoinunits.cpp \ qt/moc_clientmodel.cpp \ + qt/moc_chatwindow.cpp \ qt/moc_coincontroldialog.cpp \ qt/moc_coincontroltreewidget.cpp \ qt/moc_csvmodelwriter.cpp \ @@ -137,6 +139,7 @@ BITCOIN_QT_H = \ qt/bitcoinamountfield.h \ qt/bitcoingui.h \ qt/bitcoinunits.h \ + qt/chatwindow.h \ qt/clientmodel.h \ qt/coincontroldialog.h \ qt/coincontroltreewidget.h \ @@ -498,6 +501,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/addressbookpage.cpp \ qt/addresstablemodel.cpp \ qt/askpassphrasedialog.cpp \ + qt/chatwindow.cpp \ qt/coincontroldialog.cpp \ qt/coincontroltreewidget.cpp \ qt/editaddressdialog.cpp \ From eaaabd4e4adbb0587b40fa18acca0d853dc70a60 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:05:12 -0400 Subject: [PATCH 238/469] Add files via upload --- src/qt/res/icons/chat.png | Bin 0 -> 1039 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/qt/res/icons/chat.png diff --git a/src/qt/res/icons/chat.png b/src/qt/res/icons/chat.png new file mode 100644 index 0000000000000000000000000000000000000000..062143454d03d156cc938a2467b36a563e37733e GIT binary patch literal 1039 zcmV+q1n~QbP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1EfhrK~z{rwU^s( z3~?04&u{F^cDEH05hXRWq;5e%(rUYe5(M#B9z3X9QV|abO(b4~xU?_AgM_NYi$6dR zs%f?~R>Y+U&8Cz2SX>jBH80d=>G~>2BytCJLL?)%YwtQYkS8Y+ zy=^SH`@9fG9k*h!TF=2bh9N^NwqBiE6)U;d=SET~ zYze6IS9Za`zzUN2C0O`SdlwFo5@aj^ANjZi=fnnT)bh|BQi9YB@HPLjXV)K+0{`MN zm=Gu+<&HIELj37lQqGu77lWU+RmZuVN`P-TJYuP6JouzTb)-g4yyZ6h4!8L%gECy+PxVnmc%n28-s&^FYz>(eF2i-q`R7QrR69?qK$pjpN6-YS91 z<_1a;0Y#^ za2z>DmUX<0{Qpk@cCX@{2Y5gp*bV0M-4k!25Z=A=dz$2!;WObldVj%y7JXF2%~TyQ zPc=^=GcPy>N0bY#saUB5M3088Gs$s-1p>FCo5}}C+Uuw~Z)GR%UP Date: Tue, 2 Jun 2020 15:12:45 -0400 Subject: [PATCH 239/469] Create serveur.cpp --- src/qt/serveur.cpp | 952 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 952 insertions(+) create mode 100644 src/qt/serveur.cpp diff --git a/src/qt/serveur.cpp b/src/qt/serveur.cpp new file mode 100644 index 00000000..e44c5de9 --- /dev/null +++ b/src/qt/serveur.cpp @@ -0,0 +1,952 @@ +/* Copyright (C) 2009 Cleriot Simon +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ + +#include "serveur.h" +#include "util.h" +#include "chatwindow.h" + +#define IRC_STRIP_NICKS true +#define IRC_LOG_SERVER_INPUT true +#define IRC_LOG_SERVER_OUTPUT true + +bool delist = true; + +IrcServer::IrcServer() +{ + connect(this, SIGNAL(readyRead()), this, SLOT(readServeur())); + connect(this, SIGNAL(connected()), this, SLOT(connected())); + connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(errorSocket(QAbstractSocket::SocketError))); +} + +void IrcServer::errorSocket(QAbstractSocket::SocketError error) +{ + switch(error) + { + case QAbstractSocket::HostNotFoundError: + editor->append(tr("ERROR : can't find freenode server.")); + break; + case QAbstractSocket::ConnectionRefusedError: + editor->append(tr("ERROR : server refused connection")); + break; + case QAbstractSocket::RemoteHostClosedError: + editor->append(tr("ERROR : server cut connection")); + break; + default: + editor->append(tr("ERROR : ") + this->errorString() + tr("")); + } +} + +void IrcServer::connected() +{ + editor->append("Connecting..."); + sendData("USER "+pseudo+" localhost "+serverName+" :"+pseudo); + sendData("NICK "+pseudo); + editor->append("Connected to freenode."); +} + +void IrcServer::joins() +{ + join("#cryptobullion"); +} + +void IrcServer::readServeur() +{ + QString message=QString::fromUtf8(this->readAll()); + QString currentChan=tab->tabText(tab->currentIndex()); + + if(message.startsWith("PING :")) + { + QStringList liste=message.split(" "); + QString msg="PONG "+liste.at(1); + sendData(msg); + } + else if(message.contains("Nickname is already in use.")) + { + pseudo=pseudo+"_2"; + pseudo.remove("\r\n"); + sendData("NICK "+pseudo); + emit pseudoChanged(pseudo); + writeToTab("-> Name changed to "+pseudo); + } + else if(conversations[currentChan]->updateUsers==true) + { + //updateUsersList("", message); + } + + QStringList list=message.split("\r\n"); + foreach(QString msg,list) + HandleServerMessage(msg); + /* + QStringList list=message.split("\r\n"); + foreach(QString msg,list) + { + if(msg.contains(QRegExp(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ PRIVMSG ([a-zA-Z0-9\\#]+) :(.+)"))) + { + QRegExp reg(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ PRIVMSG ([a-zA-Z0-9\\#]+) :(.+)"); + QString msg2=msg; + ecrire(msg.replace(reg,"\\2 <\\1> \\3"),"",msg2.replace(reg,"\\2 <\\1> \\3")); + } + else if(msg.contains(QRegExp(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ JOIN ([a-zA-Z0-9\\#]+)"))) + { + QRegExp reg(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ JOIN ([a-zA-Z0-9\\#]+)"); + QString msg2=msg; + ecrire(msg.replace(reg,"\\2 -> \\1 join \\2
"),"",msg2.replace(reg,"-> \\1 join \\2")); + updateUsersList(msg.replace(reg,"\\2")); + } + else if(msg.contains(QRegExp(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ PART ([a-zA-Z0-9\\#]+)"))) + { + QRegExp reg(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ PART ([a-zA-Z0-9\\#]+) :(.+)"); + QString msg2=msg; + ecrire(msg.replace(reg,"\\2 -> \\1 quit \\2 (\\3)
"),"",msg2.replace(reg,"-> \\1 quit \\2")); + //updateUsersList(msg.replace(reg,"\\2")); + } + else if(msg.contains(QRegExp(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ QUIT (.+)"))) + { + QRegExp reg(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ QUIT (.+)"); + QString msg2=msg; + ecrire(msg.replace(reg,"\\2 -> \\1 quit (\\2)
"),"",msg2.replace(reg,"-> \\1 left")); + updateUsersList(msg.replace(reg,"\\2")); + } + else if(msg.contains(QRegExp(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NICK :(.+)"))) + { + QRegExp reg(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NICK :(.+)"); + QString msg2=msg; + ecrire(msg.replace(reg,"\\1 changed nick to \\2
"),"",msg2.replace(reg,"-> \\1 is now called \\2")); + updateUsersList(currentChan); + } + else if(msg.contains(QRegExp(":([a-zA-Z0-9\\D]+)\\![a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ KICK ([a-zA-Z0-9\\#]+) ([a-zA-Z0-9]+) :(.+)"))) + { + QRegExp reg(":([a-zA-Z0-9\\D]+)\\!~[a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ KICK ([a-zA-Z0-9\\#]+) ([a-zA-Z0-9]+) :(.+)"); + QString msg2=msg; + ecrire(msg.replace(reg,"\\2 -> \\1 kicked \\3 (\\4)
"),"",msg2.replace(reg,"-> \\1 quit \\3")); + updateUsersList(msg.replace(reg,"\\2")); + } + else if(msg.contains(QRegExp(":([a-zA-Z0-9\\D]+)\\![a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NOTICE ([a-zA-Z0-9]+) :(.+)"))) + { + if(conversations.contains(currentChan)) + { + QRegExp reg(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NOTICE [a-zA-Z0-9]+ :(.+)"); + ecrire(msg.replace(reg,"[NOTICE] \\1 : \\2
"),currentChan); + } + else if(currentChan==serverName) + { + QRegExp reg(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NOTICE [a-zA-Z0-9]+ :(.+)"); + ecrire(msg.replace(reg,"[NOTICE] \\1 : \\2
")); + } + } + else if(msg.contains("/MOTD command.")) + { + joins(); + }else{ + HandleServerMessage(msg); + } + } + //} + */ +} + +QString IrcServer::nickColorHex(QString nick) +{ + if (nick.startsWith('@') || nick.startsWith("+")) + nick = nick.remove(0, 1); + + if (!nickColors.contains(nick)) + { + std::string s = nick.toStdString(); + uint256 hashName = Hash(s.begin(), s.end()); + std::string hex = hashName.GetHex(); + + QString colorHexString = "#"; + + for(int i=0; i '7' || colorHexString.length()%2==0) + { + colorHexString.append(hex[i]); + } + + if (colorHexString.length() == 7) + break; + } + + for(int i=0; i<6; i++) + { + if (hex[i] < '7' && colorHexString.length()%2!=0) + hex[i] = '7'; + + if (colorHexString.length() < 7) + colorHexString.append(hex[i]); + } + + nickColors[nick] = colorHexString; + } + return nickColors[nick]; + +} + +QString IrcServer::resolveTarget(const QString& sender, const QString& receiver) const + { + QString target = receiver; + + if (target.contains(QLatin1Char('*')) || target.contains(QLatin1Char('?'))) + target = nick; + + if (target == nick) + { + if (target == sender) + target = this->serverName; + else + target = sender; + } + + if (target.isEmpty() || target == QLatin1String("AUTH")) + target = this->serverName; + + return target; + } + +/*! + Parses and returns the nick part from \a target. +*/ +QString IrcServer::nickFromTarget(const QString& target) +{ + int index = target.indexOf(QLatin1Char('!')); + return target.left(index); +} + +/*! + Parses and returns the host part from \a target. +*/ +QString IrcServer::hostFromTarget(const QString& target) +{ + int index = target.indexOf(QLatin1Char('!')); + return target.mid(index + 1); +} + +void IrcServer::HandleUserJoin(QString nick, QString channel) +{ + ChatTab* chanTab = conversations[channel]; + + if (!chanTab) + { + printf("IRC unable to find chat window for %s", channel.toStdString().c_str()); + return; + } + + if (!chanTab->users.contains(nick)) + { + chanTab->users.append(nick); + chanTab->users.sort(); + chanTab->UpdateUserList(); + writeToTab(""+nick+" joined "+channel+"", channel); + } +} + +void IrcServer::HandleUserPart(QString nick, QString channel) +{ + ChatTab* chanTab = conversations[channel]; + + if (!chanTab) + { + printf("IRC unable to find chat window for %s", channel.toStdString().c_str()); + return; + } + + if (chanTab->users.contains(nick)) + { + chanTab->users.removeOne(nick); + chanTab->users.sort(); + chanTab->UpdateUserList(); + writeToTab(""+nick+" left "+channel+"", channel); + } +} + +void IrcServer::HandleUserQuit(QString nick, QString reason) +{ + foreach(QString k, conversations.keys()) + { + ChatTab* ct = conversations[k]; + if (ct && ct->users.contains(nick)) + { + ct->users.removeOne(nick); + writeToTab(""+nick+" quit ("+reason+")", k); + } + } +} + +void IrcServer::HandleServerMessage(QString msg) +{ + if (msg.trimmed().length() == 0) + return; + + // From RFC 1459: + // ::= [':' ] + // ::= | [ '!' ] [ '@' ] + // ::= { } | + // ::= ' ' { ' ' } + // ::= [ ':' | ] + // ::= + // ::= + + QString prefix, command; + QStringList params; + + // format + // :[server] [command] [recipient] [message] + + QStringList lines=msg.split("\r\n"); + for(int i=0; i + if (process.startsWith(QLatin1Char(':'))) + { + prefix = process.mid(1, process.indexOf(QLatin1Char(' ')) - 1); + process.remove(0, prefix.length() + 2); + + /* + if (options & Session::StripNicks) + { + int index = prefix.indexOf(QRegExp(QLatin1String("[@!]"))); + if (index != -1) + prefix.truncate(index); + } + */ + } + + // parse + command = process.mid(0, process.indexOf(QLatin1Char(' '))); + process.remove(0, command.length() + 1); + bool isNumeric = false; + uint code = command.toInt(&isNumeric); + + // parse middle/params + while (!process.isEmpty()) + { + if (process.startsWith(QLatin1Char(':'))) + { + process.remove(0, 1); + params << process; + process.clear(); + } + else + { + QString param = process.mid(0, process.indexOf(QLatin1Char(' '))); + process.remove(0, param.length() + 1); + params << param; + } + } + + // and dump + if (isNumeric) + { + switch (code) + { + case RPL_WELCOME: + { + /* + Q_ASSERT(defaultBuffer); + defaultBuffer->d_func()->setReceiver(prefix, false); + emit q->welcomed(); + welcomed = true; + if (!capabilitiesSupported && !wantedCapabilities.isEmpty()) + emit q->capabilitiesNotAcked(wantedCapabilities); + wantedCapabilities.clear(); + */ + break; + } + + case RPL_TOPIC: + { + QString topic = params.value(2); + QString target = resolveTarget(QString(), params.value(1)); + writeToTab(topic, target); + break; + } + + case RPL_NAMREPLY: + { + QStringList list = params; + list.removeAll(QLatin1String("=")); + list.removeAll(QLatin1String("@")); + list.removeAll(QLatin1String("*")); + + QString target = resolveTarget(QString(), list.value(1)); + ChatTab* chanTab = conversations[target]; + + if (chanTab->updateUsers) + { + //Buffer* buffer = createBuffer(target); + QStringList names = list.value(2).split(QLatin1String(" "), QString::SkipEmptyParts); + + QStringList usersToRemove; + for(int i=0; iusers.count(); i++) + { + if (!names.contains(chanTab->users[i])) + usersToRemove.append(chanTab->users[i]); + } + + for(int i=0; iusers.removeAll(usersToRemove[i]); + + for(int i=0; iusers.contains(names[i])) + chanTab->users.append(names[i]); + } + + chanTab->UpdateUserList(); + + if (chanTab->userView) + { + chanTab->userView->setModel(chanTab->modelUsers); + chanTab->userView->update(); + } + chanTab->updateUsers = false; + }else{ + chanTab->updateUsers=true; + sendData("NAMES "+target); + } + break; + } + + case RPL_MOTDSTART: + motd.clear(); + break; + + case RPL_MOTD: + motd.append(params.value(1) + QLatin1Char('\n')); + break; + + case RPL_ENDOFMOTD: + motd.clear(); + writeToTab(motd); + joins(); + break; + + default: + break; + } + + if (code == RPL_TOPICSET && IRC_STRIP_NICKS) + { + QString user = params.value(2); + int index = user.indexOf(QRegExp(QLatin1String("[@!]"))); + if (index != -1) + { + user.truncate(index); + params.replace(2, user); + } + } + + //if (defaultBuffer) + // emit defaultBuffer->numericMessageReceived(prefix, code, params); + } + else + { + if (command == QLatin1String("NICK")) + { + QString oldNick = nickFromTarget(prefix); + QString newNick = params.value(0); + + if (nick == oldNick) + nick = newNick; + + foreach(QString k, conversations.keys()) + { + ChatTab* ct = conversations[k]; + for (int i=0; iusers.count(); i++) + if (ct->users[i].compare(oldNick) == 0) + ct->users[i] = newNick; + } + + /* + foreach (Buffer* buffer, buffers) + { + if (buffer->receiver() == oldNick) + buffer->d_func()->setReceiver(newNick); + if (buffer->names().contains(oldNick)) + { + buffer->d_func()->removeName(oldNick); + buffer->d_func()->addName(newNick); + emit buffer->nickChanged(prefix, newNick); + } + } + */ + } + else if (command == QLatin1String("QUIT")) + { + QString reason = params.value(0); + QString nick = nickFromTarget(prefix); + HandleUserQuit(nick, reason); + } + else if (command == QLatin1String("JOIN")) + { + QString channel = params.value(0); + QString target = resolveTarget(prefix, channel); + QString joinedNick = nickFromTarget(prefix); + HandleUserJoin(joinedNick, channel); + } + else if (command == QLatin1String("PART")) + { + QString channel = params.value(0); + QString target = nickFromTarget(prefix); + + HandleUserPart(target, channel); + + /* + if (nick != nickFromTarget(prefix)) + { + QString message = params.value(1); + Buffer* buffer = createBuffer(target); + buffer->d_func()->removeName(Util::nickFromTarget(prefix)); + emit buffer->parted(prefix, message); + } + else if (buffers.contains(target)) + { + Buffer* buffer = buffers.value(target); + removeBuffer(buffer); + buffer->deleteLater(); + }*/ + } + else if (command == QLatin1String("MODE")) + { + QString receiver = params.value(0); + QString mode = params.value(1); + QString args = params.value(2); + QString target = nickFromTarget(prefix); + /* + Buffer* buffer = createBuffer(target); + buffer->d_func()->updateMode(args, mode); + emit buffer->modeChanged(prefix, mode, args);*/ + bool haveChannel = conversations.keys().contains(receiver); + QString channel = haveChannel ? receiver : ""; + writeToTab(target+" sets mode "+mode+" "+args, channel); + + if (haveChannel) + { + ChatTab* tab = conversations[channel]; + if (QString::compare(mode, "-o", Qt::CaseInsensitive) == 0 || QString::compare(mode, "-v", Qt::CaseInsensitive) == 0) + { + for(int i=0; iusers.count(); i++) + { + QString targetName = QString::compare(mode, "-o", Qt::CaseInsensitive) == 0 ? "@"+args : "+"+args; + if (QString::compare(tab->users[i], targetName, Qt::CaseInsensitive) == 0) + { + QString newName = tab->users[i].remove(0, 1); + tab->users[i] = newName; + } + } + }else if (QString::compare(mode, "+o", Qt::CaseInsensitive) == 0 || QString::compare(mode, "+v", Qt::CaseInsensitive) == 0) + { + for(int i=0; iusers.count(); i++) + { + if (QString::compare(tab->users[i], args, Qt::CaseInsensitive) == 0) + { + QString newName = tab->users[i].prepend(QString::compare(mode, "+o") == 0 ? "@" : "+"); + tab->users[i] = newName; + } + } + } + tab->UpdateUserList(); + } + } + else if (command == QLatin1String("TOPIC")) + { + /* + QString channel = params.value(0); + QString topic = params.value(1); + QString target = resolveTarget(prefix, channel); + Buffer* buffer = createBuffer(target); + buffer->d_func()->topic = topic; + emit buffer->topicChanged(prefix, topic); + */ + } + else if (command == QLatin1String("INVITE")) + { + /* + QString receiver = params.value(0); + QString channel = params.value(1); + if (defaultBuffer) + emit defaultBuffer->invited(prefix, receiver, channel); + */ + } + else if (command == QLatin1String("KICK")) + { + /* + QString channel = params.value(0); + QString nick = params.value(1); + QString message = params.value(2); + QString target = resolveTarget(prefix, channel); + Buffer* buffer = createBuffer(target); + buffer->d_func()->removeName(nick); + emit buffer->kicked(prefix, nick, message); + */ + } + else if (command == QLatin1String("PRIVMSG")) + { + QString message = params.value(1); + + //Irc::Buffer::MessageFlags flags = getMessageFlags(message); + + if (message.startsWith(QLatin1Char('\1')) && message.endsWith(QLatin1Char('\1'))) + { + message.remove(0, 1); + message.remove(message.length() - 1, 1); + + if (message.startsWith(QLatin1String("ACTION "))) + { + QString receiver = params.value(0); + //QString target = resolveTarget(prefix, receiver); + //Buffer* buffer = createBuffer(target); + //emit buffer->ctcpActionReceived(prefix, message.mid(7), flags); + } + else + { + // TODO: check params + //if (defaultBuffer) + // emit defaultBuffer->ctcpRequestReceived(prefix, message, flags); + writeToTab(prefix+" "+message); + } + } + else + { + QString receiver = params.value(0); + QString target = resolveTarget(prefix, receiver); + //Buffer* buffer = createBuffer(target); + //emit buffer->messageReceived(prefix, message, flags); + + QString nick = nickFromTarget(prefix); + + if (conversations.contains(receiver)) + nick = conversations[receiver]->FormatNick(nick); + + writeToTab(receiver+" <"+nick+"> "+message); + } + } + else if (command == QLatin1String("NOTICE")) + { + //if (!welcomed) + //{ + // Q_ASSERT(defaultBuffer); + // defaultBuffer->d_func()->setReceiver(prefix, false); + //} + + QString receiver = params.value(0); + QString message = params.value(1); + + // Irc::Buffer::MessageFlags flags = getMessageFlags(message); + + if (message.startsWith(QLatin1Char('\1')) && message.endsWith(QLatin1Char('\1'))) + { + message.remove(0, 1); + message.remove(message.length() - 1, 1); + + // TODO: check params + //if (defaultBuffer) + // emit defaultBuffer->ctcpReplyReceived(prefix, /*receiver,*/ message, flags); + } + else + { + //QString target = resolveTarget(prefix, receiver); + //Buffer* buffer = createBuffer(target); + //emit buffer->noticeReceived(prefix, message, flags); + writeToTab(prefix+" "+message+""); + } + } + else if (command == QLatin1String("KILL")) + { + // ignore this event - not all servers generate this + } + else if (command == QLatin1String("CAP")) + { + + } + else + { + + } + } + if (serverName.length()) + { + //ecrire(message); + } + } +} + +/* +void IrcServer::HandleServerMessage(QString msg) +{ + if (msg.trimmed().length() == 0) + return; + // From RFC 1459: + // ::= [':' ] + // ::= | [ '!' ] [ '@' ] + // ::= { } | + // ::= ' ' { ' ' } + // ::= [ ':' | ] + // ::= + // ::= + QString serverName = ""; + QString commandNum = ""; + QString user = ""; + QString message = ""; + // format + // :[server] [command] [recipient] [message] + QStringList lines=msg.split("\r\n"); + for(int i=0; i-1) + continue; + QStringList words = line.split(" "); + if (words.count() >=3) + { + if (words[0].length() >=2) + serverName = words[0].remove(0, 1); + if (words.count() >4 && QString::compare(words[3], "=", Qt::CaseInsensitive) == 0 && line.contains("353")) + { + QString channelName = words[4]; + updateUsersList(channelName, line); + continue; + } + for(int j=3; j3) + message.append(" "); + if (j==3 && words[j].startsWith(QChar(':'))) + message.append(words[j].remove(0, 1)); + else + message.append(words[j]); + } + } + } + if (serverName.length()) + { + ecrire(message); + } +} +*/ + +void IrcServer::sendData(QString txt) +{ + if(this->state()==QAbstractSocket::ConnectedState) + { + this->write((txt+"\r\n").toUtf8()); + } +} + +QString IrcServer::parseCommande(QString comm, bool serveur) +{ + if(comm.startsWith("/")) + { + comm.remove(0,1); + QString pref=comm.split(" ").first(); + QStringList args=comm.split(" "); + args.removeFirst(); + QString destChan=tab->tabText(tab->currentIndex()); + QString msg=args.join(" "); + + if(pref=="me") + return "PRIVMSG "+destChan+" ACTION " + msg + ""; + else if(pref=="msg") + return "MSG "+destChan+" ACTION " + msg + ""; + else if(pref=="join") + { + join(msg); + return " "; + } + else if(pref=="quit") + { + if(msg == "") + return "QUIT "+msgQuit; + else + return "QUIT "+msg; + } + else if(pref=="part") + { + tab->removeTab(tab->currentIndex()); + + if(msg == "") + { + if(msg.startsWith("#")) + destChan=msg.split(" ").first(); + + if(msgQuit=="") + return "PART "+destChan+" using IrcLightClient"; + else + return "PART "+destChan+" "+msgQuit; + } + else + return "PART "+destChan+" "+msg; + + conversations.remove(destChan); + } + else if(pref=="kick") + { + QStringList tableau=msg.split(" "); + QString c1,c2,c3; + if(tableau.count() > 0) c1=" "+tableau.first(); + else c1=""; + if(tableau.count() > 1) c2=" "+tableau.at(1); + else c2=""; + if(tableau.count() > 2) c3=" "+tableau.at(2); + else c3=""; + + if(c1.startsWith("#")) + return "KICK"+c1+c2+c3; + else + return "KICK "+destChan+c1+c2; + } + else if(pref=="update") + { + conversations[destChan]->updateUsers=true; + return "WHO "+destChan; + } + else if(pref=="ns") + { + return "NICKSERV "+msg; + } + else if(pref=="nick") + { + emit pseudoChanged(msg); + writeToTab("-> Nickname changed to "+msg); + return "NICK "+msg; + } + else if(pref=="msg") + { + return "MSG "+msg; + } + + else + return pref+" "+msg; + } + else if(!serveur) + { + QString destChan=tab->tabText(tab->currentIndex()); + if(comm.endsWith("
")) + comm=comm.remove(QRegExp("
$")); + writeToTab("<"+pseudo+"> "+comm, destChan); + + if(!comm.startsWith(":")) + comm.insert(0,":"); + + return "PRIVMSG "+destChan+" "+comm.replace(" "," "); + } + return ""; +} + +void IrcServer::join(QString chan) +{ + editor->append("Joining "+ chan +" channel"); + emit joinTab(); + /* + QTextEdit *textEdit=new QTextEdit; + int index=tab->insertTab(tab->currentIndex()+1, textEdit, chatin); + tab->setTabToolTip(index,serverName); + tab->setCurrentIndex(index); + textEdit->setReadOnly(true); + */ + ChatTab* newTab = new ChatTab(tab, chan, 0, this); + int index=tab->insertTab(tab->currentIndex()+1, newTab, chan); + tab->setCurrentIndex(index); + + conversations.insert(chan, newTab); + + sendData("JOIN "+chan); + + emit tabJoined(); +} +void IrcServer::leave(QString chan) +{ + sendData(parseCommande("/part "+chan+ " "+msgQuit)); +} + +void IrcServer::writeToTab(QString txt, QString destChan, QString msgTray) +{ + if(destChan!="") + { + conversations[destChan]->textEdit->setHtml(conversations[destChan]->textEdit->toHtml()+txt); + QScrollBar *sb = conversations[destChan]->textEdit->verticalScrollBar(); + sb->setValue(sb->maximum()); + } + else if(txt.startsWith("#")) + { + QString dest=txt.split(" ").first(); + QStringList list=txt.split(" "); + list.removeFirst(); + txt=list.join(" "); + conversations[dest]->textEdit->setHtml(conversations[dest]->textEdit->toHtml()+txt); + QScrollBar *sb = conversations[dest]->textEdit->verticalScrollBar(); + sb->setValue(sb->maximum()); } + else + { + txt.replace("\r\n","
"); + editor->setHtml(editor->toHtml()+txt); + QScrollBar *sb = editor->verticalScrollBar(); + sb->setValue(sb->maximum()); + } +} + +void IrcServer::updateUsersList(QString chan, QString message) +{ + /* + message = message.replace("\r\n",""); + message = message.replace("\r",""); + QListView* userList = tab->ChannelTab(chan)->userView; + if(chan!=serverName) + { + if(conversations[chan]->updateUsers==true || message != "") + { + QString liste2=message.replace(":",""); + QStringList liste=liste2.split(" "); + if (delist == true) users.clear(); + for(int i=5; i < liste.count(); i++) + { + users.append(liste.at(i)); + } + conversations[chan]->updateUsers=false; + if (liste.count() < 53) + delist = true; + else + delist = false; + users.sort(); + QStringListModel *model = new QStringListModel(users); + if (userList) + { + userList->setModel(model); + userList->update(); + } + } + else + { + conversations[chan]->updateUsers=true; + sendData("NAMES "+chan); + } + } + else + { + QStringListModel model; + userList->setModel(&model); + userList->update(); + } + */ +} From 171014b63833bea1b767aea727fc513e43df38b7 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:13:11 -0400 Subject: [PATCH 240/469] Create serveur.h --- src/qt/serveur.h | 246 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 src/qt/serveur.h diff --git a/src/qt/serveur.h b/src/qt/serveur.h new file mode 100644 index 00000000..f620ef2c --- /dev/null +++ b/src/qt/serveur.h @@ -0,0 +1,246 @@ +/*Copyright (C) 2009 Cleriot Simon +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ + +#ifndef SERVEUR_H +#define SERVEUR_H + +#include +#include +#include +#include +#include +#include + + +class ChatTabHolder; +class ChatTab; + +class IrcServer : public QTcpSocket +{ + Q_OBJECT + + public: + IrcServer(); + QTextEdit *editor; + QString pseudo,serverName,msgQuit; + int port; + ChatTabHolder *tab; + QMap conversations; + QMap nickColors; + QSystemTrayIcon *tray; + + QString parseCommande(QString comm,bool serverName=false); + QWidget *parent; + + QString motd; + QString nick; + + signals: + void pseudoChanged(QString newPseudo); + void joinTab(); + void tabJoined(); + + public slots: + void readServeur(); + void errorSocket(QAbstractSocket::SocketError); + void connected(); + void joins(); + void sendData(QString txt); + void join(QString chan); + void leave(QString chan); + void writeToTab(QString txt,QString destChan="",QString msgTray=""); + void updateUsersList(QString chan="",QString message=""); + QString nickFromTarget(const QString& target); + QString hostFromTarget(const QString& target); + void HandleUserJoin(QString nick, QString channel); + void HandleUserPart(QString nick, QString channel); + void HandleUserQuit(QString nick, QString reason); + void HandleServerMessage(QString msg); + QString resolveTarget(const QString& sender, const QString& receiver) const; + QString nickColorHex(QString nick); + + //void tabChanged(int index); +}; + +enum IrcMessageCode + { + RPL_WELCOME = 001, + RPL_YOURHOST = 002, + RPL_CREATED = 003, + RPL_MYINFO = 004, + RPL_BOUNCE = 005, + + RPL_USERHOST = 302, + RPL_ISON = 303, + RPL_AWAY = 301, + RPL_UNAWAY = 305, + RPL_NOWAWAY = 306, + + RPL_WHOISUSER = 311, + RPL_WHOISSERVER = 312, + RPL_WHOISOPERATOR = 313, + RPL_WHOISIDLE = 317, + RPL_ENDOFWHOIS = 318, + RPL_WHOISCHANNELS = 319, + RPL_WHOWASUSER = 314, + RPL_ENDOFWHOWAS = 369, + + RPL_LIST = 322, + RPL_LISTEND = 323, + + RPL_UNIQOPIS = 325, + RPL_CHANNELMODEIS = 324, + RPL_CHANNELURL = 328, + RPL_CHANNELCREATED = 329, + + RPL_NOTOPIC = 331, + RPL_TOPIC = 332, + RPL_TOPICSET = 333, + + RPL_INVITING = 341, + RPL_SUMMONING = 342, + + RPL_INVITELIST = 346, + RPL_ENDOFINVITELIST = 347, + + RPL_EXCEPTLIST = 348, + RPL_ENDOFEXCEPTLIST = 349, + + RPL_VERSION = 351, + + RPL_WHOREPLY = 352, + RPL_ENDOFWHO = 315, + + RPL_NAMREPLY = 353, + RPL_ENDOFNAMES = 366, + + RPL_LINKS = 364, + RPL_ENDOFLINKS = 365, + + RPL_BANLIST = 367, + RPL_ENDOFBANLIST = 368, + + RPL_INFO = 371, + RPL_ENDOFINFO = 374, + + RPL_MOTDSTART = 375, + RPL_MOTD = 372, + RPL_ENDOFMOTD = 376, + + RPL_YOUREOPER = 381, + RPL_REHASHING = 382, + RPL_YOURESERVICE = 383, + + RPL_TIME = 391, + RPL_USERSSTART = 392, + + RPL_USERS = 393, + RPL_ENDOFUSERS = 394, + RPL_NOUSERS = 395, + + RPL_TRACELINK = 200, + RPL_TRACECONNECTING = 201, + RPL_TRACEHANDSHAKE = 202, + RPL_TRACEUNKNOWN = 203, + RPL_TRACEOPERATOR = 204, + RPL_TRACEUSER = 205, + RPL_TRACESERVER = 206, + RPL_TRACESERVICE = 207, + RPL_TRACENEWTYPE = 208, + RPL_TRACECLASS = 209, + RPL_TRACELOG = 261, + RPL_TRACEEND = 262, + + RPL_STATSLINKINFO = 211, + RPL_STATSCOMMANDS = 212, + RPL_ENDOFSTATS = 219, + RPL_STATSUPTIME = 242, + RPL_STATSOLINE = 243, + + RPL_UMODEIS = 221, + + RPL_SERVLIST = 234, + RPL_SERVLISTEND = 235, + + RPL_LUSERCLIENT = 251, + RPL_LUSEROP = 252, + RPL_LUSERUNKNOWN = 253, + RPL_LUSERCHANNELS = 254, + RPL_LUSERME = 255, + + RPL_ADMINME = 256, + RPL_ADMINLOC1 = 257, + RPL_ADMINLOC2 = 258, + RPL_ADMINEMAIL = 259, + + RPL_TRYAGAIN = 263, + + ERR_NOSUCHNICK = 401, + ERR_NOSUCHSERVER = 402, + ERR_NOSUCHCHANNEL = 403, + ERR_CANNOTSENDTOCHAN = 404, + ERR_TOOMANYCHANNELS = 405, + ERR_WASNOSUCHNICK = 406, + ERR_TOOMANYTARGETS = 407, + ERR_NOSUCHSERVICE = 408, + ERR_NOORIGIN = 409, + ERR_NORECIPIENT = 411, + ERR_NOTEXTTOSEND = 412, + ERR_NOTOPLEVEL = 413, + ERR_WILDTOPLEVEL = 414, + ERR_BADMASK = 415, + ERR_UNKNOWNCOMMAND = 421, + ERR_NOMOTD = 422, + ERR_NOADMININFO = 423, + ERR_FILEERROR = 424, + ERR_NONICKNAMEGIVEN = 431, + ERR_ERRONEUSNICKNAME = 432, + ERR_NICKNAMEINUSE = 433, + ERR_NICKCOLLISION = 436, + ERR_UNAVAILRESOURCE = 437, + ERR_USERNOTINCHANNEL = 441, + ERR_NOTONCHANNEL = 442, + ERR_USERONCHANNEL = 443, + ERR_NOLOGIN = 444, + ERR_SUMMONDISABLED = 445, + ERR_USERSDISABLED = 446, + ERR_NOTREGISTERED = 451, + ERR_NEEDMOREPARAMS = 461, + ERR_ALREADYREGISTRED = 462, + ERR_NOPERMFORHOST = 463, + ERR_PASSWDMISMATCH = 464, + ERR_YOUREBANNEDCREEP = 465, + ERR_YOUWILLBEBANNED = 466, + ERR_KEYSET = 467, + ERR_CHANNELISFULL = 471, + ERR_UNKNOWNMODE = 472, + ERR_INVITEONLYCHAN = 473, + ERR_BANNEDFROMCHAN = 474, + ERR_BADCHANNELKEY = 475, + ERR_BADCHANMASK = 476, + ERR_NOCHANMODES = 477, + ERR_BANLISTFULL = 478, + ERR_NOPRIVILEGES = 481, + ERR_CHANOPRIVSNEEDED = 482, + ERR_CANTKILLSERVER = 483, + ERR_RESTRICTED = 484, + ERR_UNIQOPPRIVSNEEDED = 485, + ERR_NOOPERHOST = 491, + ERR_UMODEUNKNOWNFLAG = 501, + ERR_USERSDONTMATCH = 502 + }; + +#endif // SERVEUR_H From 3521286cac6d95f9924c405dbe85206866384732 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:14:12 -0400 Subject: [PATCH 241/469] Update Makefile.qt.include --- src/Makefile.qt.include | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 6cefafa7..52c50bbc 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -95,6 +95,7 @@ QT_MOC_CPP = \ qt/moc_rpcconsole.cpp \ qt/moc_sendcoinsdialog.cpp \ qt/moc_sendcoinsentry.cpp \ + qt/moc_serveur.cpp \ qt/moc_signverifymessagedialog.cpp \ qt/moc_splashscreen.cpp \ qt/moc_trafficgraphwidget.cpp \ @@ -175,6 +176,7 @@ BITCOIN_QT_H = \ qt/rpcconsole.h \ qt/sendcoinsdialog.h \ qt/sendcoinsentry.h \ + qt/serveur.h \ qt/signverifymessagedialog.h \ qt/splashscreen.h \ qt/trafficgraphdata.h \ @@ -519,6 +521,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/recentrequeststablemodel.cpp \ qt/sendcoinsdialog.cpp \ qt/sendcoinsentry.cpp \ + qt/serveur.cpp \ qt/signverifymessagedialog.cpp \ qt/transactiondesc.cpp \ qt/transactiondescdialog.cpp \ From fa521123839f8114e40fb0322a79222be369da75 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:15:42 -0400 Subject: [PATCH 242/469] Update serveur.h --- src/qt/serveur.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/serveur.h b/src/qt/serveur.h index f620ef2c..1cc0c99a 100644 --- a/src/qt/serveur.h +++ b/src/qt/serveur.h @@ -48,12 +48,12 @@ class IrcServer : public QTcpSocket QString motd; QString nick; - signals: + Q_SIGNALS: void pseudoChanged(QString newPseudo); void joinTab(); void tabJoined(); - public slots: + public Q_SLOTS: void readServeur(); void errorSocket(QAbstractSocket::SocketError); void connected(); From 5e7b736925ca98ecc33528435f0b80ade71e5e40 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:16:42 -0400 Subject: [PATCH 243/469] Delete chatwindow.h --- src/qt/chatwindow.h | 124 -------------------------------------------- 1 file changed, 124 deletions(-) delete mode 100644 src/qt/chatwindow.h diff --git a/src/qt/chatwindow.h b/src/qt/chatwindow.h deleted file mode 100644 index cfdbc690..00000000 --- a/src/qt/chatwindow.h +++ /dev/null @@ -1,124 +0,0 @@ -/*Copyright (C) 2009 Cleriot Simon -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ - -#ifndef CHATWINDOW_H -#define CHATWINDOW_H - -#include -#include -#include "clientmodel.h" -#include "serveur.h" - -namespace Ui -{ - class ChatWindowClass; -} - -enum ChatWindowTabType -{ - CHATWINDOW_UNKNOWN = 0, - CHATWINDOW_SERVER = 1, - CHATWINDOW_CHANNEL = 2 -}; - -class IrcServer; -class ChatTab; -class QHBoxLayout; -class ChatWindow; - -class ChatTabHolder : public QTabWidget -{ - Q_OBJECT - public: - ChatTabHolder(QString nickname, ChatWindow* win = 0, QWidget *parent = 0); - ~ChatTabHolder(); - - ChatTab* ChannelTab(QString channelName); // #channelname - - QMap servers; - QString nick; - QString serverName; - ChatWindow* parentWindow; - - public Q_SLOTS: - void CloseTab(int index); - -}; - -class ChatTab : public QWidget -{ - Q_OBJECT - public: - ChatTab(ChatTabHolder* tabHolder, QString tabName, QWidget *parent = 0, IrcServer* server = 0); - ~ChatTab(); - - void UpdateUserList(); - QString FormatNick(QString nick); - - QListView *userView; - QLineEdit* lineEdit; - QTextEdit *textEdit; - IrcServer* ircServer; - ChatTabHolder* holder; - QStringList users; - QStandardItemModel* modelUsers; - QString tabName; - bool updateUsers; - bool isServer; - - - public Q_SLOTS: - void sendCommand(); -}; - -class ChatWindow : public QWidget -{ - Q_OBJECT - -public: - ChatWindow(QWidget *parent = 0); - ~ChatWindow(); - void setModel(ClientModel *model); - void addNewServerTab(); - IrcServer * getServer(); - ChatTabHolder* tabsChannels; - QLineEdit* editPseudo; - QWidget* connectOptionsLayout; - -Q_SIGNALS: - void changeTab(); - -public Q_SLOTS: - void connectToServer(); - void showConnectOptions(); - void closeTab(); - void tabChanged(int index); - void tabJoined(); - void tabJoining(); - void disconnectFromServer(); - void tabClosing(int index); - -private Q_SLOTS: - void on_buttonConnect_clicked(); - -private: - Ui::ChatWindowClass *ui; - ClientModel *model; - bool joining; - void closeEvent(QCloseEvent *event); -}; - -#endif // CHATWINDOW_H From 89e16badd8b0b3cea9684cb8714c1b49289ecde4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:16:51 -0400 Subject: [PATCH 244/469] Delete chatwindow.cpp --- src/qt/chatwindow.cpp | 437 ------------------------------------------ 1 file changed, 437 deletions(-) delete mode 100644 src/qt/chatwindow.cpp diff --git a/src/qt/chatwindow.cpp b/src/qt/chatwindow.cpp deleted file mode 100644 index fd955f1b..00000000 --- a/src/qt/chatwindow.cpp +++ /dev/null @@ -1,437 +0,0 @@ -/* -* Copyright (C) 2016 Joe 'raizor' McChristmas -* Copyright (C) 2009 Cleriot Simon -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ - -#include "chatwindow.h" -#include "ui_chatwindow.h" - -#include -#include -#include -#include -#include - -ChatTabHolder::ChatTabHolder(QString nickname, ChatWindow* win, QWidget *parent) : QTabWidget(parent) -{ - nick = nickname; - serverName = "chat.freenode.net"; - this->setTabsClosable(true); - parentWindow = win; - connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(CloseTab(int))); -} - -void ChatTabHolder::CloseTab(int index) -{ - ChatTab* chatTab = (ChatTab*)this->widget(index); - //chatTab->ChannelTabClosed(); - servers[serverName]->sendData(servers[serverName]->parseCommande("/part "+chatTab->tabName, true) ); - if (chatTab->isServer) - { - parentWindow->disconnectFromServer(); - } - this->removeTab(index); -} - -void ChatTab::UpdateUserList() -{ - if (this->userView) - { - users.sort(); - delete modelUsers; - modelUsers = new QStandardItemModel(); - - for(int i=0; inickColorHex(username); - - QStandardItem *colorItem = new QStandardItem(username); - colorItem->setData(QBrush(QColor(col)),Qt::ForegroundRole); - modelUsers->appendRow(colorItem); - - //QModelIndex vIndex = chanTab->modelUsers->index(i, 0); - //chanTab->modelUsers->setData(vIndex, QBrush(Qt::red), Qt::ForegroundRole); - } - userView->setModel(this->modelUsers); - userView->update(); - } -} - -// find nick in userlist (with +v, @ decoration) -QString ChatTab::FormatNick(QString nick) -{ - foreach(QString s, users) - { - if (s.length() == nick.length() + 1 && s.endsWith(nick)) - return s; - } - return nick; -} - -ChatTab::ChatTab(ChatTabHolder* tabHolder, QString tabName, QWidget *parent, IrcServer* server) - : QWidget(parent) -{ - modelUsers = 0; - updateUsers = true; // always update new tab - this->tabName = tabName; - QWidget* holder = this; - QGridLayout* gridLayout = new QGridLayout(); - - // create vertical layout to hold hlayout (editor/userlist) on top and line edit chat box below - QVBoxLayout* vlayout = new QVBoxLayout(); - - // add horizontal split with channel edit on left and user list on right - QHBoxLayout* hlayout = new QHBoxLayout(); - - // add text edit to left and make it fill spare width - textEdit=new QTextEdit(); - textEdit->setReadOnly(true); - QSizePolicy spLeft(QSizePolicy::Preferred, QSizePolicy::Preferred); - spLeft.setHorizontalStretch(1); - textEdit->setSizePolicy(spLeft); - hlayout->addWidget(textEdit); - - isServer = !server; - - if (server) - { - // add userlist on right. will be auto-constrained by sizing of text edit on left - userView = new QListView(); - QFont f(userView->font()); - f.setBold(true); - userView->setFont(f); - hlayout->addWidget(userView); - } - - // add the horizontal layout to vertical layout - vlayout->addLayout(hlayout); - gridLayout->addLayout(vlayout, 0, 0, 1, 1); - - // and add the edit line to bottom of vertical layout - lineEdit = new QLineEdit(); - lineEdit->setObjectName(QLatin1String("lineEdit")); - lineEdit->setGeometry(QRect(90, 230, 701, 30)); - QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - sizePolicy.setHorizontalStretch(1); - sizePolicy.setVerticalStretch(0); - sizePolicy.setHeightForWidth(lineEdit->sizePolicy().hasHeightForWidth()); - lineEdit->setSizePolicy(sizePolicy); - lineEdit->setMaximumSize(QSize(16777215, 30)); - vlayout->addWidget(lineEdit); - - holder->setLayout(gridLayout); - - if (!server) - { - // create server - server=new IrcServer(); - server->pseudo=tabHolder->nick; - server->serverName=tabHolder->serverName; - server->port=6667; - server->editor=textEdit; - server->tab=tabHolder; - server->parent=tabHolder; - - tabHolder->servers.insert(tabHolder->serverName, server); - // connect event signals - connect(server, SIGNAL(joinTab()),this, SLOT(tabJoined() )); - connect(server, SIGNAL(tabJoined()),this, SLOT(tabJoining() )); - server->connectToHost(tabHolder->serverName, 6667); - - // add server status tab to conversations - server->conversations.insert(server->serverName, this); - } - - connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(sendCommand())); - - ircServer = server; - holder = tabHolder; -} - -ChatTab* ChatTabHolder::ChannelTab(QString channelName) -{ - for (int i=0; icount(); i++) - { - ChatTab* tab = (ChatTab*)this->widget(i); - if (QString::compare(tab->tabName, channelName, Qt::CaseInsensitive) == 0) - return tab; - } - // return status tab - return (ChatTab*)this->widget(0); -} - -ChatTab::~ChatTab() -{ - // todo -} - -ChatTabHolder::~ChatTabHolder() -{ - // todo -} - - -ChatWindow::ChatWindow(QWidget *parent) - : QWidget(parent), ui(new Ui::ChatWindowClass) -{ - ui->setupUi(this); - tabsChannels = 0; - connectOptionsLayout = 0; - showConnectOptions(); -} - -void ChatWindow::showConnectOptions() -{ - this->connectOptionsLayout = new QWidget(); - - // main label - QLabel* label_2 = new QLabel(); - label_2->setObjectName(QLatin1String("label_2")); - label_2->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); - label_2->setText(QApplication::translate("ChatWindowOldClass", "

A few IRC commands :

  • /JOIN #channel Join a channel
  • /NICK nickname Change nickname
  • /PRIVMSG nickname message Send PM
  • If userlist gets buggy, switch tabs to fix
", 0)); - QSizePolicy spLeft(QSizePolicy::Preferred, QSizePolicy::Preferred); - spLeft.setHorizontalStretch(1); - label_2->setSizePolicy(spLeft); - - editPseudo = new QLineEdit(); - editPseudo->setObjectName(QLatin1String("editPseudo")); - //editPseudo->setGeometry(QRect(470, 250, 151, 22)); - - QLabel* label_5 = new QLabel(); - label_5->setObjectName(QLatin1String("label_5")); - //label_5->setGeometry(QRect(370, 250, 61, 21)); - label_5->setText(QApplication::translate("ChatWindowOldClass", "Nickname", 0)); - - QPushButton* buttonConnect = new QPushButton(); - buttonConnect->setObjectName(QLatin1String("buttonConnect")); - buttonConnect->setGeometry(QRect(470, 300, 151, 41)); - // buttonConnect->setStyleSheet(QLatin1String("border-radius:40px;border:1px solid grey")); - buttonConnect->setText(QApplication::translate("ChatWindowOldClass", "Connect to IRC", 0)); - - QLabel* label_10 = new QLabel(); - label_10->setObjectName(QLatin1String("label_10")); - //label_10->setGeometry(QRect(370, 200, 161, 21)); - label_10->setText(QApplication::translate("ChatWindowOldClass", "

Connect to IRC :

", 0)); - label_10->setAlignment(Qt::AlignTop | Qt::AlignLeft); - label_10->setMinimumHeight(30); - - // add horizontal split with channel edit on left and user list on right - QHBoxLayout* hlayout = new QHBoxLayout(); - - QWidget* gridHolder= new QWidget(); - gridHolder->setMaximumWidth(250); - - QGridLayout* glayout = new QGridLayout(); - glayout->addWidget(label_10, 0, 0, 2, 2); - glayout->addWidget(label_5, 1, 0, 1, 1); - glayout->addWidget(editPseudo, 1, 1, 1, 1); - glayout->addWidget(buttonConnect, 2, 0, 2, 2); - hlayout->setAlignment(Qt::AlignVCenter | Qt::AlignCenter); - - // add left spacer so contents are centered - QWidget* leftSpacer = new QWidget(); - leftSpacer->setSizePolicy(spLeft); - hlayout->addWidget(leftSpacer); - - hlayout->addWidget(label_2); - - gridHolder->setLayout(glayout); - hlayout->addWidget(gridHolder); - - // add right spacer so contents are centered - QWidget* rightSpacer = new QWidget(); - rightSpacer->setSizePolicy(spLeft); - hlayout->addWidget(rightSpacer); - - - connectOptionsLayout->setLayout(hlayout); - ui->verticalLayout->addWidget(connectOptionsLayout); - - connect(buttonConnect, SIGNAL(clicked()),this, SLOT(on_buttonConnect_clicked())); -} - -void ChatTab::sendCommand() -{ - if(isServer) { - ircServer->sendData(ircServer->parseCommande(lineEdit->text(), true) ); - } - else { - ircServer->sendData(ircServer->parseCommande(lineEdit->text()) ); - } - - lineEdit->clear(); - lineEdit->setFocus(); -} - -void ChatWindow::tabChanged(int index) -{ - // if(index != 0 && joining == false) - // currentTab()->updateUsersList(ui->tab->tabText(index)); -} - -void ChatWindow::tabClosing(int index) -{ - //currentTab()->leave(ui->tab->tabText(index)); -} -/*void ChatWindow::tabRemoved(int index) -{ - currentTab()->leave(ui->tab->tabText(index)); -}*/ - -void ChatWindow::disconnectFromServer() -{ - QMapIterator i(this->tabsChannels->servers); - while(i.hasNext()) - { - i.next(); - QMapIterator i2(i.value()->conversations); - - while(i2.hasNext()) { - i2.next(); - i.value()->sendData("QUIT " + i2.key() + " "); - } - } - - // remove the tab holder - ui->verticalLayout->removeWidget(tabsChannels); - - // recreate connection options - showConnectOptions(); - - //ui->splitter->hide(); - //ui->hide3->show(); - -} - -IrcServer *ChatWindow::getServer() -{ - //QString tooltip=ui->tab->tabToolTip(ui->tab->currentIndex()); - return this->tabsChannels->servers[0]; - //return ui->tab->currentWidget()->findChild(); -} - -void ChatWindow::closeTab() -{ - QString tooltip=this->tabsChannels->tabToolTip(this->tabsChannels->currentIndex()); - QString txt=this->tabsChannels->tabText(this->tabsChannels->currentIndex()); - //QString tooltip=ui->tab->tabToolTip(ui->tab->currentIndex()); - //QString txt=ui->tab->tabText(ui->tab->currentIndex()); -/* - if(txt==tooltip) { - QMapIterator i(servers[tooltip]->conversations); - int count=ui->tab->currentIndex()+1; - while(i.hasNext()) { - i.next(); - ui->tab->removeTab(count); - } - currentTab()->abort(); - ui->tab->removeTab(ui->tab->currentIndex()); - } - else { - ui->tab->removeTab(ui->tab->currentIndex()); - currentTab()->conversations.remove(txt); - }*/ -} - - -void ChatWindow::tabJoined() -{ - joining = true; -} - -void ChatWindow::tabJoining() -{ - joining = false; -} - -void ChatWindow::connectToServer() -{ - if (!this->tabsChannels) - { - this->tabsChannels = new ChatTabHolder(editPseudo->text(), this); - } - - // remove connections options - if (connectOptionsLayout) - { - /* - QLayoutItem *item; - while ((item = ui->verticalLayout->takeAt(0)) != 0) - delete item; - delete connectOptionsLayout; - */ - connectOptionsLayout->hide(); - } - - ui->verticalLayout->addWidget(tabsChannels); - - QString chan = tabsChannels->serverName; - ChatTab* tab = new ChatTab(tabsChannels, chan); - int idx = tabsChannels->currentIndex()+1; - int index=tabsChannels->insertTab(idx, tab, chan); - tabsChannels->setCurrentIndex(index); -} - -void ChatWindow::closeEvent(QCloseEvent *event) -{ - (void) event; - - QMapIterator i(tabsChannels->servers); - - while(i.hasNext()) - { - i.next(); - QMapIterator i2(i.value()->conversations); - - while(i2.hasNext()) { - i2.next(); - i.value()->sendData("QUIT " + i2.key() + " "); - } - } -} - -void ChatWindow ::setModel(ClientModel *model) -{ - this->model = model; -} - -ChatWindow::~ChatWindow() -{ - delete ui; - return; - /* - QMapIterator i(tabsChannels->servers); - while(i.hasNext()) - { - i.next(); - QMapIterator i2(i.value()->conversations); - while(i2.hasNext()) { - i2.next(); - i.value()->sendData("QUIT " + i2.key() + " "); - } - } - */ -} - -void ChatWindow::on_buttonConnect_clicked() -{ - this->connectToServer(); -} From cbef2d695e2dcfee1ff7386b52e19932c4bb18a5 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:16:58 -0400 Subject: [PATCH 245/469] Delete chatwindow.ui --- src/qt/forms/chatwindow.ui | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 src/qt/forms/chatwindow.ui diff --git a/src/qt/forms/chatwindow.ui b/src/qt/forms/chatwindow.ui deleted file mode 100644 index 929749d7..00000000 --- a/src/qt/forms/chatwindow.ui +++ /dev/null @@ -1,35 +0,0 @@ - - - ChatWindowClass - - - - 0 - 0 - 743 - 514 - - - - - - - - - - Quitter - - - Ctrl+Q - - - - - Fermer l'onglet - - - - - - - From c1a3e87ee0f460be97013a1ad51481c1333d593d Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:18:33 -0400 Subject: [PATCH 246/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index f8c97529..c05890cb 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -22,7 +22,6 @@ #include "platformstyle.h" #include "rpcconsole.h" #include "utilitydialog.h" -#include "chatwindow.h" #ifdef ENABLE_WALLET #include "privatesend-client.h" @@ -601,15 +600,7 @@ void BitcoinGUI::createActions() // HTHW Donate externalDonate = new QAction(QIcon(":/icons/" + theme + "/about"), tr("Donate To HTHW"), this); externalDonate->setStatusTip(tr("Donate to Help The Homeless Worldwide")); - - // HTH CHAT - - chatPage = new ChatWindow(); - centralWidget->addWidget(chatPage); - - chatAction = new QAction(QIcon(":/icons/chat"), tr("&HTH Chat"), this); - chatAction->setStatusTip(tr("HTH IRC Chat")); - + connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked())); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); @@ -621,11 +612,7 @@ void BitcoinGUI::createActions() // HTHW Donate connect(externalDonate, SIGNAL(triggered()), this, SLOT(openDonate())); - - // HTH CHAT - - connect(chatAction, SIGNAL(triggered()), this, SLOT(goChat())); - + // Jump directly to tabs in RPC-console connect(openInfoAction, SIGNAL(triggered()), this, SLOT(showInfo())); connect(openRPCConsoleAction, SIGNAL(triggered()), this, SLOT(showConsole())); @@ -725,9 +712,6 @@ void BitcoinGUI::createMenuBar() QMenu* donate = appMenuBar->addMenu(tr("&Donate")); donate->addAction(externalDonate); - - QMenu* chat = appMenuBar->addMenu(tr("&HTH Chat")); - chat->addAction(chatAction); } @@ -1053,15 +1037,6 @@ void BitcoinGUI::openClicked() } } -void BitcoinGUI::goChat() -{ - chatAction->setChecked(true); - centralWidget->setCurrentWidget(chatPage); - - exportAction->setEnabled(false); - disconnect(exportAction, SIGNAL(triggered()), 0, 0); -} - void BitcoinGUI::openDonate() { openExternalURL("https://helpthehomelessworldwide.org/donate"); From 8e94672aa10aa43219ef67bf764de189b2718167 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:19:05 -0400 Subject: [PATCH 247/469] Update bitcoingui.h --- src/qt/bitcoingui.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index f0123c38..a70473f9 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -38,7 +38,6 @@ class HelpMessageDialog; class ModalOverlay; class QNetworkAccessManager; class QNetworkRequest; -class ChatWindow; class CWallet; @@ -103,7 +102,6 @@ class BitcoinGUI : public QMainWindow QProgressDialog *progressDialog; QMenuBar *appMenuBar; - ChatWindow* chatPage; QAction *chatAction; QAction* externalDonate; QAction *governanceAction; @@ -232,7 +230,6 @@ public Q_SLOTS: private Q_SLOTS: #ifdef ENABLE_WALLET - void goChat(); /** Switch to masternode page */ void gotoGovernancePage(); /** Switch to private send page */ From 33c8e1dc87f321262dc2e2377dcdbbdb3a176e4c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:19:43 -0400 Subject: [PATCH 248/469] Update Makefile.qt.include --- src/Makefile.qt.include | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 52c50bbc..b8da13f9 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -33,7 +33,6 @@ QT_TS = \ QT_FORMS_UI = \ qt/forms/addressbookpage.ui \ qt/forms/askpassphrasedialog.ui \ - qt/forms/chatwindow.ui \ qt/forms/coincontroldialog.ui \ qt/forms/editaddressdialog.ui \ qt/forms/governancelist.ui \ @@ -65,7 +64,6 @@ QT_MOC_CPP = \ qt/moc_bitcoingui.cpp \ qt/moc_bitcoinunits.cpp \ qt/moc_clientmodel.cpp \ - qt/moc_chatwindow.cpp \ qt/moc_coincontroldialog.cpp \ qt/moc_coincontroltreewidget.cpp \ qt/moc_csvmodelwriter.cpp \ @@ -140,7 +138,6 @@ BITCOIN_QT_H = \ qt/bitcoinamountfield.h \ qt/bitcoingui.h \ qt/bitcoinunits.h \ - qt/chatwindow.h \ qt/clientmodel.h \ qt/coincontroldialog.h \ qt/coincontroltreewidget.h \ @@ -503,7 +500,6 @@ BITCOIN_QT_WALLET_CPP = \ qt/addressbookpage.cpp \ qt/addresstablemodel.cpp \ qt/askpassphrasedialog.cpp \ - qt/chatwindow.cpp \ qt/coincontroldialog.cpp \ qt/coincontroltreewidget.cpp \ qt/editaddressdialog.cpp \ From b4633784e3e766ac4b6f0a3d36666a4872eacaf4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:20:38 -0400 Subject: [PATCH 249/469] Update Makefile.qt.include --- src/Makefile.qt.include | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index b8da13f9..49c453a9 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -93,7 +93,6 @@ QT_MOC_CPP = \ qt/moc_rpcconsole.cpp \ qt/moc_sendcoinsdialog.cpp \ qt/moc_sendcoinsentry.cpp \ - qt/moc_serveur.cpp \ qt/moc_signverifymessagedialog.cpp \ qt/moc_splashscreen.cpp \ qt/moc_trafficgraphwidget.cpp \ @@ -173,7 +172,6 @@ BITCOIN_QT_H = \ qt/rpcconsole.h \ qt/sendcoinsdialog.h \ qt/sendcoinsentry.h \ - qt/serveur.h \ qt/signverifymessagedialog.h \ qt/splashscreen.h \ qt/trafficgraphdata.h \ @@ -517,7 +515,6 @@ BITCOIN_QT_WALLET_CPP = \ qt/recentrequeststablemodel.cpp \ qt/sendcoinsdialog.cpp \ qt/sendcoinsentry.cpp \ - qt/serveur.cpp \ qt/signverifymessagedialog.cpp \ qt/transactiondesc.cpp \ qt/transactiondescdialog.cpp \ From fb52297417f8a1d33cfb8132776d33db1c5c8a4c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:20:50 -0400 Subject: [PATCH 250/469] Delete serveur.h --- src/qt/serveur.h | 246 ----------------------------------------------- 1 file changed, 246 deletions(-) delete mode 100644 src/qt/serveur.h diff --git a/src/qt/serveur.h b/src/qt/serveur.h deleted file mode 100644 index 1cc0c99a..00000000 --- a/src/qt/serveur.h +++ /dev/null @@ -1,246 +0,0 @@ -/*Copyright (C) 2009 Cleriot Simon -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ - -#ifndef SERVEUR_H -#define SERVEUR_H - -#include -#include -#include -#include -#include -#include - - -class ChatTabHolder; -class ChatTab; - -class IrcServer : public QTcpSocket -{ - Q_OBJECT - - public: - IrcServer(); - QTextEdit *editor; - QString pseudo,serverName,msgQuit; - int port; - ChatTabHolder *tab; - QMap conversations; - QMap nickColors; - QSystemTrayIcon *tray; - - QString parseCommande(QString comm,bool serverName=false); - QWidget *parent; - - QString motd; - QString nick; - - Q_SIGNALS: - void pseudoChanged(QString newPseudo); - void joinTab(); - void tabJoined(); - - public Q_SLOTS: - void readServeur(); - void errorSocket(QAbstractSocket::SocketError); - void connected(); - void joins(); - void sendData(QString txt); - void join(QString chan); - void leave(QString chan); - void writeToTab(QString txt,QString destChan="",QString msgTray=""); - void updateUsersList(QString chan="",QString message=""); - QString nickFromTarget(const QString& target); - QString hostFromTarget(const QString& target); - void HandleUserJoin(QString nick, QString channel); - void HandleUserPart(QString nick, QString channel); - void HandleUserQuit(QString nick, QString reason); - void HandleServerMessage(QString msg); - QString resolveTarget(const QString& sender, const QString& receiver) const; - QString nickColorHex(QString nick); - - //void tabChanged(int index); -}; - -enum IrcMessageCode - { - RPL_WELCOME = 001, - RPL_YOURHOST = 002, - RPL_CREATED = 003, - RPL_MYINFO = 004, - RPL_BOUNCE = 005, - - RPL_USERHOST = 302, - RPL_ISON = 303, - RPL_AWAY = 301, - RPL_UNAWAY = 305, - RPL_NOWAWAY = 306, - - RPL_WHOISUSER = 311, - RPL_WHOISSERVER = 312, - RPL_WHOISOPERATOR = 313, - RPL_WHOISIDLE = 317, - RPL_ENDOFWHOIS = 318, - RPL_WHOISCHANNELS = 319, - RPL_WHOWASUSER = 314, - RPL_ENDOFWHOWAS = 369, - - RPL_LIST = 322, - RPL_LISTEND = 323, - - RPL_UNIQOPIS = 325, - RPL_CHANNELMODEIS = 324, - RPL_CHANNELURL = 328, - RPL_CHANNELCREATED = 329, - - RPL_NOTOPIC = 331, - RPL_TOPIC = 332, - RPL_TOPICSET = 333, - - RPL_INVITING = 341, - RPL_SUMMONING = 342, - - RPL_INVITELIST = 346, - RPL_ENDOFINVITELIST = 347, - - RPL_EXCEPTLIST = 348, - RPL_ENDOFEXCEPTLIST = 349, - - RPL_VERSION = 351, - - RPL_WHOREPLY = 352, - RPL_ENDOFWHO = 315, - - RPL_NAMREPLY = 353, - RPL_ENDOFNAMES = 366, - - RPL_LINKS = 364, - RPL_ENDOFLINKS = 365, - - RPL_BANLIST = 367, - RPL_ENDOFBANLIST = 368, - - RPL_INFO = 371, - RPL_ENDOFINFO = 374, - - RPL_MOTDSTART = 375, - RPL_MOTD = 372, - RPL_ENDOFMOTD = 376, - - RPL_YOUREOPER = 381, - RPL_REHASHING = 382, - RPL_YOURESERVICE = 383, - - RPL_TIME = 391, - RPL_USERSSTART = 392, - - RPL_USERS = 393, - RPL_ENDOFUSERS = 394, - RPL_NOUSERS = 395, - - RPL_TRACELINK = 200, - RPL_TRACECONNECTING = 201, - RPL_TRACEHANDSHAKE = 202, - RPL_TRACEUNKNOWN = 203, - RPL_TRACEOPERATOR = 204, - RPL_TRACEUSER = 205, - RPL_TRACESERVER = 206, - RPL_TRACESERVICE = 207, - RPL_TRACENEWTYPE = 208, - RPL_TRACECLASS = 209, - RPL_TRACELOG = 261, - RPL_TRACEEND = 262, - - RPL_STATSLINKINFO = 211, - RPL_STATSCOMMANDS = 212, - RPL_ENDOFSTATS = 219, - RPL_STATSUPTIME = 242, - RPL_STATSOLINE = 243, - - RPL_UMODEIS = 221, - - RPL_SERVLIST = 234, - RPL_SERVLISTEND = 235, - - RPL_LUSERCLIENT = 251, - RPL_LUSEROP = 252, - RPL_LUSERUNKNOWN = 253, - RPL_LUSERCHANNELS = 254, - RPL_LUSERME = 255, - - RPL_ADMINME = 256, - RPL_ADMINLOC1 = 257, - RPL_ADMINLOC2 = 258, - RPL_ADMINEMAIL = 259, - - RPL_TRYAGAIN = 263, - - ERR_NOSUCHNICK = 401, - ERR_NOSUCHSERVER = 402, - ERR_NOSUCHCHANNEL = 403, - ERR_CANNOTSENDTOCHAN = 404, - ERR_TOOMANYCHANNELS = 405, - ERR_WASNOSUCHNICK = 406, - ERR_TOOMANYTARGETS = 407, - ERR_NOSUCHSERVICE = 408, - ERR_NOORIGIN = 409, - ERR_NORECIPIENT = 411, - ERR_NOTEXTTOSEND = 412, - ERR_NOTOPLEVEL = 413, - ERR_WILDTOPLEVEL = 414, - ERR_BADMASK = 415, - ERR_UNKNOWNCOMMAND = 421, - ERR_NOMOTD = 422, - ERR_NOADMININFO = 423, - ERR_FILEERROR = 424, - ERR_NONICKNAMEGIVEN = 431, - ERR_ERRONEUSNICKNAME = 432, - ERR_NICKNAMEINUSE = 433, - ERR_NICKCOLLISION = 436, - ERR_UNAVAILRESOURCE = 437, - ERR_USERNOTINCHANNEL = 441, - ERR_NOTONCHANNEL = 442, - ERR_USERONCHANNEL = 443, - ERR_NOLOGIN = 444, - ERR_SUMMONDISABLED = 445, - ERR_USERSDISABLED = 446, - ERR_NOTREGISTERED = 451, - ERR_NEEDMOREPARAMS = 461, - ERR_ALREADYREGISTRED = 462, - ERR_NOPERMFORHOST = 463, - ERR_PASSWDMISMATCH = 464, - ERR_YOUREBANNEDCREEP = 465, - ERR_YOUWILLBEBANNED = 466, - ERR_KEYSET = 467, - ERR_CHANNELISFULL = 471, - ERR_UNKNOWNMODE = 472, - ERR_INVITEONLYCHAN = 473, - ERR_BANNEDFROMCHAN = 474, - ERR_BADCHANNELKEY = 475, - ERR_BADCHANMASK = 476, - ERR_NOCHANMODES = 477, - ERR_BANLISTFULL = 478, - ERR_NOPRIVILEGES = 481, - ERR_CHANOPRIVSNEEDED = 482, - ERR_CANTKILLSERVER = 483, - ERR_RESTRICTED = 484, - ERR_UNIQOPPRIVSNEEDED = 485, - ERR_NOOPERHOST = 491, - ERR_UMODEUNKNOWNFLAG = 501, - ERR_USERSDONTMATCH = 502 - }; - -#endif // SERVEUR_H From f4f64fbd8a45d12b45666b10260b3add7b643c1a Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:21:00 -0400 Subject: [PATCH 251/469] Delete serveur.cpp --- src/qt/serveur.cpp | 952 --------------------------------------------- 1 file changed, 952 deletions(-) delete mode 100644 src/qt/serveur.cpp diff --git a/src/qt/serveur.cpp b/src/qt/serveur.cpp deleted file mode 100644 index e44c5de9..00000000 --- a/src/qt/serveur.cpp +++ /dev/null @@ -1,952 +0,0 @@ -/* Copyright (C) 2009 Cleriot Simon -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; either -* version 2.1 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ - -#include "serveur.h" -#include "util.h" -#include "chatwindow.h" - -#define IRC_STRIP_NICKS true -#define IRC_LOG_SERVER_INPUT true -#define IRC_LOG_SERVER_OUTPUT true - -bool delist = true; - -IrcServer::IrcServer() -{ - connect(this, SIGNAL(readyRead()), this, SLOT(readServeur())); - connect(this, SIGNAL(connected()), this, SLOT(connected())); - connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(errorSocket(QAbstractSocket::SocketError))); -} - -void IrcServer::errorSocket(QAbstractSocket::SocketError error) -{ - switch(error) - { - case QAbstractSocket::HostNotFoundError: - editor->append(tr("ERROR : can't find freenode server.")); - break; - case QAbstractSocket::ConnectionRefusedError: - editor->append(tr("ERROR : server refused connection")); - break; - case QAbstractSocket::RemoteHostClosedError: - editor->append(tr("ERROR : server cut connection")); - break; - default: - editor->append(tr("ERROR : ") + this->errorString() + tr("")); - } -} - -void IrcServer::connected() -{ - editor->append("Connecting..."); - sendData("USER "+pseudo+" localhost "+serverName+" :"+pseudo); - sendData("NICK "+pseudo); - editor->append("Connected to freenode."); -} - -void IrcServer::joins() -{ - join("#cryptobullion"); -} - -void IrcServer::readServeur() -{ - QString message=QString::fromUtf8(this->readAll()); - QString currentChan=tab->tabText(tab->currentIndex()); - - if(message.startsWith("PING :")) - { - QStringList liste=message.split(" "); - QString msg="PONG "+liste.at(1); - sendData(msg); - } - else if(message.contains("Nickname is already in use.")) - { - pseudo=pseudo+"_2"; - pseudo.remove("\r\n"); - sendData("NICK "+pseudo); - emit pseudoChanged(pseudo); - writeToTab("-> Name changed to "+pseudo); - } - else if(conversations[currentChan]->updateUsers==true) - { - //updateUsersList("", message); - } - - QStringList list=message.split("\r\n"); - foreach(QString msg,list) - HandleServerMessage(msg); - /* - QStringList list=message.split("\r\n"); - foreach(QString msg,list) - { - if(msg.contains(QRegExp(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ PRIVMSG ([a-zA-Z0-9\\#]+) :(.+)"))) - { - QRegExp reg(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ PRIVMSG ([a-zA-Z0-9\\#]+) :(.+)"); - QString msg2=msg; - ecrire(msg.replace(reg,"\\2 <\\1> \\3"),"",msg2.replace(reg,"\\2 <\\1> \\3")); - } - else if(msg.contains(QRegExp(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ JOIN ([a-zA-Z0-9\\#]+)"))) - { - QRegExp reg(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ JOIN ([a-zA-Z0-9\\#]+)"); - QString msg2=msg; - ecrire(msg.replace(reg,"\\2 -> \\1 join \\2
"),"",msg2.replace(reg,"-> \\1 join \\2")); - updateUsersList(msg.replace(reg,"\\2")); - } - else if(msg.contains(QRegExp(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ PART ([a-zA-Z0-9\\#]+)"))) - { - QRegExp reg(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ PART ([a-zA-Z0-9\\#]+) :(.+)"); - QString msg2=msg; - ecrire(msg.replace(reg,"\\2 -> \\1 quit \\2 (\\3)
"),"",msg2.replace(reg,"-> \\1 quit \\2")); - //updateUsersList(msg.replace(reg,"\\2")); - } - else if(msg.contains(QRegExp(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ QUIT (.+)"))) - { - QRegExp reg(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ QUIT (.+)"); - QString msg2=msg; - ecrire(msg.replace(reg,"\\2 -> \\1 quit (\\2)
"),"",msg2.replace(reg,"-> \\1 left")); - updateUsersList(msg.replace(reg,"\\2")); - } - else if(msg.contains(QRegExp(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NICK :(.+)"))) - { - QRegExp reg(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NICK :(.+)"); - QString msg2=msg; - ecrire(msg.replace(reg,"\\1 changed nick to \\2
"),"",msg2.replace(reg,"-> \\1 is now called \\2")); - updateUsersList(currentChan); - } - else if(msg.contains(QRegExp(":([a-zA-Z0-9\\D]+)\\![a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ KICK ([a-zA-Z0-9\\#]+) ([a-zA-Z0-9]+) :(.+)"))) - { - QRegExp reg(":([a-zA-Z0-9\\D]+)\\!~[a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ KICK ([a-zA-Z0-9\\#]+) ([a-zA-Z0-9]+) :(.+)"); - QString msg2=msg; - ecrire(msg.replace(reg,"\\2 -> \\1 kicked \\3 (\\4)
"),"",msg2.replace(reg,"-> \\1 quit \\3")); - updateUsersList(msg.replace(reg,"\\2")); - } - else if(msg.contains(QRegExp(":([a-zA-Z0-9\\D]+)\\![a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NOTICE ([a-zA-Z0-9]+) :(.+)"))) - { - if(conversations.contains(currentChan)) - { - QRegExp reg(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NOTICE [a-zA-Z0-9]+ :(.+)"); - ecrire(msg.replace(reg,"[NOTICE] \\1 : \\2
"),currentChan); - } - else if(currentChan==serverName) - { - QRegExp reg(":([a-zA-Z0-9\\D]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NOTICE [a-zA-Z0-9]+ :(.+)"); - ecrire(msg.replace(reg,"[NOTICE] \\1 : \\2
")); - } - } - else if(msg.contains("/MOTD command.")) - { - joins(); - }else{ - HandleServerMessage(msg); - } - } - //} - */ -} - -QString IrcServer::nickColorHex(QString nick) -{ - if (nick.startsWith('@') || nick.startsWith("+")) - nick = nick.remove(0, 1); - - if (!nickColors.contains(nick)) - { - std::string s = nick.toStdString(); - uint256 hashName = Hash(s.begin(), s.end()); - std::string hex = hashName.GetHex(); - - QString colorHexString = "#"; - - for(int i=0; i '7' || colorHexString.length()%2==0) - { - colorHexString.append(hex[i]); - } - - if (colorHexString.length() == 7) - break; - } - - for(int i=0; i<6; i++) - { - if (hex[i] < '7' && colorHexString.length()%2!=0) - hex[i] = '7'; - - if (colorHexString.length() < 7) - colorHexString.append(hex[i]); - } - - nickColors[nick] = colorHexString; - } - return nickColors[nick]; - -} - -QString IrcServer::resolveTarget(const QString& sender, const QString& receiver) const - { - QString target = receiver; - - if (target.contains(QLatin1Char('*')) || target.contains(QLatin1Char('?'))) - target = nick; - - if (target == nick) - { - if (target == sender) - target = this->serverName; - else - target = sender; - } - - if (target.isEmpty() || target == QLatin1String("AUTH")) - target = this->serverName; - - return target; - } - -/*! - Parses and returns the nick part from \a target. -*/ -QString IrcServer::nickFromTarget(const QString& target) -{ - int index = target.indexOf(QLatin1Char('!')); - return target.left(index); -} - -/*! - Parses and returns the host part from \a target. -*/ -QString IrcServer::hostFromTarget(const QString& target) -{ - int index = target.indexOf(QLatin1Char('!')); - return target.mid(index + 1); -} - -void IrcServer::HandleUserJoin(QString nick, QString channel) -{ - ChatTab* chanTab = conversations[channel]; - - if (!chanTab) - { - printf("IRC unable to find chat window for %s", channel.toStdString().c_str()); - return; - } - - if (!chanTab->users.contains(nick)) - { - chanTab->users.append(nick); - chanTab->users.sort(); - chanTab->UpdateUserList(); - writeToTab(""+nick+" joined "+channel+"", channel); - } -} - -void IrcServer::HandleUserPart(QString nick, QString channel) -{ - ChatTab* chanTab = conversations[channel]; - - if (!chanTab) - { - printf("IRC unable to find chat window for %s", channel.toStdString().c_str()); - return; - } - - if (chanTab->users.contains(nick)) - { - chanTab->users.removeOne(nick); - chanTab->users.sort(); - chanTab->UpdateUserList(); - writeToTab(""+nick+" left "+channel+"", channel); - } -} - -void IrcServer::HandleUserQuit(QString nick, QString reason) -{ - foreach(QString k, conversations.keys()) - { - ChatTab* ct = conversations[k]; - if (ct && ct->users.contains(nick)) - { - ct->users.removeOne(nick); - writeToTab(""+nick+" quit ("+reason+")", k); - } - } -} - -void IrcServer::HandleServerMessage(QString msg) -{ - if (msg.trimmed().length() == 0) - return; - - // From RFC 1459: - // ::= [':' ] - // ::= | [ '!' ] [ '@' ] - // ::= { } | - // ::= ' ' { ' ' } - // ::= [ ':' | ] - // ::= - // ::= - - QString prefix, command; - QStringList params; - - // format - // :[server] [command] [recipient] [message] - - QStringList lines=msg.split("\r\n"); - for(int i=0; i - if (process.startsWith(QLatin1Char(':'))) - { - prefix = process.mid(1, process.indexOf(QLatin1Char(' ')) - 1); - process.remove(0, prefix.length() + 2); - - /* - if (options & Session::StripNicks) - { - int index = prefix.indexOf(QRegExp(QLatin1String("[@!]"))); - if (index != -1) - prefix.truncate(index); - } - */ - } - - // parse - command = process.mid(0, process.indexOf(QLatin1Char(' '))); - process.remove(0, command.length() + 1); - bool isNumeric = false; - uint code = command.toInt(&isNumeric); - - // parse middle/params - while (!process.isEmpty()) - { - if (process.startsWith(QLatin1Char(':'))) - { - process.remove(0, 1); - params << process; - process.clear(); - } - else - { - QString param = process.mid(0, process.indexOf(QLatin1Char(' '))); - process.remove(0, param.length() + 1); - params << param; - } - } - - // and dump - if (isNumeric) - { - switch (code) - { - case RPL_WELCOME: - { - /* - Q_ASSERT(defaultBuffer); - defaultBuffer->d_func()->setReceiver(prefix, false); - emit q->welcomed(); - welcomed = true; - if (!capabilitiesSupported && !wantedCapabilities.isEmpty()) - emit q->capabilitiesNotAcked(wantedCapabilities); - wantedCapabilities.clear(); - */ - break; - } - - case RPL_TOPIC: - { - QString topic = params.value(2); - QString target = resolveTarget(QString(), params.value(1)); - writeToTab(topic, target); - break; - } - - case RPL_NAMREPLY: - { - QStringList list = params; - list.removeAll(QLatin1String("=")); - list.removeAll(QLatin1String("@")); - list.removeAll(QLatin1String("*")); - - QString target = resolveTarget(QString(), list.value(1)); - ChatTab* chanTab = conversations[target]; - - if (chanTab->updateUsers) - { - //Buffer* buffer = createBuffer(target); - QStringList names = list.value(2).split(QLatin1String(" "), QString::SkipEmptyParts); - - QStringList usersToRemove; - for(int i=0; iusers.count(); i++) - { - if (!names.contains(chanTab->users[i])) - usersToRemove.append(chanTab->users[i]); - } - - for(int i=0; iusers.removeAll(usersToRemove[i]); - - for(int i=0; iusers.contains(names[i])) - chanTab->users.append(names[i]); - } - - chanTab->UpdateUserList(); - - if (chanTab->userView) - { - chanTab->userView->setModel(chanTab->modelUsers); - chanTab->userView->update(); - } - chanTab->updateUsers = false; - }else{ - chanTab->updateUsers=true; - sendData("NAMES "+target); - } - break; - } - - case RPL_MOTDSTART: - motd.clear(); - break; - - case RPL_MOTD: - motd.append(params.value(1) + QLatin1Char('\n')); - break; - - case RPL_ENDOFMOTD: - motd.clear(); - writeToTab(motd); - joins(); - break; - - default: - break; - } - - if (code == RPL_TOPICSET && IRC_STRIP_NICKS) - { - QString user = params.value(2); - int index = user.indexOf(QRegExp(QLatin1String("[@!]"))); - if (index != -1) - { - user.truncate(index); - params.replace(2, user); - } - } - - //if (defaultBuffer) - // emit defaultBuffer->numericMessageReceived(prefix, code, params); - } - else - { - if (command == QLatin1String("NICK")) - { - QString oldNick = nickFromTarget(prefix); - QString newNick = params.value(0); - - if (nick == oldNick) - nick = newNick; - - foreach(QString k, conversations.keys()) - { - ChatTab* ct = conversations[k]; - for (int i=0; iusers.count(); i++) - if (ct->users[i].compare(oldNick) == 0) - ct->users[i] = newNick; - } - - /* - foreach (Buffer* buffer, buffers) - { - if (buffer->receiver() == oldNick) - buffer->d_func()->setReceiver(newNick); - if (buffer->names().contains(oldNick)) - { - buffer->d_func()->removeName(oldNick); - buffer->d_func()->addName(newNick); - emit buffer->nickChanged(prefix, newNick); - } - } - */ - } - else if (command == QLatin1String("QUIT")) - { - QString reason = params.value(0); - QString nick = nickFromTarget(prefix); - HandleUserQuit(nick, reason); - } - else if (command == QLatin1String("JOIN")) - { - QString channel = params.value(0); - QString target = resolveTarget(prefix, channel); - QString joinedNick = nickFromTarget(prefix); - HandleUserJoin(joinedNick, channel); - } - else if (command == QLatin1String("PART")) - { - QString channel = params.value(0); - QString target = nickFromTarget(prefix); - - HandleUserPart(target, channel); - - /* - if (nick != nickFromTarget(prefix)) - { - QString message = params.value(1); - Buffer* buffer = createBuffer(target); - buffer->d_func()->removeName(Util::nickFromTarget(prefix)); - emit buffer->parted(prefix, message); - } - else if (buffers.contains(target)) - { - Buffer* buffer = buffers.value(target); - removeBuffer(buffer); - buffer->deleteLater(); - }*/ - } - else if (command == QLatin1String("MODE")) - { - QString receiver = params.value(0); - QString mode = params.value(1); - QString args = params.value(2); - QString target = nickFromTarget(prefix); - /* - Buffer* buffer = createBuffer(target); - buffer->d_func()->updateMode(args, mode); - emit buffer->modeChanged(prefix, mode, args);*/ - bool haveChannel = conversations.keys().contains(receiver); - QString channel = haveChannel ? receiver : ""; - writeToTab(target+" sets mode "+mode+" "+args, channel); - - if (haveChannel) - { - ChatTab* tab = conversations[channel]; - if (QString::compare(mode, "-o", Qt::CaseInsensitive) == 0 || QString::compare(mode, "-v", Qt::CaseInsensitive) == 0) - { - for(int i=0; iusers.count(); i++) - { - QString targetName = QString::compare(mode, "-o", Qt::CaseInsensitive) == 0 ? "@"+args : "+"+args; - if (QString::compare(tab->users[i], targetName, Qt::CaseInsensitive) == 0) - { - QString newName = tab->users[i].remove(0, 1); - tab->users[i] = newName; - } - } - }else if (QString::compare(mode, "+o", Qt::CaseInsensitive) == 0 || QString::compare(mode, "+v", Qt::CaseInsensitive) == 0) - { - for(int i=0; iusers.count(); i++) - { - if (QString::compare(tab->users[i], args, Qt::CaseInsensitive) == 0) - { - QString newName = tab->users[i].prepend(QString::compare(mode, "+o") == 0 ? "@" : "+"); - tab->users[i] = newName; - } - } - } - tab->UpdateUserList(); - } - } - else if (command == QLatin1String("TOPIC")) - { - /* - QString channel = params.value(0); - QString topic = params.value(1); - QString target = resolveTarget(prefix, channel); - Buffer* buffer = createBuffer(target); - buffer->d_func()->topic = topic; - emit buffer->topicChanged(prefix, topic); - */ - } - else if (command == QLatin1String("INVITE")) - { - /* - QString receiver = params.value(0); - QString channel = params.value(1); - if (defaultBuffer) - emit defaultBuffer->invited(prefix, receiver, channel); - */ - } - else if (command == QLatin1String("KICK")) - { - /* - QString channel = params.value(0); - QString nick = params.value(1); - QString message = params.value(2); - QString target = resolveTarget(prefix, channel); - Buffer* buffer = createBuffer(target); - buffer->d_func()->removeName(nick); - emit buffer->kicked(prefix, nick, message); - */ - } - else if (command == QLatin1String("PRIVMSG")) - { - QString message = params.value(1); - - //Irc::Buffer::MessageFlags flags = getMessageFlags(message); - - if (message.startsWith(QLatin1Char('\1')) && message.endsWith(QLatin1Char('\1'))) - { - message.remove(0, 1); - message.remove(message.length() - 1, 1); - - if (message.startsWith(QLatin1String("ACTION "))) - { - QString receiver = params.value(0); - //QString target = resolveTarget(prefix, receiver); - //Buffer* buffer = createBuffer(target); - //emit buffer->ctcpActionReceived(prefix, message.mid(7), flags); - } - else - { - // TODO: check params - //if (defaultBuffer) - // emit defaultBuffer->ctcpRequestReceived(prefix, message, flags); - writeToTab(prefix+" "+message); - } - } - else - { - QString receiver = params.value(0); - QString target = resolveTarget(prefix, receiver); - //Buffer* buffer = createBuffer(target); - //emit buffer->messageReceived(prefix, message, flags); - - QString nick = nickFromTarget(prefix); - - if (conversations.contains(receiver)) - nick = conversations[receiver]->FormatNick(nick); - - writeToTab(receiver+" <"+nick+"> "+message); - } - } - else if (command == QLatin1String("NOTICE")) - { - //if (!welcomed) - //{ - // Q_ASSERT(defaultBuffer); - // defaultBuffer->d_func()->setReceiver(prefix, false); - //} - - QString receiver = params.value(0); - QString message = params.value(1); - - // Irc::Buffer::MessageFlags flags = getMessageFlags(message); - - if (message.startsWith(QLatin1Char('\1')) && message.endsWith(QLatin1Char('\1'))) - { - message.remove(0, 1); - message.remove(message.length() - 1, 1); - - // TODO: check params - //if (defaultBuffer) - // emit defaultBuffer->ctcpReplyReceived(prefix, /*receiver,*/ message, flags); - } - else - { - //QString target = resolveTarget(prefix, receiver); - //Buffer* buffer = createBuffer(target); - //emit buffer->noticeReceived(prefix, message, flags); - writeToTab(prefix+" "+message+""); - } - } - else if (command == QLatin1String("KILL")) - { - // ignore this event - not all servers generate this - } - else if (command == QLatin1String("CAP")) - { - - } - else - { - - } - } - if (serverName.length()) - { - //ecrire(message); - } - } -} - -/* -void IrcServer::HandleServerMessage(QString msg) -{ - if (msg.trimmed().length() == 0) - return; - // From RFC 1459: - // ::= [':' ] - // ::= | [ '!' ] [ '@' ] - // ::= { } | - // ::= ' ' { ' ' } - // ::= [ ':' | ] - // ::= - // ::= - QString serverName = ""; - QString commandNum = ""; - QString user = ""; - QString message = ""; - // format - // :[server] [command] [recipient] [message] - QStringList lines=msg.split("\r\n"); - for(int i=0; i-1) - continue; - QStringList words = line.split(" "); - if (words.count() >=3) - { - if (words[0].length() >=2) - serverName = words[0].remove(0, 1); - if (words.count() >4 && QString::compare(words[3], "=", Qt::CaseInsensitive) == 0 && line.contains("353")) - { - QString channelName = words[4]; - updateUsersList(channelName, line); - continue; - } - for(int j=3; j3) - message.append(" "); - if (j==3 && words[j].startsWith(QChar(':'))) - message.append(words[j].remove(0, 1)); - else - message.append(words[j]); - } - } - } - if (serverName.length()) - { - ecrire(message); - } -} -*/ - -void IrcServer::sendData(QString txt) -{ - if(this->state()==QAbstractSocket::ConnectedState) - { - this->write((txt+"\r\n").toUtf8()); - } -} - -QString IrcServer::parseCommande(QString comm, bool serveur) -{ - if(comm.startsWith("/")) - { - comm.remove(0,1); - QString pref=comm.split(" ").first(); - QStringList args=comm.split(" "); - args.removeFirst(); - QString destChan=tab->tabText(tab->currentIndex()); - QString msg=args.join(" "); - - if(pref=="me") - return "PRIVMSG "+destChan+" ACTION " + msg + ""; - else if(pref=="msg") - return "MSG "+destChan+" ACTION " + msg + ""; - else if(pref=="join") - { - join(msg); - return " "; - } - else if(pref=="quit") - { - if(msg == "") - return "QUIT "+msgQuit; - else - return "QUIT "+msg; - } - else if(pref=="part") - { - tab->removeTab(tab->currentIndex()); - - if(msg == "") - { - if(msg.startsWith("#")) - destChan=msg.split(" ").first(); - - if(msgQuit=="") - return "PART "+destChan+" using IrcLightClient"; - else - return "PART "+destChan+" "+msgQuit; - } - else - return "PART "+destChan+" "+msg; - - conversations.remove(destChan); - } - else if(pref=="kick") - { - QStringList tableau=msg.split(" "); - QString c1,c2,c3; - if(tableau.count() > 0) c1=" "+tableau.first(); - else c1=""; - if(tableau.count() > 1) c2=" "+tableau.at(1); - else c2=""; - if(tableau.count() > 2) c3=" "+tableau.at(2); - else c3=""; - - if(c1.startsWith("#")) - return "KICK"+c1+c2+c3; - else - return "KICK "+destChan+c1+c2; - } - else if(pref=="update") - { - conversations[destChan]->updateUsers=true; - return "WHO "+destChan; - } - else if(pref=="ns") - { - return "NICKSERV "+msg; - } - else if(pref=="nick") - { - emit pseudoChanged(msg); - writeToTab("-> Nickname changed to "+msg); - return "NICK "+msg; - } - else if(pref=="msg") - { - return "MSG "+msg; - } - - else - return pref+" "+msg; - } - else if(!serveur) - { - QString destChan=tab->tabText(tab->currentIndex()); - if(comm.endsWith("
")) - comm=comm.remove(QRegExp("
$")); - writeToTab("<"+pseudo+"> "+comm, destChan); - - if(!comm.startsWith(":")) - comm.insert(0,":"); - - return "PRIVMSG "+destChan+" "+comm.replace(" "," "); - } - return ""; -} - -void IrcServer::join(QString chan) -{ - editor->append("Joining "+ chan +" channel"); - emit joinTab(); - /* - QTextEdit *textEdit=new QTextEdit; - int index=tab->insertTab(tab->currentIndex()+1, textEdit, chatin); - tab->setTabToolTip(index,serverName); - tab->setCurrentIndex(index); - textEdit->setReadOnly(true); - */ - ChatTab* newTab = new ChatTab(tab, chan, 0, this); - int index=tab->insertTab(tab->currentIndex()+1, newTab, chan); - tab->setCurrentIndex(index); - - conversations.insert(chan, newTab); - - sendData("JOIN "+chan); - - emit tabJoined(); -} -void IrcServer::leave(QString chan) -{ - sendData(parseCommande("/part "+chan+ " "+msgQuit)); -} - -void IrcServer::writeToTab(QString txt, QString destChan, QString msgTray) -{ - if(destChan!="") - { - conversations[destChan]->textEdit->setHtml(conversations[destChan]->textEdit->toHtml()+txt); - QScrollBar *sb = conversations[destChan]->textEdit->verticalScrollBar(); - sb->setValue(sb->maximum()); - } - else if(txt.startsWith("#")) - { - QString dest=txt.split(" ").first(); - QStringList list=txt.split(" "); - list.removeFirst(); - txt=list.join(" "); - conversations[dest]->textEdit->setHtml(conversations[dest]->textEdit->toHtml()+txt); - QScrollBar *sb = conversations[dest]->textEdit->verticalScrollBar(); - sb->setValue(sb->maximum()); } - else - { - txt.replace("\r\n","
"); - editor->setHtml(editor->toHtml()+txt); - QScrollBar *sb = editor->verticalScrollBar(); - sb->setValue(sb->maximum()); - } -} - -void IrcServer::updateUsersList(QString chan, QString message) -{ - /* - message = message.replace("\r\n",""); - message = message.replace("\r",""); - QListView* userList = tab->ChannelTab(chan)->userView; - if(chan!=serverName) - { - if(conversations[chan]->updateUsers==true || message != "") - { - QString liste2=message.replace(":",""); - QStringList liste=liste2.split(" "); - if (delist == true) users.clear(); - for(int i=5; i < liste.count(); i++) - { - users.append(liste.at(i)); - } - conversations[chan]->updateUsers=false; - if (liste.count() < 53) - delist = true; - else - delist = false; - users.sort(); - QStringListModel *model = new QStringListModel(users); - if (userList) - { - userList->setModel(model); - userList->update(); - } - } - else - { - conversations[chan]->updateUsers=true; - sendData("NAMES "+chan); - } - } - else - { - QStringListModel model; - userList->setModel(&model); - userList->update(); - } - */ -} From 6776c9ba98eb8e46db2586caee32227719eeb79b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:34:52 -0400 Subject: [PATCH 252/469] Create sendmessagesdialog.cpp --- src/qt/sendmessagesdialog.cpp | 339 ++++++++++++++++++++++++++++++++++ 1 file changed, 339 insertions(+) create mode 100644 src/qt/sendmessagesdialog.cpp diff --git a/src/qt/sendmessagesdialog.cpp b/src/qt/sendmessagesdialog.cpp new file mode 100644 index 00000000..6c043756 --- /dev/null +++ b/src/qt/sendmessagesdialog.cpp @@ -0,0 +1,339 @@ +#include "sendmessagesdialog.h" +#include "ui_sendmessagesdialog.h" +//#include "init.h" +#include "walletmodel.h" +#include "messagemodel.h" +#include "addressbookpage.h" +#include "optionsmodel.h" +#include "sendmessagesentry.h" +//#include "guiutil.h" + +#include +#include +#include +#include +#include +#include + +SendMessagesDialog::SendMessagesDialog(Mode mode, Type type, QWidget *parent) : + QDialog(parent), + ui(new Ui::SendMessagesDialog), + model(0), + mode(mode), + type(type) +{ + + ui->setupUi(this); + +#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac + ui->addButton->setIcon(QIcon()); + ui->clearButton->setIcon(QIcon()); + ui->sendButton->setIcon(QIcon()); +#endif + +#if QT_VERSION >= 0x040700 + /* Do not move this to the XML file, Qt before 4.7 will choke on it */ + if(mode == SendMessagesDialog::Encrypted) + ui->addressFrom->setPlaceholderText(tr("Enter a Swipp address (e.g. CKPnZKDzaDXqEgKJ4GdUg58gXxgzA7mkny)")); + #endif + addEntry(); + + connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry())); + connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); + connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(reject())); + + fNewRecipientAllowed = true; + + if(mode == SendMessagesDialog::Anonymous) + ui->frameAddressFrom->hide(); + + if(type == SendMessagesDialog::Page) + ui->closeButton->hide(); +} + +void SendMessagesDialog::setModel(MessageModel *model) +{ + this->model = model; + + for(int i = 0; i < ui->entries->count(); ++i) + { + SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + + if(entry) + entry->setModel(model); + } +} + +void SendMessagesDialog::loadRow(int row) +{ + if(model->data(model->index(row, model->Type, QModelIndex()), Qt::DisplayRole).toString() == MessageModel::Received) + ui->addressFrom->setText(model->data(model->index(row, model->ToAddress, QModelIndex()), Qt::DisplayRole).toString()); + else + ui->addressFrom->setText(model->data(model->index(row, model->FromAddress, QModelIndex()), Qt::DisplayRole).toString()); + + for(int i = 0; i < ui->entries->count(); ++i) + { + SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + + if(entry) + entry->loadRow(row); + } +} + +bool SendMessagesDialog::checkMode(Mode mode) +{ + return (mode == this->mode); +} + +bool SendMessagesDialog::validate() +{ + if(mode == SendMessagesDialog::Encrypted && ui->addressFrom->text() == "") + { + ui->addressFrom->setValid(false); + + return false; + } + + return true; +} + +SendMessagesDialog::~SendMessagesDialog() +{ + delete ui; +} + +void SendMessagesDialog::on_pasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->addressFrom->setText(QApplication::clipboard()->text()); +} + +void SendMessagesDialog::on_addressBookButton_clicked() +{ + if(!model) + return; + + AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::ReceivingTab, this); + + dlg.setModel(model->getWalletModel()->getAddressTableModel()); + + if(dlg.exec()) + { + ui->addressFrom->setText(dlg.getReturnValue()); + SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(0)->widget()); + entry->setFocus(); + // findChild( const QString "sentTo")->setFocus(); + } +} + +void SendMessagesDialog::on_sendButton_clicked() +{ + QList recipients; + bool valid = true; + + if(!model) + return; + + valid = validate(); + + for(int i = 0; i < ui->entries->count(); ++i) + { + SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + if(entry) + { + if(entry->validate()) + recipients.append(entry->getValue()); + else + valid = false; + } + } + + if(!valid || recipients.isEmpty()) + return; + + // Format confirmation message + QStringList formatted; + foreach(const SendMessagesRecipient &rcp, recipients) + { + formatted.append(tr("%1 to %2 (%3)").arg(rcp.message, Qt::escape(rcp.label), rcp.address)); + } + + fNewRecipientAllowed = false; + + QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send messages"), + tr("Are you sure you want to send %1?").arg(formatted.join(tr(" and "))), + QMessageBox::Yes|QMessageBox::Cancel, + QMessageBox::Cancel); + + if(retval != QMessageBox::Yes) + { + fNewRecipientAllowed = true; + return; + } + + MessageModel::StatusCode sendstatus; + + if(mode == SendMessagesDialog::Anonymous) + sendstatus = model->sendMessages(recipients); + else + sendstatus = model->sendMessages(recipients, ui->addressFrom->text()); + + switch(sendstatus) + { + case MessageModel::InvalidAddress: + QMessageBox::warning(this, tr("Send Message"), + tr("The recipient address is not valid, please recheck."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case MessageModel::InvalidMessage: + QMessageBox::warning(this, tr("Send Message"), + tr("The message can't be empty."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case MessageModel::DuplicateAddress: + QMessageBox::warning(this, tr("Send Message"), + tr("Duplicate address found, can only send to each address once per send operation."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case MessageModel::MessageCreationFailed: + QMessageBox::warning(this, tr("Send Message"), + tr("Error: Message creation failed."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case MessageModel::MessageCommitFailed: + QMessageBox::warning(this, tr("Send Message"), + tr("Error: The message was rejected."), + QMessageBox::Ok, QMessageBox::Ok); + break; + case MessageModel::Aborted: // User aborted, nothing to do + break; + case MessageModel::FailedErrorShown: // Send failed, error message was displayed + break; + case MessageModel::OK: + accept(); + break; + } + + fNewRecipientAllowed = true; +} + +void SendMessagesDialog::clear() +{ + // Remove entries until only one left + while(ui->entries->count()) + delete ui->entries->takeAt(0)->widget(); + + addEntry(); + + updateRemoveEnabled(); + + ui->sendButton->setDefault(true); +} + +void SendMessagesDialog::reject() +{ + if(type == SendMessagesDialog::Dialog) + done(1); + else + clear(); +} + +void SendMessagesDialog::accept() +{ + if(type == SendMessagesDialog::Dialog) + done(0); + else + clear(); + +} + +void SendMessagesDialog::done(int retval) +{ + if(type == SendMessagesDialog::Dialog) + QDialog::done(retval); + else + clear(); +} + +SendMessagesEntry *SendMessagesDialog::addEntry() +{ + SendMessagesEntry *entry = new SendMessagesEntry(this); + + entry->setModel(model); + ui->entries->addWidget(entry); + connect(entry, SIGNAL(removeEntry(SendMessagesEntry*)), this, SLOT(removeEntry(SendMessagesEntry*))); + updateRemoveEnabled(); + + // Focus the field, so that entry can start immediately + entry->clear(); + entry->setFocus(); + + ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); + QCoreApplication::instance()->processEvents(); + QScrollBar* bar = ui->scrollArea->verticalScrollBar(); + + if(bar) + bar->setSliderPosition(bar->maximum()); + + return entry; +} + +void SendMessagesDialog::updateRemoveEnabled() +{ + // Remove buttons are enabled as soon as there is more than one send-entry + bool enabled = (ui->entries->count() > 1); + + for(int i = 0; i < ui->entries->count(); ++i) + { + SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + if(entry) + entry->setRemoveEnabled(enabled); + } + + setupTabChain(0); +} + +void SendMessagesDialog::removeEntry(SendMessagesEntry* entry) +{ + delete entry; + + updateRemoveEnabled(); +} + +QWidget *SendMessagesDialog::setupTabChain(QWidget *prev) +{ + for(int i = 0; i < ui->entries->count(); ++i) + { + SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + if(entry) + { + prev = entry->setupTabChain(prev); + } + } + + QWidget::setTabOrder(prev, ui->addButton); + QWidget::setTabOrder(ui->addButton, ui->sendButton); + + return ui->sendButton; +} + +void SendMessagesDialog::pasteEntry(const SendMessagesRecipient &rv) +{ + if(!fNewRecipientAllowed) + return; + + SendMessagesEntry *entry = 0; + // Replace the first entry if it is still unused + if(ui->entries->count() == 1) + { + SendMessagesEntry *first = qobject_cast(ui->entries->itemAt(0)->widget()); + + if(first->isClear()) + entry = first; + } + + if(!entry) + entry = addEntry(); + + entry->setValue(rv); +} From 71eda1ae406c6e5115ed8fac5dc9515e39b75f77 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:35:37 -0400 Subject: [PATCH 253/469] Create sendmessagesentry.h --- src/qt/sendmessagesentry.h | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/qt/sendmessagesentry.h diff --git a/src/qt/sendmessagesentry.h b/src/qt/sendmessagesentry.h new file mode 100644 index 00000000..16f76d9d --- /dev/null +++ b/src/qt/sendmessagesentry.h @@ -0,0 +1,55 @@ +#ifndef SENDMESSAGESENTRY_H +#define SENDMESSAGESENTRY_H + +#include + +namespace Ui { + class SendMessagesEntry; +} +class MessageModel; +class SendMessagesRecipient; + +/** A single entry in the dialog for sending messages. */ +class SendMessagesEntry : public QFrame +{ + Q_OBJECT + +public: + explicit SendMessagesEntry(QWidget *parent = 0); + ~SendMessagesEntry(); + + void setModel(MessageModel *model); + void loadRow(int row); + bool validate(); + SendMessagesRecipient getValue(); + + /** Return whether the entry is still empty and unedited */ + bool isClear(); + + void setValue(const SendMessagesRecipient &value); + + /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). + */ + QWidget *setupTabChain(QWidget *prev); + + void setFocus(); + +public Q_SLOTS: + void setRemoveEnabled(bool enabled); + void clear(); + +signals: + void removeEntry(SendMessagesEntry *entry); + +private Q_SLOTS: + void on_deleteButton_clicked(); + void on_addressBookButton_clicked(); + void on_pasteButton_clicked(); + void on_sendTo_textChanged(const QString &address); + +private: + Ui::SendMessagesEntry *ui; + MessageModel *model; +}; + +#endif // SENDMESSAGESENTRY_H From 188ab314f59375b48df9071f1541f41598a453c0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:36:42 -0400 Subject: [PATCH 254/469] Add files via upload --- src/qt/messagemodel.cpp | 619 ++++++++++++++++++++++++++++++++++++++++ src/qt/messagemodel.h | 195 +++++++++++++ src/qt/messagepage.cpp | 419 +++++++++++++++++++++++++++ src/qt/messagepage.h | 73 +++++ 4 files changed, 1306 insertions(+) create mode 100644 src/qt/messagemodel.cpp create mode 100644 src/qt/messagemodel.h create mode 100644 src/qt/messagepage.cpp create mode 100644 src/qt/messagepage.h diff --git a/src/qt/messagemodel.cpp b/src/qt/messagemodel.cpp new file mode 100644 index 00000000..ad813292 --- /dev/null +++ b/src/qt/messagemodel.cpp @@ -0,0 +1,619 @@ +#include "guiutil.h" +#include "guiconstants.h" +#include "bitcoinunits.h" +#include "optionsmodel.h" +#include "walletmodel.h" +#include "messagemodel.h" +#include "addresstablemodel.h" + +#include "ui_interface.h" +#include "base58.h" +#include "json_spirit.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +Q_DECLARE_METATYPE(std::vector); + +QList ambiguous; /**< Specifies Ambiguous addresses */ + +const QString MessageModel::Sent = "Sent"; +const QString MessageModel::Received = "Received"; + +struct MessageTableEntryLessThan +{ + bool operator()(const MessageTableEntry &a, const MessageTableEntry &b) const {return a.received_datetime < b.received_datetime;}; + bool operator()(const MessageTableEntry &a, const QDateTime &b) const {return a.received_datetime < b;} + bool operator()(const QDateTime &a, const MessageTableEntry &b) const {return a < b.received_datetime;} +}; + +// Private implementation +class MessageTablePriv +{ +public: + QList cachedMessageTable; + MessageModel *parent; + + MessageTablePriv(MessageModel *parent): + parent(parent) {} + + void refreshMessageTable() + { + cachedMessageTable.clear(); + + if (parent->getWalletModel()->getEncryptionStatus() == WalletModel::Locked) + { + // -- messages are stored encrypted, can't load them without the private keys + return; + }; + + { + LOCK(cs_smsgDB); + + SecMsgDB dbSmsg; + + if (!dbSmsg.Open("cr+")) + //throw runtime_error("Could not open DB."); + return; + + unsigned char chKey[18]; + std::vector vchKey; + vchKey.resize(18); + + SecMsgStored smsgStored; + MessageData msg; + QString label; + QDateTime sent_datetime; + QDateTime received_datetime; + + std::string sPrefix("im"); + leveldb::Iterator* it = dbSmsg.pdb->NewIterator(leveldb::ReadOptions()); + while (dbSmsg.NextSmesg(it, sPrefix, chKey, smsgStored)) + { + uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN; + if (SecureMsgDecrypt(false, smsgStored.sAddrTo, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0) + { + label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(msg.sFromAddress)); + + sent_datetime .setTime_t(msg.timestamp); + received_datetime.setTime_t(smsgStored.timeReceived); + + memcpy(&vchKey[0], chKey, 18); + + addMessageEntry(MessageTableEntry(vchKey, + MessageTableEntry::Received, + label, + QString::fromStdString(smsgStored.sAddrTo), + QString::fromStdString(msg.sFromAddress), + sent_datetime, + received_datetime, + (char*)&msg.vchMessage[0]), + true); + } + }; + + delete it; + + sPrefix = "sm"; + it = dbSmsg.pdb->NewIterator(leveldb::ReadOptions()); + while (dbSmsg.NextSmesg(it, sPrefix, chKey, smsgStored)) + { + uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN; + if (SecureMsgDecrypt(false, smsgStored.sAddrOutbox, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0) + { + label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(smsgStored.sAddrTo)); + + sent_datetime .setTime_t(msg.timestamp); + received_datetime.setTime_t(smsgStored.timeReceived); + + memcpy(&vchKey[0], chKey, 18); + + addMessageEntry(MessageTableEntry(vchKey, + MessageTableEntry::Sent, + label, + QString::fromStdString(smsgStored.sAddrTo), + QString::fromStdString(msg.sFromAddress), + sent_datetime, + received_datetime, + (char*)&msg.vchMessage[0]), + true); + } + }; + + delete it; + } + } + + void newMessage(const SecMsgStored& inboxHdr) + { + // we have to copy it, because it doesn't like constants going into Decrypt + SecMsgStored smsgStored = inboxHdr; + MessageData msg; + QString label; + QDateTime sent_datetime; + QDateTime received_datetime; + + uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN; + if (SecureMsgDecrypt(false, smsgStored.sAddrTo, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0) + { + label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(msg.sFromAddress)); + + sent_datetime .setTime_t(msg.timestamp); + received_datetime.setTime_t(smsgStored.timeReceived); + + std::string sPrefix("im"); + SecureMessage* psmsg = (SecureMessage*) &smsgStored.vchMessage[0]; + + std::vector vchKey; + vchKey.resize(18); + memcpy(&vchKey[0], sPrefix.data(), 2); + memcpy(&vchKey[2], &psmsg->timestamp, 8); + memcpy(&vchKey[10], &smsgStored.vchMessage[SMSG_HDR_LEN], 8); // sample + + addMessageEntry(MessageTableEntry(vchKey, + MessageTableEntry::Received, + label, + QString::fromStdString(smsgStored.sAddrTo), + QString::fromStdString(msg.sFromAddress), + sent_datetime, + received_datetime, + (char*)&msg.vchMessage[0]), + false); + } + } + + void newOutboxMessage(const SecMsgStored& outboxHdr) + { + + SecMsgStored smsgStored = outboxHdr; + MessageData msg; + QString label; + QDateTime sent_datetime; + QDateTime received_datetime; + + uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN; + if (SecureMsgDecrypt(false, smsgStored.sAddrOutbox, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0) + { + label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(smsgStored.sAddrTo)); + + sent_datetime .setTime_t(msg.timestamp); + received_datetime.setTime_t(smsgStored.timeReceived); + + std::string sPrefix("sm"); + SecureMessage* psmsg = (SecureMessage*) &smsgStored.vchMessage[0]; + std::vector vchKey; + vchKey.resize(18); + memcpy(&vchKey[0], sPrefix.data(), 2); + memcpy(&vchKey[2], &psmsg->timestamp, 8); + memcpy(&vchKey[10], &smsgStored.vchMessage[SMSG_HDR_LEN], 8); // sample + + addMessageEntry(MessageTableEntry(vchKey, + MessageTableEntry::Sent, + label, + QString::fromStdString(smsgStored.sAddrTo), + QString::fromStdString(msg.sFromAddress), + sent_datetime, + received_datetime, + (char*)&msg.vchMessage[0]), + false); + } + } + + void walletUnlocked() + { + // -- wallet is unlocked, can get at the private keys now + refreshMessageTable(); + + parent->reset(); // reload table view + + if (parent->proxyModel) + { + parent->proxyModel->setFilterRole(false); + parent->proxyModel->setFilterFixedString(""); + parent->resetFilter(); + parent->proxyModel->setFilterRole(MessageModel::Ambiguous); + parent->proxyModel->setFilterFixedString("true"); + } + + //invalidateFilter() + } + + void setEncryptionStatus(int status) + { + if (status == WalletModel::Locked) + { + // -- Wallet is locked, clear secure message display. + cachedMessageTable.clear(); + + parent->reset(); // reload table view + }; + }; + + MessageTableEntry *index(int idx) + { + if(idx >= 0 && idx < cachedMessageTable.size()) + return &cachedMessageTable[idx]; + else + return 0; + } + +private: + // Get the json value + const json_spirit::mValue & find_value(json_spirit::mObject & obj, const char * key) + { + std::string newKey = key; + + json_spirit::mObject::const_iterator i = obj.find(newKey); + + if(i != obj.end() && i->first == newKey) + return i->second; + else + return json_spirit::mValue::null; + } + + const std::string get_value(json_spirit::mObject & obj, const char * key) + { + json_spirit::mValue val = find_value(obj, key); + + if(val.is_null()) + return ""; + else + return val.get_str(); + } + + // Determine if it is a special message, i.e.: Invoice, Receipt, etc... + void handleMessageEntry(const MessageTableEntry & message, const bool append) + { + addMessageEntry(message, append); + json_spirit::mValue mVal; + json_spirit::read(message.message.toStdString(), mVal); + + if(mVal.is_null()) + { + addMessageEntry(message, append); + return; + } + + json_spirit::mObject mObj(mVal.get_obj()); + json_spirit::mValue mvType = find_value(mObj, "type"); + + } + + void addMessageEntry(const MessageTableEntry & message, const bool & append) + { + if(append) + { + cachedMessageTable.append(message); + } else + { + int index = qLowerBound(cachedMessageTable.begin(), cachedMessageTable.end(), message.received_datetime, MessageTableEntryLessThan()) - cachedMessageTable.begin(); + parent->beginInsertRows(QModelIndex(), index, index); + cachedMessageTable.insert( + index, + message); + parent->endInsertRows(); + } + } + +}; + +MessageModel::MessageModel(CWallet *wallet, WalletModel *walletModel, QObject *parent) : + QAbstractTableModel(parent), wallet(wallet), walletModel(walletModel), optionsModel(0), priv(0) +{ + columns << tr("Type") << tr("Sent Date Time") << tr("Received Date Time") << tr("Label") << tr("To Address") << tr("From Address") << tr("Message"); + + proxyModel = NULL; + + optionsModel = walletModel->getOptionsModel(); + + priv = new MessageTablePriv(this); + priv->refreshMessageTable(); + + subscribeToCoreSignals(); +} + +MessageModel::~MessageModel() +{ + if (proxyModel) + delete proxyModel; + + delete priv; + unsubscribeFromCoreSignals(); +} + +bool MessageModel::getAddressOrPubkey(QString &address, QString &pubkey) const +{ + CBitcoinAddress addressParsed(address.toStdString()); + + if(addressParsed.IsValid()) { + CKeyID destinationAddress; + CPubKey destinationKey; + + addressParsed.GetKeyID(destinationAddress); + + if (SecureMsgGetStoredKey(destinationAddress, destinationKey) != 0 + && SecureMsgGetLocalKey(destinationAddress, destinationKey) != 0) // test if it's a local key + return false; + + address = destinationAddress.ToString().c_str(); + pubkey = EncodeBase58(destinationKey.Raw()).c_str(); + + return true; + } + + return false; +} + +WalletModel *MessageModel::getWalletModel() +{ + return walletModel; +} + +OptionsModel *MessageModel::getOptionsModel() +{ + return optionsModel; +} + +MessageModel::StatusCode MessageModel::sendMessages(const QList &recipients, const QString &addressFrom) +{ + + QSet setAddress; + + if(recipients.empty()) + return OK; + + // Pre-check input data for validity + foreach(const SendMessagesRecipient &rcp, recipients) + { + if(!walletModel->validateAddress(rcp.address)) + return InvalidAddress; + + if(rcp.message == "") + return MessageCreationFailed; + + std::string sendTo = rcp.address.toStdString(); + std::string pubkey = rcp.pubkey.toStdString(); + std::string message = rcp.message.toStdString(); + std::string addFrom = addressFrom.toStdString(); + + SecureMsgAddAddress(sendTo, pubkey); + setAddress.insert(rcp.address); + + std::string sError; + if (SecureMsgSend(addFrom, sendTo, message, sError) != 0) + { + QMessageBox::warning(NULL, tr("Send Secure Message"), + tr("Send failed: %1.").arg(sError.c_str()), + QMessageBox::Ok, QMessageBox::Ok); + + return FailedErrorShown; + }; + + // Add addresses / update labels that we've sent to to the address book + std::string strAddress = rcp.address.toStdString(); + CTxDestination dest = CBitcoinAddress(strAddress).Get(); + std::string strLabel = rcp.label.toStdString(); + { + LOCK(wallet->cs_wallet); + + std::map::iterator mi = wallet->mapAddressBook.find(dest); + + // Check if we have a new address or an updated label + if (mi == wallet->mapAddressBook.end() || mi->second != strLabel) + { + wallet->SetAddressBookName(dest, strLabel); + } + } + } + + if(recipients.size() > setAddress.size()) + return DuplicateAddress; + + return OK; +} + +MessageModel::StatusCode MessageModel::sendMessages(const QList &recipients) +{ + return sendMessages(recipients, "anon"); +} + +int MessageModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return priv->cachedMessageTable.size(); +} + +int MessageModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return columns.length(); +} + +QVariant MessageModel::data(const QModelIndex &index, int role) const +{ + if(!index.isValid()) + return QVariant(); + + MessageTableEntry *rec = static_cast(index.internalPointer()); + + switch(role) + { + /* + case Qt::DecorationRole: + switch(index.column()) + { + return txStatusDecoration(rec); + case ToAddress: + return txAddressDecoration(rec); + } + break;*/ + case Qt::DisplayRole: + switch(index.column()) + { + case Label: return (rec->label.isEmpty() ? tr("(no label)") : rec->label); + case ToAddress: return rec->to_address; + case FromAddress: return rec->from_address; + case SentDateTime: return rec->sent_datetime; + case ReceivedDateTime: return rec->received_datetime; + case Message: return rec->message; + case TypeInt: return rec->type; + case HTML: return rec->received_datetime.toString() + "
" + (rec->label.isEmpty() ? rec->from_address : rec->label) + "
" + rec->message; + case Type: + switch(rec->type) + { + case MessageTableEntry::Sent: return Sent; + case MessageTableEntry::Received: return Received; + default: break; + } + case Key: return QVariant::fromValue(rec->chKey); + } + break; + + case KeyRole: return QVariant::fromValue(rec->chKey); + case TypeRole: return rec->type; + case SentDateRole: return rec->sent_datetime; + case ReceivedDateRole: return rec->received_datetime; + case FromAddressRole: return rec->from_address; + case ToAddressRole: return rec->to_address; + case FilterAddressRole: return (rec->type == MessageTableEntry::Sent ? rec->to_address + rec->from_address : rec->from_address + rec->to_address); + case LabelRole: return rec->label; + case MessageRole: return rec->message; + case ShortMessageRole: return rec->message; // TODO: Short message + case HTMLRole: return rec->received_datetime.toString() + "
" + (rec->label.isEmpty() ? rec->from_address : rec->label) + "
" + rec->message; + case Ambiguous: + int it; + + for (it = 0; ittype == MessageTableEntry::Sent ? rec->to_address + rec->from_address : rec->from_address + rec->to_address)) + return false; + } + QString address = (rec->type == MessageTableEntry::Sent ? rec->to_address + rec->from_address : rec->from_address + rec->to_address); + ambiguous.append(address); + + return "true"; + break; + } + + return QVariant(); +} + +QVariant MessageModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + return (orientation == Qt::Horizontal && role == Qt::DisplayRole ? columns[section] : QVariant()); +} + +Qt::ItemFlags MessageModel::flags(const QModelIndex & index) const +{ + if(index.isValid()) + return Qt::ItemIsSelectable | Qt::ItemIsEnabled; + + return 0; +} + +QModelIndex MessageModel::index(int row, int column, const QModelIndex & parent) const +{ + Q_UNUSED(parent); + MessageTableEntry *data = priv->index(row); + return (data ? createIndex(row, column, priv->index(row)) : QModelIndex()); +} + +bool MessageModel::removeRows(int row, int count, const QModelIndex & parent) +{ + MessageTableEntry *rec = priv->index(row); + if(count != 1 || !rec) + // Can only remove one row at a time, and cannot remove rows not in model. + // Also refuse to remove receiving addresses. + return false; + + { + LOCK(cs_smsgDB); + SecMsgDB dbSmsg; + + if (!dbSmsg.Open("cr+")) + //throw runtime_error("Could not open DB."); + return false; + + dbSmsg.EraseSmesg(&rec->chKey[0]); + } + + beginRemoveRows(parent, row, row); + priv->cachedMessageTable.removeAt(row); + endRemoveRows(); + + return true; +} + +void MessageModel::resetFilter() +{ + ambiguous.clear(); +} + +void MessageModel::newMessage(const SecMsgStored &smsg) +{ + priv->newMessage(smsg); +} + + +void MessageModel::newOutboxMessage(const SecMsgStored &smsgOutbox) +{ + priv->newOutboxMessage(smsgOutbox); +} + + +void MessageModel::walletUnlocked() +{ + priv->walletUnlocked(); +} + +void MessageModel::setEncryptionStatus(int status) +{ + priv->setEncryptionStatus(status); +} + + +static void NotifySecMsgInbox(MessageModel *messageModel, SecMsgStored inboxHdr) +{ + // Too noisy: OutputDebugStringF("NotifySecMsgInboxChanged %s\n", message); + QMetaObject::invokeMethod(messageModel, "newMessage", Qt::QueuedConnection, + Q_ARG(SecMsgStored, inboxHdr)); +} + +static void NotifySecMsgOutbox(MessageModel *messageModel, SecMsgStored outboxHdr) +{ + QMetaObject::invokeMethod(messageModel, "newOutboxMessage", Qt::QueuedConnection, + Q_ARG(SecMsgStored, outboxHdr)); +} + +static void NotifySecMsgWallet(MessageModel *messageModel) +{ + QMetaObject::invokeMethod(messageModel, "walletUnlocked", Qt::QueuedConnection); +} + +void MessageModel::subscribeToCoreSignals() +{ + qRegisterMetaType("SecMsgStored"); + + // Connect signals + NotifySecMsgInboxChanged.connect(boost::bind(NotifySecMsgInbox, this, _1)); + NotifySecMsgOutboxChanged.connect(boost::bind(NotifySecMsgOutbox, this, _1)); + NotifySecMsgWalletUnlocked.connect(boost::bind(NotifySecMsgWallet, this)); + + connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int))); +} + +void MessageModel::unsubscribeFromCoreSignals() +{ + // Disconnect signals + NotifySecMsgInboxChanged.disconnect(boost::bind(NotifySecMsgInbox, this, _1)); + NotifySecMsgOutboxChanged.disconnect(boost::bind(NotifySecMsgOutbox, this, _1)); + NotifySecMsgWalletUnlocked.disconnect(boost::bind(NotifySecMsgWallet, this)); + + disconnect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int))); +} diff --git a/src/qt/messagemodel.h b/src/qt/messagemodel.h new file mode 100644 index 00000000..a246dcc4 --- /dev/null +++ b/src/qt/messagemodel.h @@ -0,0 +1,195 @@ +#ifndef MESSAGEMODEL_H +#define MESSAGEMODEL_H + +#include "uint256.h" + +#include +#include "allocators.h" /* for SecureString */ +#include "smessage.h" +#include +#include +#include +#include +#include + + +class MessageTablePriv; +class InvoiceTableModel; +class InvoiceItemTableModel; +class ReceiptTableModel; +class CWallet; +class WalletModel; +class OptionsModel; + +class SendMessagesRecipient +{ +public: + QString address; + QString label; + QString pubkey; + QString message; +}; + +struct MessageTableEntry +{ + enum Type { + Sent, + Received + }; + + std::vector chKey; + Type type; + QString label; + QString to_address; + QString from_address; + QDateTime sent_datetime; + QDateTime received_datetime; + QString message; + + MessageTableEntry() {} + MessageTableEntry(std::vector &chKey, + Type type, + const QString &label, + const QString &to_address, + const QString &from_address, + const QDateTime &sent_datetime, + const QDateTime &received_datetime, + const QString &message): + chKey(chKey), + type(type), + label(label), + to_address(to_address), + from_address(from_address), + sent_datetime(sent_datetime), + received_datetime(received_datetime), + message(message) + { + } +}; + +/** Interface to Swipp Secure Messaging from Qt view code. */ +class MessageModel : public QAbstractTableModel +{ + Q_OBJECT + +public: + explicit MessageModel(CWallet *wallet, WalletModel *walletModel, QObject *parent = 0); + ~MessageModel(); + + enum StatusCode // Returned by sendMessages + { + OK, + InvalidAddress, + InvalidMessage, + DuplicateAddress, + MessageCreationFailed, // Error returned when DB is still locked + MessageCommitFailed, + Aborted, + FailedErrorShown + }; + + enum ColumnIndex { + Type = 0, /**< Sent/Received */ + SentDateTime = 1, /**< Time Sent */ + ReceivedDateTime = 2, /**< Time Received */ + Label = 3, /**< User specified label */ + ToAddress = 4, /**< To Bitcoin address */ + FromAddress = 5, /**< From Bitcoin address */ + Message = 6, /**< Plaintext */ + TypeInt = 7, /**< Plaintext */ + Key = 8, /**< chKey */ + HTML = 9, /**< HTML Formatted Data */ + }; + + /** Roles to get specific information from a message row. + These are independent of column. + */ + enum RoleIndex { + /** Type of message */ + TypeRole = Qt::UserRole, + /** Date and time this message was sent */ + /** message key */ + KeyRole, + SentDateRole, + /** Date and time this message was received */ + ReceivedDateRole, + /** From Address of message */ + FromAddressRole, + /** To Address of message */ + ToAddressRole, + /** Filter address related to message */ + FilterAddressRole, + /** Label of address related to message */ + LabelRole, + /** Full Message */ + MessageRole, + /** Short Message */ + ShortMessageRole, + /** HTML Formatted */ + HTMLRole, + /** Ambiguous bool */ + Ambiguous + }; + + static const QString Sent; /**< Specifies sent message */ + static const QString Received; /**< Specifies sent message */ + + //QList ambiguous; /**< Specifies Ambiguous addresses */ + + /** @name Methods overridden from QAbstractTableModel + @{*/ + int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QModelIndex index(int row, int column, const QModelIndex & parent) const; + bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); + Qt::ItemFlags flags(const QModelIndex & index) const; + /*@}*/ + + /* Look up row index of a message in the model. + Return -1 if not found. + */ + int lookupMessage(const QString &message) const; + + WalletModel *getWalletModel(); + OptionsModel *getOptionsModel(); + + void resetFilter(); + + bool getAddressOrPubkey( QString &Address, QString &Pubkey) const; + + // Send messages to a list of recipients + StatusCode sendMessages(const QList &recipients); + StatusCode sendMessages(const QList &recipients, const QString &addressFrom); + + QSortFilterProxyModel *proxyModel; + +private: + CWallet *wallet; + WalletModel *walletModel; + OptionsModel *optionsModel; + MessageTablePriv *priv; + QStringList columns; + + void subscribeToCoreSignals(); + void unsubscribeFromCoreSignals(); + +public slots: + + /* Check for new messages */ + void newMessage(const SecMsgStored& smsg); + void newOutboxMessage(const SecMsgStored& smsg); + + void walletUnlocked(); + + void setEncryptionStatus(int status); + + friend class MessageTablePriv; + +signals: + // Asynchronous error notification + void error(const QString &title, const QString &message, bool modal); +}; + +#endif // MESSAGEMODEL_H diff --git a/src/qt/messagepage.cpp b/src/qt/messagepage.cpp new file mode 100644 index 00000000..dec8cd7f --- /dev/null +++ b/src/qt/messagepage.cpp @@ -0,0 +1,419 @@ +// Copyright (c) 2017-2018 The Swipp developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "messagepage.h" +#include "ui_messagepage.h" + +#include "sendmessagesdialog.h" +#include "mrichtextedit.h" +#include "messagemodel.h" +#include "bitcoingui.h" +#include "csvmodelwriter.h" +#include "guiutil.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define DECORATION_SIZE 64 +#define NUM_ITEMS 3 + +class MessageViewDelegate : public QStyledItemDelegate +{ +protected: + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; +}; + +void MessageViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QStyleOptionViewItem options = option; + initStyleOption(&options, index); + + QStyle *style = options.widget ? options.widget->style() : QApplication::style(); + + QTextDocument doc; + QString align(index.data(MessageModel::TypeRole) == 1 ? "left" : "right"); + QString html = "

" + index.data(MessageModel::HTMLRole).toString() + "

"; + doc.setHtml(html); + + /// Painting item without text + options.text = QString(); + style->drawControl(QStyle::CE_ItemViewItem, &options, painter); + + QAbstractTextDocumentLayout::PaintContext ctx; + + // Highlighting text if item is selected + if (options.state & QStyle::State_Selected) + ctx.palette.setColor(QPalette::Text, options.palette.color(QPalette::Active, QPalette::HighlightedText)); + + QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &options); + doc.setTextWidth( textRect.width() ); + painter->save(); + painter->translate(textRect.topLeft()); + painter->setClipRect(textRect.translated(-textRect.topLeft())); + doc.documentLayout()->draw(painter, ctx); + painter->restore(); +} + +QSize MessageViewDelegate::sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QStyleOptionViewItem options = option; + initStyleOption(&options, index); + + QTextDocument doc; + doc.setHtml(index.data(MessageModel::HTMLRole).toString()); + doc.setTextWidth(options.rect.width()); + return QSize(doc.idealWidth(), doc.size().height() + 20); +} + + +MessagePage::MessagePage(QWidget *parent) : QWidget(parent), ui(new Ui::MessagePage), model(0), + msgdelegate(new MessageViewDelegate()), + messageTextEdit(new MRichTextEdit()) +{ + ui->setupUi(this); + +#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac + ui->deleteButton->setIcon(QIcon()); +#endif + // Context menu actions + replyAction = new QAction(ui->sendButton->text(), this); + copyFromAddressAction = new QAction(ui->copyFromAddressButton->text(), this); + copyToAddressAction = new QAction(ui->copyToAddressButton->text(), this); + deleteAction = new QAction(ui->deleteButton->text(), this); + + // Build context menu + contextMenu = new QMenu(); + + contextMenu->addAction(replyAction); + contextMenu->addAction(copyFromAddressAction); + contextMenu->addAction(copyToAddressAction); + contextMenu->addAction(deleteAction); + + connect(replyAction, SIGNAL(triggered()), this, SLOT(on_sendButton_clicked())); + connect(copyFromAddressAction, SIGNAL(triggered()), this, SLOT(on_copyFromAddressButton_clicked())); + connect(copyToAddressAction, SIGNAL(triggered()), this, SLOT(on_copyToAddressButton_clicked())); + connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteButton_clicked())); + + connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); + + // Show messages + ui->listConversation->setItemDelegate(msgdelegate); + ui->listConversation->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE)); + ui->listConversation->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2)); + ui->listConversation->setAttribute(Qt::WA_MacShowFocusRect, false); +} + +MessagePage::~MessagePage() +{ + delete ui; +} + +void MessagePage::setModel(MessageModel *model) +{ + this->model = model; + + if (!model) + return; + + model->proxyModel = new QSortFilterProxyModel(this); + model->proxyModel->setSourceModel(model); + model->proxyModel->setDynamicSortFilter(true); + model->proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); + model->proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); + model->proxyModel->sort(MessageModel::ReceivedDateTime); + model->proxyModel->setFilterRole(MessageModel::Ambiguous); + model->proxyModel->setFilterFixedString("true"); + + ui->tableView->setModel(model->proxyModel); + ui->tableView->sortByColumn(MessageModel::ReceivedDateTime, Qt::DescendingOrder); + + ui->listConversation->setModel(model->proxyModel); + ui->listConversation->setModelColumn(MessageModel::HTML); + + // Set column widths + ui->tableView->horizontalHeader()->resizeSection(MessageModel::Type, 100); + ui->tableView->horizontalHeader()->resizeSection(MessageModel::Label, 100); + ui->tableView->horizontalHeader()->setResizeMode(MessageModel::Label, QHeaderView::Stretch); + ui->tableView->horizontalHeader()->resizeSection(MessageModel::FromAddress, 320); + ui->tableView->horizontalHeader()->resizeSection(MessageModel::ToAddress, 320); + ui->tableView->horizontalHeader()->resizeSection(MessageModel::SentDateTime, 170); + ui->tableView->horizontalHeader()->resizeSection(MessageModel::ReceivedDateTime, 170); + + // TODO: Do we really need this? + // ui->messageEdit->setMinimumHeight(100); + + // Hidden columns + ui->tableView->setColumnHidden(MessageModel::Message, true); + + connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged())); + connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectionChanged())); + connect(ui->listConversation->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(itemSelectionChanged())); + connect(ui->listConversation, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(itemSelectionChanged())); + //connect(ui->messageEdit, SIGNAL(textChanged()), this, SLOT(messageTextChanged())); + + // Scroll to bottom + connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(incomingMessage())); + selectionChanged(); +} + +void MessagePage::on_sendButton_clicked() +{ + if (!model) + return; + + std::string sError; + std::string sendTo = replyToAddress.toStdString(); + std::string message = ui->messageEdit->toHtml().toStdString(); + std::string addFrom = replyFromAddress.toStdString(); + + if (SecureMsgSend(addFrom, sendTo, message, sError) != 0) + { + QMessageBox::warning(NULL, tr("Send Secure Message"), tr("Send failed: %1.").arg(sError.c_str()), + QMessageBox::Ok, QMessageBox::Ok); + + return; + } + + // ui->messageEdit->setMaximumHeight(30); + ui->messageEdit->clear(); + ui->listConversation->scrollToBottom(); +} + +void MessagePage::on_newButton_clicked() +{ + if (!model) + return; + + SendMessagesDialog dlg(SendMessagesDialog::Encrypted, SendMessagesDialog::Dialog, this); + dlg.setModel(model); + dlg.exec(); +} + +void MessagePage::on_copyFromAddressButton_clicked() +{ + GUIUtil::copyEntryData(ui->tableView, MessageModel::FromAddress, Qt::DisplayRole); +} + +void MessagePage::on_copyToAddressButton_clicked() +{ + GUIUtil::copyEntryData(ui->tableView, MessageModel::ToAddress, Qt::DisplayRole); +} + +void MessagePage::on_deleteButton_clicked() +{ + QListView *list = ui->listConversation; + + if (!list->selectionModel()) + return; + + QModelIndexList indexes = list->selectionModel()->selectedIndexes(); + + if (!indexes.isEmpty()) + { + list->model()->removeRow(indexes.at(0).row()); + indexes = list->selectionModel()->selectedIndexes(); + + if (indexes.isEmpty()) + on_backButton_clicked(); + } +} + +void MessagePage::on_backButton_clicked() +{ + model->proxyModel->setFilterRole(false); + model->proxyModel->setFilterFixedString(""); + model->resetFilter(); + model->proxyModel->setFilterRole(MessageModel::Ambiguous); + model->proxyModel->setFilterFixedString("true"); + + ui->tableView->clearSelection(); + ui->listConversation->clearSelection(); + itemSelectionChanged(); + selectionChanged(); + + ui->messageDetails->hide(); + ui->tableView->show(); + ui->newButton->setEnabled(true); + ui->newButton->setVisible(true); + ui->sendButton->setEnabled(false); + ui->sendButton->setVisible(false); + ui->messageEdit->setVisible(false); +} + +void MessagePage::selectionChanged() +{ + // Set button states based on selected tab and selection + QTableView *table = ui->tableView; + + if (!table->selectionModel()) + return; + + if (table->selectionModel()->hasSelection()) + { + replyAction->setEnabled(true); + copyFromAddressAction->setEnabled(true); + copyToAddressAction->setEnabled(true); + deleteAction->setEnabled(true); + + ui->copyFromAddressButton->setEnabled(true); + ui->copyToAddressButton->setEnabled(true); + ui->deleteButton->setEnabled(true); + + ui->newButton->setEnabled(false); + ui->newButton->setVisible(false); + ui->sendButton->setEnabled(true); + ui->sendButton->setVisible(true); + ui->messageEdit->setVisible(true); + + ui->tableView->hide(); + + // Figure out which message was selected + QModelIndexList labelColumn = table->selectionModel()->selectedRows(MessageModel::Label); + QModelIndexList addressFromColumn = table->selectionModel()->selectedRows(MessageModel::FromAddress); + QModelIndexList addressToColumn = table->selectionModel()->selectedRows(MessageModel::ToAddress); + QModelIndexList typeColumn = table->selectionModel()->selectedRows(MessageModel::Type); + + int type = -1; + + foreach (QModelIndex index, typeColumn) + type = (table->model()->data(index).toString() == MessageModel::Sent ? MessageTableEntry::Sent : + MessageTableEntry::Received); + foreach (QModelIndex index, labelColumn) + ui->contactLabel->setText(table->model()->data(index).toString()); + + foreach (QModelIndex index, addressFromColumn) + if (type == MessageTableEntry::Sent) + replyFromAddress = table->model()->data(index).toString(); + else + replyToAddress = table->model()->data(index).toString(); + + foreach (QModelIndex index, addressToColumn) + if (type == MessageTableEntry::Sent) + replyToAddress = table->model()->data(index).toString(); + else + replyFromAddress = table->model()->data(index).toString(); + + QString filter = replyToAddress + replyFromAddress; + + model->proxyModel->setFilterRole(false); + model->proxyModel->setFilterFixedString(""); + model->proxyModel->sort(MessageModel::ReceivedDateTime); + model->proxyModel->setFilterRole(MessageModel::FilterAddressRole); + model->proxyModel->setFilterFixedString(filter); + + ui->messageDetails->show(); + ui->listConversation->setCurrentIndex(model->proxyModel->index(0, 0, QModelIndex())); + } + else + { + ui->newButton->setEnabled(true); + ui->newButton->setVisible(true); + ui->sendButton->setEnabled(false); + ui->sendButton->setVisible(false); + ui->copyFromAddressButton->setEnabled(false); + ui->copyToAddressButton->setEnabled(false); + ui->deleteButton->setEnabled(false); + ui->messageEdit->hide(); + ui->messageDetails->hide(); + ui->messageEdit->clear(); + } +} + +void MessagePage::itemSelectionChanged() +{ + // Set button states based on selected tab and selection + QListView *list = ui->listConversation; + + if (!list->selectionModel()) + return; + + if (list->selectionModel()->hasSelection()) + { + replyAction->setEnabled(true); + copyFromAddressAction->setEnabled(true); + copyToAddressAction->setEnabled(true); + deleteAction->setEnabled(true); + + ui->copyFromAddressButton->setEnabled(true); + ui->copyToAddressButton->setEnabled(true); + ui->deleteButton->setEnabled(true); + ui->newButton->setEnabled(false); + ui->newButton->setVisible(false); + ui->sendButton->setEnabled(true); + ui->sendButton->setVisible(true); + ui->messageEdit->setVisible(true); + ui->tableView->hide(); + } + else + { + ui->newButton->setEnabled(true); + ui->newButton->setVisible(true); + ui->sendButton->setEnabled(false); + ui->sendButton->setVisible(false); + ui->copyFromAddressButton->setEnabled(false); + ui->copyToAddressButton->setEnabled(false); + ui->deleteButton->setEnabled(false); + ui->messageEdit->hide(); + ui->messageDetails->hide(); + ui->messageEdit->clear(); + } +} + +void MessagePage::incomingMessage() +{ + ui->listConversation->scrollToBottom(); +} + +void MessagePage::messageTextChanged() +{ + /* + if (ui->messageEdit->toPlainText().endsWith("\n")) + { + ui->messageEdit->setMaximumHeight(80); + ui->messageEdit->resize(256, ui->messageEdit->document()->size().height() + 10); + } + */ +} + +void MessagePage::exportClicked() +{ + // CSV is currently the only supported format + QString filename = GUIUtil::getSaveFileName(this, tr("Export Messages"), QString(), + tr("Comma separated file (*.csv)")); + if (filename.isNull()) + return; + + CSVModelWriter writer(filename); + + // name, column, role + writer.setModel(model->proxyModel); + writer.addColumn("Type", MessageModel::Type, Qt::DisplayRole); + writer.addColumn("Label", MessageModel::Label, Qt::DisplayRole); + writer.addColumn("FromAddress", MessageModel::FromAddress, Qt::DisplayRole); + writer.addColumn("ToAddress", MessageModel::ToAddress, Qt::DisplayRole); + writer.addColumn("SentDateTime", MessageModel::SentDateTime, Qt::DisplayRole); + writer.addColumn("ReceivedDateTime", MessageModel::ReceivedDateTime, Qt::DisplayRole); + writer.addColumn("Message", MessageModel::Message, Qt::DisplayRole); + + if (!writer.write()) + QMessageBox::critical(this, tr("Error exporting"), tr("Could not write to file %1.").arg(filename), + QMessageBox::Abort, QMessageBox::Abort); +} + +void MessagePage::contextualMenu(const QPoint &point) +{ + QModelIndex index = ui->tableView->indexAt(point); + + if (index.isValid()) + contextMenu->exec(QCursor::pos()); +} diff --git a/src/qt/messagepage.h b/src/qt/messagepage.h new file mode 100644 index 00000000..88e4d0df --- /dev/null +++ b/src/qt/messagepage.h @@ -0,0 +1,73 @@ +// Copyright (c) 2017-2018 The Swipp developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef MESSAGEPAGE_H +#define MESSAGEPAGE_H + +#include + +namespace Ui +{ + class MessagePage; +} + +class MessageModel; + +QT_BEGIN_NAMESPACE +class QTableView; +class QItemSelection; +class QSortFilterProxyModel; +class QMenu; +class QModelIndex; +class MessageViewDelegate; +class MRichTextEdit; +QT_END_NAMESPACE + +class MessagePage : public QWidget +{ + Q_OBJECT + +public: + explicit MessagePage(QWidget *parent = 0); + ~MessagePage(); + + void setModel(MessageModel *model); + +private: + void setupTextActions(); + +public slots: + void exportClicked(); + +private: + Ui::MessagePage *ui; + MessageModel *model; + + QMenu *contextMenu; + QAction *replyAction; + QAction *copyFromAddressAction; + QAction *copyToAddressAction; + QAction *deleteAction; + QString replyFromAddress; + QString replyToAddress; + MessageViewDelegate *msgdelegate; + MRichTextEdit *messageTextEdit; + +private slots: + void on_sendButton_clicked(); + void on_newButton_clicked(); + void on_copyFromAddressButton_clicked(); + void on_copyToAddressButton_clicked(); + void on_deleteButton_clicked(); + void on_backButton_clicked(); + void messageTextChanged(); + void selectionChanged(); + void itemSelectionChanged(); + void incomingMessage(); + + // Spawn contextual menu (right mouse menu) for address book entry + void contextualMenu(const QPoint &point); +}; + +#endif // MESSAGEPAGE_H From 01c68e734278b175d3f63593c71815481ff3f6c8 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:37:20 -0400 Subject: [PATCH 255/469] Add files via upload --- src/qt/sendmessagesdialog.h | 72 +++++++++++++ src/qt/sendmessagesentry.cpp | 204 +++++++++++++++++++++++++++++++++++ 2 files changed, 276 insertions(+) create mode 100644 src/qt/sendmessagesdialog.h create mode 100644 src/qt/sendmessagesentry.cpp diff --git a/src/qt/sendmessagesdialog.h b/src/qt/sendmessagesdialog.h new file mode 100644 index 00000000..08d30038 --- /dev/null +++ b/src/qt/sendmessagesdialog.h @@ -0,0 +1,72 @@ +#ifndef SENDMESSAGESDIALOG_H +#define SENDMESSAGESDIALOG_H + +#include +#include + +namespace Ui { + class SendMessagesDialog; +} + +class MessageModel; +class SendMessagesEntry; +class SendMessagesRecipient; + +//QT_BEGIN_NAMESPACE +//class QUrl; +//QT_END_NAMESPACE + +/** Dialog for sending messages */ +class SendMessagesDialog : public QDialog +{ + Q_OBJECT + +public: + + enum Mode { + Encrypted, + Anonymous, + }; + + enum Type { + Page, + Dialog, + }; + + explicit SendMessagesDialog(Mode mode, Type type, QWidget *parent = 0); + ~SendMessagesDialog(); + + void setModel (MessageModel *model); + void loadRow(int row); + bool checkMode(Mode mode); + bool validate (); + + /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). + */ + QWidget *setupTabChain(QWidget *prev); + + void pasteEntry(const SendMessagesRecipient &rv); + +public slots: + void done(int retval); + void clear(); + void reject(); + void accept(); + SendMessagesEntry *addEntry(); + void updateRemoveEnabled(); + +private: + Ui::SendMessagesDialog *ui; + MessageModel *model; + bool fNewRecipientAllowed; + Mode mode; + Type type; + +private slots: + void on_sendButton_clicked(); + void removeEntry(SendMessagesEntry* entry); + void on_addressBookButton_clicked(); + void on_pasteButton_clicked(); +}; + +#endif // SENDMESSAGESDIALOG_H diff --git a/src/qt/sendmessagesentry.cpp b/src/qt/sendmessagesentry.cpp new file mode 100644 index 00000000..ab0d92aa --- /dev/null +++ b/src/qt/sendmessagesentry.cpp @@ -0,0 +1,204 @@ +#include "sendmessagesentry.h" +#include "ui_sendmessagesentry.h" +#include "guiutil.h" +#include "addressbookpage.h" +#include "walletmodel.h" +#include "messagemodel.h" +#include "optionsmodel.h" +#include "addresstablemodel.h" + +#include "smessage.h" + +#include +#include + +SendMessagesEntry::SendMessagesEntry(QWidget *parent) : + QFrame(parent), + ui(new Ui::SendMessagesEntry), + model(0) +{ + ui->setupUi(this); + +#ifdef Q_OS_MAC + ui->sendToLayout->setSpacing(4); +#endif +#if QT_VERSION >= 0x040700 + /* Do not move this to the XML file, Qt before 4.7 will choke on it */ + ui->addAsLabel->setPlaceholderText(tr("Enter a label for this address to add it to your address book")); + ui->sendTo->setPlaceholderText(tr("Enter a Swipp address (e.g. CKPnZKDzaDXqEgKJ4GdUg58gXxgzA7mkny)")); + ui->publicKey->setPlaceholderText(tr("Enter the public key for the address above, it is not in the blockchain")); + ui->messageText->setErrorText(tr("You cannot send a blank message!")); +#endif + setFocusPolicy(Qt::TabFocus); + setFocusProxy(ui->sendTo); + + GUIUtil::setupAddressWidget(ui->sendTo, this); +} + +SendMessagesEntry::~SendMessagesEntry() +{ + delete ui; +} + +void SendMessagesEntry::on_pasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->sendTo->setText(QApplication::clipboard()->text()); +} + +void SendMessagesEntry::on_addressBookButton_clicked() +{ + if(!model) + return; + + AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab, this); + + dlg.setModel(model->getWalletModel()->getAddressTableModel()); + + if(dlg.exec()) + { + + ui->sendTo->setText(dlg.getReturnValue()); + + if(ui->publicKey->text() == "") + ui->publicKey->setFocus(); + else + ui->messageText->setFocus(); + } +} + +void SendMessagesEntry::on_sendTo_textChanged(const QString &address) +{ + if(!model) + return; + + QString pubkey; + QString sendTo = address; + + if(model->getAddressOrPubkey(sendTo, pubkey)) + { + + ui->publicKey->setText(pubkey); + } + else + { + ui->publicKey->show(); + ui->publicKeyLabel->show(); + } + + // Fill in label from address book, if address has an associated label + QString associatedLabel = model->getWalletModel()->getAddressTableModel()->labelForAddress(address); + + if(!associatedLabel.isEmpty()) + ui->addAsLabel->setText(associatedLabel); +} + +void SendMessagesEntry::setModel(MessageModel *model) +{ + + this->model = model; + + //clear(); +} + +void SendMessagesEntry::loadRow(int row) +{ + if(model->data(model->index(row, model->Type, QModelIndex()), Qt::DisplayRole).toString() == MessageModel::Received) + ui->sendTo->setText(model->data(model->index(row, model->FromAddress, QModelIndex()), Qt::DisplayRole).toString()); + else + ui->sendTo->setText(model->data(model->index(row, model->ToAddress, QModelIndex()), Qt::DisplayRole).toString()); +} + +void SendMessagesEntry::setRemoveEnabled(bool enabled) +{ + ui->deleteButton->setEnabled(enabled); +} + +void SendMessagesEntry::clear() +{ + ui->sendTo->clear(); + ui->addAsLabel->clear(); + ui->messageText->clear(); + ui->sendTo->setFocus(); +} + +void SendMessagesEntry::on_deleteButton_clicked() +{ + emit removeEntry(this); +} + + +bool SendMessagesEntry::validate() +{ + // Check input validity + bool retval = true; + + if(ui->messageText->toPlainText() == "") + { + ui->messageText->setValid(false); + + retval = false; + } + + if(!ui->sendTo->hasAcceptableInput() || (!model->getWalletModel()->validateAddress(ui->sendTo->text()))) + { + ui->sendTo->setValid(false); + + retval = false; + } + + if(ui->publicKey->text() == "") + { + ui->publicKey->setValid(false); + ui->publicKey->show(); + + retval = false; + } + + return retval; +} + +SendMessagesRecipient SendMessagesEntry::getValue() +{ + SendMessagesRecipient rv; + + rv.address = ui->sendTo->text(); + rv.label = ui->addAsLabel->text(); + rv.pubkey = ui->publicKey->text(); + rv.message = ui->messageText->toPlainText(); + + return rv; +} + + +QWidget *SendMessagesEntry::setupTabChain(QWidget *prev) +{ + QWidget::setTabOrder(prev, ui->sendTo); + QWidget::setTabOrder(ui->sendTo, ui->addressBookButton); + QWidget::setTabOrder(ui->addressBookButton, ui->pasteButton); + QWidget::setTabOrder(ui->pasteButton, ui->deleteButton); + QWidget::setTabOrder(ui->deleteButton, ui->addAsLabel); + QWidget::setTabOrder(ui->addAsLabel, ui->publicKey); + QWidget::setTabOrder(ui->publicKey, ui->messageText); + + return ui->messageText; + +} + +void SendMessagesEntry::setValue(const SendMessagesRecipient &value) +{ + ui->sendTo->setText(value.address); + ui->addAsLabel->setText(value.label); + ui->publicKey->setText(value.pubkey); + ui->messageText->setPlainText(value.message); +} + +bool SendMessagesEntry::isClear() +{ + return ui->sendTo->text().isEmpty(); +} + +void SendMessagesEntry::setFocus() +{ + ui->sendTo->setFocus(); +} From b3d429447ec7b3ccbc4c65070fe708259c81f022 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:38:38 -0400 Subject: [PATCH 256/469] Update sendmessagesdialog.h --- src/qt/sendmessagesdialog.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/sendmessagesdialog.h b/src/qt/sendmessagesdialog.h index 08d30038..fe48e838 100644 --- a/src/qt/sendmessagesdialog.h +++ b/src/qt/sendmessagesdialog.h @@ -47,7 +47,7 @@ class SendMessagesDialog : public QDialog void pasteEntry(const SendMessagesRecipient &rv); -public slots: +public Q_SLOTS: void done(int retval); void clear(); void reject(); @@ -62,7 +62,7 @@ public slots: Mode mode; Type type; -private slots: +private Q_SLOTS: void on_sendButton_clicked(); void removeEntry(SendMessagesEntry* entry); void on_addressBookButton_clicked(); From e124d2bd9afa3d7c32553ce84a53d7370e78b6de Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:39:10 -0400 Subject: [PATCH 257/469] Update messagepage.h --- src/qt/messagepage.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/messagepage.h b/src/qt/messagepage.h index 88e4d0df..d8553a8d 100644 --- a/src/qt/messagepage.h +++ b/src/qt/messagepage.h @@ -37,7 +37,7 @@ class MessagePage : public QWidget private: void setupTextActions(); -public slots: +public Q_SLOTS: void exportClicked(); private: @@ -54,7 +54,7 @@ public slots: MessageViewDelegate *msgdelegate; MRichTextEdit *messageTextEdit; -private slots: +private Q_SLOTS: void on_sendButton_clicked(); void on_newButton_clicked(); void on_copyFromAddressButton_clicked(); From b8c950894d99c8dd4cc7a6c54b02b686ab4fa6d9 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:39:42 -0400 Subject: [PATCH 258/469] Update messagemodel.h --- src/qt/messagemodel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/messagemodel.h b/src/qt/messagemodel.h index a246dcc4..ba5a2438 100644 --- a/src/qt/messagemodel.h +++ b/src/qt/messagemodel.h @@ -175,7 +175,7 @@ class MessageModel : public QAbstractTableModel void subscribeToCoreSignals(); void unsubscribeFromCoreSignals(); -public slots: +public Q_SLOTS: /* Check for new messages */ void newMessage(const SecMsgStored& smsg); @@ -187,7 +187,7 @@ public slots: friend class MessageTablePriv; -signals: +Q_SIGNALS: // Asynchronous error notification void error(const QString &title, const QString &message, bool modal); }; From 0e06ef3d0c70b6d3c87abec29a752f54e58cbedb Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:40:33 -0400 Subject: [PATCH 259/469] Add files via upload --- src/qt/forms/messagepage.ui | 246 +++++++++++++++++++++++++++ src/qt/forms/sendmessagesdialog.ui | 262 +++++++++++++++++++++++++++++ src/qt/forms/sendmessagesentry.ui | 184 ++++++++++++++++++++ 3 files changed, 692 insertions(+) create mode 100644 src/qt/forms/messagepage.ui create mode 100644 src/qt/forms/sendmessagesdialog.ui create mode 100644 src/qt/forms/sendmessagesentry.ui diff --git a/src/qt/forms/messagepage.ui b/src/qt/forms/messagepage.ui new file mode 100644 index 00000000..5efa66ac --- /dev/null +++ b/src/qt/forms/messagepage.ui @@ -0,0 +1,246 @@ + + + MessagePage + + + + 0 + 0 + 793 + 419 + + + + Address Book + + + + + + These are your sent and received encrypted messages. Click on an item to read it. + + + Qt::PlainText + + + true + + + + + + + Qt::CustomContextMenu + + + Click on a message to view it + + + false + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + false + + + + + + + + + + + + + 2 + + + 0 + + + 6 + + + 0 + + + 0 + + + + + + + &Back + + + + :/icons/quit:/icons/quit + + + + + + + Contact: + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + #listConversation { color: #000000; } + + + + + + + + + + + + + + 0 + 100 + + + + + + + + + + &Conversation + + + + :/icons/add:/icons/add + + + + + + + Sign a message to prove you own a Swipp address + + + &Send + + + + :/icons/send:/icons/send + + + + + + + Copy the currently selected address to the system clipboard + + + &Copy From Address + + + + :/icons/editcopy:/icons/editcopy + + + + + + + Copy the currently selected address to the system clipboard + + + Copy To &Address + + + + :/icons/editcopy:/icons/editcopy + + + + + + + Delete the currently selected address from the list + + + &Delete + + + + :/icons/remove:/icons/remove + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + MRichTextEdit + QWidget +
mrichtextedit.h
+ 1 +
+
+ + + + +
diff --git a/src/qt/forms/sendmessagesdialog.ui b/src/qt/forms/sendmessagesdialog.ui new file mode 100644 index 00000000..3f508a5b --- /dev/null +++ b/src/qt/forms/sendmessagesdialog.ui @@ -0,0 +1,262 @@ + + + SendMessagesDialog + + + + 0 + 0 + 850 + 400 + + + + Send Messages + + + #SendMessagesDialog { background-color: #383838; } + + + + 8 + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + + + color: #ffffff; + + + Address &From: + + + addressFrom + + + + + + + 1 + + + + + + + + Choose address from address book + + + + + + + :/icons/address-book:/icons/address-book + + + Alt+A + + + + + + + Paste address from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + + + + + + true + + + + + 0 + 0 + 830 + 298 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 6 + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + Send to multiple recipients at once + + + Add &Recipient + + + + :/icons/add:/icons/add + + + false + + + + + + + + 0 + 0 + + + + Remove all transaction fields + + + Clear &All + + + + :/icons/remove:/icons/remove + + + 300 + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 150 + 0 + + + + Confirm the send action + + + S&end + + + + :/icons/send:/icons/send + + + true + + + + + + + &Close + + + + :/icons/quit:/icons/quit + + + + + + + + + + QValidatedLineEdit + QLineEdit +
qvalidatedlineedit.h
+
+
+ + + + +
diff --git a/src/qt/forms/sendmessagesentry.ui b/src/qt/forms/sendmessagesentry.ui new file mode 100644 index 00000000..e4e25536 --- /dev/null +++ b/src/qt/forms/sendmessagesentry.ui @@ -0,0 +1,184 @@ + + + SendMessagesEntry + + + + 0 + 0 + 729 + 236 + + + + Form + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + 12 + + + + + 0 + + + + + The address to send the payment to (e.g. CKPnZKDzaDXqEgKJ4GdUg58gXxgzA7mkny) + + + 34 + + + + + + + Choose address from address book + + + + + + + :/icons/address-book:/icons/address-book + + + Alt+A + + + + + + + Paste address from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + Remove this recipient + + + + + + + :/icons/remove:/icons/remove + + + + + + + + + &Message: + + + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing + + + messageText + + + + + + + Send &To: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + sendTo + + + + + + + true + + + Qt::WheelFocus + + + false + + + + + + + true + + + Enter a label for this address to add it to your address book + + + + + + + &Label: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + addAsLabel + + + + + + + &Public Key: + + + publicKey + + + + + + + + + + + QValidatedLineEdit + QLineEdit +
qvalidatedlineedit.h
+
+ + QValidatedTextEdit + QPlainTextEdit +
qvalidatedtextedit.h
+
+
+ + + + +
From d968f85a9068efb8f17bd4e041ecb2483b0a4fa2 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:45:28 -0400 Subject: [PATCH 260/469] Update Makefile.qt.include --- src/Makefile.qt.include | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 49c453a9..fad0890b 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -39,6 +39,9 @@ QT_FORMS_UI = \ qt/forms/governancedialog.ui \ qt/forms/helpmessagedialog.ui \ qt/forms/intro.ui \ + qt/forms/messagepage.ui \ + qt/forms/sendmessagesdialog.ui \ + qt/forms/sendmessageentry.ui \ qt/forms/modaloverlay.ui \ qt/forms/masternodelist.ui \ qt/forms/qrdialog.ui \ @@ -76,6 +79,10 @@ QT_MOC_CPP = \ qt/moc_macnotificationhandler.cpp \ qt/moc_modaloverlay.cpp \ qt/moc_masternodelist.cpp \ + qt/moc_messagemodel.cpp \ + qt/moc_messagepage.cpp \ + qt/moc_sendmessagesdialog.cpp \ + qt/moc_sendmessagesentry.cpp \ qt/moc_notificator.cpp \ qt/moc_openuridialog.cpp \ qt/moc_optionsdialog.cpp \ @@ -150,6 +157,10 @@ BITCOIN_QT_H = \ qt/macdockiconhandler.h \ qt/macnotificationhandler.h \ qt/macos_appnap.h \ + qt/messagepage.h \ + qt/messagemodel.h \ + qt/sendmessagesdialog.h \ + qt/sendmessagesentry.h \ qt/modaloverlay.h \ qt/masternodelist.h \ qt/networkstyle.h \ @@ -504,6 +515,10 @@ BITCOIN_QT_WALLET_CPP = \ qt/governancelist.cpp \ qt/governancedialog.cpp \ qt/masternodelist.cpp \ + qt/messagemodel.cpp \ + qt/messagepage.cpp \ + qt/sendmessagesdialog.cpp \ + qt/sendmessagesentry.cpp \ qt/openuridialog.cpp \ qt/overviewpage.cpp \ qt/privatesendpage.cpp \ From ad627ed5f27ad7fad843b20bb5ab163941b501a6 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 15:57:09 -0400 Subject: [PATCH 261/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 129 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 127 insertions(+), 2 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index c05890cb..146b7cdb 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -22,6 +22,8 @@ #include "platformstyle.h" #include "rpcconsole.h" #include "utilitydialog.h" +#include "messagemodel.h" +#include "messagepage.h" #ifdef ENABLE_WALLET #include "privatesend-client.h" @@ -493,6 +495,15 @@ void BitcoinGUI::createActions() connect(governanceAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(governanceAction, SIGNAL(triggered()), this, SLOT(gotoGovernancePage())); + messageAction = new QAction(QIcon(":/icons/chat"), tr("&Messages"), this); + messageAction->setStatusTip(tr("View and Send Encrypted messages")); + messageAction->setToolTip(messageAction->statusTip()); + messageAction->setCheckable(true); + tabGroup->addAction(messageAction); + connect(messageAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(messageAction, SIGNAL(triggered()), this, SLOT(gotoMessagePage())); + + } /* privatesendAction = new QAction(QIcon(":/icons/coinmix"), tr("&Private Send"), this); @@ -726,6 +737,7 @@ void BitcoinGUI::createToolBars() toolbar->addAction(sendCoinsAction); toolbar->addAction(receiveCoinsAction); toolbar->addAction(historyAction); + toolbar->addAction(messageAction); /* toolbar->addAction(privatesendAction); */ @@ -791,7 +803,12 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel) setNumConnections(_clientModel->getNumConnections()); connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, SLOT(setNetworkActive(bool))); - + + // Receive and report messages from network/worker thread + connect(clientModel, SIGNAL(message(QString,QString,bool,unsigned int)), this, SLOT(message(QString,QString,bool,unsigned int))); + // Receive and report messages from wallet thread + connect(walletModel, SIGNAL(message(QString,QString,bool,unsigned int)), this, SLOT(message(QString,QString,bool,unsigned int))); + modalOverlay->setKnownBestHeight(_clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(_clientModel->getHeaderTipTime())); setNumBlocks(_clientModel->getNumBlocks(), _clientModel->getLastBlockDate(), _clientModel->getVerificationProgress(NULL), false); connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,double,bool))); @@ -887,7 +904,8 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled) if (!fLiteMode && settings.value("fShowMasternodesTab").toBool() && masternodeAction) { masternodeAction->setEnabled(enabled); } - governanceAction->setEnabled(enabled); + governanceAction->setEnabled(enabled); + messageAction->setEnabled(enabled); encryptWalletAction->setEnabled(enabled); backupWalletAction->setEnabled(enabled); changePassphraseAction->setEnabled(enabled); @@ -1037,6 +1055,113 @@ void BitcoinGUI::openClicked() } } +void BitcoinGUI::setMessageModel(MessageModel *messageModel) +{ + this->messageModel = messageModel; + if(messageModel) + { + // Report errors from message thread + connect(messageModel, SIGNAL(error(QString,QString,bool)), this, SLOT(error(QString,QString,bool))); + + // Put transaction list in tabs + messagePage->setModel(messageModel); + + // Balloon pop-up for new message + connect(messageModel, SIGNAL(rowsInserted(QModelIndex,int,int)), + this, SLOT(incomingMessage(QModelIndex,int,int))); + } +} + +void BitcoinGUI::message(const QString &title, const QString &message, bool modal, unsigned int style) +{ + QString strTitle = tr("HTH") + " - "; + // Default to information icon + int nMBoxIcon = QMessageBox::Information; + int nNotifyIcon = Notificator::Information; + + // Check for usage of predefined title + switch (style) { + case CClientUIInterface::MSG_ERROR: + strTitle += tr("Error"); + break; + case CClientUIInterface::MSG_WARNING: + strTitle += tr("Warning"); + break; + case CClientUIInterface::MSG_INFORMATION: + strTitle += tr("Information"); + break; + default: + strTitle += title; // Use supplied title + } + + // Check for error/warning icon + if (style & CClientUIInterface::ICON_ERROR) { + nMBoxIcon = QMessageBox::Critical; + nNotifyIcon = Notificator::Critical; + } + else if (style & CClientUIInterface::ICON_WARNING) { + nMBoxIcon = QMessageBox::Warning; + nNotifyIcon = Notificator::Warning; + } + + // Display message + if (modal) { + // Check for buttons, use OK as default, if none was supplied + QMessageBox::StandardButton buttons; + if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK))) + buttons = QMessageBox::Ok; + + QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons); + mBox.exec(); + } + else + notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message); +} + + + + +void BitcoinGUI::incomingMessage(const QModelIndex & parent, int start, int end) +{ + if(!messageModel) + return; + + MessageModel *mm = messageModel; + + if (mm->index(start, MessageModel::TypeInt, parent).data().toInt() == MessageTableEntry::Received) + { + QString sent_datetime = mm->index(start, MessageModel::ReceivedDateTime, parent).data().toString(); + QString from_address = mm->index(start, MessageModel::FromAddress, parent).data().toString(); + QString to_address = mm->index(start, MessageModel::ToAddress, parent).data().toString(); + QString message = mm->index(start, MessageModel::Message, parent).data().toString(); + QTextDocument html; + html.setHtml(message); + QString messageText(html.toPlainText()); + notificator->notify(Notificator::Information, + tr("Incoming Message"), + tr("Date: %1\n" + "From Address: %2\n" + "To Address: %3\n" + "Message: %4\n") + .arg(sent_datetime) + .arg(from_address) + .arg(to_address) + .arg(messageText)); + }; +} + + + +void BitcoinGUI::gotoMessagePage() +{ + messageAction->setChecked(true); + centralStackedWidget->setCurrentWidget(messagePage); + + exportAction->setEnabled(true); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); + connect(exportAction, SIGNAL(triggered()), messagePage, SLOT(exportClicked())); +} + void BitcoinGUI::openDonate() { openExternalURL("https://helpthehomelessworldwide.org/donate"); From 4a228f1bdbeab4d12fa1f86cd5fa6b4445131d9b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:00:54 -0400 Subject: [PATCH 262/469] Update bitcoingui.h --- src/qt/bitcoingui.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index a70473f9..2c746a67 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -38,6 +38,8 @@ class HelpMessageDialog; class ModalOverlay; class QNetworkAccessManager; class QNetworkRequest; +class MessagePage; +class MessageModel; class CWallet; @@ -68,6 +70,7 @@ class BitcoinGUI : public QMainWindow The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic. */ void setClientModel(ClientModel *clientModel); + void setMessageModel(MessageModel *messageModel); #ifdef ENABLE_WALLET /** Set the wallet model. @@ -91,7 +94,7 @@ class BitcoinGUI : public QMainWindow private: ClientModel *clientModel; WalletFrame *walletFrame; - + MessageModel *messageModel; UnitDisplayStatusBarControl *unitDisplayControl; QLabel *labelWalletEncryptionIcon; QLabel *labelWalletHDStatusIcon; @@ -100,12 +103,14 @@ class BitcoinGUI : public QMainWindow QLabel *progressBarLabel; QProgressBar *progressBar; QProgressDialog *progressDialog; + MessagePage *messagePage; QMenuBar *appMenuBar; QAction *chatAction; QAction* externalDonate; QAction *governanceAction; /* QAction* privatesendAction; */ + QAction *messageAction; QAction *overviewAction; QAction *historyAction; QAction *masternodeAction; @@ -230,6 +235,8 @@ public Q_SLOTS: private Q_SLOTS: #ifdef ENABLE_WALLET + + void gotoMessagePage(); /** Switch to masternode page */ void gotoGovernancePage(); /** Switch to private send page */ @@ -249,6 +256,7 @@ private Q_SLOTS: void gotoSignMessageTab(QString addr = ""); /** Show Sign/Verify Message dialog and switch to verify message tab */ void gotoVerifyMessageTab(QString addr = ""); + void incomingMessage(const QModelIndex & parent, int start, int end); /** Show open dialog */ void openClicked(); From 2fec626b6ba5706e7644005de4ca744aa8cf22b0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:01:44 -0400 Subject: [PATCH 263/469] Add files via upload From b682e8010709c95bf43b8d2b8abdd4f02be0737a Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:02:46 -0400 Subject: [PATCH 264/469] Update Makefile.qt.include --- src/Makefile.qt.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index fad0890b..47f2d007 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -41,7 +41,7 @@ QT_FORMS_UI = \ qt/forms/intro.ui \ qt/forms/messagepage.ui \ qt/forms/sendmessagesdialog.ui \ - qt/forms/sendmessageentry.ui \ + qt/forms/sendmessagesentry.ui \ qt/forms/modaloverlay.ui \ qt/forms/masternodelist.ui \ qt/forms/qrdialog.ui \ From 4ecf45d4b460ca07bd1b1338b448ed0cd1d20f93 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:05:09 -0400 Subject: [PATCH 265/469] Add files via upload --- .../mrichtexteditor/LGPL_EXCEPTION.txt | 23 + src/qt/plugins/mrichtexteditor/LICENSE.LGPL | 505 ++++++++++++++++ src/qt/plugins/mrichtexteditor/README.md | 11 + src/qt/plugins/mrichtexteditor/example.png | Bin 0 -> 32169 bytes .../plugins/mrichtexteditor/mrichtextedit.cpp | 468 +++++++++++++++ .../plugins/mrichtexteditor/mrichtextedit.h | 92 +++ .../plugins/mrichtexteditor/mrichtextedit.ui | 538 ++++++++++++++++++ src/qt/plugins/rangeslider/rangeslider.cpp | 312 ++++++++++ src/qt/plugins/rangeslider/rangeslider.h | 68 +++ 9 files changed, 2017 insertions(+) create mode 100644 src/qt/plugins/mrichtexteditor/LGPL_EXCEPTION.txt create mode 100644 src/qt/plugins/mrichtexteditor/LICENSE.LGPL create mode 100644 src/qt/plugins/mrichtexteditor/README.md create mode 100644 src/qt/plugins/mrichtexteditor/example.png create mode 100644 src/qt/plugins/mrichtexteditor/mrichtextedit.cpp create mode 100644 src/qt/plugins/mrichtexteditor/mrichtextedit.h create mode 100644 src/qt/plugins/mrichtexteditor/mrichtextedit.ui create mode 100644 src/qt/plugins/rangeslider/rangeslider.cpp create mode 100644 src/qt/plugins/rangeslider/rangeslider.h diff --git a/src/qt/plugins/mrichtexteditor/LGPL_EXCEPTION.txt b/src/qt/plugins/mrichtexteditor/LGPL_EXCEPTION.txt new file mode 100644 index 00000000..e4e581a9 --- /dev/null +++ b/src/qt/plugins/mrichtexteditor/LGPL_EXCEPTION.txt @@ -0,0 +1,23 @@ +Digia Qt LGPL Exception version 1.1 + +As an additional permission to the GNU Lesser General Public License version +2.1, the object code form of a "work that uses the Library" may incorporate +material from a header file that is part of the Library. You may distribute +such object code under terms of your choice, provided that: + (i) the header files of the Library have not been modified; and + (ii) the incorporated material is limited to numerical parameters, data + structure layouts, accessors, macros, inline functions and + templates; and + (iii) you comply with the terms of Section 6 of the GNU Lesser General + Public License version 2.1. + +Moreover, you may apply this exception to a modified version of the Library, +provided that such modification does not involve copying material from the +Library into the modified Library's header files unless such material is +limited to (i) numerical parameters; (ii) data structure layouts; +(iii) accessors; and (iv) small macros, templates and inline functions of +five lines or less in length. + +Furthermore, you are not required to apply this additional permission to a +modified version of the Library. + diff --git a/src/qt/plugins/mrichtexteditor/LICENSE.LGPL b/src/qt/plugins/mrichtexteditor/LICENSE.LGPL new file mode 100644 index 00000000..3e12d084 --- /dev/null +++ b/src/qt/plugins/mrichtexteditor/LICENSE.LGPL @@ -0,0 +1,505 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + + diff --git a/src/qt/plugins/mrichtexteditor/README.md b/src/qt/plugins/mrichtexteditor/README.md new file mode 100644 index 00000000..f76d7e39 --- /dev/null +++ b/src/qt/plugins/mrichtexteditor/README.md @@ -0,0 +1,11 @@ +# MRichTextEdit + +A simple Qt rich-text editor widget, easy to use in any Qt project. + +![Screenshot](https://github.com/Anchakor/MRichTextEditor/raw/master/example.png) + +The icons used are standard icons from theme as defined by [freedesktop.org Icon Naming Specification](http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html) (which lacks button/ordered list icons). + +The editor automatically converts plain text http(s) links and emails to html links in toHtml(). + +Courtesy of [Hobrasoft](http://www.hobrasoft.cz/). diff --git a/src/qt/plugins/mrichtexteditor/example.png b/src/qt/plugins/mrichtexteditor/example.png new file mode 100644 index 0000000000000000000000000000000000000000..2bc545a4c8557ae307d039e41676ce872ddbe4dc GIT binary patch literal 32169 zcmce-Wn5J6*FK7(h=53UDF#=XP{MZ0a;M)b zi<=4+pY?aSdqRX6QQb_#^EL=o<-b&R;o!!7jF5^W613*xk&ux2BBS=95?S`Z;k#fN z;`X+3UFg8>{0#HM@AKP>j;6V(WM2FE!RFNTxll<7397%n_(bp$S?%wqcGXAdYNJHI zt+_#A18X8K$i!b78ylr8n6OYWP>@%r$UH?t=#Yy)+Nsybr-&zKB`26RB6+Zkp!!~) zwYcr2SdCaMwEDg}9vmL#Iiu{YwmSB~P_Tf6EiNuf5h$yuJf61e;|hH%#>vv<5$ zzb>8RPO<~RQdr(zzw_~8;fqe4r_H6Jp`l@8J0Pyk2*;&gUt61Nbd97@sI!{`fk4sZ zf>QLI9f8lz_vc8Vj>}Bhy31_QE1G3`m)8evq;H(d=f{M-T%?IWe6nq6j;GcZu1oPW z5nu1;zCn1;8T*;a%qCmSVReS~_Sw9WpZoiZz6@yYek=XA`$!|49UUEWP40*-7j12A z4P2M)-&W&4W#Di)7w7I+4iufO`JJ0aK8$}6BEP*NQWc3Fa>5tA!gp6EU^1MR$WIn6 zl@r@XTP?W0d=V(NI7_ZS?i$rO-Oe5&t(BQ|cAFQoH&v+csV?7HCZ6lqz|+ssb$zcO zBCYLbZZe-;1*g*P7WYef);ci4fFw$)P^}-&sSI}nK19pCmZnqcS@oG5n3CnL@H|SA zxIR@eP8l%w474N}7>II?^tOvYylk#Y;crHWY$@=oOEX?YTUAw#J~JYs{}O#;>xCBt zIA07e3QaChw+>cu+*!9JI_>~hrjpOp4eM7FtTFtmXB=H+XaCOrBTtvq^AGJ^0~5uN zPUPX?VXf^90U@EKx%rg(s}_TWQeEB_gEser`Po^$>gw3oSVu=k{U$dBMa5dVOjlRe zglql_pH_o%_bj*0AAIQ{gC>q?*r0B>il?=rv2s91mL+@A+d>+n3npq2J5=gYsj@Mj zc$Ycj%-}vWQhxvaO=a;PQ_OifrHqAG_~B|K$Y-E~T2*Pc%S$9t+Ng3C8S$uEV%0Sx zA`5n+lrGG0x&x7;R*S(>jwu`jg`k_wub}5F{%W3SQ#^4NCEqd=@Aqd8 zlwU78HIPN`g?gd=L0_hWs(LOdvY5xbKOPcXga{Gt%c&B7wGzR=7$Q~`cHJJV*nEM3 za&HsjUEM#Cr;xhT8LFwF;nXlYI4HkeEI-n}<`fLVCMUOLCvw}L)mBq86M_TtTd11v zwl}Sw{h`%0cQKt^` zU@pHdCR21IJb!Har%LjpO7TwZJwE1_F9Qt9nV8y?vVDs4S?`>~JB%u(mLQ& zL~G}Rt+*O2N^~$oIP~=A$S9sGC>lrgJtIrZp9EKKD{(c%jlFJg-T&=)QV@&1RBGmQ znJ(!5lH#r< zL}Q>*V~88*bw{W(DU7(GE}9S#QU|>X)F_thjU{9un#`~jI7{JaWs3&mS=%Z)>YJ&( zPAztFcXl&pY^+5$e#_CK*t9*Ac-NZ3)S?-+WroR15VP^S?H(&#u^evAMN%r2Gxm`S zEm(yadxZ}+G<5o>8zZVGT9;j(u38Q;tl#8%jD5x3`?H~;fdnF({UMB2g+9Z1X98O& zLserUeFtGTNlTwP^ymD1ga5c*QI9Szz(LK>knQA@ck_jUU3=GRsBuz${zlMq+yrLr zDwnNsOZ&;w^K-)%uT#KI+iuTvgGSo}kTuHiqaxbqE~ILlH~*U)eM zZcO&xGIT-$9S=Gntiou^rWtb**Nn$-C%2lQMZdw04&Gk`!q`;)W{Vq^W_OPRA~ z)k($0JN-%`1gJu(){Rd#@}8DLxSr=oVJHcE+c^&l2X?SKT|`C_49-*>?a;HrPhx+B z<3fYZ^%7nEEG}ERmW0O+GfrbjXd2@;oJ3%^cG;Z1sa@>y40s{I!I#(9y88*eBO`#{ zMn=IH-Eu(*T)J}AahFw5RlU8rnVp?=5zrsW5PpHuIU;($ySmEdygmr*sfccqbj8HD zxML`#|0v$KLpdT0lqsEoZ?tmqyc-7f4jpb8IxJWAyfS)h28Ct%v=m0{R3@qDcI>Y; zm-(Ve`@0Kny#qTM{%*M`>)YM`&bVbd=w{AK4iY$maC)@nt2CZ`liqiv=AP+lSKyOYc(hFC1fxwQOv550^UA)6>}uTbpfX zc;aOxOO~(H|BDwA7g_iSs$8w|#!PcJq+Hb3DD61_PnHX{Npwwhm zH9Ao`IU2=qYY6DbVdpurc;v5Q=xOvvVSkq6mLr$ugri5_2;2B5u3*wP1D?9azNpaL z#-c`W-LOunqQb75a-kX{L`BlQ9HU#wF6Y3cUkaSN(IDVI;6-O2h*!K}AKy*RNkc zeL||L`_yYzwLjOCn2<1jqC-ML0?hcz>gsPG4uph+PzZYgD@zfBXmH*L2| zTU|8^Md$!l3hWmmj4sD?MP8dpc2&aAXv7b=HHKGU$ER08vuXTmkXE)4{dWmkIa8aT z5TB2lb)R|?s{fAv9)5MU*JsB50>w92tuTT2X${S6qZ~H6_1^lX!q_*$L`6rRtMVq1 ziRM)fJ6)sqwVj_|wmwLpiH}oT&oS_4ef@`W#1aZ}2>X{l7gxuGfz=@{Mq{F$jbmsO zsry03+%~zWpAR&eJds70E^&a6S&Q9vy2jA&(j17yZgbrp8|m&qbWDhi?btZZS4>Yy zNwK!a{0(?6a{vwJNso_@Pm~+l-%MAULTTj^u-Lq#qM}}4VE7yl@jmY;_%93mbNt6J z1JXV%`#Pr2OxQu&>q5G#Ev4yn@0dns0KVlqyrjDjom6R-wl5dNhzh0UYK z`?pRT)Rc2K*A9}#jpmPe5=pV98Q(TGX?SPbR?y^6PFZBk&(A-4^k{FUj*XSI6~Gg4 zT^2t-zp=3~0Btw;-;4NK9W1o@UmP08%ifbv0=@QtxL*0&P8(lB{m@hPHej)yi26<#D*jks; zXNJ}+#7~B~RL-6(PX>h72EF}0cW7)!cX#p~Q)!ZXUft+SC#(rbp2`}lel&w}RYWT| zcv7J&!NI|KY5c0n%7yUB^Au*XCB@<9U(G_vYDEa#42JdP?dA1#6GX}j1^LY4#6C03 zSqc&kldfq9IGiwgZ?bYFlC70}c>{&gOl478k@P!!wVD5fboA{&p}uga?3ToNXwo0P0s&D;PT*=yMwTvOU~8zXiD`x!rndnsdrHD zb4<*$v$Nr$ApkX4D=K0hd0#CFf3CIlKHY}5`d<6r-<|`u9WT5B z9XrdrN%>9ck4jqJ|4do7&ec#JaWvIbQ~St4UphQWrD>%F!Co@% zN-sEkCpNvH`8$bl>GhbQsK?}v7PC@-kkEt^^_ z*t0>Pg<>ge$ik5??Tmby5RZTtsuOuc-xL}Ot#@1@VAeY9qtBd-4~&T!c`14`+Dlml zY@eve$jF$OMA=-?+Y=bPSTnUYMWs-U3QJ8xgCqv^$zxcl2Tg46$@inu@;p*Q25W1t ze?#ci*^cd5bV5JcHraL&y960 z)f+RMxr$wA3I`&>zPCOKaq4Pn)7KLO0uqvL4z8{(X&Fa9*V8xVz?F@pi5H7&YY@9r z*@0m!0s<0VPnGxYDRG3U!diZ+NRh?w5&Ol_|_VeKR zqxY*NZDq$fg5M!t0mS>#;Fb;;4A$3ISW&?)D!MRePA$biPoIBsasqgw>C?mN)Kpz9 zEh212W}wxu%@1H&xQH;wFgNB~yn%p0trzv{7bs;WEqo2v(o#iq&?S*|XsBUY8lh7o zzyb>EHi@C&B}{qYduwY0p7 zBqj=Z`V^&dYOtzmJS61V9c^HTk@KVtrY?=@>bekNH)Fbx^tqjG4_Tc)VV&!_JWriuO79f6;~ zMo?9}@9F8eGf~>fULqYsVc&ezlg96y;zoPl6Gh6_eE93`_Bu*B1e4sl5qYqtq_I)J z&~V|~HyjgUxP=0XFi~+|ZDfoQ)u3O!RB=|BC;El?e6LM6x1ut z@YC?C7BjY&x2Bo~O;8YsG`d!$P*z4*(7Nler#OV2iW62zNG1)vJBsby5vXmvKOjFo zB(NK9oG0%B`4cL03l@h>z-VY<3-a=M;BfBOuV3@>CK5rT@bK^ev=saPdupoOLjR?Y zUz6J&z)FR2Zv#i${hc5?`_~~0LIMIDC46EGlw|q!-QBdfI8{UYYx-*-VgfEqrq}4o zMDMYvsHn-8T5zdkKAhylYxb~L2R*J&D9#C`lO2O2?0hvkf;bq(SeN{P1o) zz8EEN-oqZ9dKL;z9av&eXKavz>EZF=9togv{BBPXb+$7a+S7$l{ z4**m=kJqu4NRubhOY*qzK?!@N6Y>Uj^Y`;Uh!fP9jX|@w3gn6D-6GuEje?T*8MsGV ztH~v60v%TQ&`Q)*yIFUFq9$@_22oDwO=4FVL57X9AH zv9smKWYhgSNI}mC!hJR=iDkwQgzCtzmn)mAQQXq}#8H)w6lU0%mVrfhJy70+1%fS` zZV|e?5q{;j{heIU{Z$aoa*1L6;#z}DU!OXh=H<)tu~*U-8?#`XJ+APrMZT+7s)y3+ zfxM9pQz1r_>R&$)ujW{j|3J5A*&LnPDF6MLiND5RO+`nCgn(e8(G`pmh)qPKrK+k5 zY`)P^s@V5H77BnVZSCY19JJtHK%iV-U!QMs2hgY+u$SxWFS^2UQL|a~8#hm{iZ#ng zFi?Oi0rCylzXAqw7QnIIskzIhSMLC@l8o^Y^}1#a{D~7fk&1yUUY-6i*w|nec@*ct zBo29$xDF#DB4nszpqNrUU-Zc{$-d;{63BS$BZ(dWwkTCcc#Y|rcdGTlIvr3f1VXIORONgOb#jCX1X z4JDs(tk<(sS6AZ`scDuMdtX#L& z#&ZvX$dgZ|A&872;~y{9WUC@m%n%A+xfsut^Y!%|7#ILhs~nlA&&6TL3sOBjz0FEB4^ZabA!sg zQp!?;2EB4brlL&L?r4C882vXzg~*s|o3(temOH)aO!DcvYI*0|^&v@g!i(!m9(6)!#Xhst5)nkcMs;a6IaM^q(^j4wyjYK(O$3=h)T3uaDj3M>z z-KXN>Vr0q5*)%zN+!jSk_RS;da|l(?H>Grdbj3j7aogn!!m8}(u7nVT)EXFgZk(Il zYvW#TomPSCs_q+T5e|Uoj$6sU4^UcoZz`*rDdy?@PI?Bzk-u&aokMjk9 z2)u3I#aVeq1_iLF=bu#>IsY)`pagR|LRP&BpMofwXU`azne`f+Xvu{?LZ(>&tDC9{ zzPJL)5vqvayG~VRW>X?!Ltk4|o=#nA!~&qsgqIV+0_Fye3tPzi)@w~8w0yKF8fd-3=Z;N>3&yrYRFqC6}tFHd~`8kCLI z$sX`7>jMKbFKo19eO+(*QfM|xZdZ?k2;-G>)azz~bVa#lQ-VrzJ+K&RW$qLqti_XT z{ZBVr1W84BAQA1FI$5-8@mDH;LrQo1m=~h-3-z&mv4nhfAe58q1E@|Nm>vri*nc$B zHB7|}ZE@-PhN?L*t6Om$Amv|jxE23ZqoZ#yVVi0YSzHX(*Vnh3&?nZyy_1HV}b0-Ci0ER%`?GF$1-9+NcC&uxVWh3?sn&KWmdNldxN4LFj1|cp<2wX?i;a92R?sD1@hhkSwld( zkK}7As`mNH5iT)X1>1Z@Wq^hE!rz-1nqmL>IEwN$OI-%hl2ZdSL8?WDXM-nGVtH*! zPhVeOnXf)jWyA!y((5g#Tr#u9`YCB>425?Z`Icu^QBlOe8c;UE=u~4=S5}Ta+QJV8 zIiBz915gQIqu7Z6CZGJe(rIUcrD~{wFB;~PJPAP)nXc}+@Y2gbw9_866$Ct zbz;B8!{@O;{0xA9RrhQ0@m3UA_Ied92;v*(qEcs()9xRaA@3b?@kR?VzI!+{5;$h( z=EOlDoiN|^we`7Hb3p;t7-&udm#_5O0ir0vd=-ZLwq6Dw3wnZH#VP)F)S?!iD(}o zt*0k!LMoYPEFO8-_P;tfn{Ufa>k11bNP(81@6MelRtcicZqG594Q# z860vCAp_@T4RoXo&nJ(?+}zweJT5r3n{IA=0^Yrwz4ECAPZJFZ<#NGpP>&UJnh8K` zi$jngu?GGS(O%eg)}=?p!z18D>aQXh7#KXJAwW$CxRIaVUG?;B6vXeJ>+{f$O$Q!D zhJ_)q@O{xKrJMh3AJk!#)GY}%qYo8ImxN2{H-=;_);{8t0Bzu zXbRXEo<1~vBKYjQCD{=*w{C#GR5iLVj`8;oM|Yo`N}^&%4~Uls1EkpeEYj7ZhZ9-J z1;u3_7~@?uWa{;Rc`qiph@~kgZ$LcM=8=#_XR%o2)YQHYeFs1?hv4IbC6tHe#UnA8 zxfm)?{!U`)Yu7=4XhVu2g+3-}*NL3loovPb{{?pBoD8yTU zf};+6MiYdA(wSd8@jW4)I_Ps?pa%1GScef+&~WZ;gQY(W=;OP#*5mbIy0UR=h)LyZ zCVKiemoBc5UM}$!x41+?RtjP3)vq1MKwWZRfGIjtzQ5V8v%A~8|7ZAIlj~Z=RJ=Mo zUv*e-xE|zoc}N)A%5L_xE-_Jyron~(wyRH-q;$d}O2B=a&+IVku!3DvlQ3RKUrp@> zdf8T{*McJTcczu<5LK4`ChtD^&+wEIWAvN^6=wQh;)6a)frOT-W*dDi7Xkt$`hj3W zQf^W`1$;vSU}mB+C*0b!$+iM3z$=)ag3#3}@rB$ZqSIJZ?}yNwd#D z?H&LF-;b;uo$ZS{tgM%MRZdP#d2W8~!0m}zI!fz_B5&EtH)NKxfi<4?bMG)RG8+0A zJM6B?pk_BzTL834sZMok^AD4*itIQ##doMtB>caM5aR$@ySHITkof({v!_G;p0(vM zN=>!4p)Y)?X-}E8$)BAZ$kj8)$E&yP&#QjW0!WULB!UItqTZ~4h6c}jz2+xU$PXil z63bQLcQb}HmrF9n`(57>L`el=rH}~n+x5Q=`VgpgHMD*Z-yizT_quZe2>4;v)&R~I z7w-)JsS3~_+(fEp`%28r%s}ORgYD+{&}cc}^DhuY$9LU^#Ib8(1aY-?jX66qq+Sef z@bvUPr=-F>+k>V4pkc$Hknp*;^?AXWFwy#s;(3<$}6Ba-{Ab zm-g+rM}U4T2ZFNMDFz4Fs6-0j)?`o)49?+KiAek+F6^MAhI2di6>pC(O)vYAk{p(OO@S?mzP^r1xJ7{=PZ-GYua0m;eS!OWM z;7&;m;wk ziAMilwF|v6kP}NqACXtzD;-!VX__uHwVJ%Ml$m*W`sixKyQeGx0telnQ&@(p+TP(m zw7v@obPpTUcuJ=GdelKDK8U>H=7#LYlGNcUA!&}h_349owjb{R^>4edQMG2CiujBmF5bC}YXDh8AN|!3pc}Uc+onstr-_uQC6d_Mg2a)mN zs}U*b69!>LSMD?u4$K)ypf%f|{MXz$r z@6C3orUGxuyfp2NwrNqRbDd)Z4iGhIAM#qG4eMYEPTxwHRiCD?))C>GKY=EhbdV)` ze+gLnRX($&oEgSEVNp^<_%O1JNC-i&Gu!<*FX$M`H^2tJV&)i*EZu*}<;Q+|weWq4 zv%X{54K+n|M6#m z{{<@}k%(peTUt5YaAGxz({StjTCU?$99xrZ3HkK*RMX7PlvWKmS#A*~;0Pj=e)ySl^nW+8v^1Z5crC*Jk7M-@EVPr8oA@N_m9yRJzb4D6Xov$n5jXTCg-1@p8BV zWPAHEzhXa_sLXVtf7&oqwMpe1b5wK}Qp#dV^wZ#n zy@Jx4^c+$l100RA8a1|u2^V5BKvy+9HzMg#=j+K$W|PxZ^f3Ytd?|h$Gh8L?8G%tf zqS#+-Z6Iypc3!5#Sw zjczdYqx_o)mtCZlX952n;Bw*AisD|n6oozOYmElXcV|9=xd`% zi0pI}Q8itmyPTk2ZNCPMi^gKEr_`&A!m2yRq8sw#Uso`d|Vb79VorY*s3 zU84~OR}7;2>n@`xxlrxr~N**60Z zT)H+f6X-MwzOgr{9|rmumj9lY{VD6XGb%OV7Qe8n(QL-@%Favu!p(B>0>?6ERsp*L9?#oqI?qZjfDl=ii< zQ6o6fdA<5Ry}O*FuRqBGPWuyq++E9q@QMuTNG6R+e4pY=dk3gM3!%27jnAIawnSw7 z)?F{LvwoB!-tza}gYQlg8hV;_=GP&)*-fQ>C@D{JWD5!Zo?Ik8(lPq=7msDFwIls? zwEw>cgNI=Ai57@#Py4d_N0LM`#b=P(!Jhq%U4Uw2>%Al=F$V5pE0+weC`B>S`BRS` zuFJHVgKA}k9#!SO26O^3dwN*kihWN0@X3Pb@u{7D6PJ1w)B=u~bi1tzuq7U9zd{TW4+uVS3d; z;28w+_wAfYAK$-Mc63ywMJA(QZO|*rELXbs^VMXz_ZYfjv$h5U+TZ|9L+uZ`n&+o^ z2i7~=K>i9yVxTePzPwDNT*yGULkH-P)VGE1BOilC*S;`4^B4R9+d@@xyYCRs33<74 ze96Y9_r-W}a*QJo3|NT}Hz$j`nIi400_>g%%zxC(Ti;Ds2A8xje*^kUhwiP`GUQTpGx^6b4N zgAO@my_dQ{ovaphJn4> zUECPr6P(~D>lhwe02Qm76SNnTFZ$l^rmLYw6dUBz3jHp_=DPJew%f#fZFUA?S+2zl z$Xzc@<}5{T>V0n}IkK~<(Sny3?WI`_8oyxSpbD+z$?uQ0rUQi}4UID(5AeKvT2{u2 z3ys+sZ-`4R-f6jRc*r_5HSHl1mX;d_yuQI$(-)TlL8JRE*RXQE%H|2?silROXfl!A zDE9;`d`EX@-6pT@9s9PO<>f!!jojBbFEPB2o?2!cUsJN=8tI07Es zF^TAgV(A?INvq5;jiwM4OS4|6-7A9ZbelW}ee9|roT&phEe(|8qjdwRE}H^TqQ@aG zjdr3UdE1S3+|O*|i%9YN^NAg8{&OC`>V|AFft&8^YD-1k`)*CVTxm%+txD?`ppSP0 z)zGdl0&dH%K_5Gs8@$hH4ca^hI_G?E>N$93+6^9|ydYz@ocKb@Ywufm1P&Ta)8>>P z!6d!aC6(QL}-s7Ri(HK)Jlprkl}Zmp%B0o5VeRDyM;djl+FF z;EexOaG!}n1|PNCco%uo+2}up7S@zH6ME3*y&ofbzALv{F=Yzvq6*T}*B8B7Y&j;p z6LHwA&?qJ+<+Pqpn<8zS+TB^{w5WcDxp@y1u7GWvLnFxS;fc8fVK%6z0$5^zQYOX- zp_psz`9gLyFg!=;duXtJnhKt<{Q&-LDh(Y>=XM5av84$G9~gkS@dUC6L%){i)T_I@ z%{E)t35XQhov{{O1HXVu*49=LbvPWA+K`fxV#Mk&>yh^vd4*m)HSBD1Ea%3@S46v# z#CY;^;>Kv5wKXykE@zc(Di3MvjSg#K3?*;R+y7UJCSClH9~&twnWL3Yif>$(GL=NG zM%VviR#R%IlJ4v#)s-Yu`MWCh=24qFvt`sAg7lWdCB&8^x%l|_;2Ir)soqS9~*Zt@y8|RK0Ou5FMuba;-Z*r*)oRmclTR9cEF1?Jc=+HYOrF&N8i7{ozXvWhb5 z40wHSEWbz(RwVBp#^xljMj}Hv0Rhi;$u3!xMzI>>OG;rNsrar>lJ!w6^$R8MdVf4P zUsVN2o&moG&?(_>IE8Oz#|vSANF-M!oiBd2R$=FvotXM*%#1%!V*>bX$?k5V5bVo~ z>uZ3<2UPkHo!gOaxdq!x$D7G9e*W{9u8D3aG`~nkqE{P;4r_>1=i@&$F_`;!)B7{|=g2vw4^#Q6Rb7>|{gdDA z*{)IvLHH_K_Z@O5^YJXi-B7`{6wqfX%Di~-f*SK|3(j=ZZf{a4!JM!w>d{-o9%bd8 z5=M&yP+6%f;c&*U;g+h@cymijix$QItn?6xvJoPy(sf1&VAeVFX?=hw_W~@MDq#K= zAbk^}qSZyCkP&eyCLawz&=8g)=k`H!D|whuDVPP&B)(S@_bDqQ@ceVxquK?!4J3VH zV6dZ6&gIA5VoH-B^x=n8ju@)U>lZ!cWIU;jC!vy&6a+1o*DNd0=nQtd5IhG3bMsyXNxMFpj{eobJQ#*b(=yX zd5yCja3k^MKYvROP3D>uY?U(+s#njf@+^sXHjNPz>bUp2NzqmX{SY!Vt(ZI;va~VK>;2RyH+V|P)2%O$%UD^ZLfgaQa1$L=@2+LI4zGq%gLEBs zhRIis!VWc_2ER-YsH$=X{;^~1OgF%OU9#PKA62EM&M=j?$Z!=8;XHTms^^h%E7h)A z%*tB6pQXd-Y;@a7^AQOCdVDs=>!^~i=XNYTAwN-JttHL5%|dALuCe_Jf@huA>>z&SZz z&CxOB_kZ~{1%OVb4u|UqT2Lq*k^hj}B8IK32njzN`A{W5yk*R-J)OC+F`R+DcmOr2 z{QMZ1kS%TDH4c4Ow-=x}_VEMh?RLw(^dn=_;S;55&+Id!339jzxYpKEBja@9OB}%W z@*c_H&*2Ep%TN$U?S?8Yd3ziR3oV=GCuQ7TXGWrCC&hLGD(b;rY}9PgyPJWxxG8da+SN*sc~79fJAMWbcTzd&1e9_MMTIXG5Byn&--iLKqo0;^WAho@On~`@{1SaKVfg?8eQD#M*;W%)aN@x zU)=iaZ3A`C@6{WPF8gLe50%c4?7Q15ObV_FK$`{Nc}v(`#bA)dTe*^n;rA*|{ZPu* zgWX-5hOyoML$c74st=(9i&f*y)I`^3rdrzZG`WqWh}fPKU~@xUo6dG$Vcs=*kL(h| z+AjY%rz^T2pQXEI`pcAjzPb{bM88d?o zn(@Enrnc+1WD;3A^5~|e1%&mq2_+>7VORq3K3AQz_s(u^^A|%FRp6m-d!h~uZsT$Q z=}Aa{Pbr#=H<#1oXej5(U5EhX?cvJw!IoDv%Js?+J4*RKrQ9~(!GMLQ;$Oo^9MHa+ zZz5w&bhz7epxOEj;JFbEzaqrWNbc=awr^9RN3DY?cS0-Ds~-_La%-pARJ*@VX0TDoet9U{FB4g8c7J zCJ=Fe6ub$cGfSz|#AzDL$qo2l>GQX4*Nfz*Kq2sc&Ry|!dVl}$BXuEt4RSKPiym;~ zf?*>@3KEi0glF37!azhs#4pFR`T+AA@LBvtYGPtOMV;6V1>W})#?O2b?^dQNj=&Du z88kR~JzgI5-k#5wS4=oL?LUD4PBG$>`^w|?V@U;ty?jbG^D3=mggu#v7X}`{J9w}R zJuR7gG(r(GRirwStKIq-8wn}NBm->`Q#ms0NU)BYjs;05gyIqT9tZD&DG_P5LI?Pf zk^B?aM@U-C1(+VY1_M9>j3~MJec|OAgcV{8)+j|nwx%=k#rX~YLmvWNxXny{1pQcf zqTT}JeulNSm&V7uOo{$vf|r2GzHS2+_i-sb{bM2UBBI@Nz46_E^Or|V8RHh#eZs?M ztw6yAmg}6q!)u3Q*yOtRgW5CafqEV#tL9D|I6XeyS|~p#TB9u2zL$(^b0+&(l<;Tu z7}(s3F_~8@N^PGMGrl047}o|jm0v{}3;;jl6!V*FKT;pXGdtAkkFECM#03}8GyS$W zu`SN6)+(ug6X$jQMG94axZdfo?v=zxr>b#n<_W-D490{{ynJQ1rzZR23dDQj;L(Gf zv}ILwc(2U*v*UV-{3tjQr8{9zg-UAmSFeU~>+9=F?rqjWDcN{iD;9tP;NCVqCCl|m zlY(K(-C2{FCB7_evVO9pJ@2iobbwi{apDwjgSigG|B42?tt_k!FAtpjrQ~!7PY(LH zR3j?SD4}I5xFc}04qMWn7vc%CPML_N(d9IK_4#EgyqC@z(pXUcv!Gt0P)#v~FT;Z~ zsfA#jdid8mrvM8={o;df-W_Ze-OHsn`P`lO)gG`!Ht zEmNv?7Z-Zgn!u!44#?dh(P8gUA@+y~IDBmzBEK@FNys99y)ts&a=z3=$&8PPG^JN~ z9ZhN)>|fzR9M=aVM|{im9A{V8a*3W^e+qGP?m_Ujqv3CW1ZE_IBfW9->G67oyuj&p z>OslOp}9nTe0_?B93?Lu9ecZfx8;t8Pc170yTk4#(e^k%Ozf@EYSo&+^NSHK9~b8H z9>1}c4rs}pw80jzD%pnOnR;B|XO`yR+I>4&32*<08AgnG}nf&B2lL zO(~Njsz-u=Z>DT=2QQ$zG~|Cw@_cX3+kUy@>dK2|)oVedr9kcgR;;-ku+U`^uEjj% zKk9bj0sWOXqZ=_q@Yf3EvvD&r^4Q%Zos@)Ac}{{m08o0N4-}KzISV&zGIB?owNKn& zdOp=6a(Qxc1S0F%S zJSb4+07c6Dg2%)>P|qs5YHb3^$5&Ck8{YDANnZ3!17%CW@||w3)+uxOR@WYK&Ei2= zSJw-XxIHm@bH$b)J}l-P_^}I1{?ADFA|`A(uWI4rmp(6HUw3*&SIu&dFDZVcJll#Q zR9V!Tbn%v}oT70V*Mg6{Li>sR&(O*XN|>40V)n;`g;!)pDCV4YwD(U2pIqficIMmC-A=Qt;TjxEw*Cty>v+JW8F z*|(+BZTd9Hg~7Wz)n<4+GCZi$#bzm=x$~lSA)d~NpxR1qCodwdiu<{ysc7x6l{1+U z95QWzs%kWso_|+SfSa}{6J+T@4Xe;kPq8@n6k?H!1GFrF%vtcod8YCVfpinMwEr3^gR7BC)i_(OrF=}xF(BbTIZ2}sJ$3RzaotKB z=UmQLTsjuM@QDek52c>&GYOv26@3{Nb0XB)%W)G6qNA>+ z2ihnxO|kzn=$7mor<U_P5nE|!i*yQPoQ9WzS$Y!W0@lX`^kZ4SOz0UOlb zCMMf_3kE27Q#1Drz}cVv9oUTSf0j@*)`iio|0n)H0!`3(xt?(BcX|CQ0M-G(Lqzwo z5O|j`@ys&xY%lD;mo%MAt!%$8!CooX1!0__$Ak8D!0iJQpy(-!Uy$r|G=|wSQ;MEcg5|1sX#(|wy%z> za_QOz73nT%NokalZjc7)?(RlFLMiD6=@x0&NP`GScXvp4cYcGO^Ss|V@ALin?LYi+ z@9n<#%-m~c*1E2>uCY)dt)OGx=mgCfBxJq)juTA1`vePpebbNTwLiU)OS(=Y2I>tJ zj?_M(U(w6!x|Z z@;q(qJar}yYnoH5=|SA5EYFbq(0rSpF~3_(9Cbwb^d?Ws!&%lu)rco7a|;^kor&2J zhsZyMqtl9SL0IWn;A!^DubV2Vctn;%VkfH{jx;N)1p>(_+P6K^?g~f%A0z6!+(}j-A^<>NDNXn>CKPm)A z_AN6%4a@4;{&Yj=6fy~E!^o_DU4Ab>eNvS;Kd(QbCYU)m^DHUFWY&#Ke>}NBM@2Y3 zSvkIl)2iJi4_^Jw#2}LGgUqY1nDXDO$ae>!H6_8utv@>nez!HSvBqPcZwql3Sx#;p zq_Xz>vV&9Y1rzLxc2sWl>n&bjx0pZMiO7=QPVa_s$U&=j?f|Ud|B7pi`cBS(ajLu| zWjtHTb=vCfI~68}xG9eHSadp6bVsuV_D$}wlJ+b}BSEOjXr4Mh3VyIfE8+lBf&FB9rOF-tX z|L6Mx4^$;3l-xMR4>-`kQWz85&(HMOJxerUlTe|2OlK{p%01~0BTSZD7rZcA%hrgg z`;JoT^`agpa=45+@=>zZ4ihJ%WI7WIAM-W`JPt&9pgUjoPO%MltsZ4EAqC+4?wXI! zm;vQXrR)6*DgGLd*Y#PD;hos@()|?)Ozv-%J$f(qO-%3WEF+|;$h|0br|SW#XeYzUTR!uch43;7M9q8)Yv4{-k+4_F;DLh15GG(0Del$x71&0C4Q>*?^C^U3MAi z=-$A+dKL=5+r14jtIB!Kdg#2`nXqH@lx?^RmCfgtR5$kWA3k1?rT_N$?VIyG5&?_O1MUX|=QQ zS@7}o@wRi zMO(i*>d~6}#mu*@frppx4Q>ZmO_?pf%`cc?9Uir`DRnz3sTw&bB!BB$%T~OldNmF5 zCIMTBa&T^G7D+6}bvohSL{roc5s`{1b7yG#tT*K*lZ>>60rhTtTw_NxQ+{W*!WDRz z(o`cmqlF=#df0?MkxclG;z+rN6N#B_*Lfc_6AswWPnhf5;4|AsrnIWq-MAF0DUP3K6lW zyy~5Dl$Dj`cHKu0viMY5tWgPZEI0ipvw^ZPVLNd5(;`Z|M1F_gu5%~)yQllU3=e?4 zCnhGqAB%Q0SZdfAw)^vdaT=ePz+46CoFQEIe2wmu#1}I3@t@kFZ(&iV=$!z!R)4;W zJ2u*h9sE-`FuUHhnl7x5i(S8PXho1Es10zur`t0#U+@73g%(1oQjt|ACS`^rm?<6T zEK2pFQewu6k88{pBb)7?l+-S><*(xd8B<_wxAeb!~0C zul~PDi^Ev8BRw>rJp)G?l+%0>*J?7O{B6vVm-ljPj0_^hbNT*(6O)eWHF@Zs&%pUh zhKZPgy#DlobF?uYaodK-M@&qm&V{P@O-md$s`$yyRxK*oUBb>m#04QjVb0E{M(S_X zvME_ZGUUIs){(`;Oy^kR2WUz=pNUe0hUjg3uQU%&+s z>^@){f3p&As9A|8EGh|60zaGZ@XQjB1M3BzNUMXV->JbX=R3etZS2bId_Y5JwC+|{ z)vN}yg{`tuDJe7R3+MBg#5&`!EewRlu&pflY;zkE&Kct{)(|rkCg7lGRdS|E;(6X1{KHpu7zd2*L@zVjEYAR0NPe!0>(jhyzlOe^gYB8|;i3$+^he zvF}FQH=YI@ZZmPaQvPiFe%1Y`T*QHklC93;bzrWfr0gZgEe0Yq=G`$V4j`AA-g93Y zCBfsyD0*t@zd*T!3$>>Ev+68>!M8Arq)L_D9M7$2edx8wa6Z88ROmH>(IlH3PDK9XUGt)@vh!khkYw7s}0s*g1+6J)nv*Sf`bbQyiInffREPC1h+R*|v`5la#U z3VU5EIqc?v71j>fplax@eMwYD=i^auw>AHMhDz)hMjw9oLlA!E0@68?u<6OjK3*ts zt-)4m%pI>imG5>G1vOp-r3_x)n-Cnv_3Qobj%1rkDlW1y9D{PpQo}y?)vjy$Z?&ct zngpa~FfyaYc-w;rlH9VszFlVQEO?p=lK>@Vhj*MT!Q8cBhE;7AiZ3H=up}Ld7?Kel zOr8AMh{_hL*DMs#M2IlK9@@{Oni6@R#JF4Xw6WSonQidLB@Z9Zu(tC)=Yr#2zSOA$ zFiWDFn`LDZl60UnvuCVwm$#w1X9|`G8Yjh6$7-9+5cK!i-pP~>CN&`;70H@;aKaat z#|tyxo0F>=Y~vUn5+es4hJ2n_$3#cN7REC<4x07rUfc~vWj_ZBflyHOI6uU?_~Md1 zX{)WTP?%7GGxAM-5u1$8@bc{=f_u9UyWVHbbvPQvtQS8XzObXAad`&gbBkjHu6*#5 zHn6h%L*9tXyd%XlrKn?qX0$OX2+b=`S`w#xaA*1oM=wf|$u!<^9c@?Tw4!QJQ1JtZL5- z^d2^e!ZCLbw{Uz;gTC(7?bqKYPIMa|)G46^W~M8xyu7*3Nn*O378f(ElNXG6hK!i! zYTUNl`!p*nEA>ad*ex(pR(J4vaC=zfJ+x`)||eAI?6bW>AO*h@4Uoi4k#lJM`M zT*uq*o!bhMrZtM1;W7^mJJbT=NYp>zVUbW`3S1OYV~Sk8)DREGVlP6_`oV}$8}ez1 z&6rvTnVXv%##E5o7z#>+we?y9BoKMrHoaa+J3ZxZ`qgBiViVzU=5j{gxn(@?izUPR zCh63+qjYy?7n|^zKs5sCXsKK}+rHI`Bzv2B+N7#McwV~Njd!W_Xsi>;1d!O%@8;TuAgc7iT z?YRMTEBN_j*%5UJdD|Pd#OI@dLqgHZlV!Aa(1mHUq9TV$%vhxXkctd}$54a4_3>%E zb#MBS7Alwo_k!Awj`GqRmhPCUI~tQ*&QwTAIdgl>=vnYFV-(+nKa&M5kBxl)!;C(` zDL!u=)a7ocrgHO9Gt4!bl6c;rGa-3f$*HRg9YGg018BTa!*2JjwzjqPZYKE~zhr_; z>+UDL{avXqy^0zed0jCLW+#W#r}8#F>a})f_aX&HY#H2&kcc5lgd4UN{D3KPcfdu5 z>6TYx8%=?M5+KNvXe!OsUEn)j7xiv9uJAbD@8MP5UsAZ-p0lmx-5dK>QH>y1#NcJX z&_(MfZ*D$?+0oU1^!{Mzg`&{MF988c6G|_ra5?%hcGLRP4*2`eAo zVC!ScgRGj%j^Sbc=}UEM>tflwnR07HFIRueNQ$Hlm!8qV$c7t7uNbO5De+h=5wh>W zy%`sse4mV|^c;QD%qcp`_2af59j@i}0t1L*jy(`JHU&!zoOzb&C#q{1=3cm&Z^p^1 z@&0$k*x}*fAd*kV)_-=q^wpctb2e5PShM=>j(=p*Xo&li6oxsR>)5vT>6N(fMYZYC zhDwm0y^H?r4Wl*}HwVXq2Ex|nayn;n#|#S{86kK6_*>2EgUl`?2ghx!+atngT{UQl zEcjZd%V60FuO&Zws*zTZO4fz(Q^Ta}f|?V~kZO=6Y=r|%xt1J`Qt?j>CWMkx>IcOj zaAs|7jE8GQ@*Cu~Tu#?AOSp-;_k+vVU}I(FaX|*2XdOuU(t16m~Xx? z6@4~dqGQgU%)(r8dCq}&`F>y?^mPfQ988eVUaN)X0YmFn1aS-*5fxdRli4ZFYHw;h zDv8*{=B4bF=b?!L1FXNN99+y&0~zU2l0EgG;V$2vtABmoG}BCyEd3=D_w@(rhlLZ0 z6@&l&-5AI%%FO)W!TI@~<|+T$7n_YeSRuqDhT`994YlK24e)L5hx9_tD6x1ZW%!wxh^qtof zXC7b8nW3lWtx;1DqM`28w^dJhl7~h?CC^mCom1nfa|%Mo#7%aOPtW)FGg4670XmT@ zb?@d9@j3>@PS>>BW1_ziUgAT{t=8$)wWuhd)!g0O{hq+OI5;=DZJ#Z;?$>(kr>*L? z&yu{acioldb$SPBO80HNO>DSXiS?Zw1tnT6y`SfED_liISIbW@b?=XLTPo;bqbz;I zvV&6a_}+glowDlh?2d{RDp6@sr2cN_z2m^oaNiHA^Zv`G5Im=A)v&>WP+nb~j*rh{ zu>z-keFmOC3k0&cw?CKujPTjw&g|h@@eJS-mcJX5Y;)5@(VKqz7C%HISrFMGqL3U* z8_n5E;)4xMw{NR}pO+_=od_n*8uw4I8=0*8$)Q#tkxA%8t?nd(f!fh1icl#`W!1kK z`)G;Kzp6Py?q{$r3Kn}}&iHoTw#usYtDjeLNt30v=`zU+rTO`ZM4ZRD`I%ibu(hpT z{AP=wDLr(wH&n9kZX={hbgu1ts!&0--z}Bwrz9{XJTz%4u8}rKnoM{>8fU}T#UDP| z<{jul<)uFfSDLCvL(oNInzFpn|l^B}L=IA}t z6TGs+MiBHWL*K<@t@V1X&z*~ZkHP425R8W>Zm$B2c4QsIc|6w}(HsEY)e;sCYq<7mF8WEM{on zumwWwTG;KrQ}@RCsoG`V;o&)tGl{zA6Fv{S7LV=kUF-J(H}3|*R4Tl(g&f_9$m=>H9O}q#JDIY z63fTq|E~rsmb%g~(xA&&I0yaS*RmBguV1oozxc5r*IXM~yemZ#Ycq8w*yRg5UYU|U z-P)R(e%0QWOybor(%-*VEBJU_wCN^~zsVo1ps>)<$!Vozgpsk|f{K9!KfPw>S2LME zeX*aOr+)2M`ru@5dWPHV)bz3O@hzu1qM54BdLGQBws&}R40M1UTb!3|E z2`(~r3XZ0wIG3=9Q4nPgq!jtV+4D_lZm#y6!R=j5PjEeDStc};PhOA?X>cm;NNz>7 zudi^PYzeSpx|%ccd#vjYd_2vWb+1ch>CqI%)J8xLRhMYvw)Is9BSr<-sW#3lmqxJq zd3#Vrc-Z}8Un9OByIvr8{rJT-$jd`@J^xzkI4bSFW<|`uU-Ze&h2~i$#>Z3tJRln) zWoo+6L|rmL@5@uUZGOWD@rAZAr?vz=_aE+Y2sT@APM1{x=eR^qkVf<%D6 zDVBQAM(jr=(tH_7>@LDDAwJIW#`$8sDVY=X8>ft*X>r@JuQ0*G@L*6`ZfOfaTsGha z$$&~qIyb+DO9q-Ec|?^y8yMg+S5*yk@y-nnmKhxifo1|%iGS4@#7i8wzvFC+`I4KS zf~~Js@1Fax!1fXkHr_j z&b_^8zwz7}nZ&DX*X;DYCajz`>==owjW|s;dgdY)RT(NvBaZ#o#HoW*GsQbP`&k6n zS~phMYjT`F%XEFdU1*Z3-~iCsssQc%`NrD&Ih4CeBWC2r8hDXro6HOYb|%}#Lk*29 zc;j@w$4RdO>s`06wn%UqE3IJsz$zS`?%lApygV{E_@nWz=N{{}`xX=*v-;Z69JSSvTG%qvwW>cA}FZsN2PxVIS}W8Z-Uq4U&WgLzW#e( z|NHa5ufctPfA8PdP-TB405Vn|&0&I{2b;YDG2eT*zwT>ARICCt;X1v_;QzV-D z*E;%aVxOLlrNUD##s+GuuOH3`kV)2Xokk(TtENxo;ZC-oMc>g_q#d)MVC#jG;(fZ}C(aKe_)T(_)XhgshIFSQEXw&yl4LsrqHC$>SqY^b*23$=jIz-7w+#|105PbDfLO2`R(;td9`be zg8V_-{4G#(inSLZQ250jc^x;C3%ruoLHJ=NDt`K(_t7e*QW8@!`FKOQP0mYFC1~=Y zy<$$>ZyRbv<5hrfYo%4~4nlVj*3ZfV^mV@|?0!2~8KD2GPXQbm#R8P@PT7+CfCqMy zLqSq*#){t>TJ}rW6J5ykcp#UMr&l{p6leHEP8=a+XT4xzfr)myf@!E{gq(t-ET(W9 zNblT#_ZXP-I3KmTFK^M{^G6QL#r-cHSVP6^;eYeNV%;Q?)RF{A#)s|eqT;7ER#qqy z8FG;Fir_Mxgb>v+khUS+^kg)`c=0PA>5s(`!=6Zx40E(NDMzLQkxWHl-#1}|nU)KD z47WyNDph9ERwJY;=TpQ#lQno`( zk|Ii9>{;Xc@^^yjO_Q$}D%yr=V9-f(@pzp@#b`V0+G{2hG@MlDON?7;$~kLw$^1YZ z&1QeY;We?uZ*I`^-ILwgtLe)Z6PK0Vgf9V9d4wxz_!}&Gz?GscEO>PDLbNaOw!eP= zZMbg3OU6xs?vf_Yy^JC0bapl#t7%Y+M6+DBb5cI+2)1Gn-+UwULKfPH+o1lXczboC ze%vpXU7lj3eCK*k%x!WK6e_(3Y*OqYHqwnp6CxFap4UkOz<{WWOZjouWd{wP1_nOi zWTn*lg);$~5O`1cdsfurrS@-*}$g>U39&V!k3qRpY@9n$BEcqWcU{TRr@Wxw5 zQ|tG(g-iUI;w{5$xTGhKNLT&<4{({6$5|gAKMwywgiB0#Eh#NzaO5AtU&FyI2ak+n z%_MTHz={qY9tL=JN~)?-CWthxG*e{JvML|-wN=tZ)r_fIqqQQ9iOn;ko^Q4?hkv|5 zLP?ojpE7+7hOVy8UDB*<_48znqGSvueSA!KrqVNYN^zVWOU3d3JS7{l@^_?#(}oX^ z#~3|RS73Eq0LFoBxDh8v^%KCGJ$UDit#tUR+qO@g!v?hw(=M@ ztlc5IoQH-|`9cX`5`1TBg%C%F7ojAUwzdP-ksV<~sd1i?94()41OD<9jg8^EU@smX z1GB-!f!|6j1j1|+2|UDB4e_D-kjCqf;1C%qMV0>iv)!5fsp_Vh8o%pGpakFNWh=h{ zBeYR&@VB!m3OkX!4ZO_?#}3%s-1_sK>ra3Ip%W?l>EdJDSNsk>Ki zR+hn)87m@;Z_U=J8Y0aVK~Im{+)B3@domk-*g?2Gke&4NEqt@#{}Ms8t;s%q**AhO z5d(vjjWwt43)d@})g{Vl0$ZA-uXrlM;`Gr|LI}u|nj*tpk}r#TwkqHXk&M-%5h1UZ#ad z#P*69915vans(u|p=b6`RzIbUEX13i7zPUXZ^?DvIc^?B!=e%|xZAsWUzd7cb_{(3 z%F4sAxtdj;Klmvu;pp|MiRUz2rNbu7aJE+5AjWx6Ab#Dw)}YNV7|YlEA=ga8v`jP#Q6D_j?d5 zq$4eDzBOT8Dr}Oz#jDj-n$7k&PcPM7C)pfoB=D}yg`;y1#=`F*cQfVXnf32?n5}U; zZjErAo|@u)ZMN93k#K*qUX8W#nGzB}i6?OwMX4z+5Ao08m-=6myDKjC!Sd8KRMs{( z^)LB&xMGKm;6wgnZVjXO4Bjr(K5+WMY^i@&OVH{M9nj*6Kp`Vm3GCn$+ z7JD#comUR(kmB==p097;V~c@|TfnLkv<6&()wk(}mdZjlp?@Af?2G0^NyyULNHGOb zsq^SK-+MFW#MxOc(I%cZ@$2`E_AGXgbd|zWJJ*P$>y=sHR0ChVJTIlIC*m`waH%UW zLNerEA~NtQ+I8Ko3xVjL2{K*I5qNr%T;R;cky?h>+ZO9dU3vITZn)+H4 z4nECC3Qy|guU!M)p2xc>op7kAu6Za#WTpWuv|VaRlMFA2$kp|qNktaPtwZwsW>?Ua ziHA2Q#iJ<57_4z-#Jj}sF_Rg{@}7~CA*$!b@opzw>h%0PT)wksl{s15WNJ#oz&Po< zzh-}N?gZ3yqT3L8XXp0kfKYkotGc+HW&VYV*TZPv-w76#H}H_N%(xyL@1*TdrK24m z%>rZq9C~vS+Pm(3Pk8?Bs;hTZYGG?I(|5ImpW*i39(M>)qJi>%pe{2vP^H|ZjvfFK zuaf%KLVI_hZ?EYNUNPMI>5Hk|1RKL;HaITi=BCHy=1IzWpPpvFi6Cpq1Cpv_etQc{ zT#1RNebuHE{@A>t2w{|}hzLunjIMTeojpDLUP3!Nz`X*+p@RS%0IDo}*Vi`2oF?!t zlcwGi*Zln05Q45Ha$v;NYUuQNdVlsOEF`+$Yo};r4yrj}+@%{ci&UYr*4Y|CxW;bz z@@A+cb3By`SOdgWp0#68AfClWCi7%<3v&?>&_s*me@~sF)iM z)KS$;7=W|@+dc1UUw-yPX<;TCA?tv>xw`LHfugnynjZjbd>ivd=7*+jLwvl~l0`F{ zCObw;-t&(P{esjokpsm9>Y6y#f#I(M8#Ml)c%$r1L;U|@h=dD$mj_iF4F=@}#g!*{p!^8;2|O zql%%PZ>rqll6isDH@Pj<MYqO@t zM4udi*gTyrpj@K<)sC#kZ8No7LOK~EI>sYOk%08%_;j1Z^C-X5eyB8yaVvK5Da?i3 z*|}p`HGfP(dWu721ks$=l~YrfgOIPYq}=7GaG(U0#I%)pa?WVZY>d_Gff^yon6R8G zv|ufIc0JFW0r6g9F$sPKoLRn7?odP|v;qK?#sCa1b$|$4wLt<}YosBpV zMfHaiW2M_=-;|nkcjvDZ=regb;NsIvQA6NHgqhV4aH5Jl%xPhxoJ(`7s?OF)O3C~} z#mHA*Ogs|=c^dHnr#bVpvGd!LRMYgl-^;ZZX~G)HG4+$3V(KD$tOvqQTOgM;XhpmT zN}@R0{WQnjTS|Nx-c7A_*;r%;z02>7El{r%wE_fVE;^$uYyUsh2_ zQt`v|s8g#1r5PaMp*AMb(B(xJim7bI)DM<*iA9NiCXQ}aDEl<2>u1r;G*wt!%$6t( z&P<4Yqx1c}`ulaEBf@|8$+PjFePXCqRJG40S)>W2kGT^(^(z)#uHB z{W|x&uE^d`@7i4v-_7tv3;QOOGikz1nx;*jLo^utIR7HqRS@$DMd6{lyv^%85}99G z_$kYn^JO;&uHcnKd|$Lej037fWwNPOX7F9bg*rTHWQ8Z|yG?+&++Y2_?xwl4z*&XcK%Sfkku~ zWs>LU<*SPb?crjdZ_MAWZ%FF5Jt%B(^+YEx6in|4O&fAs zs~8&vT!-4ZUJ0E~NfA=h*=ou|A~|jnsomx2-rNp5H4A?504xS_sciUtERAV*tywTm zM3cTfJp|@(_h-_?b42Z%evxEfCn<)ZDP|~=TVfnaUu6&ocPYfLN_d#%*m$>nwu_0U{?HkZ%8ch; zs}8WRfej5e%P(Yy=k!x#;b=Yv%a9QXKx7mw6!zGjIvG-{cSCq+BH!oqb}}Lwqs5!i z+9`hE4)q;*qemYU-Noce^h!fC+MhKQn3KG$G9z@HUQF1l7>Q5FP%|(?YLpKuqBKnz&Zn0 zoRK65d3AIgq3Zem{e|n~`?D$27SrXWrHlLfqaLP*!$$^XWF`XP+)I6d6epB?9~Anm zr9c(~Vs()DiRve6fqiHB2j!XqJReGSc9ro%nR5hCYWMI0f1D>WbDf@^%G@GEX^lEL zKzMSk*|SZtV4;eli6b?j=7W>;&*tp>a3X(`4Q9)Nm0pv=RmM7I3o)9KxMQYf)k^}rYiM3GJw|Zzfc&@t!W5< z&5+u6`?;-Lz*A0)+CAptky6Vb+tEy>QF8 zHG<)Z}Std5ccAAGJB?Q&SdxHI}eN2a3_)_=z)L|6NSV z`H7Zu0dLDG1l5U-unZyJ$Mr6ogiSWWH+9H!buP&82rCimSH4YG)9KzdPBa$%JAh@n z*}vm;={39a`2(P+YAaT})7RSDWYYC^+$8W;H=$<<2$YFopHu=e|}|D<31;O#uWzUzTtqoANL$sn(SUkY&C6gtET>GV{8i`6fMFZsc2vWdgc z02kp{6D))$6mt~9!Vp4k#4|wzE!ay+Z};Wishf%W8l!{7^=hl@#j%OI_rI<~00i@v zK4&AJDi$uY^!^h0zA=6Wa50b^dNmS>Z2y0xbdYFAuSTy!=n3O2<<;5DN}%4-lHRI| z#fdaA;~>QQ`}$M5#g2hdRpe1#Bswz?{6MVYj`Nnj1IK8XW-{95`qMN=50{$3#K+wa zeE)$eN|Mh2mT}mjc?LW1pFE56>du<->_+0EMZw zGT|Sa1}vk$yD;imZMFP z-h!(Eah(!57t+VOJQ_O~;}nC0+~u%CKMA|3`do)D+6jOQ?gj9aLgK$uLwMcPxBba} zKZ2m_%~PSm106K_1fGQ7R^DA8$nx})68z=>bHU$+edGLr^q)f?NUUPqMyMG{PdZad#a+A}#u^_#I>Ec&cKD|!e9){fLf!nI7T0LWQD!;?nr=?@ zktG>DcJB!)Q#2Ho83!nB8Jh!6E;qUnxy)n@)Wd*oJMuo1gT|`rLX$DL<(XvCW z1sR`XN?>vn)k=t}f|z?Kbx2#z1b}DD&)u>J=F!#`7q`LMRKxqL=U}-T0@P#5%YGyG zcgt%Gdx9|9`+rPC>q}mA=PnA#QUulTo-D9BTf3P?hA ziPEZ5uY_A^%a!9IO5|+~nwhOsyT8@|_AxRn_sqnvtyC=lt(*H?TjNSX zVj1G#kiFgyisOav(En=m#A~gpJf{_xK-^}sq!p~t-OlpN7n@Xg_|dDA>Sd?}u_%_A zA1QKnOu!i(;OsbXaN|wuDqZ1tQR&6$w!n%Bx`a^?eKcRRn3NPhCtXXK%c&&5<)ae& zn%Lqf?OYjNChS(#l7R-Qo{HPA?G}a)XIr|8^aB8=55oVSEEJcEgBC- z-^6NQN}$JU{iCu$&i~EtAbc zM#sjc+)2oO?{^x!H$4JCMeD{F{KN1a_0Kj~>^w0%IEY3-5P}vQ7G{n7hxAF#J=9VA z5bj`&V6#jnvAm~|l)InH@Os8iEW?N4@g=+lv^B+JYtj#Ko&j)sl~4>GZ7pq&8GrO` z*M}9tBIbxUH_JjxLDch_o^}Kg^5Ss*cy0v6TV*pRAC2@Q|mp>|!rYT{_r-jBKpd=xhpqRIWC+VZEIds=Fkt z<1gQ=s$~#RmG5Yj44EOZv;?369q!aV{sf1EmkSg`GpkzhywP)@n)Xj@M}YQsY)3OL zs88TtEAy+IDoP}SyJzo9QT$>2?SjNw(D1-Za%rQ_;*7%@Xo*Sg8wW<-{IDL^EN+(% zSr)b8>jh3SW)|{3O{)#TiinnFxzH*_od0HOZY4O%Fv_om3Rob_Xap+pv___;Z-SD{ zMByyMjh6J|$|XaM;@EodjJ4U!5?-$53gQ!LethPb{7O2u@TqsO(No%bS@qQxQruz{ zkIN(DyX_@vEF2t*N{yHz4+gEK{i9%nrXWn6`{n4u39nhmu5WO#BzPlht$+GrUd3;4 z$=_ZAR>9?V*AX_%|API5l?{4?=_;;fdwMQFlQB)V;)8 zN0X-GJrB6d!NngX+FTu_Gd^g5Rwu&1dbgs6zxq!7tP{gc;NA=9;m0I@q?aHw$B=j; zW~x5>GdQU4!{6eNx$mlUrO{0WM6 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +MRichTextEdit::MRichTextEdit(QWidget *parent) : QWidget(parent) { + setupUi(this); + m_lastBlockList = 0; + f_textedit->setTabStopWidth(40); + + connect(f_textedit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), + this, SLOT(slotCurrentCharFormatChanged(QTextCharFormat))); + connect(f_textedit, SIGNAL(cursorPositionChanged()), + this, SLOT(slotCursorPositionChanged())); + + m_fontsize_h1 = 18; + m_fontsize_h2 = 16; + m_fontsize_h3 = 14; + m_fontsize_h4 = 12; + + fontChanged(f_textedit->font()); + bgColorChanged(f_textedit->textColor()); + + // paragraph formatting + + m_paragraphItems << tr("Standard") + << tr("Heading 1") + << tr("Heading 2") + << tr("Heading 3") + << tr("Heading 4") + << tr("Monospace"); + f_paragraph->addItems(m_paragraphItems); + + connect(f_paragraph, SIGNAL(activated(int)), + this, SLOT(textStyle(int))); + + // undo & redo + + f_undo->setShortcut(QKeySequence::Undo); + f_redo->setShortcut(QKeySequence::Redo); + + connect(f_textedit->document(), SIGNAL(undoAvailable(bool)), + f_undo, SLOT(setEnabled(bool))); + connect(f_textedit->document(), SIGNAL(redoAvailable(bool)), + f_redo, SLOT(setEnabled(bool))); + + f_undo->setEnabled(f_textedit->document()->isUndoAvailable()); + f_redo->setEnabled(f_textedit->document()->isRedoAvailable()); + + connect(f_undo, SIGNAL(clicked()), f_textedit, SLOT(undo())); + connect(f_redo, SIGNAL(clicked()), f_textedit, SLOT(redo())); + + // cut, copy & paste + + f_cut->setShortcut(QKeySequence::Cut); + f_copy->setShortcut(QKeySequence::Copy); + f_paste->setShortcut(QKeySequence::Paste); + + f_cut->setEnabled(false); + f_copy->setEnabled(false); + + connect(f_cut, SIGNAL(clicked()), f_textedit, SLOT(cut())); + connect(f_copy, SIGNAL(clicked()), f_textedit, SLOT(copy())); + connect(f_paste, SIGNAL(clicked()), f_textedit, SLOT(paste())); + + connect(f_textedit, SIGNAL(copyAvailable(bool)), f_cut, SLOT(setEnabled(bool))); + connect(f_textedit, SIGNAL(copyAvailable(bool)), f_copy, SLOT(setEnabled(bool))); + +#ifndef QT_NO_CLIPBOARD + connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slotClipboardDataChanged())); +#endif + + // link + + f_link->setShortcut(Qt::CTRL + Qt::Key_L); + + connect(f_link, SIGNAL(clicked(bool)), this, SLOT(textLink(bool))); + + // bold, italic & underline + + f_bold->setShortcut(Qt::CTRL + Qt::Key_B); + f_italic->setShortcut(Qt::CTRL + Qt::Key_I); + f_underline->setShortcut(Qt::CTRL + Qt::Key_U); + + connect(f_bold, SIGNAL(clicked()), this, SLOT(textBold())); + connect(f_italic, SIGNAL(clicked()), this, SLOT(textItalic())); + connect(f_underline, SIGNAL(clicked()), this, SLOT(textUnderline())); + connect(f_strikeout, SIGNAL(clicked()), this, SLOT(textStrikeout())); + + // lists + + f_list_bullet->setShortcut(Qt::CTRL + Qt::Key_Minus); + f_list_ordered->setShortcut(Qt::CTRL + Qt::Key_Equal); + + connect(f_list_bullet, SIGNAL(clicked(bool)), this, SLOT(listBullet(bool))); + connect(f_list_ordered, SIGNAL(clicked(bool)), this, SLOT(listOrdered(bool))); + + // indentation + + f_indent_dec->setShortcut(Qt::CTRL + Qt::Key_Comma); + f_indent_inc->setShortcut(Qt::CTRL + Qt::Key_Period); + + connect(f_indent_inc, SIGNAL(clicked()), this, SLOT(increaseIndentation())); + connect(f_indent_dec, SIGNAL(clicked()), this, SLOT(decreaseIndentation())); + + // font size + + QFontDatabase db; + foreach(int size, db.standardSizes()) + f_fontsize->addItem(QString::number(size)); + + connect(f_fontsize, SIGNAL(activated(QString)), + this, SLOT(textSize(QString))); + f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(QApplication::font() + .pointSize()))); + + // text background color + + QPixmap pix(16, 16); + pix.fill(QApplication::palette().background().color()); + f_bgcolor->setIcon(pix); + + connect(f_bgcolor, SIGNAL(clicked()), this, SLOT(textBgColor())); + + // images + //connect(f_image, SIGNAL(clicked()), this, SLOT(insertImage())); +} + +void MRichTextEdit::textBold() { + QTextCharFormat fmt; + fmt.setFontWeight(f_bold->isChecked() ? QFont::Bold : QFont::Normal); + mergeFormatOnWordOrSelection(fmt); +} + + +void MRichTextEdit::focusInEvent(QFocusEvent *) { + f_textedit->setFocus(Qt::TabFocusReason); +} + + +void MRichTextEdit::textUnderline() { + QTextCharFormat fmt; + fmt.setFontUnderline(f_underline->isChecked()); + mergeFormatOnWordOrSelection(fmt); +} + +void MRichTextEdit::textItalic() { + QTextCharFormat fmt; + fmt.setFontItalic(f_italic->isChecked()); + mergeFormatOnWordOrSelection(fmt); +} + +void MRichTextEdit::textStrikeout() { + QTextCharFormat fmt; + fmt.setFontStrikeOut(f_strikeout->isChecked()); + mergeFormatOnWordOrSelection(fmt); +} + +void MRichTextEdit::textSize(const QString &p) { + qreal pointSize = p.toFloat(); + if (p.toFloat() > 0) { + QTextCharFormat fmt; + fmt.setFontPointSize(pointSize); + mergeFormatOnWordOrSelection(fmt); + } +} + +void MRichTextEdit::textLink(bool checked) { + bool unlink = false; + QTextCharFormat fmt; + if (checked) { + QString url = f_textedit->currentCharFormat().anchorHref(); + bool ok; + QString newUrl = QInputDialog::getText(this, tr("Create a link"), + tr("Link URL:"), QLineEdit::Normal, + url, + &ok); + if (ok) { + fmt.setAnchor(true); + fmt.setAnchorHref(newUrl); + fmt.setForeground(QApplication::palette().color(QPalette::Link)); + fmt.setFontUnderline(true); + } else { + unlink = true; + } + } else { + unlink = true; + } + if (unlink) { + fmt.setAnchor(false); + fmt.setForeground(QApplication::palette().color(QPalette::Text)); + fmt.setFontUnderline(false); + } + mergeFormatOnWordOrSelection(fmt); +} + +void MRichTextEdit::textStyle(int index) { + QTextCursor cursor = f_textedit->textCursor(); + cursor.beginEditBlock(); + + // standard + if (!cursor.hasSelection()) { + cursor.select(QTextCursor::BlockUnderCursor); + } + QTextCharFormat fmt; + cursor.setCharFormat(fmt); + f_textedit->setCurrentCharFormat(fmt); + + if (index == ParagraphHeading1 + || index == ParagraphHeading2 + || index == ParagraphHeading3 + || index == ParagraphHeading4 ) { + if (index == ParagraphHeading1) { + fmt.setFontPointSize(m_fontsize_h1); + } + if (index == ParagraphHeading2) { + fmt.setFontPointSize(m_fontsize_h2); + } + if (index == ParagraphHeading3) { + fmt.setFontPointSize(m_fontsize_h3); + } + if (index == ParagraphHeading4) { + fmt.setFontPointSize(m_fontsize_h4); + } + if (index == ParagraphHeading2 || index == ParagraphHeading4) { + fmt.setFontItalic(true); + } + + fmt.setFontWeight(QFont::Bold); + } + if (index == ParagraphMonospace) { + fmt = cursor.charFormat(); + fmt.setFontFamily("Monospace"); + fmt.setFontStyleHint(QFont::Monospace); + fmt.setFontFixedPitch(true); + } + cursor.setCharFormat(fmt); + f_textedit->setCurrentCharFormat(fmt); + + cursor.endEditBlock(); +} + +void MRichTextEdit::textBgColor() { + QColor col = QColorDialog::getColor(f_textedit->textBackgroundColor(), this); + QTextCursor cursor = f_textedit->textCursor(); + if (!cursor.hasSelection()) { + cursor.select(QTextCursor::WordUnderCursor); + } + QTextCharFormat fmt = cursor.charFormat(); + if (col.isValid()) { + fmt.setBackground(col); + } else { + fmt.clearBackground(); + } + cursor.setCharFormat(fmt); + f_textedit->setCurrentCharFormat(fmt); + bgColorChanged(col); +} + +void MRichTextEdit::listBullet(bool checked) { + if (checked) { + f_list_ordered->setChecked(false); + } + list(checked, QTextListFormat::ListDisc); +} + +void MRichTextEdit::listOrdered(bool checked) { + if (checked) { + f_list_bullet->setChecked(false); + } + list(checked, QTextListFormat::ListDecimal); +} + +void MRichTextEdit::list(bool checked, QTextListFormat::Style style) { + QTextCursor cursor = f_textedit->textCursor(); + cursor.beginEditBlock(); + if (!checked) { + QTextBlockFormat obfmt = cursor.blockFormat(); + QTextBlockFormat bfmt; + bfmt.setIndent(obfmt.indent()); + cursor.setBlockFormat(bfmt); + } else { + QTextListFormat listFmt; + if (cursor.currentList()) { + listFmt = cursor.currentList()->format(); + } + listFmt.setStyle(style); + cursor.createList(listFmt); + } + cursor.endEditBlock(); +} + +void MRichTextEdit::mergeFormatOnWordOrSelection(const QTextCharFormat &format) { + QTextCursor cursor = f_textedit->textCursor(); + if (!cursor.hasSelection()) { + cursor.select(QTextCursor::WordUnderCursor); + } + cursor.mergeCharFormat(format); + f_textedit->mergeCurrentCharFormat(format); +} + +void MRichTextEdit::slotCursorPositionChanged() { + QTextList *l = f_textedit->textCursor().currentList(); + if (m_lastBlockList && (l == m_lastBlockList || (l != 0 && m_lastBlockList != 0 + && l->format().style() == m_lastBlockList->format().style()))) { + return; + } + m_lastBlockList = l; + if (l) { + QTextListFormat lfmt = l->format(); + if (lfmt.style() == QTextListFormat::ListDisc) { + f_list_bullet->setChecked(true); + f_list_ordered->setChecked(false); + } else if (lfmt.style() == QTextListFormat::ListDecimal) { + f_list_bullet->setChecked(false); + f_list_ordered->setChecked(true); + } else { + f_list_bullet->setChecked(false); + f_list_ordered->setChecked(false); + } + } else { + f_list_bullet->setChecked(false); + f_list_ordered->setChecked(false); + } +} + +void MRichTextEdit::fontChanged(const QFont &f) { + f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(f.pointSize()))); + f_bold->setChecked(f.bold()); + f_italic->setChecked(f.italic()); + f_underline->setChecked(f.underline()); + f_strikeout->setChecked(f.strikeOut()); + if (f.pointSize() == m_fontsize_h1) { + f_paragraph->setCurrentIndex(ParagraphHeading1); + } else if (f.pointSize() == m_fontsize_h2) { + f_paragraph->setCurrentIndex(ParagraphHeading2); + } else if (f.pointSize() == m_fontsize_h3) { + f_paragraph->setCurrentIndex(ParagraphHeading3); + } else if (f.pointSize() == m_fontsize_h4) { + f_paragraph->setCurrentIndex(ParagraphHeading4); + } else { + if (f.fixedPitch() && f.family() == "Monospace") { + f_paragraph->setCurrentIndex(ParagraphMonospace); + } else { + f_paragraph->setCurrentIndex(ParagraphStandard); + } + } + if (f_textedit->textCursor().currentList()) { + QTextListFormat lfmt = f_textedit->textCursor().currentList()->format(); + if (lfmt.style() == QTextListFormat::ListDisc) { + f_list_bullet->setChecked(true); + f_list_ordered->setChecked(false); + } else if (lfmt.style() == QTextListFormat::ListDecimal) { + f_list_bullet->setChecked(false); + f_list_ordered->setChecked(true); + } else { + f_list_bullet->setChecked(false); + f_list_ordered->setChecked(false); + } + } else { + f_list_bullet->setChecked(false); + f_list_ordered->setChecked(false); + } +} + +void MRichTextEdit::bgColorChanged(const QColor &c) { + QPixmap pix(16, 16); + if (c.isValid()) { + pix.fill(c); + } else { + pix.fill(QApplication::palette().background().color()); + } + f_bgcolor->setIcon(pix); +} + +void MRichTextEdit::slotCurrentCharFormatChanged(const QTextCharFormat &format) { + fontChanged(format.font()); + bgColorChanged((format.background().isOpaque()) ? format.background().color() : QColor()); + f_link->setChecked(format.isAnchor()); +} + +void MRichTextEdit::slotClipboardDataChanged() { +#ifndef QT_NO_CLIPBOARD + if (const QMimeData *md = QApplication::clipboard()->mimeData()) + f_paste->setEnabled(md->hasText()); +#endif +} + +QString MRichTextEdit::toHtml() const { + QString s = f_textedit->toHtml(); + // convert emails to links + s = s.replace(QRegExp("(<[^a][^>]+>(?:]+>)?|\\s)([a-zA-Z\\d]+@[a-zA-Z\\d]+\\.[a-zA-Z]+)"), "\\1\\2"); + // convert links + s = s.replace(QRegExp("(<[^a][^>]+>(?:]+>)?|\\s)((?:https?|ftp|file)://[^\\s'\"<>]+)"), "\\1\\2"); + // see also: Utils::linkify() + return s; +} + +void MRichTextEdit::increaseIndentation() { + indent(+1); +} + +void MRichTextEdit::decreaseIndentation() { + indent(-1); +} + +void MRichTextEdit::indent(int delta) { + QTextCursor cursor = f_textedit->textCursor(); + cursor.beginEditBlock(); + QTextBlockFormat bfmt = cursor.blockFormat(); + int ind = bfmt.indent(); + if (ind + delta >= 0) { + bfmt.setIndent(ind + delta); + } + cursor.setBlockFormat(bfmt); + cursor.endEditBlock(); +} + +void MRichTextEdit::setText(const QString& text) { + if (text.isEmpty()) { + setPlainText(text); + return; + } + if (text[0] == '<') { + setHtml(text); + } else { + setPlainText(text); + } +} + +void MRichTextEdit::clear() { + f_textedit->clear(); +} + + diff --git a/src/qt/plugins/mrichtexteditor/mrichtextedit.h b/src/qt/plugins/mrichtexteditor/mrichtextedit.h new file mode 100644 index 00000000..24e3fbb0 --- /dev/null +++ b/src/qt/plugins/mrichtexteditor/mrichtextedit.h @@ -0,0 +1,92 @@ +/* +** Copyright (C) 2013 Jiří Procházka (Hobrasoft) +** Contact: http://www.hobrasoft.cz/ +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file is under the terms of the GNU Lesser General Public License +** version 2.1 as published by the Free Software Foundation and appearing +** in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the +** GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +*/ + +#ifndef _MRICHTEXTEDIT_H_ +#define _MRICHTEXTEDIT_H_ + +#include +#include "ui_mrichtextedit.h" + +/** + * @Brief A simple rich-text editor + */ +class MRichTextEdit : public QWidget, protected Ui::MRichTextEdit { + Q_OBJECT + public: + MRichTextEdit(QWidget *parent = 0); + + QString toPlainText() const { return f_textedit->toPlainText(); } + QString toHtml() const; + QTextDocument *document() { return f_textedit->document(); } + QTextCursor textCursor() const { return f_textedit->textCursor(); } + void setTextCursor(const QTextCursor& cursor) { f_textedit->setTextCursor(cursor); } + + + public slots: + void setText(const QString &text); + void clear(); + + protected slots: + void setPlainText(const QString &text) { f_textedit->setPlainText(text); } + void setHtml(const QString &text) { f_textedit->setHtml(text); } + void textBold(); + void textUnderline(); + void textStrikeout(); + void textItalic(); + void textSize(const QString &p); + void textLink(bool checked); + void textStyle(int index); + void textBgColor(); + void listBullet(bool checked); + void listOrdered(bool checked); + void slotCurrentCharFormatChanged(const QTextCharFormat &format); + void slotCursorPositionChanged(); + void slotClipboardDataChanged(); + void increaseIndentation(); + void decreaseIndentation(); + + protected: + void mergeFormatOnWordOrSelection(const QTextCharFormat &format); + void fontChanged(const QFont &f); + void bgColorChanged(const QColor &c); + void list(bool checked, QTextListFormat::Style style); + void indent(int delta); + void focusInEvent(QFocusEvent *event); + + QStringList m_paragraphItems; + int m_fontsize_h1; + int m_fontsize_h2; + int m_fontsize_h3; + int m_fontsize_h4; + + enum ParagraphItems { ParagraphStandard = 0, + ParagraphHeading1, + ParagraphHeading2, + ParagraphHeading3, + ParagraphHeading4, + ParagraphMonospace }; + + QPointer m_lastBlockList; +}; + +#endif diff --git a/src/qt/plugins/mrichtexteditor/mrichtextedit.ui b/src/qt/plugins/mrichtexteditor/mrichtextedit.ui new file mode 100644 index 00000000..50c5c424 --- /dev/null +++ b/src/qt/plugins/mrichtexteditor/mrichtextedit.ui @@ -0,0 +1,538 @@ + + + MRichTextEdit + + + + 0 + 0 + 819 + 312 + + + + + + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + + + + 2 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::ClickFocus + + + Paragraph formatting + + + true + + + + + + + Qt::Vertical + + + + + + + false + + + Qt::ClickFocus + + + Undo (CTRL+Z) + + + Undo + + + + + + + + + 16 + 16 + + + + + + + + false + + + Qt::ClickFocus + + + Redo + + + Redo + + + + + + + + + 16 + 16 + + + + + + + + Qt::ClickFocus + + + Cut (CTRL+X) + + + Cut + + + + + + + + + 16 + 16 + + + + + + + + Qt::ClickFocus + + + Copy (CTRL+C) + + + Copy + + + + + + + + + 16 + 16 + + + + + + + + Qt::ClickFocus + + + Paste (CTRL+V) + + + Paste + + + + + + + + + 16 + 16 + + + + + + + + Qt::Vertical + + + + + + + Qt::ClickFocus + + + Link (CTRL+L) + + + Link + + + + + + + + + 16 + 16 + + + + true + + + + + + + Qt::Vertical + + + + + + + Qt::ClickFocus + + + Bold (CTRL+B) + + + Bold + + + + + + + + + 16 + 16 + + + + true + + + + + + + Qt::ClickFocus + + + Italic (CTRL+I) + + + Italic + + + + + + + + + 16 + 16 + + + + true + + + + + + + Qt::ClickFocus + + + Underline (CTRL+U) + + + Underline + + + + + + + + + 16 + 16 + + + + true + + + + + + + Strike Out + + + true + + + + + + + Qt::Vertical + + + + + + + Qt::ClickFocus + + + Bullet list (CTRL+-) + + + Bullet list + + + + 16 + 16 + + + + true + + + + + + + Qt::ClickFocus + + + Ordered list (CTRL+=) + + + Ordered list + + + + 16 + 16 + + + + true + + + + + + + Qt::ClickFocus + + + Decrease indentation (CTRL+,) + + + Decrease indentation + + + + + + + + + 16 + 16 + + + + + + + + Qt::ClickFocus + + + Increase indentation (CTRL+.) + + + Increase indentation + + + + + + + + + 16 + 16 + + + + + + + + Qt::Vertical + + + + + + + + 16 + 16 + + + + + 16 + 16 + + + + Qt::ClickFocus + + + Text background color + + + . + + + + 16 + 16 + + + + + + + + Qt::ClickFocus + + + Font size + + + true + + + + + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + f_paragraph + line_4 + f_undo + f_redo + f_cut + f_copy + f_paste + line + f_link + line_3 + f_italic + f_underline + line_2 + f_fontsize + line_5 + f_list_bullet + f_list_ordered + f_indent_dec + f_indent_inc + f_bold + f_bgcolor + f_strikeout + line_6 + + + + + + QTextEdit::AutoNone + + + true + + + + + + + + diff --git a/src/qt/plugins/rangeslider/rangeslider.cpp b/src/qt/plugins/rangeslider/rangeslider.cpp new file mode 100644 index 00000000..59a9819c --- /dev/null +++ b/src/qt/plugins/rangeslider/rangeslider.cpp @@ -0,0 +1,312 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Copyright (c) 2017-2018 The Swipp developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include "rangeslider.h" + +namespace +{ + const int scHandleSideLength = 15; + const int scSliderBarHeight = 5; + const int scLeftRightMargin = 1; +} + +RangeSlider::RangeSlider(QWidget* aParent) : QWidget(aParent), mMinimum(0), mMaximum(100), + mLowerValue(0), mUpperValue(100), + mFirstHandlePressed(false), mSecondHandlePressed(false), + mInterval(mMaximum - mMinimum), + mBackgroudColorEnabled(QApplication::palette().color(QPalette::Highlight)), + mBackgroudColorDisabled(QApplication::palette().color(QPalette::Dark)), + mBackgroudColor(mBackgroudColorEnabled) +{ + setMouseTracking(true); +} + +void RangeSlider::paintEvent(QPaintEvent* aEvent) +{ + Q_UNUSED(aEvent); + QPainter painter(this); + + // Background + QRectF backgroundRect = QRectF(scLeftRightMargin, (height() - scSliderBarHeight) / 2, width() - scLeftRightMargin * 2, scSliderBarHeight); + QPen pen(QApplication::palette().color(QPalette::Dark), 0.8); + painter.setPen(pen); + painter.setRenderHint(QPainter::Qt4CompatiblePainting); + QBrush backgroundBrush(QApplication::palette().color(QPalette::Mid)); + painter.setBrush(backgroundBrush); + painter.drawRoundedRect(backgroundRect, 1, 1); + + // First value handle rect + pen.setColor(QApplication::palette().color(QPalette::Dark)); + pen.setWidth(0.4); + painter.setPen(pen); + painter.setRenderHint(QPainter::Antialiasing); + QBrush handleBrush(QApplication::palette().color(QPalette::Light)); + painter.setBrush(handleBrush); + QRectF leftHandleRect = firstHandleRect(); + painter.drawRoundedRect(leftHandleRect, 6, 6); + + // Second value handle rect + QRectF rightHandleRect = secondHandleRect(); + painter.drawRoundedRect(rightHandleRect, 6, 6); + + // Handles + painter.setRenderHint(QPainter::Antialiasing, false); + QRectF selectedRect(backgroundRect); + selectedRect.setLeft(leftHandleRect.right() + 0.5); + selectedRect.setRight(rightHandleRect.left() - 0.5); + QBrush selectedBrush(mBackgroudColor); + painter.setBrush(selectedBrush); + painter.drawRect(selectedRect); +} + +QRectF RangeSlider::firstHandleRect() const +{ + float percentage = (mLowerValue - mMinimum) * 1.0 / mInterval; + return handleRect(percentage * validWidth() + scLeftRightMargin); +} + +QRectF RangeSlider::secondHandleRect() const +{ + float percentage = (mUpperValue - mMinimum) * 1.0 / mInterval; + return handleRect(percentage * validWidth() + scLeftRightMargin + scHandleSideLength); +} + +QRectF RangeSlider::handleRect(int aValue) const +{ + return QRect(aValue, (height()-scHandleSideLength) / 2, scHandleSideLength, scHandleSideLength); +} + +void RangeSlider::mousePressEvent(QMouseEvent* aEvent) +{ + if(aEvent->buttons() & Qt::LeftButton) + { + mSecondHandlePressed = secondHandleRect().contains(aEvent->pos()); + mFirstHandlePressed = !mSecondHandlePressed && firstHandleRect().contains(aEvent->pos()); + + if(mFirstHandlePressed) + { + mDelta = aEvent->pos().x() - (firstHandleRect().x() + scHandleSideLength / 2); + } + else if(mSecondHandlePressed) + { + mDelta = aEvent->pos().x() - (secondHandleRect().x() + scHandleSideLength / 2); + } + + if(aEvent->pos().y() >= 2 && aEvent->pos().y() <= height()- 2) + { + int step = mInterval / 10 < 1 ? 1 : mInterval / 10; + if(aEvent->pos().x() < firstHandleRect().x()) + { + setLowerValue(mLowerValue - step); + } + else if(aEvent->pos().x() > firstHandleRect().x() + scHandleSideLength && aEvent->pos().x() < secondHandleRect().x()) + { + if(aEvent->pos().x() - (firstHandleRect().x() + scHandleSideLength) < + (secondHandleRect().x() - (firstHandleRect().x() + scHandleSideLength)) / 2) + { + if(mLowerValue + step < mUpperValue) + setLowerValue(mLowerValue + step); + else + setLowerValue(mUpperValue); + } + else + { + if(mUpperValue - step > mLowerValue) + setUpperValue(mUpperValue - step); + else + setUpperValue(mLowerValue); + } + } + else if(aEvent->pos().x() > secondHandleRect().x() + scHandleSideLength) + setUpperValue(mUpperValue + step); + } + } +} + +void RangeSlider::mouseMoveEvent(QMouseEvent* aEvent) +{ + if(aEvent->buttons() & Qt::LeftButton) + { + if(mFirstHandlePressed) + { + if(aEvent->pos().x() - mDelta + scHandleSideLength / 2 <= secondHandleRect().x()) + setLowerValue((aEvent->pos().x() - mDelta - scLeftRightMargin - + scHandleSideLength / 2) * 1.0 / validWidth() * mInterval + mMinimum, false); + else + setLowerValue(mUpperValue, false); + } + else if(mSecondHandlePressed) + { + if(firstHandleRect().x() + scHandleSideLength * 1.5 <= aEvent->pos().x() - mDelta) + { + setUpperValue((aEvent->pos().x() - mDelta - scLeftRightMargin - + scHandleSideLength / 2 - scHandleSideLength) * 1.0 / validWidth() * mInterval + mMinimum, false); + } + else + setUpperValue(mLowerValue, false); + } + } +} + +void RangeSlider::mouseReleaseEvent(QMouseEvent* aEvent) +{ + Q_UNUSED(aEvent); + + if (mFirstHandlePressed) + { + emit lowerValueChanged(mLowerValue); + emit valueChanged(mLowerValue, mUpperValue); + } + else if (mSecondHandlePressed) + { + emit upperValueChanged(mUpperValue); + emit valueChanged(mLowerValue, mUpperValue); + } + + mFirstHandlePressed = false; + mSecondHandlePressed = false; +} + +void RangeSlider::changeEvent(QEvent* aEvent) +{ + if(aEvent->type() == QEvent::EnabledChange) + { + if(isEnabled()) + mBackgroudColor = mBackgroudColorEnabled; + else + mBackgroudColor = mBackgroudColorDisabled; + + update(); + } +} + +QSize RangeSlider::minimumSizeHint() const +{ + return QSize(scHandleSideLength * 2 + scLeftRightMargin * 2, scHandleSideLength); +} + +int RangeSlider::GetMinimun() const +{ + return mMinimum; +} + +int RangeSlider::GetMaximun() const +{ + return mMaximum; +} + +int RangeSlider::GetLowerValue() const +{ + return mLowerValue; +} + +void RangeSlider::setLowerValue(int aLowerValue, bool fireEvent) +{ + if(aLowerValue > mMaximum) + aLowerValue = mMaximum; + + if(aLowerValue < mMinimum) + aLowerValue = mMinimum; + + mLowerValue = aLowerValue; + + if (mLowerValue == mUpperValue) + mLowerValue--; + + if (fireEvent) + { + emit lowerValueChanged(mLowerValue); + emit valueChanged(mLowerValue, mUpperValue); + } + + update(); +} + +int RangeSlider::GetUpperValue() const +{ + return mUpperValue; +} + +void RangeSlider::setUpperValue(int aUpperValue, bool fireEvent) +{ + if(aUpperValue > mMaximum) + aUpperValue = mMaximum; + + if(aUpperValue < mMinimum) + aUpperValue = mMinimum; + + mUpperValue = aUpperValue; + + if (mUpperValue == mLowerValue) + mUpperValue++; + + if (fireEvent) + { + emit lowerValueChanged(mLowerValue); + emit valueChanged(mLowerValue, mUpperValue); + } + + update(); +} + +void RangeSlider::setMinimum(int aMinimum) +{ + if(aMinimum <= mMaximum) + mMinimum = aMinimum; + else + { + int oldMax = mMaximum; + mMinimum = oldMax; + mMaximum = aMinimum; + } + + mInterval = mMaximum - mMinimum; + update(); + + if (mLowerValue < mMinimum) + setLowerValue(mMinimum); + + if (mUpperValue > mMaximum) + setUpperValue(mMaximum); + + emit rangeChanged(mMinimum, mMaximum); +} + +void RangeSlider::setMaximum(int aMaximum) +{ + if(aMaximum >= mMinimum) + mMaximum = aMaximum; + else + { + int oldMin = mMinimum; + mMaximum = oldMin; + mMinimum = aMaximum; + } + + mInterval = mMaximum - mMinimum; + update(); + + if (mLowerValue < mMinimum) + setLowerValue(mMinimum); + + if (mUpperValue > mMaximum) + setUpperValue(mMaximum); + + emit rangeChanged(mMinimum, mMaximum); +} + +int RangeSlider::validWidth() const +{ + return width() - scLeftRightMargin * 2 - scHandleSideLength * 2; +} + +void RangeSlider::setRange(int aMinimum, int aMaximum) +{ + setMinimum(aMinimum); + setMaximum(aMaximum); +} diff --git a/src/qt/plugins/rangeslider/rangeslider.h b/src/qt/plugins/rangeslider/rangeslider.h new file mode 100644 index 00000000..dbcd6c2f --- /dev/null +++ b/src/qt/plugins/rangeslider/rangeslider.h @@ -0,0 +1,68 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Copyright (c) 2017-2018 The Swipp developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#pragma once + +#include +#include +#include + +class RangeSlider : public QWidget +{ + Q_OBJECT + +public: + RangeSlider(QWidget* aParent = Q_NULLPTR); + + QSize minimumSizeHint() const override; + + int GetMinimun() const; + int GetMaximun() const; + int GetLowerValue() const; + int GetUpperValue() const; + + void setRange(int aMinimum, int aMaximum); + +protected: + void paintEvent(QPaintEvent* aEvent) override; + void mousePressEvent(QMouseEvent* aEvent) override; + void mouseMoveEvent(QMouseEvent* aEvent) override; + void mouseReleaseEvent(QMouseEvent* aEvent) override; + void changeEvent(QEvent* aEvent) override; + + QRectF firstHandleRect() const; + QRectF secondHandleRect() const; + QRectF handleRect(int aValue) const; + +signals: + void lowerValueChanged(int aLowerValue); + void upperValueChanged(int aUpperValue); + void valueChanged(int aLowerValue, int aUpperValue); + void rangeChanged(int aMin, int aMax); + +public slots: + void setLowerValue(int aLowerValue, bool fireEvent = true); + void setUpperValue(int aUpperValue, bool fireEvent = true); + void setMinimum(int aMinimum); + void setMaximum(int aMaximum); + +private: + Q_DISABLE_COPY(RangeSlider) + float currentPercentage(); + int validWidth() const; + + int mMinimum; + int mMaximum; + int mLowerValue; + int mUpperValue; + bool mFirstHandlePressed; + bool mSecondHandlePressed; + int mInterval; + int mDelta; + QColor mBackgroudColorEnabled; + QColor mBackgroudColorDisabled; + QColor mBackgroudColor; +}; From 613001d8c1464f439c8c0fa158c88898588ada61 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:05:55 -0400 Subject: [PATCH 266/469] Create allocators.h --- src/allocators.h | 259 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 src/allocators.h diff --git a/src/allocators.h b/src/allocators.h new file mode 100644 index 00000000..3d0637df --- /dev/null +++ b/src/allocators.h @@ -0,0 +1,259 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Copyright (c) 2017-2018 The Swipp developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_ALLOCATORS_H +#define BITCOIN_ALLOCATORS_H + +#include +#include +#include +#include +#include + +#ifdef WIN32 +#ifdef _WIN32_WINNT +#undef _WIN32_WINNT +#endif +#define _WIN32_WINNT 0x0501 +#define WIN32_LEAN_AND_MEAN 1 +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include +// This is used to attempt to keep keying material out of swap +// Note that VirtualLock does not provide this as a guarantee on Windows, +// but, in practice, memory that has been VirtualLock'd almost never gets written to +// the pagefile except in rare circumstances where memory is extremely low. +#else +#include +#include +#include +#endif + +// Thread-safe class to keep track of locked (ie, non-swappable) memory pages +// Memory locks do not stack, that is, pages which have been locked several times by calls to mlock(). +// will be unlocked by a single call to munlock(). This can result in keying material ending up in swap when +// those functions are used naively. This class simulates stacking memory locks by keeping a counter per page + +template class LockedPageManagerBase +{ +public: + LockedPageManagerBase(size_t page_size) : page_size(page_size) + { + // Determine bitmask for extracting page from address + assert(!(page_size & (page_size - 1))); // Size must be power of two + page_mask = ~(page_size - 1); + } + + // For all pages in affected range, increase lock count + void LockRange(void *p, size_t size) + { + boost::mutex::scoped_lock lock(mutex); + + if(!size) + return; + + const size_t base_addr = reinterpret_cast(p); + const size_t start_page = base_addr & page_mask; + const size_t end_page = (base_addr + size - 1) & page_mask; + + for(size_t page = start_page; page <= end_page; page += page_size) + { + Histogram::iterator it = histogram.find(page); + + if(it == histogram.end()) + { + locker.Lock(reinterpret_cast(page), page_size); + histogram.insert(std::make_pair(page, 1)); + } + else + it->second += 1; + } + } + + // For all pages in affected range, decrease lock count + void UnlockRange(void *p, size_t size) + { + boost::mutex::scoped_lock lock(mutex); + + if(!size) + return; + + const size_t base_addr = reinterpret_cast(p); + const size_t start_page = base_addr & page_mask; + const size_t end_page = (base_addr + size - 1) & page_mask; + + for(size_t page = start_page; page <= end_page; page += page_size) + { + Histogram::iterator it = histogram.find(page); + assert(it != histogram.end()); + it->second -= 1; + + if(it->second == 0) + { + locker.Unlock(reinterpret_cast(page), page_size); + histogram.erase(it); + } + } + } + + // Get number of locked pages for diagnostics + int GetLockedPageCount() + { + boost::mutex::scoped_lock lock(mutex); + return histogram.size(); + } + +private: + Locker locker; + boost::mutex mutex; + size_t page_size, page_mask; + typedef std::map Histogram; + Histogram histogram; +}; + +static inline size_t GetSystemPageSize() +{ + size_t page_size; +#if defined(WIN32) + SYSTEM_INFO sSysInfo; + GetSystemInfo(&sSysInfo); + page_size = sSysInfo.dwPageSize; +#elif defined(PAGESIZE) + page_size = PAGESIZE; +#else + page_size = sysconf(_SC_PAGESIZE); +#endif + return page_size; +} + +class MemoryPageLocker +{ +public: + bool Lock(const void *addr, size_t len) + { +#ifdef WIN32 + return VirtualLock(const_cast(addr), len); +#else + return mlock(addr, len) == 0; +#endif + } + + bool Unlock(const void *addr, size_t len) + { +#ifdef WIN32 + return VirtualUnlock(const_cast(addr), len); +#else + return munlock(addr, len) == 0; +#endif + } +}; + +// Singleton class to keep track of locked (ie, non-swappable) memory pages, for use in std::allocator templates +class LockedPageManager : public LockedPageManagerBase +{ +public: + static LockedPageManager instance; +private: + LockedPageManager() : LockedPageManagerBase(GetSystemPageSize()) { } +}; + +// Functions for directly locking/unlocking memory objects +// Intended for non-dynamically allocated structures + +template void LockObject(const T &t) +{ + LockedPageManager::instance.LockRange((void*)(&t), sizeof(T)); +} + +template void UnlockObject(const T &t) +{ + OPENSSL_cleanse((void*)(&t), sizeof(T)); + LockedPageManager::instance.UnlockRange((void*)(&t), sizeof(T)); +} + +// Allocator that locks its contents from being paged out of memory and clears its contents before deletion +template struct secure_allocator : public std::allocator +{ + // MSVC8 default copy constructor is broken + typedef std::allocator base; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::value_type value_type; + + secure_allocator() throw() { } + secure_allocator(const secure_allocator& a) throw() : base(a) { } + + template secure_allocator(const secure_allocator& a) throw() : base(a) { } + ~secure_allocator() throw() { } + + template struct rebind + { + typedef secure_allocator<_Other> other; + }; + + T* allocate(std::size_t n, const void *hint = 0) + { + T *p; + p = std::allocator::allocate(n, hint); + + if (p != NULL) + LockedPageManager::instance.LockRange(p, sizeof(T) * n); + + return p; + } + + void deallocate(T* p, std::size_t n) + { + if (p != NULL) + { + OPENSSL_cleanse(p, sizeof(T) * n); + LockedPageManager::instance.UnlockRange(p, sizeof(T) * n); + } + + std::allocator::deallocate(p, n); + } +}; + +// Allocator that clears its contents before deletion. +template struct zero_after_free_allocator : public std::allocator +{ + // MSVC8 default copy constructor is broken + typedef std::allocator base; + typedef typename base::size_type size_type; + typedef typename base::difference_type difference_type; + typedef typename base::pointer pointer; + typedef typename base::const_pointer const_pointer; + typedef typename base::reference reference; + typedef typename base::const_reference const_reference; + typedef typename base::value_type value_type; + + zero_after_free_allocator() throw() { } + zero_after_free_allocator(const zero_after_free_allocator& a) throw() : base(a) { } + template zero_after_free_allocator(const zero_after_free_allocator& a) throw() : base(a) { } + ~zero_after_free_allocator() throw() { } + + template struct rebind + { + typedef zero_after_free_allocator<_Other> other; + }; + + void deallocate(T* p, std::size_t n) + { + if (p != NULL) + OPENSSL_cleanse(p, sizeof(T) * n); + + std::allocator::deallocate(p, n); + } +}; + +typedef std::basic_string, secure_allocator > SecureString; + +#endif From aa8e380caa51f2cbe58698d1872cf675c05b4f0d Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:06:31 -0400 Subject: [PATCH 267/469] Update Makefile.am --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.am b/src/Makefile.am index ac252b97..b5a08ed9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -104,6 +104,7 @@ BITCOIN_CORE_H = \ addrdb.h \ activemasternode.h \ addressindex.h \ + allocators.h \ spentindex.h \ addrman.h \ alert.h \ From 8f3b7fa5bf53ec2db71f0e1981694d176845686a Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:09:07 -0400 Subject: [PATCH 268/469] Update Makefile.qt.include --- src/Makefile.qt.include | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 47f2d007..869a8758 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -55,7 +55,8 @@ QT_FORMS_UI = \ qt/forms/sendcoinsdialog.ui \ qt/forms/sendcoinsentry.ui \ qt/forms/signverifymessagedialog.ui \ - qt/forms/transactiondescdialog.ui + qt/forms/transactiondescdialog.ui \ + qt/plugins/forms/mrichtextedit.ui QT_MOC_CPP = \ qt/moc_addressbookpage.cpp \ @@ -198,7 +199,8 @@ BITCOIN_QT_H = \ qt/walletmodel.h \ qt/walletmodeltransaction.h \ qt/walletview.h \ - qt/winshutdownmonitor.h + qt/winshutdownmonitor.h \ + qt/plugins/nrichtextedit.h RES_ICONS = \ qt/res/icons/bitcoin.ico \ @@ -540,7 +542,8 @@ BITCOIN_QT_WALLET_CPP = \ qt/walletframe.cpp \ qt/walletmodel.cpp \ qt/walletmodeltransaction.cpp \ - qt/walletview.cpp + qt/walletview.cpp \ + qt/plugins/mrichtextedit.cpp BITCOIN_QT_CPP = $(BITCOIN_QT_BASE_CPP) if TARGET_WINDOWS From 6ac6bfd29a7b77272f4f36805efbbcf06222a394 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:09:51 -0400 Subject: [PATCH 269/469] Update mrichtextedit.h --- src/qt/plugins/mrichtexteditor/mrichtextedit.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/plugins/mrichtexteditor/mrichtextedit.h b/src/qt/plugins/mrichtexteditor/mrichtextedit.h index 24e3fbb0..543c8e60 100644 --- a/src/qt/plugins/mrichtexteditor/mrichtextedit.h +++ b/src/qt/plugins/mrichtexteditor/mrichtextedit.h @@ -42,11 +42,11 @@ class MRichTextEdit : public QWidget, protected Ui::MRichTextEdit { void setTextCursor(const QTextCursor& cursor) { f_textedit->setTextCursor(cursor); } - public slots: + public Q_SLOTS: void setText(const QString &text); void clear(); - protected slots: + protected Q_SLOTS: void setPlainText(const QString &text) { f_textedit->setPlainText(text); } void setHtml(const QString &text) { f_textedit->setHtml(text); } void textBold(); From a22fe47a6a37b80b1112299609fc40dcfc9d83de Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:13:25 -0400 Subject: [PATCH 270/469] Update Makefile.qt.include --- src/Makefile.qt.include | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 869a8758..7679b7b8 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -56,7 +56,7 @@ QT_FORMS_UI = \ qt/forms/sendcoinsentry.ui \ qt/forms/signverifymessagedialog.ui \ qt/forms/transactiondescdialog.ui \ - qt/plugins/forms/mrichtextedit.ui + qt/plugins/forms/mrichtextedit/mrichtextedit.ui QT_MOC_CPP = \ qt/moc_addressbookpage.cpp \ @@ -200,7 +200,7 @@ BITCOIN_QT_H = \ qt/walletmodeltransaction.h \ qt/walletview.h \ qt/winshutdownmonitor.h \ - qt/plugins/nrichtextedit.h + qt/plugins/mrichtextedit/mrichtextedit.h RES_ICONS = \ qt/res/icons/bitcoin.ico \ @@ -543,7 +543,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/walletmodel.cpp \ qt/walletmodeltransaction.cpp \ qt/walletview.cpp \ - qt/plugins/mrichtextedit.cpp + qt/plugins/mrichtextedit/mrichtextedit.cpp BITCOIN_QT_CPP = $(BITCOIN_QT_BASE_CPP) if TARGET_WINDOWS From 9f97a3338634877bf7b69896c1db9036d13983db Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:15:49 -0400 Subject: [PATCH 271/469] Update Makefile.qt.include --- src/Makefile.qt.include | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 7679b7b8..23fd04a2 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -56,7 +56,7 @@ QT_FORMS_UI = \ qt/forms/sendcoinsentry.ui \ qt/forms/signverifymessagedialog.ui \ qt/forms/transactiondescdialog.ui \ - qt/plugins/forms/mrichtextedit/mrichtextedit.ui + qt/plugins/mrichtexteditor/mrichtextedit.ui QT_MOC_CPP = \ qt/moc_addressbookpage.cpp \ @@ -200,7 +200,7 @@ BITCOIN_QT_H = \ qt/walletmodeltransaction.h \ qt/walletview.h \ qt/winshutdownmonitor.h \ - qt/plugins/mrichtextedit/mrichtextedit.h + qt/plugins/mrichtexteditor/mrichtextedit.h RES_ICONS = \ qt/res/icons/bitcoin.ico \ @@ -543,7 +543,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/walletmodel.cpp \ qt/walletmodeltransaction.cpp \ qt/walletview.cpp \ - qt/plugins/mrichtextedit/mrichtextedit.cpp + qt/plugins/mrichtexteditor/mrichtextedit.cpp BITCOIN_QT_CPP = $(BITCOIN_QT_BASE_CPP) if TARGET_WINDOWS From 4dd2fb47e4f09818629659b568b761da2b5966ea Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:18:00 -0400 Subject: [PATCH 272/469] Add files via upload --- src/qt/qvalidatedtextedit.cpp | 44 +++++++++++++++++++++++++++++++++++ src/qt/qvalidatedtextedit.h | 31 ++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 src/qt/qvalidatedtextedit.cpp create mode 100644 src/qt/qvalidatedtextedit.h diff --git a/src/qt/qvalidatedtextedit.cpp b/src/qt/qvalidatedtextedit.cpp new file mode 100644 index 00000000..c0cb83ba --- /dev/null +++ b/src/qt/qvalidatedtextedit.cpp @@ -0,0 +1,44 @@ +#include "qvalidatedtextedit.h" + +#include "guiconstants.h" + +#include +QValidatedTextEdit::QValidatedTextEdit(QWidget *parent) : + QPlainTextEdit(parent), valid(true) +{} + +void QValidatedTextEdit::setValid(bool valid) +{ + setStyleSheet(valid ? "" : STYLE_INVALID); + + if(valid) + { + if(toPlainText() == this->errorText) + setPlainText(""); + } + else if(toPlainText() == "") + setPlainText(this->errorText); +} + +void QValidatedTextEdit::setErrorText(QString errorText) +{ + this->errorText = errorText; +} + +void QValidatedTextEdit::focusInEvent(QFocusEvent *evt) +{ + // Clear invalid flag on focus + setValid(true); + QPlainTextEdit::focusInEvent(evt); +} + +void QValidatedTextEdit::markValid() +{ + setValid(true); +} + +void QValidatedTextEdit::clear() +{ + setValid(true); + QPlainTextEdit::clear(); +} diff --git a/src/qt/qvalidatedtextedit.h b/src/qt/qvalidatedtextedit.h new file mode 100644 index 00000000..f1039e5c --- /dev/null +++ b/src/qt/qvalidatedtextedit.h @@ -0,0 +1,31 @@ +#ifndef QVALIDATEDTEXTEDIT_H +#define QVALIDATEDTEXTEDIT_H + +#include + +/** Text edit that can be marked as "invalid" to show input validation feedback. When marked as invalid, + it will get a red background until it is focused. + */ +class QValidatedTextEdit : public QPlainTextEdit +{ + Q_OBJECT +public: + explicit QValidatedTextEdit(QWidget *parent = 0); + void clear(); + +protected: + void focusInEvent(QFocusEvent *evt); + +private: + bool valid; + QString errorText; + +public slots: + void setValid(bool valid); + void setErrorText(QString errorText); + +private slots: + void markValid(); +}; + +#endif // QVALIDATEDTEXTEDIT_H From 9418df3809da71e3fbbbe4bab5cb531615cfbc19 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:19:31 -0400 Subject: [PATCH 273/469] Update Makefile.qt.include --- src/Makefile.qt.include | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 23fd04a2..0baaabd3 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -112,7 +112,8 @@ QT_MOC_CPP = \ qt/moc_utilitydialog.cpp \ qt/moc_walletframe.cpp \ qt/moc_walletmodel.cpp \ - qt/moc_walletview.cpp + qt/moc_walletview.cpp \ + qt/moc_qvalidatetextedit.cpp BITCOIN_MM = \ qt/macdockiconhandler.mm \ @@ -200,7 +201,8 @@ BITCOIN_QT_H = \ qt/walletmodeltransaction.h \ qt/walletview.h \ qt/winshutdownmonitor.h \ - qt/plugins/mrichtexteditor/mrichtextedit.h + qt/plugins/mrichtexteditor/mrichtextedit.h \ + qt/qvalidatetextedit.h RES_ICONS = \ qt/res/icons/bitcoin.ico \ @@ -498,6 +500,7 @@ BITCOIN_QT_BASE_CPP = \ qt/peertablemodel.cpp \ qt/platformstyle.cpp \ qt/qvalidatedlineedit.cpp \ + qt/qvalidatetextedit.cpp \ qt/qvaluecombobox.cpp \ qt/rpcconsole.cpp \ qt/splashscreen.cpp \ @@ -543,7 +546,8 @@ BITCOIN_QT_WALLET_CPP = \ qt/walletmodel.cpp \ qt/walletmodeltransaction.cpp \ qt/walletview.cpp \ - qt/plugins/mrichtexteditor/mrichtextedit.cpp + qt/plugins/mrichtexteditor/mrichtextedit.cpp \ + qt/qvalidatetextedit BITCOIN_QT_CPP = $(BITCOIN_QT_BASE_CPP) if TARGET_WINDOWS From 34f16c82c43ffa96ac71cf83eda699b4df9f336b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:21:54 -0400 Subject: [PATCH 274/469] Update Makefile.qt.include --- src/Makefile.qt.include | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 0baaabd3..49c453a9 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -39,9 +39,6 @@ QT_FORMS_UI = \ qt/forms/governancedialog.ui \ qt/forms/helpmessagedialog.ui \ qt/forms/intro.ui \ - qt/forms/messagepage.ui \ - qt/forms/sendmessagesdialog.ui \ - qt/forms/sendmessagesentry.ui \ qt/forms/modaloverlay.ui \ qt/forms/masternodelist.ui \ qt/forms/qrdialog.ui \ @@ -55,8 +52,7 @@ QT_FORMS_UI = \ qt/forms/sendcoinsdialog.ui \ qt/forms/sendcoinsentry.ui \ qt/forms/signverifymessagedialog.ui \ - qt/forms/transactiondescdialog.ui \ - qt/plugins/mrichtexteditor/mrichtextedit.ui + qt/forms/transactiondescdialog.ui QT_MOC_CPP = \ qt/moc_addressbookpage.cpp \ @@ -80,10 +76,6 @@ QT_MOC_CPP = \ qt/moc_macnotificationhandler.cpp \ qt/moc_modaloverlay.cpp \ qt/moc_masternodelist.cpp \ - qt/moc_messagemodel.cpp \ - qt/moc_messagepage.cpp \ - qt/moc_sendmessagesdialog.cpp \ - qt/moc_sendmessagesentry.cpp \ qt/moc_notificator.cpp \ qt/moc_openuridialog.cpp \ qt/moc_optionsdialog.cpp \ @@ -112,8 +104,7 @@ QT_MOC_CPP = \ qt/moc_utilitydialog.cpp \ qt/moc_walletframe.cpp \ qt/moc_walletmodel.cpp \ - qt/moc_walletview.cpp \ - qt/moc_qvalidatetextedit.cpp + qt/moc_walletview.cpp BITCOIN_MM = \ qt/macdockiconhandler.mm \ @@ -159,10 +150,6 @@ BITCOIN_QT_H = \ qt/macdockiconhandler.h \ qt/macnotificationhandler.h \ qt/macos_appnap.h \ - qt/messagepage.h \ - qt/messagemodel.h \ - qt/sendmessagesdialog.h \ - qt/sendmessagesentry.h \ qt/modaloverlay.h \ qt/masternodelist.h \ qt/networkstyle.h \ @@ -200,9 +187,7 @@ BITCOIN_QT_H = \ qt/walletmodel.h \ qt/walletmodeltransaction.h \ qt/walletview.h \ - qt/winshutdownmonitor.h \ - qt/plugins/mrichtexteditor/mrichtextedit.h \ - qt/qvalidatetextedit.h + qt/winshutdownmonitor.h RES_ICONS = \ qt/res/icons/bitcoin.ico \ @@ -500,7 +485,6 @@ BITCOIN_QT_BASE_CPP = \ qt/peertablemodel.cpp \ qt/platformstyle.cpp \ qt/qvalidatedlineedit.cpp \ - qt/qvalidatetextedit.cpp \ qt/qvaluecombobox.cpp \ qt/rpcconsole.cpp \ qt/splashscreen.cpp \ @@ -520,10 +504,6 @@ BITCOIN_QT_WALLET_CPP = \ qt/governancelist.cpp \ qt/governancedialog.cpp \ qt/masternodelist.cpp \ - qt/messagemodel.cpp \ - qt/messagepage.cpp \ - qt/sendmessagesdialog.cpp \ - qt/sendmessagesentry.cpp \ qt/openuridialog.cpp \ qt/overviewpage.cpp \ qt/privatesendpage.cpp \ @@ -545,9 +525,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/walletframe.cpp \ qt/walletmodel.cpp \ qt/walletmodeltransaction.cpp \ - qt/walletview.cpp \ - qt/plugins/mrichtexteditor/mrichtextedit.cpp \ - qt/qvalidatetextedit + qt/walletview.cpp BITCOIN_QT_CPP = $(BITCOIN_QT_BASE_CPP) if TARGET_WINDOWS From b65d713c091928b6304b9df291e25b56c1c0ce11 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:22:08 -0400 Subject: [PATCH 275/469] Delete messagepage.ui --- src/qt/forms/messagepage.ui | 246 ------------------------------------ 1 file changed, 246 deletions(-) delete mode 100644 src/qt/forms/messagepage.ui diff --git a/src/qt/forms/messagepage.ui b/src/qt/forms/messagepage.ui deleted file mode 100644 index 5efa66ac..00000000 --- a/src/qt/forms/messagepage.ui +++ /dev/null @@ -1,246 +0,0 @@ - - - MessagePage - - - - 0 - 0 - 793 - 419 - - - - Address Book - - - - - - These are your sent and received encrypted messages. Click on an item to read it. - - - Qt::PlainText - - - true - - - - - - - Qt::CustomContextMenu - - - Click on a message to view it - - - false - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - false - - - - - - - - - - - - - 2 - - - 0 - - - 6 - - - 0 - - - 0 - - - - - - - &Back - - - - :/icons/quit:/icons/quit - - - - - - - Contact: - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - #listConversation { color: #000000; } - - - - - - - - - - - - - - 0 - 100 - - - - - - - - - - &Conversation - - - - :/icons/add:/icons/add - - - - - - - Sign a message to prove you own a Swipp address - - - &Send - - - - :/icons/send:/icons/send - - - - - - - Copy the currently selected address to the system clipboard - - - &Copy From Address - - - - :/icons/editcopy:/icons/editcopy - - - - - - - Copy the currently selected address to the system clipboard - - - Copy To &Address - - - - :/icons/editcopy:/icons/editcopy - - - - - - - Delete the currently selected address from the list - - - &Delete - - - - :/icons/remove:/icons/remove - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - MRichTextEdit - QWidget -
mrichtextedit.h
- 1 -
-
- - - - -
From 18609a565aa1cc6b393cdffb78cb1dab2225be10 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:22:16 -0400 Subject: [PATCH 276/469] Delete sendmessagesdialog.ui --- src/qt/forms/sendmessagesdialog.ui | 262 ----------------------------- 1 file changed, 262 deletions(-) delete mode 100644 src/qt/forms/sendmessagesdialog.ui diff --git a/src/qt/forms/sendmessagesdialog.ui b/src/qt/forms/sendmessagesdialog.ui deleted file mode 100644 index 3f508a5b..00000000 --- a/src/qt/forms/sendmessagesdialog.ui +++ /dev/null @@ -1,262 +0,0 @@ - - - SendMessagesDialog - - - - 0 - 0 - 850 - 400 - - - - Send Messages - - - #SendMessagesDialog { background-color: #383838; } - - - - 8 - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - - - - color: #ffffff; - - - Address &From: - - - addressFrom - - - - - - - 1 - - - - - - - - Choose address from address book - - - - - - - :/icons/address-book:/icons/address-book - - - Alt+A - - - - - - - Paste address from clipboard - - - - - - - :/icons/editpaste:/icons/editpaste - - - Alt+P - - - - - - - - - - - - true - - - - - 0 - 0 - 830 - 298 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 6 - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - Send to multiple recipients at once - - - Add &Recipient - - - - :/icons/add:/icons/add - - - false - - - - - - - - 0 - 0 - - - - Remove all transaction fields - - - Clear &All - - - - :/icons/remove:/icons/remove - - - 300 - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 150 - 0 - - - - Confirm the send action - - - S&end - - - - :/icons/send:/icons/send - - - true - - - - - - - &Close - - - - :/icons/quit:/icons/quit - - - - - - - - - - QValidatedLineEdit - QLineEdit -
qvalidatedlineedit.h
-
-
- - - - -
From 5692a874c75ab48906e24190809bcd5eef92c971 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:22:25 -0400 Subject: [PATCH 277/469] Delete sendmessagesentry.ui --- src/qt/forms/sendmessagesentry.ui | 184 ------------------------------ 1 file changed, 184 deletions(-) delete mode 100644 src/qt/forms/sendmessagesentry.ui diff --git a/src/qt/forms/sendmessagesentry.ui b/src/qt/forms/sendmessagesentry.ui deleted file mode 100644 index e4e25536..00000000 --- a/src/qt/forms/sendmessagesentry.ui +++ /dev/null @@ -1,184 +0,0 @@ - - - SendMessagesEntry - - - - 0 - 0 - 729 - 236 - - - - Form - - - QFrame::StyledPanel - - - QFrame::Sunken - - - - 12 - - - - - 0 - - - - - The address to send the payment to (e.g. CKPnZKDzaDXqEgKJ4GdUg58gXxgzA7mkny) - - - 34 - - - - - - - Choose address from address book - - - - - - - :/icons/address-book:/icons/address-book - - - Alt+A - - - - - - - Paste address from clipboard - - - - - - - :/icons/editpaste:/icons/editpaste - - - Alt+P - - - - - - - Remove this recipient - - - - - - - :/icons/remove:/icons/remove - - - - - - - - - &Message: - - - Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - - - messageText - - - - - - - Send &To: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - sendTo - - - - - - - true - - - Qt::WheelFocus - - - false - - - - - - - true - - - Enter a label for this address to add it to your address book - - - - - - - &Label: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - addAsLabel - - - - - - - &Public Key: - - - publicKey - - - - - - - - - - - QValidatedLineEdit - QLineEdit -
qvalidatedlineedit.h
-
- - QValidatedTextEdit - QPlainTextEdit -
qvalidatedtextedit.h
-
-
- - - - -
From 5203dd036d2e7ef13d66f3ffbdceba7b2b31cd9c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:22:34 -0400 Subject: [PATCH 278/469] Delete messagemodel.cpp --- src/qt/messagemodel.cpp | 619 ---------------------------------------- 1 file changed, 619 deletions(-) delete mode 100644 src/qt/messagemodel.cpp diff --git a/src/qt/messagemodel.cpp b/src/qt/messagemodel.cpp deleted file mode 100644 index ad813292..00000000 --- a/src/qt/messagemodel.cpp +++ /dev/null @@ -1,619 +0,0 @@ -#include "guiutil.h" -#include "guiconstants.h" -#include "bitcoinunits.h" -#include "optionsmodel.h" -#include "walletmodel.h" -#include "messagemodel.h" -#include "addresstablemodel.h" - -#include "ui_interface.h" -#include "base58.h" -#include "json_spirit.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -Q_DECLARE_METATYPE(std::vector); - -QList ambiguous; /**< Specifies Ambiguous addresses */ - -const QString MessageModel::Sent = "Sent"; -const QString MessageModel::Received = "Received"; - -struct MessageTableEntryLessThan -{ - bool operator()(const MessageTableEntry &a, const MessageTableEntry &b) const {return a.received_datetime < b.received_datetime;}; - bool operator()(const MessageTableEntry &a, const QDateTime &b) const {return a.received_datetime < b;} - bool operator()(const QDateTime &a, const MessageTableEntry &b) const {return a < b.received_datetime;} -}; - -// Private implementation -class MessageTablePriv -{ -public: - QList cachedMessageTable; - MessageModel *parent; - - MessageTablePriv(MessageModel *parent): - parent(parent) {} - - void refreshMessageTable() - { - cachedMessageTable.clear(); - - if (parent->getWalletModel()->getEncryptionStatus() == WalletModel::Locked) - { - // -- messages are stored encrypted, can't load them without the private keys - return; - }; - - { - LOCK(cs_smsgDB); - - SecMsgDB dbSmsg; - - if (!dbSmsg.Open("cr+")) - //throw runtime_error("Could not open DB."); - return; - - unsigned char chKey[18]; - std::vector vchKey; - vchKey.resize(18); - - SecMsgStored smsgStored; - MessageData msg; - QString label; - QDateTime sent_datetime; - QDateTime received_datetime; - - std::string sPrefix("im"); - leveldb::Iterator* it = dbSmsg.pdb->NewIterator(leveldb::ReadOptions()); - while (dbSmsg.NextSmesg(it, sPrefix, chKey, smsgStored)) - { - uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN; - if (SecureMsgDecrypt(false, smsgStored.sAddrTo, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0) - { - label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(msg.sFromAddress)); - - sent_datetime .setTime_t(msg.timestamp); - received_datetime.setTime_t(smsgStored.timeReceived); - - memcpy(&vchKey[0], chKey, 18); - - addMessageEntry(MessageTableEntry(vchKey, - MessageTableEntry::Received, - label, - QString::fromStdString(smsgStored.sAddrTo), - QString::fromStdString(msg.sFromAddress), - sent_datetime, - received_datetime, - (char*)&msg.vchMessage[0]), - true); - } - }; - - delete it; - - sPrefix = "sm"; - it = dbSmsg.pdb->NewIterator(leveldb::ReadOptions()); - while (dbSmsg.NextSmesg(it, sPrefix, chKey, smsgStored)) - { - uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN; - if (SecureMsgDecrypt(false, smsgStored.sAddrOutbox, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0) - { - label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(smsgStored.sAddrTo)); - - sent_datetime .setTime_t(msg.timestamp); - received_datetime.setTime_t(smsgStored.timeReceived); - - memcpy(&vchKey[0], chKey, 18); - - addMessageEntry(MessageTableEntry(vchKey, - MessageTableEntry::Sent, - label, - QString::fromStdString(smsgStored.sAddrTo), - QString::fromStdString(msg.sFromAddress), - sent_datetime, - received_datetime, - (char*)&msg.vchMessage[0]), - true); - } - }; - - delete it; - } - } - - void newMessage(const SecMsgStored& inboxHdr) - { - // we have to copy it, because it doesn't like constants going into Decrypt - SecMsgStored smsgStored = inboxHdr; - MessageData msg; - QString label; - QDateTime sent_datetime; - QDateTime received_datetime; - - uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN; - if (SecureMsgDecrypt(false, smsgStored.sAddrTo, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0) - { - label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(msg.sFromAddress)); - - sent_datetime .setTime_t(msg.timestamp); - received_datetime.setTime_t(smsgStored.timeReceived); - - std::string sPrefix("im"); - SecureMessage* psmsg = (SecureMessage*) &smsgStored.vchMessage[0]; - - std::vector vchKey; - vchKey.resize(18); - memcpy(&vchKey[0], sPrefix.data(), 2); - memcpy(&vchKey[2], &psmsg->timestamp, 8); - memcpy(&vchKey[10], &smsgStored.vchMessage[SMSG_HDR_LEN], 8); // sample - - addMessageEntry(MessageTableEntry(vchKey, - MessageTableEntry::Received, - label, - QString::fromStdString(smsgStored.sAddrTo), - QString::fromStdString(msg.sFromAddress), - sent_datetime, - received_datetime, - (char*)&msg.vchMessage[0]), - false); - } - } - - void newOutboxMessage(const SecMsgStored& outboxHdr) - { - - SecMsgStored smsgStored = outboxHdr; - MessageData msg; - QString label; - QDateTime sent_datetime; - QDateTime received_datetime; - - uint32_t nPayload = smsgStored.vchMessage.size() - SMSG_HDR_LEN; - if (SecureMsgDecrypt(false, smsgStored.sAddrOutbox, &smsgStored.vchMessage[0], &smsgStored.vchMessage[SMSG_HDR_LEN], nPayload, msg) == 0) - { - label = parent->getWalletModel()->getAddressTableModel()->labelForAddress(QString::fromStdString(smsgStored.sAddrTo)); - - sent_datetime .setTime_t(msg.timestamp); - received_datetime.setTime_t(smsgStored.timeReceived); - - std::string sPrefix("sm"); - SecureMessage* psmsg = (SecureMessage*) &smsgStored.vchMessage[0]; - std::vector vchKey; - vchKey.resize(18); - memcpy(&vchKey[0], sPrefix.data(), 2); - memcpy(&vchKey[2], &psmsg->timestamp, 8); - memcpy(&vchKey[10], &smsgStored.vchMessage[SMSG_HDR_LEN], 8); // sample - - addMessageEntry(MessageTableEntry(vchKey, - MessageTableEntry::Sent, - label, - QString::fromStdString(smsgStored.sAddrTo), - QString::fromStdString(msg.sFromAddress), - sent_datetime, - received_datetime, - (char*)&msg.vchMessage[0]), - false); - } - } - - void walletUnlocked() - { - // -- wallet is unlocked, can get at the private keys now - refreshMessageTable(); - - parent->reset(); // reload table view - - if (parent->proxyModel) - { - parent->proxyModel->setFilterRole(false); - parent->proxyModel->setFilterFixedString(""); - parent->resetFilter(); - parent->proxyModel->setFilterRole(MessageModel::Ambiguous); - parent->proxyModel->setFilterFixedString("true"); - } - - //invalidateFilter() - } - - void setEncryptionStatus(int status) - { - if (status == WalletModel::Locked) - { - // -- Wallet is locked, clear secure message display. - cachedMessageTable.clear(); - - parent->reset(); // reload table view - }; - }; - - MessageTableEntry *index(int idx) - { - if(idx >= 0 && idx < cachedMessageTable.size()) - return &cachedMessageTable[idx]; - else - return 0; - } - -private: - // Get the json value - const json_spirit::mValue & find_value(json_spirit::mObject & obj, const char * key) - { - std::string newKey = key; - - json_spirit::mObject::const_iterator i = obj.find(newKey); - - if(i != obj.end() && i->first == newKey) - return i->second; - else - return json_spirit::mValue::null; - } - - const std::string get_value(json_spirit::mObject & obj, const char * key) - { - json_spirit::mValue val = find_value(obj, key); - - if(val.is_null()) - return ""; - else - return val.get_str(); - } - - // Determine if it is a special message, i.e.: Invoice, Receipt, etc... - void handleMessageEntry(const MessageTableEntry & message, const bool append) - { - addMessageEntry(message, append); - json_spirit::mValue mVal; - json_spirit::read(message.message.toStdString(), mVal); - - if(mVal.is_null()) - { - addMessageEntry(message, append); - return; - } - - json_spirit::mObject mObj(mVal.get_obj()); - json_spirit::mValue mvType = find_value(mObj, "type"); - - } - - void addMessageEntry(const MessageTableEntry & message, const bool & append) - { - if(append) - { - cachedMessageTable.append(message); - } else - { - int index = qLowerBound(cachedMessageTable.begin(), cachedMessageTable.end(), message.received_datetime, MessageTableEntryLessThan()) - cachedMessageTable.begin(); - parent->beginInsertRows(QModelIndex(), index, index); - cachedMessageTable.insert( - index, - message); - parent->endInsertRows(); - } - } - -}; - -MessageModel::MessageModel(CWallet *wallet, WalletModel *walletModel, QObject *parent) : - QAbstractTableModel(parent), wallet(wallet), walletModel(walletModel), optionsModel(0), priv(0) -{ - columns << tr("Type") << tr("Sent Date Time") << tr("Received Date Time") << tr("Label") << tr("To Address") << tr("From Address") << tr("Message"); - - proxyModel = NULL; - - optionsModel = walletModel->getOptionsModel(); - - priv = new MessageTablePriv(this); - priv->refreshMessageTable(); - - subscribeToCoreSignals(); -} - -MessageModel::~MessageModel() -{ - if (proxyModel) - delete proxyModel; - - delete priv; - unsubscribeFromCoreSignals(); -} - -bool MessageModel::getAddressOrPubkey(QString &address, QString &pubkey) const -{ - CBitcoinAddress addressParsed(address.toStdString()); - - if(addressParsed.IsValid()) { - CKeyID destinationAddress; - CPubKey destinationKey; - - addressParsed.GetKeyID(destinationAddress); - - if (SecureMsgGetStoredKey(destinationAddress, destinationKey) != 0 - && SecureMsgGetLocalKey(destinationAddress, destinationKey) != 0) // test if it's a local key - return false; - - address = destinationAddress.ToString().c_str(); - pubkey = EncodeBase58(destinationKey.Raw()).c_str(); - - return true; - } - - return false; -} - -WalletModel *MessageModel::getWalletModel() -{ - return walletModel; -} - -OptionsModel *MessageModel::getOptionsModel() -{ - return optionsModel; -} - -MessageModel::StatusCode MessageModel::sendMessages(const QList &recipients, const QString &addressFrom) -{ - - QSet setAddress; - - if(recipients.empty()) - return OK; - - // Pre-check input data for validity - foreach(const SendMessagesRecipient &rcp, recipients) - { - if(!walletModel->validateAddress(rcp.address)) - return InvalidAddress; - - if(rcp.message == "") - return MessageCreationFailed; - - std::string sendTo = rcp.address.toStdString(); - std::string pubkey = rcp.pubkey.toStdString(); - std::string message = rcp.message.toStdString(); - std::string addFrom = addressFrom.toStdString(); - - SecureMsgAddAddress(sendTo, pubkey); - setAddress.insert(rcp.address); - - std::string sError; - if (SecureMsgSend(addFrom, sendTo, message, sError) != 0) - { - QMessageBox::warning(NULL, tr("Send Secure Message"), - tr("Send failed: %1.").arg(sError.c_str()), - QMessageBox::Ok, QMessageBox::Ok); - - return FailedErrorShown; - }; - - // Add addresses / update labels that we've sent to to the address book - std::string strAddress = rcp.address.toStdString(); - CTxDestination dest = CBitcoinAddress(strAddress).Get(); - std::string strLabel = rcp.label.toStdString(); - { - LOCK(wallet->cs_wallet); - - std::map::iterator mi = wallet->mapAddressBook.find(dest); - - // Check if we have a new address or an updated label - if (mi == wallet->mapAddressBook.end() || mi->second != strLabel) - { - wallet->SetAddressBookName(dest, strLabel); - } - } - } - - if(recipients.size() > setAddress.size()) - return DuplicateAddress; - - return OK; -} - -MessageModel::StatusCode MessageModel::sendMessages(const QList &recipients) -{ - return sendMessages(recipients, "anon"); -} - -int MessageModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return priv->cachedMessageTable.size(); -} - -int MessageModel::columnCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return columns.length(); -} - -QVariant MessageModel::data(const QModelIndex &index, int role) const -{ - if(!index.isValid()) - return QVariant(); - - MessageTableEntry *rec = static_cast(index.internalPointer()); - - switch(role) - { - /* - case Qt::DecorationRole: - switch(index.column()) - { - return txStatusDecoration(rec); - case ToAddress: - return txAddressDecoration(rec); - } - break;*/ - case Qt::DisplayRole: - switch(index.column()) - { - case Label: return (rec->label.isEmpty() ? tr("(no label)") : rec->label); - case ToAddress: return rec->to_address; - case FromAddress: return rec->from_address; - case SentDateTime: return rec->sent_datetime; - case ReceivedDateTime: return rec->received_datetime; - case Message: return rec->message; - case TypeInt: return rec->type; - case HTML: return rec->received_datetime.toString() + "
" + (rec->label.isEmpty() ? rec->from_address : rec->label) + "
" + rec->message; - case Type: - switch(rec->type) - { - case MessageTableEntry::Sent: return Sent; - case MessageTableEntry::Received: return Received; - default: break; - } - case Key: return QVariant::fromValue(rec->chKey); - } - break; - - case KeyRole: return QVariant::fromValue(rec->chKey); - case TypeRole: return rec->type; - case SentDateRole: return rec->sent_datetime; - case ReceivedDateRole: return rec->received_datetime; - case FromAddressRole: return rec->from_address; - case ToAddressRole: return rec->to_address; - case FilterAddressRole: return (rec->type == MessageTableEntry::Sent ? rec->to_address + rec->from_address : rec->from_address + rec->to_address); - case LabelRole: return rec->label; - case MessageRole: return rec->message; - case ShortMessageRole: return rec->message; // TODO: Short message - case HTMLRole: return rec->received_datetime.toString() + "
" + (rec->label.isEmpty() ? rec->from_address : rec->label) + "
" + rec->message; - case Ambiguous: - int it; - - for (it = 0; ittype == MessageTableEntry::Sent ? rec->to_address + rec->from_address : rec->from_address + rec->to_address)) - return false; - } - QString address = (rec->type == MessageTableEntry::Sent ? rec->to_address + rec->from_address : rec->from_address + rec->to_address); - ambiguous.append(address); - - return "true"; - break; - } - - return QVariant(); -} - -QVariant MessageModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - return (orientation == Qt::Horizontal && role == Qt::DisplayRole ? columns[section] : QVariant()); -} - -Qt::ItemFlags MessageModel::flags(const QModelIndex & index) const -{ - if(index.isValid()) - return Qt::ItemIsSelectable | Qt::ItemIsEnabled; - - return 0; -} - -QModelIndex MessageModel::index(int row, int column, const QModelIndex & parent) const -{ - Q_UNUSED(parent); - MessageTableEntry *data = priv->index(row); - return (data ? createIndex(row, column, priv->index(row)) : QModelIndex()); -} - -bool MessageModel::removeRows(int row, int count, const QModelIndex & parent) -{ - MessageTableEntry *rec = priv->index(row); - if(count != 1 || !rec) - // Can only remove one row at a time, and cannot remove rows not in model. - // Also refuse to remove receiving addresses. - return false; - - { - LOCK(cs_smsgDB); - SecMsgDB dbSmsg; - - if (!dbSmsg.Open("cr+")) - //throw runtime_error("Could not open DB."); - return false; - - dbSmsg.EraseSmesg(&rec->chKey[0]); - } - - beginRemoveRows(parent, row, row); - priv->cachedMessageTable.removeAt(row); - endRemoveRows(); - - return true; -} - -void MessageModel::resetFilter() -{ - ambiguous.clear(); -} - -void MessageModel::newMessage(const SecMsgStored &smsg) -{ - priv->newMessage(smsg); -} - - -void MessageModel::newOutboxMessage(const SecMsgStored &smsgOutbox) -{ - priv->newOutboxMessage(smsgOutbox); -} - - -void MessageModel::walletUnlocked() -{ - priv->walletUnlocked(); -} - -void MessageModel::setEncryptionStatus(int status) -{ - priv->setEncryptionStatus(status); -} - - -static void NotifySecMsgInbox(MessageModel *messageModel, SecMsgStored inboxHdr) -{ - // Too noisy: OutputDebugStringF("NotifySecMsgInboxChanged %s\n", message); - QMetaObject::invokeMethod(messageModel, "newMessage", Qt::QueuedConnection, - Q_ARG(SecMsgStored, inboxHdr)); -} - -static void NotifySecMsgOutbox(MessageModel *messageModel, SecMsgStored outboxHdr) -{ - QMetaObject::invokeMethod(messageModel, "newOutboxMessage", Qt::QueuedConnection, - Q_ARG(SecMsgStored, outboxHdr)); -} - -static void NotifySecMsgWallet(MessageModel *messageModel) -{ - QMetaObject::invokeMethod(messageModel, "walletUnlocked", Qt::QueuedConnection); -} - -void MessageModel::subscribeToCoreSignals() -{ - qRegisterMetaType("SecMsgStored"); - - // Connect signals - NotifySecMsgInboxChanged.connect(boost::bind(NotifySecMsgInbox, this, _1)); - NotifySecMsgOutboxChanged.connect(boost::bind(NotifySecMsgOutbox, this, _1)); - NotifySecMsgWalletUnlocked.connect(boost::bind(NotifySecMsgWallet, this)); - - connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int))); -} - -void MessageModel::unsubscribeFromCoreSignals() -{ - // Disconnect signals - NotifySecMsgInboxChanged.disconnect(boost::bind(NotifySecMsgInbox, this, _1)); - NotifySecMsgOutboxChanged.disconnect(boost::bind(NotifySecMsgOutbox, this, _1)); - NotifySecMsgWalletUnlocked.disconnect(boost::bind(NotifySecMsgWallet, this)); - - disconnect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int))); -} From 63deab8acc8cca7094947e969411e098e892596f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:22:42 -0400 Subject: [PATCH 279/469] Delete messagemodel.h --- src/qt/messagemodel.h | 195 ------------------------------------------ 1 file changed, 195 deletions(-) delete mode 100644 src/qt/messagemodel.h diff --git a/src/qt/messagemodel.h b/src/qt/messagemodel.h deleted file mode 100644 index ba5a2438..00000000 --- a/src/qt/messagemodel.h +++ /dev/null @@ -1,195 +0,0 @@ -#ifndef MESSAGEMODEL_H -#define MESSAGEMODEL_H - -#include "uint256.h" - -#include -#include "allocators.h" /* for SecureString */ -#include "smessage.h" -#include -#include -#include -#include -#include - - -class MessageTablePriv; -class InvoiceTableModel; -class InvoiceItemTableModel; -class ReceiptTableModel; -class CWallet; -class WalletModel; -class OptionsModel; - -class SendMessagesRecipient -{ -public: - QString address; - QString label; - QString pubkey; - QString message; -}; - -struct MessageTableEntry -{ - enum Type { - Sent, - Received - }; - - std::vector chKey; - Type type; - QString label; - QString to_address; - QString from_address; - QDateTime sent_datetime; - QDateTime received_datetime; - QString message; - - MessageTableEntry() {} - MessageTableEntry(std::vector &chKey, - Type type, - const QString &label, - const QString &to_address, - const QString &from_address, - const QDateTime &sent_datetime, - const QDateTime &received_datetime, - const QString &message): - chKey(chKey), - type(type), - label(label), - to_address(to_address), - from_address(from_address), - sent_datetime(sent_datetime), - received_datetime(received_datetime), - message(message) - { - } -}; - -/** Interface to Swipp Secure Messaging from Qt view code. */ -class MessageModel : public QAbstractTableModel -{ - Q_OBJECT - -public: - explicit MessageModel(CWallet *wallet, WalletModel *walletModel, QObject *parent = 0); - ~MessageModel(); - - enum StatusCode // Returned by sendMessages - { - OK, - InvalidAddress, - InvalidMessage, - DuplicateAddress, - MessageCreationFailed, // Error returned when DB is still locked - MessageCommitFailed, - Aborted, - FailedErrorShown - }; - - enum ColumnIndex { - Type = 0, /**< Sent/Received */ - SentDateTime = 1, /**< Time Sent */ - ReceivedDateTime = 2, /**< Time Received */ - Label = 3, /**< User specified label */ - ToAddress = 4, /**< To Bitcoin address */ - FromAddress = 5, /**< From Bitcoin address */ - Message = 6, /**< Plaintext */ - TypeInt = 7, /**< Plaintext */ - Key = 8, /**< chKey */ - HTML = 9, /**< HTML Formatted Data */ - }; - - /** Roles to get specific information from a message row. - These are independent of column. - */ - enum RoleIndex { - /** Type of message */ - TypeRole = Qt::UserRole, - /** Date and time this message was sent */ - /** message key */ - KeyRole, - SentDateRole, - /** Date and time this message was received */ - ReceivedDateRole, - /** From Address of message */ - FromAddressRole, - /** To Address of message */ - ToAddressRole, - /** Filter address related to message */ - FilterAddressRole, - /** Label of address related to message */ - LabelRole, - /** Full Message */ - MessageRole, - /** Short Message */ - ShortMessageRole, - /** HTML Formatted */ - HTMLRole, - /** Ambiguous bool */ - Ambiguous - }; - - static const QString Sent; /**< Specifies sent message */ - static const QString Received; /**< Specifies sent message */ - - //QList ambiguous; /**< Specifies Ambiguous addresses */ - - /** @name Methods overridden from QAbstractTableModel - @{*/ - int rowCount(const QModelIndex &parent) const; - int columnCount(const QModelIndex &parent) const; - QVariant data(const QModelIndex &index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - QModelIndex index(int row, int column, const QModelIndex & parent) const; - bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); - Qt::ItemFlags flags(const QModelIndex & index) const; - /*@}*/ - - /* Look up row index of a message in the model. - Return -1 if not found. - */ - int lookupMessage(const QString &message) const; - - WalletModel *getWalletModel(); - OptionsModel *getOptionsModel(); - - void resetFilter(); - - bool getAddressOrPubkey( QString &Address, QString &Pubkey) const; - - // Send messages to a list of recipients - StatusCode sendMessages(const QList &recipients); - StatusCode sendMessages(const QList &recipients, const QString &addressFrom); - - QSortFilterProxyModel *proxyModel; - -private: - CWallet *wallet; - WalletModel *walletModel; - OptionsModel *optionsModel; - MessageTablePriv *priv; - QStringList columns; - - void subscribeToCoreSignals(); - void unsubscribeFromCoreSignals(); - -public Q_SLOTS: - - /* Check for new messages */ - void newMessage(const SecMsgStored& smsg); - void newOutboxMessage(const SecMsgStored& smsg); - - void walletUnlocked(); - - void setEncryptionStatus(int status); - - friend class MessageTablePriv; - -Q_SIGNALS: - // Asynchronous error notification - void error(const QString &title, const QString &message, bool modal); -}; - -#endif // MESSAGEMODEL_H From ab9056386284fac6369e9b6f5359819503b2d8a6 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:22:49 -0400 Subject: [PATCH 280/469] Delete messagepage.cpp --- src/qt/messagepage.cpp | 419 ----------------------------------------- 1 file changed, 419 deletions(-) delete mode 100644 src/qt/messagepage.cpp diff --git a/src/qt/messagepage.cpp b/src/qt/messagepage.cpp deleted file mode 100644 index dec8cd7f..00000000 --- a/src/qt/messagepage.cpp +++ /dev/null @@ -1,419 +0,0 @@ -// Copyright (c) 2017-2018 The Swipp developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "messagepage.h" -#include "ui_messagepage.h" - -#include "sendmessagesdialog.h" -#include "mrichtextedit.h" -#include "messagemodel.h" -#include "bitcoingui.h" -#include "csvmodelwriter.h" -#include "guiutil.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#define DECORATION_SIZE 64 -#define NUM_ITEMS 3 - -class MessageViewDelegate : public QStyledItemDelegate -{ -protected: - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; -}; - -void MessageViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - QStyleOptionViewItem options = option; - initStyleOption(&options, index); - - QStyle *style = options.widget ? options.widget->style() : QApplication::style(); - - QTextDocument doc; - QString align(index.data(MessageModel::TypeRole) == 1 ? "left" : "right"); - QString html = "

" + index.data(MessageModel::HTMLRole).toString() + "

"; - doc.setHtml(html); - - /// Painting item without text - options.text = QString(); - style->drawControl(QStyle::CE_ItemViewItem, &options, painter); - - QAbstractTextDocumentLayout::PaintContext ctx; - - // Highlighting text if item is selected - if (options.state & QStyle::State_Selected) - ctx.palette.setColor(QPalette::Text, options.palette.color(QPalette::Active, QPalette::HighlightedText)); - - QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &options); - doc.setTextWidth( textRect.width() ); - painter->save(); - painter->translate(textRect.topLeft()); - painter->setClipRect(textRect.translated(-textRect.topLeft())); - doc.documentLayout()->draw(painter, ctx); - painter->restore(); -} - -QSize MessageViewDelegate::sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - QStyleOptionViewItem options = option; - initStyleOption(&options, index); - - QTextDocument doc; - doc.setHtml(index.data(MessageModel::HTMLRole).toString()); - doc.setTextWidth(options.rect.width()); - return QSize(doc.idealWidth(), doc.size().height() + 20); -} - - -MessagePage::MessagePage(QWidget *parent) : QWidget(parent), ui(new Ui::MessagePage), model(0), - msgdelegate(new MessageViewDelegate()), - messageTextEdit(new MRichTextEdit()) -{ - ui->setupUi(this); - -#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac - ui->deleteButton->setIcon(QIcon()); -#endif - // Context menu actions - replyAction = new QAction(ui->sendButton->text(), this); - copyFromAddressAction = new QAction(ui->copyFromAddressButton->text(), this); - copyToAddressAction = new QAction(ui->copyToAddressButton->text(), this); - deleteAction = new QAction(ui->deleteButton->text(), this); - - // Build context menu - contextMenu = new QMenu(); - - contextMenu->addAction(replyAction); - contextMenu->addAction(copyFromAddressAction); - contextMenu->addAction(copyToAddressAction); - contextMenu->addAction(deleteAction); - - connect(replyAction, SIGNAL(triggered()), this, SLOT(on_sendButton_clicked())); - connect(copyFromAddressAction, SIGNAL(triggered()), this, SLOT(on_copyFromAddressButton_clicked())); - connect(copyToAddressAction, SIGNAL(triggered()), this, SLOT(on_copyToAddressButton_clicked())); - connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteButton_clicked())); - - connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); - - // Show messages - ui->listConversation->setItemDelegate(msgdelegate); - ui->listConversation->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE)); - ui->listConversation->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2)); - ui->listConversation->setAttribute(Qt::WA_MacShowFocusRect, false); -} - -MessagePage::~MessagePage() -{ - delete ui; -} - -void MessagePage::setModel(MessageModel *model) -{ - this->model = model; - - if (!model) - return; - - model->proxyModel = new QSortFilterProxyModel(this); - model->proxyModel->setSourceModel(model); - model->proxyModel->setDynamicSortFilter(true); - model->proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); - model->proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); - model->proxyModel->sort(MessageModel::ReceivedDateTime); - model->proxyModel->setFilterRole(MessageModel::Ambiguous); - model->proxyModel->setFilterFixedString("true"); - - ui->tableView->setModel(model->proxyModel); - ui->tableView->sortByColumn(MessageModel::ReceivedDateTime, Qt::DescendingOrder); - - ui->listConversation->setModel(model->proxyModel); - ui->listConversation->setModelColumn(MessageModel::HTML); - - // Set column widths - ui->tableView->horizontalHeader()->resizeSection(MessageModel::Type, 100); - ui->tableView->horizontalHeader()->resizeSection(MessageModel::Label, 100); - ui->tableView->horizontalHeader()->setResizeMode(MessageModel::Label, QHeaderView::Stretch); - ui->tableView->horizontalHeader()->resizeSection(MessageModel::FromAddress, 320); - ui->tableView->horizontalHeader()->resizeSection(MessageModel::ToAddress, 320); - ui->tableView->horizontalHeader()->resizeSection(MessageModel::SentDateTime, 170); - ui->tableView->horizontalHeader()->resizeSection(MessageModel::ReceivedDateTime, 170); - - // TODO: Do we really need this? - // ui->messageEdit->setMinimumHeight(100); - - // Hidden columns - ui->tableView->setColumnHidden(MessageModel::Message, true); - - connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged())); - connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectionChanged())); - connect(ui->listConversation->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(itemSelectionChanged())); - connect(ui->listConversation, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(itemSelectionChanged())); - //connect(ui->messageEdit, SIGNAL(textChanged()), this, SLOT(messageTextChanged())); - - // Scroll to bottom - connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(incomingMessage())); - selectionChanged(); -} - -void MessagePage::on_sendButton_clicked() -{ - if (!model) - return; - - std::string sError; - std::string sendTo = replyToAddress.toStdString(); - std::string message = ui->messageEdit->toHtml().toStdString(); - std::string addFrom = replyFromAddress.toStdString(); - - if (SecureMsgSend(addFrom, sendTo, message, sError) != 0) - { - QMessageBox::warning(NULL, tr("Send Secure Message"), tr("Send failed: %1.").arg(sError.c_str()), - QMessageBox::Ok, QMessageBox::Ok); - - return; - } - - // ui->messageEdit->setMaximumHeight(30); - ui->messageEdit->clear(); - ui->listConversation->scrollToBottom(); -} - -void MessagePage::on_newButton_clicked() -{ - if (!model) - return; - - SendMessagesDialog dlg(SendMessagesDialog::Encrypted, SendMessagesDialog::Dialog, this); - dlg.setModel(model); - dlg.exec(); -} - -void MessagePage::on_copyFromAddressButton_clicked() -{ - GUIUtil::copyEntryData(ui->tableView, MessageModel::FromAddress, Qt::DisplayRole); -} - -void MessagePage::on_copyToAddressButton_clicked() -{ - GUIUtil::copyEntryData(ui->tableView, MessageModel::ToAddress, Qt::DisplayRole); -} - -void MessagePage::on_deleteButton_clicked() -{ - QListView *list = ui->listConversation; - - if (!list->selectionModel()) - return; - - QModelIndexList indexes = list->selectionModel()->selectedIndexes(); - - if (!indexes.isEmpty()) - { - list->model()->removeRow(indexes.at(0).row()); - indexes = list->selectionModel()->selectedIndexes(); - - if (indexes.isEmpty()) - on_backButton_clicked(); - } -} - -void MessagePage::on_backButton_clicked() -{ - model->proxyModel->setFilterRole(false); - model->proxyModel->setFilterFixedString(""); - model->resetFilter(); - model->proxyModel->setFilterRole(MessageModel::Ambiguous); - model->proxyModel->setFilterFixedString("true"); - - ui->tableView->clearSelection(); - ui->listConversation->clearSelection(); - itemSelectionChanged(); - selectionChanged(); - - ui->messageDetails->hide(); - ui->tableView->show(); - ui->newButton->setEnabled(true); - ui->newButton->setVisible(true); - ui->sendButton->setEnabled(false); - ui->sendButton->setVisible(false); - ui->messageEdit->setVisible(false); -} - -void MessagePage::selectionChanged() -{ - // Set button states based on selected tab and selection - QTableView *table = ui->tableView; - - if (!table->selectionModel()) - return; - - if (table->selectionModel()->hasSelection()) - { - replyAction->setEnabled(true); - copyFromAddressAction->setEnabled(true); - copyToAddressAction->setEnabled(true); - deleteAction->setEnabled(true); - - ui->copyFromAddressButton->setEnabled(true); - ui->copyToAddressButton->setEnabled(true); - ui->deleteButton->setEnabled(true); - - ui->newButton->setEnabled(false); - ui->newButton->setVisible(false); - ui->sendButton->setEnabled(true); - ui->sendButton->setVisible(true); - ui->messageEdit->setVisible(true); - - ui->tableView->hide(); - - // Figure out which message was selected - QModelIndexList labelColumn = table->selectionModel()->selectedRows(MessageModel::Label); - QModelIndexList addressFromColumn = table->selectionModel()->selectedRows(MessageModel::FromAddress); - QModelIndexList addressToColumn = table->selectionModel()->selectedRows(MessageModel::ToAddress); - QModelIndexList typeColumn = table->selectionModel()->selectedRows(MessageModel::Type); - - int type = -1; - - foreach (QModelIndex index, typeColumn) - type = (table->model()->data(index).toString() == MessageModel::Sent ? MessageTableEntry::Sent : - MessageTableEntry::Received); - foreach (QModelIndex index, labelColumn) - ui->contactLabel->setText(table->model()->data(index).toString()); - - foreach (QModelIndex index, addressFromColumn) - if (type == MessageTableEntry::Sent) - replyFromAddress = table->model()->data(index).toString(); - else - replyToAddress = table->model()->data(index).toString(); - - foreach (QModelIndex index, addressToColumn) - if (type == MessageTableEntry::Sent) - replyToAddress = table->model()->data(index).toString(); - else - replyFromAddress = table->model()->data(index).toString(); - - QString filter = replyToAddress + replyFromAddress; - - model->proxyModel->setFilterRole(false); - model->proxyModel->setFilterFixedString(""); - model->proxyModel->sort(MessageModel::ReceivedDateTime); - model->proxyModel->setFilterRole(MessageModel::FilterAddressRole); - model->proxyModel->setFilterFixedString(filter); - - ui->messageDetails->show(); - ui->listConversation->setCurrentIndex(model->proxyModel->index(0, 0, QModelIndex())); - } - else - { - ui->newButton->setEnabled(true); - ui->newButton->setVisible(true); - ui->sendButton->setEnabled(false); - ui->sendButton->setVisible(false); - ui->copyFromAddressButton->setEnabled(false); - ui->copyToAddressButton->setEnabled(false); - ui->deleteButton->setEnabled(false); - ui->messageEdit->hide(); - ui->messageDetails->hide(); - ui->messageEdit->clear(); - } -} - -void MessagePage::itemSelectionChanged() -{ - // Set button states based on selected tab and selection - QListView *list = ui->listConversation; - - if (!list->selectionModel()) - return; - - if (list->selectionModel()->hasSelection()) - { - replyAction->setEnabled(true); - copyFromAddressAction->setEnabled(true); - copyToAddressAction->setEnabled(true); - deleteAction->setEnabled(true); - - ui->copyFromAddressButton->setEnabled(true); - ui->copyToAddressButton->setEnabled(true); - ui->deleteButton->setEnabled(true); - ui->newButton->setEnabled(false); - ui->newButton->setVisible(false); - ui->sendButton->setEnabled(true); - ui->sendButton->setVisible(true); - ui->messageEdit->setVisible(true); - ui->tableView->hide(); - } - else - { - ui->newButton->setEnabled(true); - ui->newButton->setVisible(true); - ui->sendButton->setEnabled(false); - ui->sendButton->setVisible(false); - ui->copyFromAddressButton->setEnabled(false); - ui->copyToAddressButton->setEnabled(false); - ui->deleteButton->setEnabled(false); - ui->messageEdit->hide(); - ui->messageDetails->hide(); - ui->messageEdit->clear(); - } -} - -void MessagePage::incomingMessage() -{ - ui->listConversation->scrollToBottom(); -} - -void MessagePage::messageTextChanged() -{ - /* - if (ui->messageEdit->toPlainText().endsWith("\n")) - { - ui->messageEdit->setMaximumHeight(80); - ui->messageEdit->resize(256, ui->messageEdit->document()->size().height() + 10); - } - */ -} - -void MessagePage::exportClicked() -{ - // CSV is currently the only supported format - QString filename = GUIUtil::getSaveFileName(this, tr("Export Messages"), QString(), - tr("Comma separated file (*.csv)")); - if (filename.isNull()) - return; - - CSVModelWriter writer(filename); - - // name, column, role - writer.setModel(model->proxyModel); - writer.addColumn("Type", MessageModel::Type, Qt::DisplayRole); - writer.addColumn("Label", MessageModel::Label, Qt::DisplayRole); - writer.addColumn("FromAddress", MessageModel::FromAddress, Qt::DisplayRole); - writer.addColumn("ToAddress", MessageModel::ToAddress, Qt::DisplayRole); - writer.addColumn("SentDateTime", MessageModel::SentDateTime, Qt::DisplayRole); - writer.addColumn("ReceivedDateTime", MessageModel::ReceivedDateTime, Qt::DisplayRole); - writer.addColumn("Message", MessageModel::Message, Qt::DisplayRole); - - if (!writer.write()) - QMessageBox::critical(this, tr("Error exporting"), tr("Could not write to file %1.").arg(filename), - QMessageBox::Abort, QMessageBox::Abort); -} - -void MessagePage::contextualMenu(const QPoint &point) -{ - QModelIndex index = ui->tableView->indexAt(point); - - if (index.isValid()) - contextMenu->exec(QCursor::pos()); -} From 1f886616987472f3b44b868a2c8aa21cc4d273ab Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:22:57 -0400 Subject: [PATCH 281/469] Delete messagepage.h --- src/qt/messagepage.h | 73 -------------------------------------------- 1 file changed, 73 deletions(-) delete mode 100644 src/qt/messagepage.h diff --git a/src/qt/messagepage.h b/src/qt/messagepage.h deleted file mode 100644 index d8553a8d..00000000 --- a/src/qt/messagepage.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2017-2018 The Swipp developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef MESSAGEPAGE_H -#define MESSAGEPAGE_H - -#include - -namespace Ui -{ - class MessagePage; -} - -class MessageModel; - -QT_BEGIN_NAMESPACE -class QTableView; -class QItemSelection; -class QSortFilterProxyModel; -class QMenu; -class QModelIndex; -class MessageViewDelegate; -class MRichTextEdit; -QT_END_NAMESPACE - -class MessagePage : public QWidget -{ - Q_OBJECT - -public: - explicit MessagePage(QWidget *parent = 0); - ~MessagePage(); - - void setModel(MessageModel *model); - -private: - void setupTextActions(); - -public Q_SLOTS: - void exportClicked(); - -private: - Ui::MessagePage *ui; - MessageModel *model; - - QMenu *contextMenu; - QAction *replyAction; - QAction *copyFromAddressAction; - QAction *copyToAddressAction; - QAction *deleteAction; - QString replyFromAddress; - QString replyToAddress; - MessageViewDelegate *msgdelegate; - MRichTextEdit *messageTextEdit; - -private Q_SLOTS: - void on_sendButton_clicked(); - void on_newButton_clicked(); - void on_copyFromAddressButton_clicked(); - void on_copyToAddressButton_clicked(); - void on_deleteButton_clicked(); - void on_backButton_clicked(); - void messageTextChanged(); - void selectionChanged(); - void itemSelectionChanged(); - void incomingMessage(); - - // Spawn contextual menu (right mouse menu) for address book entry - void contextualMenu(const QPoint &point); -}; - -#endif // MESSAGEPAGE_H From b4c9cdca1f39c9556343ab207fe879132fec44f5 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:23:11 -0400 Subject: [PATCH 282/469] Delete qvalidatedtextedit.cpp --- src/qt/qvalidatedtextedit.cpp | 44 ----------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 src/qt/qvalidatedtextedit.cpp diff --git a/src/qt/qvalidatedtextedit.cpp b/src/qt/qvalidatedtextedit.cpp deleted file mode 100644 index c0cb83ba..00000000 --- a/src/qt/qvalidatedtextedit.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "qvalidatedtextedit.h" - -#include "guiconstants.h" - -#include -QValidatedTextEdit::QValidatedTextEdit(QWidget *parent) : - QPlainTextEdit(parent), valid(true) -{} - -void QValidatedTextEdit::setValid(bool valid) -{ - setStyleSheet(valid ? "" : STYLE_INVALID); - - if(valid) - { - if(toPlainText() == this->errorText) - setPlainText(""); - } - else if(toPlainText() == "") - setPlainText(this->errorText); -} - -void QValidatedTextEdit::setErrorText(QString errorText) -{ - this->errorText = errorText; -} - -void QValidatedTextEdit::focusInEvent(QFocusEvent *evt) -{ - // Clear invalid flag on focus - setValid(true); - QPlainTextEdit::focusInEvent(evt); -} - -void QValidatedTextEdit::markValid() -{ - setValid(true); -} - -void QValidatedTextEdit::clear() -{ - setValid(true); - QPlainTextEdit::clear(); -} From ab6bf579bc720dc8d391882861417c4b519f4de4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:23:24 -0400 Subject: [PATCH 283/469] Delete qvalidatedtextedit.h --- src/qt/qvalidatedtextedit.h | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 src/qt/qvalidatedtextedit.h diff --git a/src/qt/qvalidatedtextedit.h b/src/qt/qvalidatedtextedit.h deleted file mode 100644 index f1039e5c..00000000 --- a/src/qt/qvalidatedtextedit.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef QVALIDATEDTEXTEDIT_H -#define QVALIDATEDTEXTEDIT_H - -#include - -/** Text edit that can be marked as "invalid" to show input validation feedback. When marked as invalid, - it will get a red background until it is focused. - */ -class QValidatedTextEdit : public QPlainTextEdit -{ - Q_OBJECT -public: - explicit QValidatedTextEdit(QWidget *parent = 0); - void clear(); - -protected: - void focusInEvent(QFocusEvent *evt); - -private: - bool valid; - QString errorText; - -public slots: - void setValid(bool valid); - void setErrorText(QString errorText); - -private slots: - void markValid(); -}; - -#endif // QVALIDATEDTEXTEDIT_H From 6f271a2608464e565ccf09a7b990b8d57eff3799 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:23:35 -0400 Subject: [PATCH 284/469] Delete sendmessagesdialog.cpp --- src/qt/sendmessagesdialog.cpp | 339 ---------------------------------- 1 file changed, 339 deletions(-) delete mode 100644 src/qt/sendmessagesdialog.cpp diff --git a/src/qt/sendmessagesdialog.cpp b/src/qt/sendmessagesdialog.cpp deleted file mode 100644 index 6c043756..00000000 --- a/src/qt/sendmessagesdialog.cpp +++ /dev/null @@ -1,339 +0,0 @@ -#include "sendmessagesdialog.h" -#include "ui_sendmessagesdialog.h" -//#include "init.h" -#include "walletmodel.h" -#include "messagemodel.h" -#include "addressbookpage.h" -#include "optionsmodel.h" -#include "sendmessagesentry.h" -//#include "guiutil.h" - -#include -#include -#include -#include -#include -#include - -SendMessagesDialog::SendMessagesDialog(Mode mode, Type type, QWidget *parent) : - QDialog(parent), - ui(new Ui::SendMessagesDialog), - model(0), - mode(mode), - type(type) -{ - - ui->setupUi(this); - -#ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac - ui->addButton->setIcon(QIcon()); - ui->clearButton->setIcon(QIcon()); - ui->sendButton->setIcon(QIcon()); -#endif - -#if QT_VERSION >= 0x040700 - /* Do not move this to the XML file, Qt before 4.7 will choke on it */ - if(mode == SendMessagesDialog::Encrypted) - ui->addressFrom->setPlaceholderText(tr("Enter a Swipp address (e.g. CKPnZKDzaDXqEgKJ4GdUg58gXxgzA7mkny)")); - #endif - addEntry(); - - connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry())); - connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); - connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(reject())); - - fNewRecipientAllowed = true; - - if(mode == SendMessagesDialog::Anonymous) - ui->frameAddressFrom->hide(); - - if(type == SendMessagesDialog::Page) - ui->closeButton->hide(); -} - -void SendMessagesDialog::setModel(MessageModel *model) -{ - this->model = model; - - for(int i = 0; i < ui->entries->count(); ++i) - { - SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); - - if(entry) - entry->setModel(model); - } -} - -void SendMessagesDialog::loadRow(int row) -{ - if(model->data(model->index(row, model->Type, QModelIndex()), Qt::DisplayRole).toString() == MessageModel::Received) - ui->addressFrom->setText(model->data(model->index(row, model->ToAddress, QModelIndex()), Qt::DisplayRole).toString()); - else - ui->addressFrom->setText(model->data(model->index(row, model->FromAddress, QModelIndex()), Qt::DisplayRole).toString()); - - for(int i = 0; i < ui->entries->count(); ++i) - { - SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); - - if(entry) - entry->loadRow(row); - } -} - -bool SendMessagesDialog::checkMode(Mode mode) -{ - return (mode == this->mode); -} - -bool SendMessagesDialog::validate() -{ - if(mode == SendMessagesDialog::Encrypted && ui->addressFrom->text() == "") - { - ui->addressFrom->setValid(false); - - return false; - } - - return true; -} - -SendMessagesDialog::~SendMessagesDialog() -{ - delete ui; -} - -void SendMessagesDialog::on_pasteButton_clicked() -{ - // Paste text from clipboard into recipient field - ui->addressFrom->setText(QApplication::clipboard()->text()); -} - -void SendMessagesDialog::on_addressBookButton_clicked() -{ - if(!model) - return; - - AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::ReceivingTab, this); - - dlg.setModel(model->getWalletModel()->getAddressTableModel()); - - if(dlg.exec()) - { - ui->addressFrom->setText(dlg.getReturnValue()); - SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(0)->widget()); - entry->setFocus(); - // findChild( const QString "sentTo")->setFocus(); - } -} - -void SendMessagesDialog::on_sendButton_clicked() -{ - QList recipients; - bool valid = true; - - if(!model) - return; - - valid = validate(); - - for(int i = 0; i < ui->entries->count(); ++i) - { - SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); - if(entry) - { - if(entry->validate()) - recipients.append(entry->getValue()); - else - valid = false; - } - } - - if(!valid || recipients.isEmpty()) - return; - - // Format confirmation message - QStringList formatted; - foreach(const SendMessagesRecipient &rcp, recipients) - { - formatted.append(tr("%1 to %2 (%3)").arg(rcp.message, Qt::escape(rcp.label), rcp.address)); - } - - fNewRecipientAllowed = false; - - QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send messages"), - tr("Are you sure you want to send %1?").arg(formatted.join(tr(" and "))), - QMessageBox::Yes|QMessageBox::Cancel, - QMessageBox::Cancel); - - if(retval != QMessageBox::Yes) - { - fNewRecipientAllowed = true; - return; - } - - MessageModel::StatusCode sendstatus; - - if(mode == SendMessagesDialog::Anonymous) - sendstatus = model->sendMessages(recipients); - else - sendstatus = model->sendMessages(recipients, ui->addressFrom->text()); - - switch(sendstatus) - { - case MessageModel::InvalidAddress: - QMessageBox::warning(this, tr("Send Message"), - tr("The recipient address is not valid, please recheck."), - QMessageBox::Ok, QMessageBox::Ok); - break; - case MessageModel::InvalidMessage: - QMessageBox::warning(this, tr("Send Message"), - tr("The message can't be empty."), - QMessageBox::Ok, QMessageBox::Ok); - break; - case MessageModel::DuplicateAddress: - QMessageBox::warning(this, tr("Send Message"), - tr("Duplicate address found, can only send to each address once per send operation."), - QMessageBox::Ok, QMessageBox::Ok); - break; - case MessageModel::MessageCreationFailed: - QMessageBox::warning(this, tr("Send Message"), - tr("Error: Message creation failed."), - QMessageBox::Ok, QMessageBox::Ok); - break; - case MessageModel::MessageCommitFailed: - QMessageBox::warning(this, tr("Send Message"), - tr("Error: The message was rejected."), - QMessageBox::Ok, QMessageBox::Ok); - break; - case MessageModel::Aborted: // User aborted, nothing to do - break; - case MessageModel::FailedErrorShown: // Send failed, error message was displayed - break; - case MessageModel::OK: - accept(); - break; - } - - fNewRecipientAllowed = true; -} - -void SendMessagesDialog::clear() -{ - // Remove entries until only one left - while(ui->entries->count()) - delete ui->entries->takeAt(0)->widget(); - - addEntry(); - - updateRemoveEnabled(); - - ui->sendButton->setDefault(true); -} - -void SendMessagesDialog::reject() -{ - if(type == SendMessagesDialog::Dialog) - done(1); - else - clear(); -} - -void SendMessagesDialog::accept() -{ - if(type == SendMessagesDialog::Dialog) - done(0); - else - clear(); - -} - -void SendMessagesDialog::done(int retval) -{ - if(type == SendMessagesDialog::Dialog) - QDialog::done(retval); - else - clear(); -} - -SendMessagesEntry *SendMessagesDialog::addEntry() -{ - SendMessagesEntry *entry = new SendMessagesEntry(this); - - entry->setModel(model); - ui->entries->addWidget(entry); - connect(entry, SIGNAL(removeEntry(SendMessagesEntry*)), this, SLOT(removeEntry(SendMessagesEntry*))); - updateRemoveEnabled(); - - // Focus the field, so that entry can start immediately - entry->clear(); - entry->setFocus(); - - ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); - QCoreApplication::instance()->processEvents(); - QScrollBar* bar = ui->scrollArea->verticalScrollBar(); - - if(bar) - bar->setSliderPosition(bar->maximum()); - - return entry; -} - -void SendMessagesDialog::updateRemoveEnabled() -{ - // Remove buttons are enabled as soon as there is more than one send-entry - bool enabled = (ui->entries->count() > 1); - - for(int i = 0; i < ui->entries->count(); ++i) - { - SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); - if(entry) - entry->setRemoveEnabled(enabled); - } - - setupTabChain(0); -} - -void SendMessagesDialog::removeEntry(SendMessagesEntry* entry) -{ - delete entry; - - updateRemoveEnabled(); -} - -QWidget *SendMessagesDialog::setupTabChain(QWidget *prev) -{ - for(int i = 0; i < ui->entries->count(); ++i) - { - SendMessagesEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); - if(entry) - { - prev = entry->setupTabChain(prev); - } - } - - QWidget::setTabOrder(prev, ui->addButton); - QWidget::setTabOrder(ui->addButton, ui->sendButton); - - return ui->sendButton; -} - -void SendMessagesDialog::pasteEntry(const SendMessagesRecipient &rv) -{ - if(!fNewRecipientAllowed) - return; - - SendMessagesEntry *entry = 0; - // Replace the first entry if it is still unused - if(ui->entries->count() == 1) - { - SendMessagesEntry *first = qobject_cast(ui->entries->itemAt(0)->widget()); - - if(first->isClear()) - entry = first; - } - - if(!entry) - entry = addEntry(); - - entry->setValue(rv); -} From 95e0a3abb49679009177e177bf6585813a2c4d29 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:23:43 -0400 Subject: [PATCH 285/469] Delete sendmessagesdialog.h --- src/qt/sendmessagesdialog.h | 72 ------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 src/qt/sendmessagesdialog.h diff --git a/src/qt/sendmessagesdialog.h b/src/qt/sendmessagesdialog.h deleted file mode 100644 index fe48e838..00000000 --- a/src/qt/sendmessagesdialog.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef SENDMESSAGESDIALOG_H -#define SENDMESSAGESDIALOG_H - -#include -#include - -namespace Ui { - class SendMessagesDialog; -} - -class MessageModel; -class SendMessagesEntry; -class SendMessagesRecipient; - -//QT_BEGIN_NAMESPACE -//class QUrl; -//QT_END_NAMESPACE - -/** Dialog for sending messages */ -class SendMessagesDialog : public QDialog -{ - Q_OBJECT - -public: - - enum Mode { - Encrypted, - Anonymous, - }; - - enum Type { - Page, - Dialog, - }; - - explicit SendMessagesDialog(Mode mode, Type type, QWidget *parent = 0); - ~SendMessagesDialog(); - - void setModel (MessageModel *model); - void loadRow(int row); - bool checkMode(Mode mode); - bool validate (); - - /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). - */ - QWidget *setupTabChain(QWidget *prev); - - void pasteEntry(const SendMessagesRecipient &rv); - -public Q_SLOTS: - void done(int retval); - void clear(); - void reject(); - void accept(); - SendMessagesEntry *addEntry(); - void updateRemoveEnabled(); - -private: - Ui::SendMessagesDialog *ui; - MessageModel *model; - bool fNewRecipientAllowed; - Mode mode; - Type type; - -private Q_SLOTS: - void on_sendButton_clicked(); - void removeEntry(SendMessagesEntry* entry); - void on_addressBookButton_clicked(); - void on_pasteButton_clicked(); -}; - -#endif // SENDMESSAGESDIALOG_H From 893ac42bfef6ca5bb315fc989f914f16433abbef Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:23:51 -0400 Subject: [PATCH 286/469] Delete sendmessagesentry.cpp --- src/qt/sendmessagesentry.cpp | 204 ----------------------------------- 1 file changed, 204 deletions(-) delete mode 100644 src/qt/sendmessagesentry.cpp diff --git a/src/qt/sendmessagesentry.cpp b/src/qt/sendmessagesentry.cpp deleted file mode 100644 index ab0d92aa..00000000 --- a/src/qt/sendmessagesentry.cpp +++ /dev/null @@ -1,204 +0,0 @@ -#include "sendmessagesentry.h" -#include "ui_sendmessagesentry.h" -#include "guiutil.h" -#include "addressbookpage.h" -#include "walletmodel.h" -#include "messagemodel.h" -#include "optionsmodel.h" -#include "addresstablemodel.h" - -#include "smessage.h" - -#include -#include - -SendMessagesEntry::SendMessagesEntry(QWidget *parent) : - QFrame(parent), - ui(new Ui::SendMessagesEntry), - model(0) -{ - ui->setupUi(this); - -#ifdef Q_OS_MAC - ui->sendToLayout->setSpacing(4); -#endif -#if QT_VERSION >= 0x040700 - /* Do not move this to the XML file, Qt before 4.7 will choke on it */ - ui->addAsLabel->setPlaceholderText(tr("Enter a label for this address to add it to your address book")); - ui->sendTo->setPlaceholderText(tr("Enter a Swipp address (e.g. CKPnZKDzaDXqEgKJ4GdUg58gXxgzA7mkny)")); - ui->publicKey->setPlaceholderText(tr("Enter the public key for the address above, it is not in the blockchain")); - ui->messageText->setErrorText(tr("You cannot send a blank message!")); -#endif - setFocusPolicy(Qt::TabFocus); - setFocusProxy(ui->sendTo); - - GUIUtil::setupAddressWidget(ui->sendTo, this); -} - -SendMessagesEntry::~SendMessagesEntry() -{ - delete ui; -} - -void SendMessagesEntry::on_pasteButton_clicked() -{ - // Paste text from clipboard into recipient field - ui->sendTo->setText(QApplication::clipboard()->text()); -} - -void SendMessagesEntry::on_addressBookButton_clicked() -{ - if(!model) - return; - - AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab, this); - - dlg.setModel(model->getWalletModel()->getAddressTableModel()); - - if(dlg.exec()) - { - - ui->sendTo->setText(dlg.getReturnValue()); - - if(ui->publicKey->text() == "") - ui->publicKey->setFocus(); - else - ui->messageText->setFocus(); - } -} - -void SendMessagesEntry::on_sendTo_textChanged(const QString &address) -{ - if(!model) - return; - - QString pubkey; - QString sendTo = address; - - if(model->getAddressOrPubkey(sendTo, pubkey)) - { - - ui->publicKey->setText(pubkey); - } - else - { - ui->publicKey->show(); - ui->publicKeyLabel->show(); - } - - // Fill in label from address book, if address has an associated label - QString associatedLabel = model->getWalletModel()->getAddressTableModel()->labelForAddress(address); - - if(!associatedLabel.isEmpty()) - ui->addAsLabel->setText(associatedLabel); -} - -void SendMessagesEntry::setModel(MessageModel *model) -{ - - this->model = model; - - //clear(); -} - -void SendMessagesEntry::loadRow(int row) -{ - if(model->data(model->index(row, model->Type, QModelIndex()), Qt::DisplayRole).toString() == MessageModel::Received) - ui->sendTo->setText(model->data(model->index(row, model->FromAddress, QModelIndex()), Qt::DisplayRole).toString()); - else - ui->sendTo->setText(model->data(model->index(row, model->ToAddress, QModelIndex()), Qt::DisplayRole).toString()); -} - -void SendMessagesEntry::setRemoveEnabled(bool enabled) -{ - ui->deleteButton->setEnabled(enabled); -} - -void SendMessagesEntry::clear() -{ - ui->sendTo->clear(); - ui->addAsLabel->clear(); - ui->messageText->clear(); - ui->sendTo->setFocus(); -} - -void SendMessagesEntry::on_deleteButton_clicked() -{ - emit removeEntry(this); -} - - -bool SendMessagesEntry::validate() -{ - // Check input validity - bool retval = true; - - if(ui->messageText->toPlainText() == "") - { - ui->messageText->setValid(false); - - retval = false; - } - - if(!ui->sendTo->hasAcceptableInput() || (!model->getWalletModel()->validateAddress(ui->sendTo->text()))) - { - ui->sendTo->setValid(false); - - retval = false; - } - - if(ui->publicKey->text() == "") - { - ui->publicKey->setValid(false); - ui->publicKey->show(); - - retval = false; - } - - return retval; -} - -SendMessagesRecipient SendMessagesEntry::getValue() -{ - SendMessagesRecipient rv; - - rv.address = ui->sendTo->text(); - rv.label = ui->addAsLabel->text(); - rv.pubkey = ui->publicKey->text(); - rv.message = ui->messageText->toPlainText(); - - return rv; -} - - -QWidget *SendMessagesEntry::setupTabChain(QWidget *prev) -{ - QWidget::setTabOrder(prev, ui->sendTo); - QWidget::setTabOrder(ui->sendTo, ui->addressBookButton); - QWidget::setTabOrder(ui->addressBookButton, ui->pasteButton); - QWidget::setTabOrder(ui->pasteButton, ui->deleteButton); - QWidget::setTabOrder(ui->deleteButton, ui->addAsLabel); - QWidget::setTabOrder(ui->addAsLabel, ui->publicKey); - QWidget::setTabOrder(ui->publicKey, ui->messageText); - - return ui->messageText; - -} - -void SendMessagesEntry::setValue(const SendMessagesRecipient &value) -{ - ui->sendTo->setText(value.address); - ui->addAsLabel->setText(value.label); - ui->publicKey->setText(value.pubkey); - ui->messageText->setPlainText(value.message); -} - -bool SendMessagesEntry::isClear() -{ - return ui->sendTo->text().isEmpty(); -} - -void SendMessagesEntry::setFocus() -{ - ui->sendTo->setFocus(); -} From 10bac8b5a735c4cfadf882ec8d9be9a198f62b38 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:23:59 -0400 Subject: [PATCH 287/469] Delete sendmessagesentry.h --- src/qt/sendmessagesentry.h | 55 -------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 src/qt/sendmessagesentry.h diff --git a/src/qt/sendmessagesentry.h b/src/qt/sendmessagesentry.h deleted file mode 100644 index 16f76d9d..00000000 --- a/src/qt/sendmessagesentry.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef SENDMESSAGESENTRY_H -#define SENDMESSAGESENTRY_H - -#include - -namespace Ui { - class SendMessagesEntry; -} -class MessageModel; -class SendMessagesRecipient; - -/** A single entry in the dialog for sending messages. */ -class SendMessagesEntry : public QFrame -{ - Q_OBJECT - -public: - explicit SendMessagesEntry(QWidget *parent = 0); - ~SendMessagesEntry(); - - void setModel(MessageModel *model); - void loadRow(int row); - bool validate(); - SendMessagesRecipient getValue(); - - /** Return whether the entry is still empty and unedited */ - bool isClear(); - - void setValue(const SendMessagesRecipient &value); - - /** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907). - */ - QWidget *setupTabChain(QWidget *prev); - - void setFocus(); - -public Q_SLOTS: - void setRemoveEnabled(bool enabled); - void clear(); - -signals: - void removeEntry(SendMessagesEntry *entry); - -private Q_SLOTS: - void on_deleteButton_clicked(); - void on_addressBookButton_clicked(); - void on_pasteButton_clicked(); - void on_sendTo_textChanged(const QString &address); - -private: - Ui::SendMessagesEntry *ui; - MessageModel *model; -}; - -#endif // SENDMESSAGESENTRY_H From 9b08ef13c71142d5959dcb7e063edb271be6b835 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:25:28 -0400 Subject: [PATCH 288/469] Update bitcoingui.h --- src/qt/bitcoingui.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 2c746a67..b3ad8e51 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -38,8 +38,6 @@ class HelpMessageDialog; class ModalOverlay; class QNetworkAccessManager; class QNetworkRequest; -class MessagePage; -class MessageModel; class CWallet; @@ -70,7 +68,6 @@ class BitcoinGUI : public QMainWindow The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic. */ void setClientModel(ClientModel *clientModel); - void setMessageModel(MessageModel *messageModel); #ifdef ENABLE_WALLET /** Set the wallet model. @@ -94,7 +91,6 @@ class BitcoinGUI : public QMainWindow private: ClientModel *clientModel; WalletFrame *walletFrame; - MessageModel *messageModel; UnitDisplayStatusBarControl *unitDisplayControl; QLabel *labelWalletEncryptionIcon; QLabel *labelWalletHDStatusIcon; @@ -103,14 +99,12 @@ class BitcoinGUI : public QMainWindow QLabel *progressBarLabel; QProgressBar *progressBar; QProgressDialog *progressDialog; - MessagePage *messagePage; + QMenuBar *appMenuBar; - QAction *chatAction; QAction* externalDonate; QAction *governanceAction; /* QAction* privatesendAction; */ - QAction *messageAction; QAction *overviewAction; QAction *historyAction; QAction *masternodeAction; @@ -211,7 +205,6 @@ public Q_SLOTS: @see CClientUIInterface::MessageBoxFlags @param[in] ret pointer to a bool that will be modified to whether Ok was clicked (modal only) */ - void message(const QString &title, const QString &message, unsigned int style, bool *ret = NULL); #ifdef ENABLE_WALLET /** Set the hd-enabled status as shown in the UI. @@ -235,8 +228,7 @@ public Q_SLOTS: private Q_SLOTS: #ifdef ENABLE_WALLET - - void gotoMessagePage(); + /** Switch to masternode page */ void gotoGovernancePage(); /** Switch to private send page */ @@ -256,7 +248,7 @@ private Q_SLOTS: void gotoSignMessageTab(QString addr = ""); /** Show Sign/Verify Message dialog and switch to verify message tab */ void gotoVerifyMessageTab(QString addr = ""); - void incomingMessage(const QModelIndex & parent, int start, int end); + /** Show open dialog */ void openClicked(); From 147b57ce16eba8b1c1f49a5dfc28939d392db081 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:27:49 -0400 Subject: [PATCH 289/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 110 +----------------------------------------- 1 file changed, 1 insertion(+), 109 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 146b7cdb..46e6cfad 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -22,8 +22,6 @@ #include "platformstyle.h" #include "rpcconsole.h" #include "utilitydialog.h" -#include "messagemodel.h" -#include "messagepage.h" #ifdef ENABLE_WALLET #include "privatesend-client.h" @@ -495,16 +493,7 @@ void BitcoinGUI::createActions() connect(governanceAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(governanceAction, SIGNAL(triggered()), this, SLOT(gotoGovernancePage())); - messageAction = new QAction(QIcon(":/icons/chat"), tr("&Messages"), this); - messageAction->setStatusTip(tr("View and Send Encrypted messages")); - messageAction->setToolTip(messageAction->statusTip()); - messageAction->setCheckable(true); - tabGroup->addAction(messageAction); - connect(messageAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); - connect(messageAction, SIGNAL(triggered()), this, SLOT(gotoMessagePage())); - - - } +} /* privatesendAction = new QAction(QIcon(":/icons/coinmix"), tr("&Private Send"), this); privatesendAction->setStatusTip(tr("Show Private Send of wallet")); @@ -737,7 +726,6 @@ void BitcoinGUI::createToolBars() toolbar->addAction(sendCoinsAction); toolbar->addAction(receiveCoinsAction); toolbar->addAction(historyAction); - toolbar->addAction(messageAction); /* toolbar->addAction(privatesendAction); */ @@ -804,11 +792,6 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel) connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, SLOT(setNetworkActive(bool))); - // Receive and report messages from network/worker thread - connect(clientModel, SIGNAL(message(QString,QString,bool,unsigned int)), this, SLOT(message(QString,QString,bool,unsigned int))); - // Receive and report messages from wallet thread - connect(walletModel, SIGNAL(message(QString,QString,bool,unsigned int)), this, SLOT(message(QString,QString,bool,unsigned int))); - modalOverlay->setKnownBestHeight(_clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(_clientModel->getHeaderTipTime())); setNumBlocks(_clientModel->getNumBlocks(), _clientModel->getLastBlockDate(), _clientModel->getVerificationProgress(NULL), false); connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,double,bool))); @@ -905,7 +888,6 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled) masternodeAction->setEnabled(enabled); } governanceAction->setEnabled(enabled); - messageAction->setEnabled(enabled); encryptWalletAction->setEnabled(enabled); backupWalletAction->setEnabled(enabled); changePassphraseAction->setEnabled(enabled); @@ -1072,96 +1054,6 @@ void BitcoinGUI::setMessageModel(MessageModel *messageModel) } } -void BitcoinGUI::message(const QString &title, const QString &message, bool modal, unsigned int style) -{ - QString strTitle = tr("HTH") + " - "; - // Default to information icon - int nMBoxIcon = QMessageBox::Information; - int nNotifyIcon = Notificator::Information; - - // Check for usage of predefined title - switch (style) { - case CClientUIInterface::MSG_ERROR: - strTitle += tr("Error"); - break; - case CClientUIInterface::MSG_WARNING: - strTitle += tr("Warning"); - break; - case CClientUIInterface::MSG_INFORMATION: - strTitle += tr("Information"); - break; - default: - strTitle += title; // Use supplied title - } - - // Check for error/warning icon - if (style & CClientUIInterface::ICON_ERROR) { - nMBoxIcon = QMessageBox::Critical; - nNotifyIcon = Notificator::Critical; - } - else if (style & CClientUIInterface::ICON_WARNING) { - nMBoxIcon = QMessageBox::Warning; - nNotifyIcon = Notificator::Warning; - } - - // Display message - if (modal) { - // Check for buttons, use OK as default, if none was supplied - QMessageBox::StandardButton buttons; - if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK))) - buttons = QMessageBox::Ok; - - QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons); - mBox.exec(); - } - else - notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message); -} - - - - -void BitcoinGUI::incomingMessage(const QModelIndex & parent, int start, int end) -{ - if(!messageModel) - return; - - MessageModel *mm = messageModel; - - if (mm->index(start, MessageModel::TypeInt, parent).data().toInt() == MessageTableEntry::Received) - { - QString sent_datetime = mm->index(start, MessageModel::ReceivedDateTime, parent).data().toString(); - QString from_address = mm->index(start, MessageModel::FromAddress, parent).data().toString(); - QString to_address = mm->index(start, MessageModel::ToAddress, parent).data().toString(); - QString message = mm->index(start, MessageModel::Message, parent).data().toString(); - QTextDocument html; - html.setHtml(message); - QString messageText(html.toPlainText()); - notificator->notify(Notificator::Information, - tr("Incoming Message"), - tr("Date: %1\n" - "From Address: %2\n" - "To Address: %3\n" - "Message: %4\n") - .arg(sent_datetime) - .arg(from_address) - .arg(to_address) - .arg(messageText)); - }; -} - - - -void BitcoinGUI::gotoMessagePage() -{ - messageAction->setChecked(true); - centralStackedWidget->setCurrentWidget(messagePage); - - exportAction->setEnabled(true); - disconnect(exportAction, SIGNAL(triggered()), 0, 0); - connect(exportAction, SIGNAL(triggered()), messagePage, SLOT(exportClicked())); -} - void BitcoinGUI::openDonate() { openExternalURL("https://helpthehomelessworldwide.org/donate"); From da6f84008a99c777e36cdeaddea836995b7b8c10 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:28:03 -0400 Subject: [PATCH 290/469] Delete rangeslider.h --- src/qt/plugins/rangeslider/rangeslider.h | 68 ------------------------ 1 file changed, 68 deletions(-) delete mode 100644 src/qt/plugins/rangeslider/rangeslider.h diff --git a/src/qt/plugins/rangeslider/rangeslider.h b/src/qt/plugins/rangeslider/rangeslider.h deleted file mode 100644 index dbcd6c2f..00000000 --- a/src/qt/plugins/rangeslider/rangeslider.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2012 The Bitcoin developers -// Copyright (c) 2017-2018 The Swipp developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#pragma once - -#include -#include -#include - -class RangeSlider : public QWidget -{ - Q_OBJECT - -public: - RangeSlider(QWidget* aParent = Q_NULLPTR); - - QSize minimumSizeHint() const override; - - int GetMinimun() const; - int GetMaximun() const; - int GetLowerValue() const; - int GetUpperValue() const; - - void setRange(int aMinimum, int aMaximum); - -protected: - void paintEvent(QPaintEvent* aEvent) override; - void mousePressEvent(QMouseEvent* aEvent) override; - void mouseMoveEvent(QMouseEvent* aEvent) override; - void mouseReleaseEvent(QMouseEvent* aEvent) override; - void changeEvent(QEvent* aEvent) override; - - QRectF firstHandleRect() const; - QRectF secondHandleRect() const; - QRectF handleRect(int aValue) const; - -signals: - void lowerValueChanged(int aLowerValue); - void upperValueChanged(int aUpperValue); - void valueChanged(int aLowerValue, int aUpperValue); - void rangeChanged(int aMin, int aMax); - -public slots: - void setLowerValue(int aLowerValue, bool fireEvent = true); - void setUpperValue(int aUpperValue, bool fireEvent = true); - void setMinimum(int aMinimum); - void setMaximum(int aMaximum); - -private: - Q_DISABLE_COPY(RangeSlider) - float currentPercentage(); - int validWidth() const; - - int mMinimum; - int mMaximum; - int mLowerValue; - int mUpperValue; - bool mFirstHandlePressed; - bool mSecondHandlePressed; - int mInterval; - int mDelta; - QColor mBackgroudColorEnabled; - QColor mBackgroudColorDisabled; - QColor mBackgroudColor; -}; From 983cff51005b934ab8ff9a70baa89c53c7248fcc Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:28:08 -0400 Subject: [PATCH 291/469] Delete rangeslider.cpp --- src/qt/plugins/rangeslider/rangeslider.cpp | 312 --------------------- 1 file changed, 312 deletions(-) delete mode 100644 src/qt/plugins/rangeslider/rangeslider.cpp diff --git a/src/qt/plugins/rangeslider/rangeslider.cpp b/src/qt/plugins/rangeslider/rangeslider.cpp deleted file mode 100644 index 59a9819c..00000000 --- a/src/qt/plugins/rangeslider/rangeslider.cpp +++ /dev/null @@ -1,312 +0,0 @@ -// Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2012 The Bitcoin developers -// Copyright (c) 2017-2018 The Swipp developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include - -#include "rangeslider.h" - -namespace -{ - const int scHandleSideLength = 15; - const int scSliderBarHeight = 5; - const int scLeftRightMargin = 1; -} - -RangeSlider::RangeSlider(QWidget* aParent) : QWidget(aParent), mMinimum(0), mMaximum(100), - mLowerValue(0), mUpperValue(100), - mFirstHandlePressed(false), mSecondHandlePressed(false), - mInterval(mMaximum - mMinimum), - mBackgroudColorEnabled(QApplication::palette().color(QPalette::Highlight)), - mBackgroudColorDisabled(QApplication::palette().color(QPalette::Dark)), - mBackgroudColor(mBackgroudColorEnabled) -{ - setMouseTracking(true); -} - -void RangeSlider::paintEvent(QPaintEvent* aEvent) -{ - Q_UNUSED(aEvent); - QPainter painter(this); - - // Background - QRectF backgroundRect = QRectF(scLeftRightMargin, (height() - scSliderBarHeight) / 2, width() - scLeftRightMargin * 2, scSliderBarHeight); - QPen pen(QApplication::palette().color(QPalette::Dark), 0.8); - painter.setPen(pen); - painter.setRenderHint(QPainter::Qt4CompatiblePainting); - QBrush backgroundBrush(QApplication::palette().color(QPalette::Mid)); - painter.setBrush(backgroundBrush); - painter.drawRoundedRect(backgroundRect, 1, 1); - - // First value handle rect - pen.setColor(QApplication::palette().color(QPalette::Dark)); - pen.setWidth(0.4); - painter.setPen(pen); - painter.setRenderHint(QPainter::Antialiasing); - QBrush handleBrush(QApplication::palette().color(QPalette::Light)); - painter.setBrush(handleBrush); - QRectF leftHandleRect = firstHandleRect(); - painter.drawRoundedRect(leftHandleRect, 6, 6); - - // Second value handle rect - QRectF rightHandleRect = secondHandleRect(); - painter.drawRoundedRect(rightHandleRect, 6, 6); - - // Handles - painter.setRenderHint(QPainter::Antialiasing, false); - QRectF selectedRect(backgroundRect); - selectedRect.setLeft(leftHandleRect.right() + 0.5); - selectedRect.setRight(rightHandleRect.left() - 0.5); - QBrush selectedBrush(mBackgroudColor); - painter.setBrush(selectedBrush); - painter.drawRect(selectedRect); -} - -QRectF RangeSlider::firstHandleRect() const -{ - float percentage = (mLowerValue - mMinimum) * 1.0 / mInterval; - return handleRect(percentage * validWidth() + scLeftRightMargin); -} - -QRectF RangeSlider::secondHandleRect() const -{ - float percentage = (mUpperValue - mMinimum) * 1.0 / mInterval; - return handleRect(percentage * validWidth() + scLeftRightMargin + scHandleSideLength); -} - -QRectF RangeSlider::handleRect(int aValue) const -{ - return QRect(aValue, (height()-scHandleSideLength) / 2, scHandleSideLength, scHandleSideLength); -} - -void RangeSlider::mousePressEvent(QMouseEvent* aEvent) -{ - if(aEvent->buttons() & Qt::LeftButton) - { - mSecondHandlePressed = secondHandleRect().contains(aEvent->pos()); - mFirstHandlePressed = !mSecondHandlePressed && firstHandleRect().contains(aEvent->pos()); - - if(mFirstHandlePressed) - { - mDelta = aEvent->pos().x() - (firstHandleRect().x() + scHandleSideLength / 2); - } - else if(mSecondHandlePressed) - { - mDelta = aEvent->pos().x() - (secondHandleRect().x() + scHandleSideLength / 2); - } - - if(aEvent->pos().y() >= 2 && aEvent->pos().y() <= height()- 2) - { - int step = mInterval / 10 < 1 ? 1 : mInterval / 10; - if(aEvent->pos().x() < firstHandleRect().x()) - { - setLowerValue(mLowerValue - step); - } - else if(aEvent->pos().x() > firstHandleRect().x() + scHandleSideLength && aEvent->pos().x() < secondHandleRect().x()) - { - if(aEvent->pos().x() - (firstHandleRect().x() + scHandleSideLength) < - (secondHandleRect().x() - (firstHandleRect().x() + scHandleSideLength)) / 2) - { - if(mLowerValue + step < mUpperValue) - setLowerValue(mLowerValue + step); - else - setLowerValue(mUpperValue); - } - else - { - if(mUpperValue - step > mLowerValue) - setUpperValue(mUpperValue - step); - else - setUpperValue(mLowerValue); - } - } - else if(aEvent->pos().x() > secondHandleRect().x() + scHandleSideLength) - setUpperValue(mUpperValue + step); - } - } -} - -void RangeSlider::mouseMoveEvent(QMouseEvent* aEvent) -{ - if(aEvent->buttons() & Qt::LeftButton) - { - if(mFirstHandlePressed) - { - if(aEvent->pos().x() - mDelta + scHandleSideLength / 2 <= secondHandleRect().x()) - setLowerValue((aEvent->pos().x() - mDelta - scLeftRightMargin - - scHandleSideLength / 2) * 1.0 / validWidth() * mInterval + mMinimum, false); - else - setLowerValue(mUpperValue, false); - } - else if(mSecondHandlePressed) - { - if(firstHandleRect().x() + scHandleSideLength * 1.5 <= aEvent->pos().x() - mDelta) - { - setUpperValue((aEvent->pos().x() - mDelta - scLeftRightMargin - - scHandleSideLength / 2 - scHandleSideLength) * 1.0 / validWidth() * mInterval + mMinimum, false); - } - else - setUpperValue(mLowerValue, false); - } - } -} - -void RangeSlider::mouseReleaseEvent(QMouseEvent* aEvent) -{ - Q_UNUSED(aEvent); - - if (mFirstHandlePressed) - { - emit lowerValueChanged(mLowerValue); - emit valueChanged(mLowerValue, mUpperValue); - } - else if (mSecondHandlePressed) - { - emit upperValueChanged(mUpperValue); - emit valueChanged(mLowerValue, mUpperValue); - } - - mFirstHandlePressed = false; - mSecondHandlePressed = false; -} - -void RangeSlider::changeEvent(QEvent* aEvent) -{ - if(aEvent->type() == QEvent::EnabledChange) - { - if(isEnabled()) - mBackgroudColor = mBackgroudColorEnabled; - else - mBackgroudColor = mBackgroudColorDisabled; - - update(); - } -} - -QSize RangeSlider::minimumSizeHint() const -{ - return QSize(scHandleSideLength * 2 + scLeftRightMargin * 2, scHandleSideLength); -} - -int RangeSlider::GetMinimun() const -{ - return mMinimum; -} - -int RangeSlider::GetMaximun() const -{ - return mMaximum; -} - -int RangeSlider::GetLowerValue() const -{ - return mLowerValue; -} - -void RangeSlider::setLowerValue(int aLowerValue, bool fireEvent) -{ - if(aLowerValue > mMaximum) - aLowerValue = mMaximum; - - if(aLowerValue < mMinimum) - aLowerValue = mMinimum; - - mLowerValue = aLowerValue; - - if (mLowerValue == mUpperValue) - mLowerValue--; - - if (fireEvent) - { - emit lowerValueChanged(mLowerValue); - emit valueChanged(mLowerValue, mUpperValue); - } - - update(); -} - -int RangeSlider::GetUpperValue() const -{ - return mUpperValue; -} - -void RangeSlider::setUpperValue(int aUpperValue, bool fireEvent) -{ - if(aUpperValue > mMaximum) - aUpperValue = mMaximum; - - if(aUpperValue < mMinimum) - aUpperValue = mMinimum; - - mUpperValue = aUpperValue; - - if (mUpperValue == mLowerValue) - mUpperValue++; - - if (fireEvent) - { - emit lowerValueChanged(mLowerValue); - emit valueChanged(mLowerValue, mUpperValue); - } - - update(); -} - -void RangeSlider::setMinimum(int aMinimum) -{ - if(aMinimum <= mMaximum) - mMinimum = aMinimum; - else - { - int oldMax = mMaximum; - mMinimum = oldMax; - mMaximum = aMinimum; - } - - mInterval = mMaximum - mMinimum; - update(); - - if (mLowerValue < mMinimum) - setLowerValue(mMinimum); - - if (mUpperValue > mMaximum) - setUpperValue(mMaximum); - - emit rangeChanged(mMinimum, mMaximum); -} - -void RangeSlider::setMaximum(int aMaximum) -{ - if(aMaximum >= mMinimum) - mMaximum = aMaximum; - else - { - int oldMin = mMinimum; - mMaximum = oldMin; - mMinimum = aMaximum; - } - - mInterval = mMaximum - mMinimum; - update(); - - if (mLowerValue < mMinimum) - setLowerValue(mMinimum); - - if (mUpperValue > mMaximum) - setUpperValue(mMaximum); - - emit rangeChanged(mMinimum, mMaximum); -} - -int RangeSlider::validWidth() const -{ - return width() - scLeftRightMargin * 2 - scHandleSideLength * 2; -} - -void RangeSlider::setRange(int aMinimum, int aMaximum) -{ - setMinimum(aMinimum); - setMaximum(aMaximum); -} From 934e1bc4cec4fc957bb90085b53fa3f94997cdb4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:28:14 -0400 Subject: [PATCH 292/469] Delete mrichtextedit.ui --- .../plugins/mrichtexteditor/mrichtextedit.ui | 538 ------------------ 1 file changed, 538 deletions(-) delete mode 100644 src/qt/plugins/mrichtexteditor/mrichtextedit.ui diff --git a/src/qt/plugins/mrichtexteditor/mrichtextedit.ui b/src/qt/plugins/mrichtexteditor/mrichtextedit.ui deleted file mode 100644 index 50c5c424..00000000 --- a/src/qt/plugins/mrichtexteditor/mrichtextedit.ui +++ /dev/null @@ -1,538 +0,0 @@ - - - MRichTextEdit - - - - 0 - 0 - 819 - 312 - - - - - - - - 1 - - - 1 - - - 1 - - - 1 - - - 1 - - - - - - 2 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::ClickFocus - - - Paragraph formatting - - - true - - - - - - - Qt::Vertical - - - - - - - false - - - Qt::ClickFocus - - - Undo (CTRL+Z) - - - Undo - - - - - - - - - 16 - 16 - - - - - - - - false - - - Qt::ClickFocus - - - Redo - - - Redo - - - - - - - - - 16 - 16 - - - - - - - - Qt::ClickFocus - - - Cut (CTRL+X) - - - Cut - - - - - - - - - 16 - 16 - - - - - - - - Qt::ClickFocus - - - Copy (CTRL+C) - - - Copy - - - - - - - - - 16 - 16 - - - - - - - - Qt::ClickFocus - - - Paste (CTRL+V) - - - Paste - - - - - - - - - 16 - 16 - - - - - - - - Qt::Vertical - - - - - - - Qt::ClickFocus - - - Link (CTRL+L) - - - Link - - - - - - - - - 16 - 16 - - - - true - - - - - - - Qt::Vertical - - - - - - - Qt::ClickFocus - - - Bold (CTRL+B) - - - Bold - - - - - - - - - 16 - 16 - - - - true - - - - - - - Qt::ClickFocus - - - Italic (CTRL+I) - - - Italic - - - - - - - - - 16 - 16 - - - - true - - - - - - - Qt::ClickFocus - - - Underline (CTRL+U) - - - Underline - - - - - - - - - 16 - 16 - - - - true - - - - - - - Strike Out - - - true - - - - - - - Qt::Vertical - - - - - - - Qt::ClickFocus - - - Bullet list (CTRL+-) - - - Bullet list - - - - 16 - 16 - - - - true - - - - - - - Qt::ClickFocus - - - Ordered list (CTRL+=) - - - Ordered list - - - - 16 - 16 - - - - true - - - - - - - Qt::ClickFocus - - - Decrease indentation (CTRL+,) - - - Decrease indentation - - - - - - - - - 16 - 16 - - - - - - - - Qt::ClickFocus - - - Increase indentation (CTRL+.) - - - Increase indentation - - - - - - - - - 16 - 16 - - - - - - - - Qt::Vertical - - - - - - - - 16 - 16 - - - - - 16 - 16 - - - - Qt::ClickFocus - - - Text background color - - - . - - - - 16 - 16 - - - - - - - - Qt::ClickFocus - - - Font size - - - true - - - - - - - Qt::Vertical - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - f_paragraph - line_4 - f_undo - f_redo - f_cut - f_copy - f_paste - line - f_link - line_3 - f_italic - f_underline - line_2 - f_fontsize - line_5 - f_list_bullet - f_list_ordered - f_indent_dec - f_indent_inc - f_bold - f_bgcolor - f_strikeout - line_6 - - - - - - QTextEdit::AutoNone - - - true - - - - - - - - From bdb9a511c50e58d566a1b39de8b1d959f9f941a4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:28:19 -0400 Subject: [PATCH 293/469] Delete mrichtextedit.h --- .../plugins/mrichtexteditor/mrichtextedit.h | 92 ------------------- 1 file changed, 92 deletions(-) delete mode 100644 src/qt/plugins/mrichtexteditor/mrichtextedit.h diff --git a/src/qt/plugins/mrichtexteditor/mrichtextedit.h b/src/qt/plugins/mrichtexteditor/mrichtextedit.h deleted file mode 100644 index 543c8e60..00000000 --- a/src/qt/plugins/mrichtexteditor/mrichtextedit.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -** Copyright (C) 2013 Jiří Procházka (Hobrasoft) -** Contact: http://www.hobrasoft.cz/ -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file is under the terms of the GNU Lesser General Public License -** version 2.1 as published by the Free Software Foundation and appearing -** in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the -** GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -*/ - -#ifndef _MRICHTEXTEDIT_H_ -#define _MRICHTEXTEDIT_H_ - -#include -#include "ui_mrichtextedit.h" - -/** - * @Brief A simple rich-text editor - */ -class MRichTextEdit : public QWidget, protected Ui::MRichTextEdit { - Q_OBJECT - public: - MRichTextEdit(QWidget *parent = 0); - - QString toPlainText() const { return f_textedit->toPlainText(); } - QString toHtml() const; - QTextDocument *document() { return f_textedit->document(); } - QTextCursor textCursor() const { return f_textedit->textCursor(); } - void setTextCursor(const QTextCursor& cursor) { f_textedit->setTextCursor(cursor); } - - - public Q_SLOTS: - void setText(const QString &text); - void clear(); - - protected Q_SLOTS: - void setPlainText(const QString &text) { f_textedit->setPlainText(text); } - void setHtml(const QString &text) { f_textedit->setHtml(text); } - void textBold(); - void textUnderline(); - void textStrikeout(); - void textItalic(); - void textSize(const QString &p); - void textLink(bool checked); - void textStyle(int index); - void textBgColor(); - void listBullet(bool checked); - void listOrdered(bool checked); - void slotCurrentCharFormatChanged(const QTextCharFormat &format); - void slotCursorPositionChanged(); - void slotClipboardDataChanged(); - void increaseIndentation(); - void decreaseIndentation(); - - protected: - void mergeFormatOnWordOrSelection(const QTextCharFormat &format); - void fontChanged(const QFont &f); - void bgColorChanged(const QColor &c); - void list(bool checked, QTextListFormat::Style style); - void indent(int delta); - void focusInEvent(QFocusEvent *event); - - QStringList m_paragraphItems; - int m_fontsize_h1; - int m_fontsize_h2; - int m_fontsize_h3; - int m_fontsize_h4; - - enum ParagraphItems { ParagraphStandard = 0, - ParagraphHeading1, - ParagraphHeading2, - ParagraphHeading3, - ParagraphHeading4, - ParagraphMonospace }; - - QPointer m_lastBlockList; -}; - -#endif From e14dc0e04fe6cd41331a95b6bc9f2190a9db174c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:28:24 -0400 Subject: [PATCH 294/469] Delete mrichtextedit.cpp --- .../plugins/mrichtexteditor/mrichtextedit.cpp | 468 ------------------ 1 file changed, 468 deletions(-) delete mode 100644 src/qt/plugins/mrichtexteditor/mrichtextedit.cpp diff --git a/src/qt/plugins/mrichtexteditor/mrichtextedit.cpp b/src/qt/plugins/mrichtexteditor/mrichtextedit.cpp deleted file mode 100644 index 939b9427..00000000 --- a/src/qt/plugins/mrichtexteditor/mrichtextedit.cpp +++ /dev/null @@ -1,468 +0,0 @@ -/* -** Copyright (C) 2013 Jiří Procházka (Hobrasoft) -** Contact: http://www.hobrasoft.cz/ -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file is under the terms of the GNU Lesser General Public License -** version 2.1 as published by the Free Software Foundation and appearing -** in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the -** GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -*/ - -#include "mrichtextedit.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -MRichTextEdit::MRichTextEdit(QWidget *parent) : QWidget(parent) { - setupUi(this); - m_lastBlockList = 0; - f_textedit->setTabStopWidth(40); - - connect(f_textedit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), - this, SLOT(slotCurrentCharFormatChanged(QTextCharFormat))); - connect(f_textedit, SIGNAL(cursorPositionChanged()), - this, SLOT(slotCursorPositionChanged())); - - m_fontsize_h1 = 18; - m_fontsize_h2 = 16; - m_fontsize_h3 = 14; - m_fontsize_h4 = 12; - - fontChanged(f_textedit->font()); - bgColorChanged(f_textedit->textColor()); - - // paragraph formatting - - m_paragraphItems << tr("Standard") - << tr("Heading 1") - << tr("Heading 2") - << tr("Heading 3") - << tr("Heading 4") - << tr("Monospace"); - f_paragraph->addItems(m_paragraphItems); - - connect(f_paragraph, SIGNAL(activated(int)), - this, SLOT(textStyle(int))); - - // undo & redo - - f_undo->setShortcut(QKeySequence::Undo); - f_redo->setShortcut(QKeySequence::Redo); - - connect(f_textedit->document(), SIGNAL(undoAvailable(bool)), - f_undo, SLOT(setEnabled(bool))); - connect(f_textedit->document(), SIGNAL(redoAvailable(bool)), - f_redo, SLOT(setEnabled(bool))); - - f_undo->setEnabled(f_textedit->document()->isUndoAvailable()); - f_redo->setEnabled(f_textedit->document()->isRedoAvailable()); - - connect(f_undo, SIGNAL(clicked()), f_textedit, SLOT(undo())); - connect(f_redo, SIGNAL(clicked()), f_textedit, SLOT(redo())); - - // cut, copy & paste - - f_cut->setShortcut(QKeySequence::Cut); - f_copy->setShortcut(QKeySequence::Copy); - f_paste->setShortcut(QKeySequence::Paste); - - f_cut->setEnabled(false); - f_copy->setEnabled(false); - - connect(f_cut, SIGNAL(clicked()), f_textedit, SLOT(cut())); - connect(f_copy, SIGNAL(clicked()), f_textedit, SLOT(copy())); - connect(f_paste, SIGNAL(clicked()), f_textedit, SLOT(paste())); - - connect(f_textedit, SIGNAL(copyAvailable(bool)), f_cut, SLOT(setEnabled(bool))); - connect(f_textedit, SIGNAL(copyAvailable(bool)), f_copy, SLOT(setEnabled(bool))); - -#ifndef QT_NO_CLIPBOARD - connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slotClipboardDataChanged())); -#endif - - // link - - f_link->setShortcut(Qt::CTRL + Qt::Key_L); - - connect(f_link, SIGNAL(clicked(bool)), this, SLOT(textLink(bool))); - - // bold, italic & underline - - f_bold->setShortcut(Qt::CTRL + Qt::Key_B); - f_italic->setShortcut(Qt::CTRL + Qt::Key_I); - f_underline->setShortcut(Qt::CTRL + Qt::Key_U); - - connect(f_bold, SIGNAL(clicked()), this, SLOT(textBold())); - connect(f_italic, SIGNAL(clicked()), this, SLOT(textItalic())); - connect(f_underline, SIGNAL(clicked()), this, SLOT(textUnderline())); - connect(f_strikeout, SIGNAL(clicked()), this, SLOT(textStrikeout())); - - // lists - - f_list_bullet->setShortcut(Qt::CTRL + Qt::Key_Minus); - f_list_ordered->setShortcut(Qt::CTRL + Qt::Key_Equal); - - connect(f_list_bullet, SIGNAL(clicked(bool)), this, SLOT(listBullet(bool))); - connect(f_list_ordered, SIGNAL(clicked(bool)), this, SLOT(listOrdered(bool))); - - // indentation - - f_indent_dec->setShortcut(Qt::CTRL + Qt::Key_Comma); - f_indent_inc->setShortcut(Qt::CTRL + Qt::Key_Period); - - connect(f_indent_inc, SIGNAL(clicked()), this, SLOT(increaseIndentation())); - connect(f_indent_dec, SIGNAL(clicked()), this, SLOT(decreaseIndentation())); - - // font size - - QFontDatabase db; - foreach(int size, db.standardSizes()) - f_fontsize->addItem(QString::number(size)); - - connect(f_fontsize, SIGNAL(activated(QString)), - this, SLOT(textSize(QString))); - f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(QApplication::font() - .pointSize()))); - - // text background color - - QPixmap pix(16, 16); - pix.fill(QApplication::palette().background().color()); - f_bgcolor->setIcon(pix); - - connect(f_bgcolor, SIGNAL(clicked()), this, SLOT(textBgColor())); - - // images - //connect(f_image, SIGNAL(clicked()), this, SLOT(insertImage())); -} - -void MRichTextEdit::textBold() { - QTextCharFormat fmt; - fmt.setFontWeight(f_bold->isChecked() ? QFont::Bold : QFont::Normal); - mergeFormatOnWordOrSelection(fmt); -} - - -void MRichTextEdit::focusInEvent(QFocusEvent *) { - f_textedit->setFocus(Qt::TabFocusReason); -} - - -void MRichTextEdit::textUnderline() { - QTextCharFormat fmt; - fmt.setFontUnderline(f_underline->isChecked()); - mergeFormatOnWordOrSelection(fmt); -} - -void MRichTextEdit::textItalic() { - QTextCharFormat fmt; - fmt.setFontItalic(f_italic->isChecked()); - mergeFormatOnWordOrSelection(fmt); -} - -void MRichTextEdit::textStrikeout() { - QTextCharFormat fmt; - fmt.setFontStrikeOut(f_strikeout->isChecked()); - mergeFormatOnWordOrSelection(fmt); -} - -void MRichTextEdit::textSize(const QString &p) { - qreal pointSize = p.toFloat(); - if (p.toFloat() > 0) { - QTextCharFormat fmt; - fmt.setFontPointSize(pointSize); - mergeFormatOnWordOrSelection(fmt); - } -} - -void MRichTextEdit::textLink(bool checked) { - bool unlink = false; - QTextCharFormat fmt; - if (checked) { - QString url = f_textedit->currentCharFormat().anchorHref(); - bool ok; - QString newUrl = QInputDialog::getText(this, tr("Create a link"), - tr("Link URL:"), QLineEdit::Normal, - url, - &ok); - if (ok) { - fmt.setAnchor(true); - fmt.setAnchorHref(newUrl); - fmt.setForeground(QApplication::palette().color(QPalette::Link)); - fmt.setFontUnderline(true); - } else { - unlink = true; - } - } else { - unlink = true; - } - if (unlink) { - fmt.setAnchor(false); - fmt.setForeground(QApplication::palette().color(QPalette::Text)); - fmt.setFontUnderline(false); - } - mergeFormatOnWordOrSelection(fmt); -} - -void MRichTextEdit::textStyle(int index) { - QTextCursor cursor = f_textedit->textCursor(); - cursor.beginEditBlock(); - - // standard - if (!cursor.hasSelection()) { - cursor.select(QTextCursor::BlockUnderCursor); - } - QTextCharFormat fmt; - cursor.setCharFormat(fmt); - f_textedit->setCurrentCharFormat(fmt); - - if (index == ParagraphHeading1 - || index == ParagraphHeading2 - || index == ParagraphHeading3 - || index == ParagraphHeading4 ) { - if (index == ParagraphHeading1) { - fmt.setFontPointSize(m_fontsize_h1); - } - if (index == ParagraphHeading2) { - fmt.setFontPointSize(m_fontsize_h2); - } - if (index == ParagraphHeading3) { - fmt.setFontPointSize(m_fontsize_h3); - } - if (index == ParagraphHeading4) { - fmt.setFontPointSize(m_fontsize_h4); - } - if (index == ParagraphHeading2 || index == ParagraphHeading4) { - fmt.setFontItalic(true); - } - - fmt.setFontWeight(QFont::Bold); - } - if (index == ParagraphMonospace) { - fmt = cursor.charFormat(); - fmt.setFontFamily("Monospace"); - fmt.setFontStyleHint(QFont::Monospace); - fmt.setFontFixedPitch(true); - } - cursor.setCharFormat(fmt); - f_textedit->setCurrentCharFormat(fmt); - - cursor.endEditBlock(); -} - -void MRichTextEdit::textBgColor() { - QColor col = QColorDialog::getColor(f_textedit->textBackgroundColor(), this); - QTextCursor cursor = f_textedit->textCursor(); - if (!cursor.hasSelection()) { - cursor.select(QTextCursor::WordUnderCursor); - } - QTextCharFormat fmt = cursor.charFormat(); - if (col.isValid()) { - fmt.setBackground(col); - } else { - fmt.clearBackground(); - } - cursor.setCharFormat(fmt); - f_textedit->setCurrentCharFormat(fmt); - bgColorChanged(col); -} - -void MRichTextEdit::listBullet(bool checked) { - if (checked) { - f_list_ordered->setChecked(false); - } - list(checked, QTextListFormat::ListDisc); -} - -void MRichTextEdit::listOrdered(bool checked) { - if (checked) { - f_list_bullet->setChecked(false); - } - list(checked, QTextListFormat::ListDecimal); -} - -void MRichTextEdit::list(bool checked, QTextListFormat::Style style) { - QTextCursor cursor = f_textedit->textCursor(); - cursor.beginEditBlock(); - if (!checked) { - QTextBlockFormat obfmt = cursor.blockFormat(); - QTextBlockFormat bfmt; - bfmt.setIndent(obfmt.indent()); - cursor.setBlockFormat(bfmt); - } else { - QTextListFormat listFmt; - if (cursor.currentList()) { - listFmt = cursor.currentList()->format(); - } - listFmt.setStyle(style); - cursor.createList(listFmt); - } - cursor.endEditBlock(); -} - -void MRichTextEdit::mergeFormatOnWordOrSelection(const QTextCharFormat &format) { - QTextCursor cursor = f_textedit->textCursor(); - if (!cursor.hasSelection()) { - cursor.select(QTextCursor::WordUnderCursor); - } - cursor.mergeCharFormat(format); - f_textedit->mergeCurrentCharFormat(format); -} - -void MRichTextEdit::slotCursorPositionChanged() { - QTextList *l = f_textedit->textCursor().currentList(); - if (m_lastBlockList && (l == m_lastBlockList || (l != 0 && m_lastBlockList != 0 - && l->format().style() == m_lastBlockList->format().style()))) { - return; - } - m_lastBlockList = l; - if (l) { - QTextListFormat lfmt = l->format(); - if (lfmt.style() == QTextListFormat::ListDisc) { - f_list_bullet->setChecked(true); - f_list_ordered->setChecked(false); - } else if (lfmt.style() == QTextListFormat::ListDecimal) { - f_list_bullet->setChecked(false); - f_list_ordered->setChecked(true); - } else { - f_list_bullet->setChecked(false); - f_list_ordered->setChecked(false); - } - } else { - f_list_bullet->setChecked(false); - f_list_ordered->setChecked(false); - } -} - -void MRichTextEdit::fontChanged(const QFont &f) { - f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(f.pointSize()))); - f_bold->setChecked(f.bold()); - f_italic->setChecked(f.italic()); - f_underline->setChecked(f.underline()); - f_strikeout->setChecked(f.strikeOut()); - if (f.pointSize() == m_fontsize_h1) { - f_paragraph->setCurrentIndex(ParagraphHeading1); - } else if (f.pointSize() == m_fontsize_h2) { - f_paragraph->setCurrentIndex(ParagraphHeading2); - } else if (f.pointSize() == m_fontsize_h3) { - f_paragraph->setCurrentIndex(ParagraphHeading3); - } else if (f.pointSize() == m_fontsize_h4) { - f_paragraph->setCurrentIndex(ParagraphHeading4); - } else { - if (f.fixedPitch() && f.family() == "Monospace") { - f_paragraph->setCurrentIndex(ParagraphMonospace); - } else { - f_paragraph->setCurrentIndex(ParagraphStandard); - } - } - if (f_textedit->textCursor().currentList()) { - QTextListFormat lfmt = f_textedit->textCursor().currentList()->format(); - if (lfmt.style() == QTextListFormat::ListDisc) { - f_list_bullet->setChecked(true); - f_list_ordered->setChecked(false); - } else if (lfmt.style() == QTextListFormat::ListDecimal) { - f_list_bullet->setChecked(false); - f_list_ordered->setChecked(true); - } else { - f_list_bullet->setChecked(false); - f_list_ordered->setChecked(false); - } - } else { - f_list_bullet->setChecked(false); - f_list_ordered->setChecked(false); - } -} - -void MRichTextEdit::bgColorChanged(const QColor &c) { - QPixmap pix(16, 16); - if (c.isValid()) { - pix.fill(c); - } else { - pix.fill(QApplication::palette().background().color()); - } - f_bgcolor->setIcon(pix); -} - -void MRichTextEdit::slotCurrentCharFormatChanged(const QTextCharFormat &format) { - fontChanged(format.font()); - bgColorChanged((format.background().isOpaque()) ? format.background().color() : QColor()); - f_link->setChecked(format.isAnchor()); -} - -void MRichTextEdit::slotClipboardDataChanged() { -#ifndef QT_NO_CLIPBOARD - if (const QMimeData *md = QApplication::clipboard()->mimeData()) - f_paste->setEnabled(md->hasText()); -#endif -} - -QString MRichTextEdit::toHtml() const { - QString s = f_textedit->toHtml(); - // convert emails to links - s = s.replace(QRegExp("(<[^a][^>]+>(?:]+>)?|\\s)([a-zA-Z\\d]+@[a-zA-Z\\d]+\\.[a-zA-Z]+)"), "\\1\\2"); - // convert links - s = s.replace(QRegExp("(<[^a][^>]+>(?:]+>)?|\\s)((?:https?|ftp|file)://[^\\s'\"<>]+)"), "\\1\\2"); - // see also: Utils::linkify() - return s; -} - -void MRichTextEdit::increaseIndentation() { - indent(+1); -} - -void MRichTextEdit::decreaseIndentation() { - indent(-1); -} - -void MRichTextEdit::indent(int delta) { - QTextCursor cursor = f_textedit->textCursor(); - cursor.beginEditBlock(); - QTextBlockFormat bfmt = cursor.blockFormat(); - int ind = bfmt.indent(); - if (ind + delta >= 0) { - bfmt.setIndent(ind + delta); - } - cursor.setBlockFormat(bfmt); - cursor.endEditBlock(); -} - -void MRichTextEdit::setText(const QString& text) { - if (text.isEmpty()) { - setPlainText(text); - return; - } - if (text[0] == '<') { - setHtml(text); - } else { - setPlainText(text); - } -} - -void MRichTextEdit::clear() { - f_textedit->clear(); -} - - From 7cf159f10a9e6d489a635bc87c081044593101f2 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:28:29 -0400 Subject: [PATCH 295/469] Delete LGPL_EXCEPTION.txt --- .../mrichtexteditor/LGPL_EXCEPTION.txt | 23 ------------------- 1 file changed, 23 deletions(-) delete mode 100644 src/qt/plugins/mrichtexteditor/LGPL_EXCEPTION.txt diff --git a/src/qt/plugins/mrichtexteditor/LGPL_EXCEPTION.txt b/src/qt/plugins/mrichtexteditor/LGPL_EXCEPTION.txt deleted file mode 100644 index e4e581a9..00000000 --- a/src/qt/plugins/mrichtexteditor/LGPL_EXCEPTION.txt +++ /dev/null @@ -1,23 +0,0 @@ -Digia Qt LGPL Exception version 1.1 - -As an additional permission to the GNU Lesser General Public License version -2.1, the object code form of a "work that uses the Library" may incorporate -material from a header file that is part of the Library. You may distribute -such object code under terms of your choice, provided that: - (i) the header files of the Library have not been modified; and - (ii) the incorporated material is limited to numerical parameters, data - structure layouts, accessors, macros, inline functions and - templates; and - (iii) you comply with the terms of Section 6 of the GNU Lesser General - Public License version 2.1. - -Moreover, you may apply this exception to a modified version of the Library, -provided that such modification does not involve copying material from the -Library into the modified Library's header files unless such material is -limited to (i) numerical parameters; (ii) data structure layouts; -(iii) accessors; and (iv) small macros, templates and inline functions of -five lines or less in length. - -Furthermore, you are not required to apply this additional permission to a -modified version of the Library. - From 0447f2feb69f2d14fcdfc6e1ba6447520ebc45c2 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:28:33 -0400 Subject: [PATCH 296/469] Delete LICENSE.LGPL --- src/qt/plugins/mrichtexteditor/LICENSE.LGPL | 505 -------------------- 1 file changed, 505 deletions(-) delete mode 100644 src/qt/plugins/mrichtexteditor/LICENSE.LGPL diff --git a/src/qt/plugins/mrichtexteditor/LICENSE.LGPL b/src/qt/plugins/mrichtexteditor/LICENSE.LGPL deleted file mode 100644 index 3e12d084..00000000 --- a/src/qt/plugins/mrichtexteditor/LICENSE.LGPL +++ /dev/null @@ -1,505 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - - From 4421ebbef36af94ac1d5f2eda797f732bad72d00 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:28:38 -0400 Subject: [PATCH 297/469] Delete example.png --- src/qt/plugins/mrichtexteditor/example.png | Bin 32169 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/qt/plugins/mrichtexteditor/example.png diff --git a/src/qt/plugins/mrichtexteditor/example.png b/src/qt/plugins/mrichtexteditor/example.png deleted file mode 100644 index 2bc545a4c8557ae307d039e41676ce872ddbe4dc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32169 zcmce-Wn5J6*FK7(h=53UDF#=XP{MZ0a;M)b zi<=4+pY?aSdqRX6QQb_#^EL=o<-b&R;o!!7jF5^W613*xk&ux2BBS=95?S`Z;k#fN z;`X+3UFg8>{0#HM@AKP>j;6V(WM2FE!RFNTxll<7397%n_(bp$S?%wqcGXAdYNJHI zt+_#A18X8K$i!b78ylr8n6OYWP>@%r$UH?t=#Yy)+Nsybr-&zKB`26RB6+Zkp!!~) zwYcr2SdCaMwEDg}9vmL#Iiu{YwmSB~P_Tf6EiNuf5h$yuJf61e;|hH%#>vv<5$ zzb>8RPO<~RQdr(zzw_~8;fqe4r_H6Jp`l@8J0Pyk2*;&gUt61Nbd97@sI!{`fk4sZ zf>QLI9f8lz_vc8Vj>}Bhy31_QE1G3`m)8evq;H(d=f{M-T%?IWe6nq6j;GcZu1oPW z5nu1;zCn1;8T*;a%qCmSVReS~_Sw9WpZoiZz6@yYek=XA`$!|49UUEWP40*-7j12A z4P2M)-&W&4W#Di)7w7I+4iufO`JJ0aK8$}6BEP*NQWc3Fa>5tA!gp6EU^1MR$WIn6 zl@r@XTP?W0d=V(NI7_ZS?i$rO-Oe5&t(BQ|cAFQoH&v+csV?7HCZ6lqz|+ssb$zcO zBCYLbZZe-;1*g*P7WYef);ci4fFw$)P^}-&sSI}nK19pCmZnqcS@oG5n3CnL@H|SA zxIR@eP8l%w474N}7>II?^tOvYylk#Y;crHWY$@=oOEX?YTUAw#J~JYs{}O#;>xCBt zIA07e3QaChw+>cu+*!9JI_>~hrjpOp4eM7FtTFtmXB=H+XaCOrBTtvq^AGJ^0~5uN zPUPX?VXf^90U@EKx%rg(s}_TWQeEB_gEser`Po^$>gw3oSVu=k{U$dBMa5dVOjlRe zglql_pH_o%_bj*0AAIQ{gC>q?*r0B>il?=rv2s91mL+@A+d>+n3npq2J5=gYsj@Mj zc$Ycj%-}vWQhxvaO=a;PQ_OifrHqAG_~B|K$Y-E~T2*Pc%S$9t+Ng3C8S$uEV%0Sx zA`5n+lrGG0x&x7;R*S(>jwu`jg`k_wub}5F{%W3SQ#^4NCEqd=@Aqd8 zlwU78HIPN`g?gd=L0_hWs(LOdvY5xbKOPcXga{Gt%c&B7wGzR=7$Q~`cHJJV*nEM3 za&HsjUEM#Cr;xhT8LFwF;nXlYI4HkeEI-n}<`fLVCMUOLCvw}L)mBq86M_TtTd11v zwl}Sw{h`%0cQKt^` zU@pHdCR21IJb!Har%LjpO7TwZJwE1_F9Qt9nV8y?vVDs4S?`>~JB%u(mLQ& zL~G}Rt+*O2N^~$oIP~=A$S9sGC>lrgJtIrZp9EKKD{(c%jlFJg-T&=)QV@&1RBGmQ znJ(!5lH#r< zL}Q>*V~88*bw{W(DU7(GE}9S#QU|>X)F_thjU{9un#`~jI7{JaWs3&mS=%Z)>YJ&( zPAztFcXl&pY^+5$e#_CK*t9*Ac-NZ3)S?-+WroR15VP^S?H(&#u^evAMN%r2Gxm`S zEm(yadxZ}+G<5o>8zZVGT9;j(u38Q;tl#8%jD5x3`?H~;fdnF({UMB2g+9Z1X98O& zLserUeFtGTNlTwP^ymD1ga5c*QI9Szz(LK>knQA@ck_jUU3=GRsBuz${zlMq+yrLr zDwnNsOZ&;w^K-)%uT#KI+iuTvgGSo}kTuHiqaxbqE~ILlH~*U)eM zZcO&xGIT-$9S=Gntiou^rWtb**Nn$-C%2lQMZdw04&Gk`!q`;)W{Vq^W_OPRA~ z)k($0JN-%`1gJu(){Rd#@}8DLxSr=oVJHcE+c^&l2X?SKT|`C_49-*>?a;HrPhx+B z<3fYZ^%7nEEG}ERmW0O+GfrbjXd2@;oJ3%^cG;Z1sa@>y40s{I!I#(9y88*eBO`#{ zMn=IH-Eu(*T)J}AahFw5RlU8rnVp?=5zrsW5PpHuIU;($ySmEdygmr*sfccqbj8HD zxML`#|0v$KLpdT0lqsEoZ?tmqyc-7f4jpb8IxJWAyfS)h28Ct%v=m0{R3@qDcI>Y; zm-(Ve`@0Kny#qTM{%*M`>)YM`&bVbd=w{AK4iY$maC)@nt2CZ`liqiv=AP+lSKyOYc(hFC1fxwQOv550^UA)6>}uTbpfX zc;aOxOO~(H|BDwA7g_iSs$8w|#!PcJq+Hb3DD61_PnHX{Npwwhm zH9Ao`IU2=qYY6DbVdpurc;v5Q=xOvvVSkq6mLr$ugri5_2;2B5u3*wP1D?9azNpaL z#-c`W-LOunqQb75a-kX{L`BlQ9HU#wF6Y3cUkaSN(IDVI;6-O2h*!K}AKy*RNkc zeL||L`_yYzwLjOCn2<1jqC-ML0?hcz>gsPG4uph+PzZYgD@zfBXmH*L2| zTU|8^Md$!l3hWmmj4sD?MP8dpc2&aAXv7b=HHKGU$ER08vuXTmkXE)4{dWmkIa8aT z5TB2lb)R|?s{fAv9)5MU*JsB50>w92tuTT2X${S6qZ~H6_1^lX!q_*$L`6rRtMVq1 ziRM)fJ6)sqwVj_|wmwLpiH}oT&oS_4ef@`W#1aZ}2>X{l7gxuGfz=@{Mq{F$jbmsO zsry03+%~zWpAR&eJds70E^&a6S&Q9vy2jA&(j17yZgbrp8|m&qbWDhi?btZZS4>Yy zNwK!a{0(?6a{vwJNso_@Pm~+l-%MAULTTj^u-Lq#qM}}4VE7yl@jmY;_%93mbNt6J z1JXV%`#Pr2OxQu&>q5G#Ev4yn@0dns0KVlqyrjDjom6R-wl5dNhzh0UYK z`?pRT)Rc2K*A9}#jpmPe5=pV98Q(TGX?SPbR?y^6PFZBk&(A-4^k{FUj*XSI6~Gg4 zT^2t-zp=3~0Btw;-;4NK9W1o@UmP08%ifbv0=@QtxL*0&P8(lB{m@hPHej)yi26<#D*jks; zXNJ}+#7~B~RL-6(PX>h72EF}0cW7)!cX#p~Q)!ZXUft+SC#(rbp2`}lel&w}RYWT| zcv7J&!NI|KY5c0n%7yUB^Au*XCB@<9U(G_vYDEa#42JdP?dA1#6GX}j1^LY4#6C03 zSqc&kldfq9IGiwgZ?bYFlC70}c>{&gOl478k@P!!wVD5fboA{&p}uga?3ToNXwo0P0s&D;PT*=yMwTvOU~8zXiD`x!rndnsdrHD zb4<*$v$Nr$ApkX4D=K0hd0#CFf3CIlKHY}5`d<6r-<|`u9WT5B z9XrdrN%>9ck4jqJ|4do7&ec#JaWvIbQ~St4UphQWrD>%F!Co@% zN-sEkCpNvH`8$bl>GhbQsK?}v7PC@-kkEt^^_ z*t0>Pg<>ge$ik5??Tmby5RZTtsuOuc-xL}Ot#@1@VAeY9qtBd-4~&T!c`14`+Dlml zY@eve$jF$OMA=-?+Y=bPSTnUYMWs-U3QJ8xgCqv^$zxcl2Tg46$@inu@;p*Q25W1t ze?#ci*^cd5bV5JcHraL&y960 z)f+RMxr$wA3I`&>zPCOKaq4Pn)7KLO0uqvL4z8{(X&Fa9*V8xVz?F@pi5H7&YY@9r z*@0m!0s<0VPnGxYDRG3U!diZ+NRh?w5&Ol_|_VeKR zqxY*NZDq$fg5M!t0mS>#;Fb;;4A$3ISW&?)D!MRePA$biPoIBsasqgw>C?mN)Kpz9 zEh212W}wxu%@1H&xQH;wFgNB~yn%p0trzv{7bs;WEqo2v(o#iq&?S*|XsBUY8lh7o zzyb>EHi@C&B}{qYduwY0p7 zBqj=Z`V^&dYOtzmJS61V9c^HTk@KVtrY?=@>bekNH)Fbx^tqjG4_Tc)VV&!_JWriuO79f6;~ zMo?9}@9F8eGf~>fULqYsVc&ezlg96y;zoPl6Gh6_eE93`_Bu*B1e4sl5qYqtq_I)J z&~V|~HyjgUxP=0XFi~+|ZDfoQ)u3O!RB=|BC;El?e6LM6x1ut z@YC?C7BjY&x2Bo~O;8YsG`d!$P*z4*(7Nler#OV2iW62zNG1)vJBsby5vXmvKOjFo zB(NK9oG0%B`4cL03l@h>z-VY<3-a=M;BfBOuV3@>CK5rT@bK^ev=saPdupoOLjR?Y zUz6J&z)FR2Zv#i${hc5?`_~~0LIMIDC46EGlw|q!-QBdfI8{UYYx-*-VgfEqrq}4o zMDMYvsHn-8T5zdkKAhylYxb~L2R*J&D9#C`lO2O2?0hvkf;bq(SeN{P1o) zz8EEN-oqZ9dKL;z9av&eXKavz>EZF=9togv{BBPXb+$7a+S7$l{ z4**m=kJqu4NRubhOY*qzK?!@N6Y>Uj^Y`;Uh!fP9jX|@w3gn6D-6GuEje?T*8MsGV ztH~v60v%TQ&`Q)*yIFUFq9$@_22oDwO=4FVL57X9AH zv9smKWYhgSNI}mC!hJR=iDkwQgzCtzmn)mAQQXq}#8H)w6lU0%mVrfhJy70+1%fS` zZV|e?5q{;j{heIU{Z$aoa*1L6;#z}DU!OXh=H<)tu~*U-8?#`XJ+APrMZT+7s)y3+ zfxM9pQz1r_>R&$)ujW{j|3J5A*&LnPDF6MLiND5RO+`nCgn(e8(G`pmh)qPKrK+k5 zY`)P^s@V5H77BnVZSCY19JJtHK%iV-U!QMs2hgY+u$SxWFS^2UQL|a~8#hm{iZ#ng zFi?Oi0rCylzXAqw7QnIIskzIhSMLC@l8o^Y^}1#a{D~7fk&1yUUY-6i*w|nec@*ct zBo29$xDF#DB4nszpqNrUU-Zc{$-d;{63BS$BZ(dWwkTCcc#Y|rcdGTlIvr3f1VXIORONgOb#jCX1X z4JDs(tk<(sS6AZ`scDuMdtX#L& z#&ZvX$dgZ|A&872;~y{9WUC@m%n%A+xfsut^Y!%|7#ILhs~nlA&&6TL3sOBjz0FEB4^ZabA!sg zQp!?;2EB4brlL&L?r4C882vXzg~*s|o3(temOH)aO!DcvYI*0|^&v@g!i(!m9(6)!#Xhst5)nkcMs;a6IaM^q(^j4wyjYK(O$3=h)T3uaDj3M>z z-KXN>Vr0q5*)%zN+!jSk_RS;da|l(?H>Grdbj3j7aogn!!m8}(u7nVT)EXFgZk(Il zYvW#TomPSCs_q+T5e|Uoj$6sU4^UcoZz`*rDdy?@PI?Bzk-u&aokMjk9 z2)u3I#aVeq1_iLF=bu#>IsY)`pagR|LRP&BpMofwXU`azne`f+Xvu{?LZ(>&tDC9{ zzPJL)5vqvayG~VRW>X?!Ltk4|o=#nA!~&qsgqIV+0_Fye3tPzi)@w~8w0yKF8fd-3=Z;N>3&yrYRFqC6}tFHd~`8kCLI z$sX`7>jMKbFKo19eO+(*QfM|xZdZ?k2;-G>)azz~bVa#lQ-VrzJ+K&RW$qLqti_XT z{ZBVr1W84BAQA1FI$5-8@mDH;LrQo1m=~h-3-z&mv4nhfAe58q1E@|Nm>vri*nc$B zHB7|}ZE@-PhN?L*t6Om$Amv|jxE23ZqoZ#yVVi0YSzHX(*Vnh3&?nZyy_1HV}b0-Ci0ER%`?GF$1-9+NcC&uxVWh3?sn&KWmdNldxN4LFj1|cp<2wX?i;a92R?sD1@hhkSwld( zkK}7As`mNH5iT)X1>1Z@Wq^hE!rz-1nqmL>IEwN$OI-%hl2ZdSL8?WDXM-nGVtH*! zPhVeOnXf)jWyA!y((5g#Tr#u9`YCB>425?Z`Icu^QBlOe8c;UE=u~4=S5}Ta+QJV8 zIiBz915gQIqu7Z6CZGJe(rIUcrD~{wFB;~PJPAP)nXc}+@Y2gbw9_866$Ct zbz;B8!{@O;{0xA9RrhQ0@m3UA_Ied92;v*(qEcs()9xRaA@3b?@kR?VzI!+{5;$h( z=EOlDoiN|^we`7Hb3p;t7-&udm#_5O0ir0vd=-ZLwq6Dw3wnZH#VP)F)S?!iD(}o zt*0k!LMoYPEFO8-_P;tfn{Ufa>k11bNP(81@6MelRtcicZqG594Q# z860vCAp_@T4RoXo&nJ(?+}zweJT5r3n{IA=0^Yrwz4ECAPZJFZ<#NGpP>&UJnh8K` zi$jngu?GGS(O%eg)}=?p!z18D>aQXh7#KXJAwW$CxRIaVUG?;B6vXeJ>+{f$O$Q!D zhJ_)q@O{xKrJMh3AJk!#)GY}%qYo8ImxN2{H-=;_);{8t0Bzu zXbRXEo<1~vBKYjQCD{=*w{C#GR5iLVj`8;oM|Yo`N}^&%4~Uls1EkpeEYj7ZhZ9-J z1;u3_7~@?uWa{;Rc`qiph@~kgZ$LcM=8=#_XR%o2)YQHYeFs1?hv4IbC6tHe#UnA8 zxfm)?{!U`)Yu7=4XhVu2g+3-}*NL3loovPb{{?pBoD8yTU zf};+6MiYdA(wSd8@jW4)I_Ps?pa%1GScef+&~WZ;gQY(W=;OP#*5mbIy0UR=h)LyZ zCVKiemoBc5UM}$!x41+?RtjP3)vq1MKwWZRfGIjtzQ5V8v%A~8|7ZAIlj~Z=RJ=Mo zUv*e-xE|zoc}N)A%5L_xE-_Jyron~(wyRH-q;$d}O2B=a&+IVku!3DvlQ3RKUrp@> zdf8T{*McJTcczu<5LK4`ChtD^&+wEIWAvN^6=wQh;)6a)frOT-W*dDi7Xkt$`hj3W zQf^W`1$;vSU}mB+C*0b!$+iM3z$=)ag3#3}@rB$ZqSIJZ?}yNwd#D z?H&LF-;b;uo$ZS{tgM%MRZdP#d2W8~!0m}zI!fz_B5&EtH)NKxfi<4?bMG)RG8+0A zJM6B?pk_BzTL834sZMok^AD4*itIQ##doMtB>caM5aR$@ySHITkof({v!_G;p0(vM zN=>!4p)Y)?X-}E8$)BAZ$kj8)$E&yP&#QjW0!WULB!UItqTZ~4h6c}jz2+xU$PXil z63bQLcQb}HmrF9n`(57>L`el=rH}~n+x5Q=`VgpgHMD*Z-yizT_quZe2>4;v)&R~I z7w-)JsS3~_+(fEp`%28r%s}ORgYD+{&}cc}^DhuY$9LU^#Ib8(1aY-?jX66qq+Sef z@bvUPr=-F>+k>V4pkc$Hknp*;^?AXWFwy#s;(3<$}6Ba-{Ab zm-g+rM}U4T2ZFNMDFz4Fs6-0j)?`o)49?+KiAek+F6^MAhI2di6>pC(O)vYAk{p(OO@S?mzP^r1xJ7{=PZ-GYua0m;eS!OWM z;7&;m;wk ziAMilwF|v6kP}NqACXtzD;-!VX__uHwVJ%Ml$m*W`sixKyQeGx0telnQ&@(p+TP(m zw7v@obPpTUcuJ=GdelKDK8U>H=7#LYlGNcUA!&}h_349owjb{R^>4edQMG2CiujBmF5bC}YXDh8AN|!3pc}Uc+onstr-_uQC6d_Mg2a)mN zs}U*b69!>LSMD?u4$K)ypf%f|{MXz$r z@6C3orUGxuyfp2NwrNqRbDd)Z4iGhIAM#qG4eMYEPTxwHRiCD?))C>GKY=EhbdV)` ze+gLnRX($&oEgSEVNp^<_%O1JNC-i&Gu!<*FX$M`H^2tJV&)i*EZu*}<;Q+|weWq4 zv%X{54K+n|M6#m z{{<@}k%(peTUt5YaAGxz({StjTCU?$99xrZ3HkK*RMX7PlvWKmS#A*~;0Pj=e)ySl^nW+8v^1Z5crC*Jk7M-@EVPr8oA@N_m9yRJzb4D6Xov$n5jXTCg-1@p8BV zWPAHEzhXa_sLXVtf7&oqwMpe1b5wK}Qp#dV^wZ#n zy@Jx4^c+$l100RA8a1|u2^V5BKvy+9HzMg#=j+K$W|PxZ^f3Ytd?|h$Gh8L?8G%tf zqS#+-Z6Iypc3!5#Sw zjczdYqx_o)mtCZlX952n;Bw*AisD|n6oozOYmElXcV|9=xd`% zi0pI}Q8itmyPTk2ZNCPMi^gKEr_`&A!m2yRq8sw#Uso`d|Vb79VorY*s3 zU84~OR}7;2>n@`xxlrxr~N**60Z zT)H+f6X-MwzOgr{9|rmumj9lY{VD6XGb%OV7Qe8n(QL-@%Favu!p(B>0>?6ERsp*L9?#oqI?qZjfDl=ii< zQ6o6fdA<5Ry}O*FuRqBGPWuyq++E9q@QMuTNG6R+e4pY=dk3gM3!%27jnAIawnSw7 z)?F{LvwoB!-tza}gYQlg8hV;_=GP&)*-fQ>C@D{JWD5!Zo?Ik8(lPq=7msDFwIls? zwEw>cgNI=Ai57@#Py4d_N0LM`#b=P(!Jhq%U4Uw2>%Al=F$V5pE0+weC`B>S`BRS` zuFJHVgKA}k9#!SO26O^3dwN*kihWN0@X3Pb@u{7D6PJ1w)B=u~bi1tzuq7U9zd{TW4+uVS3d; z;28w+_wAfYAK$-Mc63ywMJA(QZO|*rELXbs^VMXz_ZYfjv$h5U+TZ|9L+uZ`n&+o^ z2i7~=K>i9yVxTePzPwDNT*yGULkH-P)VGE1BOilC*S;`4^B4R9+d@@xyYCRs33<74 ze96Y9_r-W}a*QJo3|NT}Hz$j`nIi400_>g%%zxC(Ti;Ds2A8xje*^kUhwiP`GUQTpGx^6b4N zgAO@my_dQ{ovaphJn4> zUECPr6P(~D>lhwe02Qm76SNnTFZ$l^rmLYw6dUBz3jHp_=DPJew%f#fZFUA?S+2zl z$Xzc@<}5{T>V0n}IkK~<(Sny3?WI`_8oyxSpbD+z$?uQ0rUQi}4UID(5AeKvT2{u2 z3ys+sZ-`4R-f6jRc*r_5HSHl1mX;d_yuQI$(-)TlL8JRE*RXQE%H|2?silROXfl!A zDE9;`d`EX@-6pT@9s9PO<>f!!jojBbFEPB2o?2!cUsJN=8tI07Es zF^TAgV(A?INvq5;jiwM4OS4|6-7A9ZbelW}ee9|roT&phEe(|8qjdwRE}H^TqQ@aG zjdr3UdE1S3+|O*|i%9YN^NAg8{&OC`>V|AFft&8^YD-1k`)*CVTxm%+txD?`ppSP0 z)zGdl0&dH%K_5Gs8@$hH4ca^hI_G?E>N$93+6^9|ydYz@ocKb@Ywufm1P&Ta)8>>P z!6d!aC6(QL}-s7Ri(HK)Jlprkl}Zmp%B0o5VeRDyM;djl+FF z;EexOaG!}n1|PNCco%uo+2}up7S@zH6ME3*y&ofbzALv{F=Yzvq6*T}*B8B7Y&j;p z6LHwA&?qJ+<+Pqpn<8zS+TB^{w5WcDxp@y1u7GWvLnFxS;fc8fVK%6z0$5^zQYOX- zp_psz`9gLyFg!=;duXtJnhKt<{Q&-LDh(Y>=XM5av84$G9~gkS@dUC6L%){i)T_I@ z%{E)t35XQhov{{O1HXVu*49=LbvPWA+K`fxV#Mk&>yh^vd4*m)HSBD1Ea%3@S46v# z#CY;^;>Kv5wKXykE@zc(Di3MvjSg#K3?*;R+y7UJCSClH9~&twnWL3Yif>$(GL=NG zM%VviR#R%IlJ4v#)s-Yu`MWCh=24qFvt`sAg7lWdCB&8^x%l|_;2Ir)soqS9~*Zt@y8|RK0Ou5FMuba;-Z*r*)oRmclTR9cEF1?Jc=+HYOrF&N8i7{ozXvWhb5 z40wHSEWbz(RwVBp#^xljMj}Hv0Rhi;$u3!xMzI>>OG;rNsrar>lJ!w6^$R8MdVf4P zUsVN2o&moG&?(_>IE8Oz#|vSANF-M!oiBd2R$=FvotXM*%#1%!V*>bX$?k5V5bVo~ z>uZ3<2UPkHo!gOaxdq!x$D7G9e*W{9u8D3aG`~nkqE{P;4r_>1=i@&$F_`;!)B7{|=g2vw4^#Q6Rb7>|{gdDA z*{)IvLHH_K_Z@O5^YJXi-B7`{6wqfX%Di~-f*SK|3(j=ZZf{a4!JM!w>d{-o9%bd8 z5=M&yP+6%f;c&*U;g+h@cymijix$QItn?6xvJoPy(sf1&VAeVFX?=hw_W~@MDq#K= zAbk^}qSZyCkP&eyCLawz&=8g)=k`H!D|whuDVPP&B)(S@_bDqQ@ceVxquK?!4J3VH zV6dZ6&gIA5VoH-B^x=n8ju@)U>lZ!cWIU;jC!vy&6a+1o*DNd0=nQtd5IhG3bMsyXNxMFpj{eobJQ#*b(=yX zd5yCja3k^MKYvROP3D>uY?U(+s#njf@+^sXHjNPz>bUp2NzqmX{SY!Vt(ZI;va~VK>;2RyH+V|P)2%O$%UD^ZLfgaQa1$L=@2+LI4zGq%gLEBs zhRIis!VWc_2ER-YsH$=X{;^~1OgF%OU9#PKA62EM&M=j?$Z!=8;XHTms^^h%E7h)A z%*tB6pQXd-Y;@a7^AQOCdVDs=>!^~i=XNYTAwN-JttHL5%|dALuCe_Jf@huA>>z&SZz z&CxOB_kZ~{1%OVb4u|UqT2Lq*k^hj}B8IK32njzN`A{W5yk*R-J)OC+F`R+DcmOr2 z{QMZ1kS%TDH4c4Ow-=x}_VEMh?RLw(^dn=_;S;55&+Id!339jzxYpKEBja@9OB}%W z@*c_H&*2Ep%TN$U?S?8Yd3ziR3oV=GCuQ7TXGWrCC&hLGD(b;rY}9PgyPJWxxG8da+SN*sc~79fJAMWbcTzd&1e9_MMTIXG5Byn&--iLKqo0;^WAho@On~`@{1SaKVfg?8eQD#M*;W%)aN@x zU)=iaZ3A`C@6{WPF8gLe50%c4?7Q15ObV_FK$`{Nc}v(`#bA)dTe*^n;rA*|{ZPu* zgWX-5hOyoML$c74st=(9i&f*y)I`^3rdrzZG`WqWh}fPKU~@xUo6dG$Vcs=*kL(h| z+AjY%rz^T2pQXEI`pcAjzPb{bM88d?o zn(@Enrnc+1WD;3A^5~|e1%&mq2_+>7VORq3K3AQz_s(u^^A|%FRp6m-d!h~uZsT$Q z=}Aa{Pbr#=H<#1oXej5(U5EhX?cvJw!IoDv%Js?+J4*RKrQ9~(!GMLQ;$Oo^9MHa+ zZz5w&bhz7epxOEj;JFbEzaqrWNbc=awr^9RN3DY?cS0-Ds~-_La%-pARJ*@VX0TDoet9U{FB4g8c7J zCJ=Fe6ub$cGfSz|#AzDL$qo2l>GQX4*Nfz*Kq2sc&Ry|!dVl}$BXuEt4RSKPiym;~ zf?*>@3KEi0glF37!azhs#4pFR`T+AA@LBvtYGPtOMV;6V1>W})#?O2b?^dQNj=&Du z88kR~JzgI5-k#5wS4=oL?LUD4PBG$>`^w|?V@U;ty?jbG^D3=mggu#v7X}`{J9w}R zJuR7gG(r(GRirwStKIq-8wn}NBm->`Q#ms0NU)BYjs;05gyIqT9tZD&DG_P5LI?Pf zk^B?aM@U-C1(+VY1_M9>j3~MJec|OAgcV{8)+j|nwx%=k#rX~YLmvWNxXny{1pQcf zqTT}JeulNSm&V7uOo{$vf|r2GzHS2+_i-sb{bM2UBBI@Nz46_E^Or|V8RHh#eZs?M ztw6yAmg}6q!)u3Q*yOtRgW5CafqEV#tL9D|I6XeyS|~p#TB9u2zL$(^b0+&(l<;Tu z7}(s3F_~8@N^PGMGrl047}o|jm0v{}3;;jl6!V*FKT;pXGdtAkkFECM#03}8GyS$W zu`SN6)+(ug6X$jQMG94axZdfo?v=zxr>b#n<_W-D490{{ynJQ1rzZR23dDQj;L(Gf zv}ILwc(2U*v*UV-{3tjQr8{9zg-UAmSFeU~>+9=F?rqjWDcN{iD;9tP;NCVqCCl|m zlY(K(-C2{FCB7_evVO9pJ@2iobbwi{apDwjgSigG|B42?tt_k!FAtpjrQ~!7PY(LH zR3j?SD4}I5xFc}04qMWn7vc%CPML_N(d9IK_4#EgyqC@z(pXUcv!Gt0P)#v~FT;Z~ zsfA#jdid8mrvM8={o;df-W_Ze-OHsn`P`lO)gG`!Ht zEmNv?7Z-Zgn!u!44#?dh(P8gUA@+y~IDBmzBEK@FNys99y)ts&a=z3=$&8PPG^JN~ z9ZhN)>|fzR9M=aVM|{im9A{V8a*3W^e+qGP?m_Ujqv3CW1ZE_IBfW9->G67oyuj&p z>OslOp}9nTe0_?B93?Lu9ecZfx8;t8Pc170yTk4#(e^k%Ozf@EYSo&+^NSHK9~b8H z9>1}c4rs}pw80jzD%pnOnR;B|XO`yR+I>4&32*<08AgnG}nf&B2lL zO(~Njsz-u=Z>DT=2QQ$zG~|Cw@_cX3+kUy@>dK2|)oVedr9kcgR;;-ku+U`^uEjj% zKk9bj0sWOXqZ=_q@Yf3EvvD&r^4Q%Zos@)Ac}{{m08o0N4-}KzISV&zGIB?owNKn& zdOp=6a(Qxc1S0F%S zJSb4+07c6Dg2%)>P|qs5YHb3^$5&Ck8{YDANnZ3!17%CW@||w3)+uxOR@WYK&Ei2= zSJw-XxIHm@bH$b)J}l-P_^}I1{?ADFA|`A(uWI4rmp(6HUw3*&SIu&dFDZVcJll#Q zR9V!Tbn%v}oT70V*Mg6{Li>sR&(O*XN|>40V)n;`g;!)pDCV4YwD(U2pIqficIMmC-A=Qt;TjxEw*Cty>v+JW8F z*|(+BZTd9Hg~7Wz)n<4+GCZi$#bzm=x$~lSA)d~NpxR1qCodwdiu<{ysc7x6l{1+U z95QWzs%kWso_|+SfSa}{6J+T@4Xe;kPq8@n6k?H!1GFrF%vtcod8YCVfpinMwEr3^gR7BC)i_(OrF=}xF(BbTIZ2}sJ$3RzaotKB z=UmQLTsjuM@QDek52c>&GYOv26@3{Nb0XB)%W)G6qNA>+ z2ihnxO|kzn=$7mor<U_P5nE|!i*yQPoQ9WzS$Y!W0@lX`^kZ4SOz0UOlb zCMMf_3kE27Q#1Drz}cVv9oUTSf0j@*)`iio|0n)H0!`3(xt?(BcX|CQ0M-G(Lqzwo z5O|j`@ys&xY%lD;mo%MAt!%$8!CooX1!0__$Ak8D!0iJQpy(-!Uy$r|G=|wSQ;MEcg5|1sX#(|wy%z> za_QOz73nT%NokalZjc7)?(RlFLMiD6=@x0&NP`GScXvp4cYcGO^Ss|V@ALin?LYi+ z@9n<#%-m~c*1E2>uCY)dt)OGx=mgCfBxJq)juTA1`vePpebbNTwLiU)OS(=Y2I>tJ zj?_M(U(w6!x|Z z@;q(qJar}yYnoH5=|SA5EYFbq(0rSpF~3_(9Cbwb^d?Ws!&%lu)rco7a|;^kor&2J zhsZyMqtl9SL0IWn;A!^DubV2Vctn;%VkfH{jx;N)1p>(_+P6K^?g~f%A0z6!+(}j-A^<>NDNXn>CKPm)A z_AN6%4a@4;{&Yj=6fy~E!^o_DU4Ab>eNvS;Kd(QbCYU)m^DHUFWY&#Ke>}NBM@2Y3 zSvkIl)2iJi4_^Jw#2}LGgUqY1nDXDO$ae>!H6_8utv@>nez!HSvBqPcZwql3Sx#;p zq_Xz>vV&9Y1rzLxc2sWl>n&bjx0pZMiO7=QPVa_s$U&=j?f|Ud|B7pi`cBS(ajLu| zWjtHTb=vCfI~68}xG9eHSadp6bVsuV_D$}wlJ+b}BSEOjXr4Mh3VyIfE8+lBf&FB9rOF-tX z|L6Mx4^$;3l-xMR4>-`kQWz85&(HMOJxerUlTe|2OlK{p%01~0BTSZD7rZcA%hrgg z`;JoT^`agpa=45+@=>zZ4ihJ%WI7WIAM-W`JPt&9pgUjoPO%MltsZ4EAqC+4?wXI! zm;vQXrR)6*DgGLd*Y#PD;hos@()|?)Ozv-%J$f(qO-%3WEF+|;$h|0br|SW#XeYzUTR!uch43;7M9q8)Yv4{-k+4_F;DLh15GG(0Del$x71&0C4Q>*?^C^U3MAi z=-$A+dKL=5+r14jtIB!Kdg#2`nXqH@lx?^RmCfgtR5$kWA3k1?rT_N$?VIyG5&?_O1MUX|=QQ zS@7}o@wRi zMO(i*>d~6}#mu*@frppx4Q>ZmO_?pf%`cc?9Uir`DRnz3sTw&bB!BB$%T~OldNmF5 zCIMTBa&T^G7D+6}bvohSL{roc5s`{1b7yG#tT*K*lZ>>60rhTtTw_NxQ+{W*!WDRz z(o`cmqlF=#df0?MkxclG;z+rN6N#B_*Lfc_6AswWPnhf5;4|AsrnIWq-MAF0DUP3K6lW zyy~5Dl$Dj`cHKu0viMY5tWgPZEI0ipvw^ZPVLNd5(;`Z|M1F_gu5%~)yQllU3=e?4 zCnhGqAB%Q0SZdfAw)^vdaT=ePz+46CoFQEIe2wmu#1}I3@t@kFZ(&iV=$!z!R)4;W zJ2u*h9sE-`FuUHhnl7x5i(S8PXho1Es10zur`t0#U+@73g%(1oQjt|ACS`^rm?<6T zEK2pFQewu6k88{pBb)7?l+-S><*(xd8B<_wxAeb!~0C zul~PDi^Ev8BRw>rJp)G?l+%0>*J?7O{B6vVm-ljPj0_^hbNT*(6O)eWHF@Zs&%pUh zhKZPgy#DlobF?uYaodK-M@&qm&V{P@O-md$s`$yyRxK*oUBb>m#04QjVb0E{M(S_X zvME_ZGUUIs){(`;Oy^kR2WUz=pNUe0hUjg3uQU%&+s z>^@){f3p&As9A|8EGh|60zaGZ@XQjB1M3BzNUMXV->JbX=R3etZS2bId_Y5JwC+|{ z)vN}yg{`tuDJe7R3+MBg#5&`!EewRlu&pflY;zkE&Kct{)(|rkCg7lGRdS|E;(6X1{KHpu7zd2*L@zVjEYAR0NPe!0>(jhyzlOe^gYB8|;i3$+^he zvF}FQH=YI@ZZmPaQvPiFe%1Y`T*QHklC93;bzrWfr0gZgEe0Yq=G`$V4j`AA-g93Y zCBfsyD0*t@zd*T!3$>>Ev+68>!M8Arq)L_D9M7$2edx8wa6Z88ROmH>(IlH3PDK9XUGt)@vh!khkYw7s}0s*g1+6J)nv*Sf`bbQyiInffREPC1h+R*|v`5la#U z3VU5EIqc?v71j>fplax@eMwYD=i^auw>AHMhDz)hMjw9oLlA!E0@68?u<6OjK3*ts zt-)4m%pI>imG5>G1vOp-r3_x)n-Cnv_3Qobj%1rkDlW1y9D{PpQo}y?)vjy$Z?&ct zngpa~FfyaYc-w;rlH9VszFlVQEO?p=lK>@Vhj*MT!Q8cBhE;7AiZ3H=up}Ld7?Kel zOr8AMh{_hL*DMs#M2IlK9@@{Oni6@R#JF4Xw6WSonQidLB@Z9Zu(tC)=Yr#2zSOA$ zFiWDFn`LDZl60UnvuCVwm$#w1X9|`G8Yjh6$7-9+5cK!i-pP~>CN&`;70H@;aKaat z#|tyxo0F>=Y~vUn5+es4hJ2n_$3#cN7REC<4x07rUfc~vWj_ZBflyHOI6uU?_~Md1 zX{)WTP?%7GGxAM-5u1$8@bc{=f_u9UyWVHbbvPQvtQS8XzObXAad`&gbBkjHu6*#5 zHn6h%L*9tXyd%XlrKn?qX0$OX2+b=`S`w#xaA*1oM=wf|$u!<^9c@?Tw4!QJQ1JtZL5- z^d2^e!ZCLbw{Uz;gTC(7?bqKYPIMa|)G46^W~M8xyu7*3Nn*O378f(ElNXG6hK!i! zYTUNl`!p*nEA>ad*ex(pR(J4vaC=zfJ+x`)||eAI?6bW>AO*h@4Uoi4k#lJM`M zT*uq*o!bhMrZtM1;W7^mJJbT=NYp>zVUbW`3S1OYV~Sk8)DREGVlP6_`oV}$8}ez1 z&6rvTnVXv%##E5o7z#>+we?y9BoKMrHoaa+J3ZxZ`qgBiViVzU=5j{gxn(@?izUPR zCh63+qjYy?7n|^zKs5sCXsKK}+rHI`Bzv2B+N7#McwV~Njd!W_Xsi>;1d!O%@8;TuAgc7iT z?YRMTEBN_j*%5UJdD|Pd#OI@dLqgHZlV!Aa(1mHUq9TV$%vhxXkctd}$54a4_3>%E zb#MBS7Alwo_k!Awj`GqRmhPCUI~tQ*&QwTAIdgl>=vnYFV-(+nKa&M5kBxl)!;C(` zDL!u=)a7ocrgHO9Gt4!bl6c;rGa-3f$*HRg9YGg018BTa!*2JjwzjqPZYKE~zhr_; z>+UDL{avXqy^0zed0jCLW+#W#r}8#F>a})f_aX&HY#H2&kcc5lgd4UN{D3KPcfdu5 z>6TYx8%=?M5+KNvXe!OsUEn)j7xiv9uJAbD@8MP5UsAZ-p0lmx-5dK>QH>y1#NcJX z&_(MfZ*D$?+0oU1^!{Mzg`&{MF988c6G|_ra5?%hcGLRP4*2`eAo zVC!ScgRGj%j^Sbc=}UEM>tflwnR07HFIRueNQ$Hlm!8qV$c7t7uNbO5De+h=5wh>W zy%`sse4mV|^c;QD%qcp`_2af59j@i}0t1L*jy(`JHU&!zoOzb&C#q{1=3cm&Z^p^1 z@&0$k*x}*fAd*kV)_-=q^wpctb2e5PShM=>j(=p*Xo&li6oxsR>)5vT>6N(fMYZYC zhDwm0y^H?r4Wl*}HwVXq2Ex|nayn;n#|#S{86kK6_*>2EgUl`?2ghx!+atngT{UQl zEcjZd%V60FuO&Zws*zTZO4fz(Q^Ta}f|?V~kZO=6Y=r|%xt1J`Qt?j>CWMkx>IcOj zaAs|7jE8GQ@*Cu~Tu#?AOSp-;_k+vVU}I(FaX|*2XdOuU(t16m~Xx? z6@4~dqGQgU%)(r8dCq}&`F>y?^mPfQ988eVUaN)X0YmFn1aS-*5fxdRli4ZFYHw;h zDv8*{=B4bF=b?!L1FXNN99+y&0~zU2l0EgG;V$2vtABmoG}BCyEd3=D_w@(rhlLZ0 z6@&l&-5AI%%FO)W!TI@~<|+T$7n_YeSRuqDhT`994YlK24e)L5hx9_tD6x1ZW%!wxh^qtof zXC7b8nW3lWtx;1DqM`28w^dJhl7~h?CC^mCom1nfa|%Mo#7%aOPtW)FGg4670XmT@ zb?@d9@j3>@PS>>BW1_ziUgAT{t=8$)wWuhd)!g0O{hq+OI5;=DZJ#Z;?$>(kr>*L? z&yu{acioldb$SPBO80HNO>DSXiS?Zw1tnT6y`SfED_liISIbW@b?=XLTPo;bqbz;I zvV&6a_}+glowDlh?2d{RDp6@sr2cN_z2m^oaNiHA^Zv`G5Im=A)v&>WP+nb~j*rh{ zu>z-keFmOC3k0&cw?CKujPTjw&g|h@@eJS-mcJX5Y;)5@(VKqz7C%HISrFMGqL3U* z8_n5E;)4xMw{NR}pO+_=od_n*8uw4I8=0*8$)Q#tkxA%8t?nd(f!fh1icl#`W!1kK z`)G;Kzp6Py?q{$r3Kn}}&iHoTw#usYtDjeLNt30v=`zU+rTO`ZM4ZRD`I%ibu(hpT z{AP=wDLr(wH&n9kZX={hbgu1ts!&0--z}Bwrz9{XJTz%4u8}rKnoM{>8fU}T#UDP| z<{jul<)uFfSDLCvL(oNInzFpn|l^B}L=IA}t z6TGs+MiBHWL*K<@t@V1X&z*~ZkHP425R8W>Zm$B2c4QsIc|6w}(HsEY)e;sCYq<7mF8WEM{on zumwWwTG;KrQ}@RCsoG`V;o&)tGl{zA6Fv{S7LV=kUF-J(H}3|*R4Tl(g&f_9$m=>H9O}q#JDIY z63fTq|E~rsmb%g~(xA&&I0yaS*RmBguV1oozxc5r*IXM~yemZ#Ycq8w*yRg5UYU|U z-P)R(e%0QWOybor(%-*VEBJU_wCN^~zsVo1ps>)<$!Vozgpsk|f{K9!KfPw>S2LME zeX*aOr+)2M`ru@5dWPHV)bz3O@hzu1qM54BdLGQBws&}R40M1UTb!3|E z2`(~r3XZ0wIG3=9Q4nPgq!jtV+4D_lZm#y6!R=j5PjEeDStc};PhOA?X>cm;NNz>7 zudi^PYzeSpx|%ccd#vjYd_2vWb+1ch>CqI%)J8xLRhMYvw)Is9BSr<-sW#3lmqxJq zd3#Vrc-Z}8Un9OByIvr8{rJT-$jd`@J^xzkI4bSFW<|`uU-Ze&h2~i$#>Z3tJRln) zWoo+6L|rmL@5@uUZGOWD@rAZAr?vz=_aE+Y2sT@APM1{x=eR^qkVf<%D6 zDVBQAM(jr=(tH_7>@LDDAwJIW#`$8sDVY=X8>ft*X>r@JuQ0*G@L*6`ZfOfaTsGha z$$&~qIyb+DO9q-Ec|?^y8yMg+S5*yk@y-nnmKhxifo1|%iGS4@#7i8wzvFC+`I4KS zf~~Js@1Fax!1fXkHr_j z&b_^8zwz7}nZ&DX*X;DYCajz`>==owjW|s;dgdY)RT(NvBaZ#o#HoW*GsQbP`&k6n zS~phMYjT`F%XEFdU1*Z3-~iCsssQc%`NrD&Ih4CeBWC2r8hDXro6HOYb|%}#Lk*29 zc;j@w$4RdO>s`06wn%UqE3IJsz$zS`?%lApygV{E_@nWz=N{{}`xX=*v-;Z69JSSvTG%qvwW>cA}FZsN2PxVIS}W8Z-Uq4U&WgLzW#e( z|NHa5ufctPfA8PdP-TB405Vn|&0&I{2b;YDG2eT*zwT>ARICCt;X1v_;QzV-D z*E;%aVxOLlrNUD##s+GuuOH3`kV)2Xokk(TtENxo;ZC-oMc>g_q#d)MVC#jG;(fZ}C(aKe_)T(_)XhgshIFSQEXw&yl4LsrqHC$>SqY^b*23$=jIz-7w+#|105PbDfLO2`R(;td9`be zg8V_-{4G#(inSLZQ250jc^x;C3%ruoLHJ=NDt`K(_t7e*QW8@!`FKOQP0mYFC1~=Y zy<$$>ZyRbv<5hrfYo%4~4nlVj*3ZfV^mV@|?0!2~8KD2GPXQbm#R8P@PT7+CfCqMy zLqSq*#){t>TJ}rW6J5ykcp#UMr&l{p6leHEP8=a+XT4xzfr)myf@!E{gq(t-ET(W9 zNblT#_ZXP-I3KmTFK^M{^G6QL#r-cHSVP6^;eYeNV%;Q?)RF{A#)s|eqT;7ER#qqy z8FG;Fir_Mxgb>v+khUS+^kg)`c=0PA>5s(`!=6Zx40E(NDMzLQkxWHl-#1}|nU)KD z47WyNDph9ERwJY;=TpQ#lQno`( zk|Ii9>{;Xc@^^yjO_Q$}D%yr=V9-f(@pzp@#b`V0+G{2hG@MlDON?7;$~kLw$^1YZ z&1QeY;We?uZ*I`^-ILwgtLe)Z6PK0Vgf9V9d4wxz_!}&Gz?GscEO>PDLbNaOw!eP= zZMbg3OU6xs?vf_Yy^JC0bapl#t7%Y+M6+DBb5cI+2)1Gn-+UwULKfPH+o1lXczboC ze%vpXU7lj3eCK*k%x!WK6e_(3Y*OqYHqwnp6CxFap4UkOz<{WWOZjouWd{wP1_nOi zWTn*lg);$~5O`1cdsfurrS@-*}$g>U39&V!k3qRpY@9n$BEcqWcU{TRr@Wxw5 zQ|tG(g-iUI;w{5$xTGhKNLT&<4{({6$5|gAKMwywgiB0#Eh#NzaO5AtU&FyI2ak+n z%_MTHz={qY9tL=JN~)?-CWthxG*e{JvML|-wN=tZ)r_fIqqQQ9iOn;ko^Q4?hkv|5 zLP?ojpE7+7hOVy8UDB*<_48znqGSvueSA!KrqVNYN^zVWOU3d3JS7{l@^_?#(}oX^ z#~3|RS73Eq0LFoBxDh8v^%KCGJ$UDit#tUR+qO@g!v?hw(=M@ ztlc5IoQH-|`9cX`5`1TBg%C%F7ojAUwzdP-ksV<~sd1i?94()41OD<9jg8^EU@smX z1GB-!f!|6j1j1|+2|UDB4e_D-kjCqf;1C%qMV0>iv)!5fsp_Vh8o%pGpakFNWh=h{ zBeYR&@VB!m3OkX!4ZO_?#}3%s-1_sK>ra3Ip%W?l>EdJDSNsk>Ki zR+hn)87m@;Z_U=J8Y0aVK~Im{+)B3@domk-*g?2Gke&4NEqt@#{}Ms8t;s%q**AhO z5d(vjjWwt43)d@})g{Vl0$ZA-uXrlM;`Gr|LI}u|nj*tpk}r#TwkqHXk&M-%5h1UZ#ad z#P*69915vans(u|p=b6`RzIbUEX13i7zPUXZ^?DvIc^?B!=e%|xZAsWUzd7cb_{(3 z%F4sAxtdj;Klmvu;pp|MiRUz2rNbu7aJE+5AjWx6Ab#Dw)}YNV7|YlEA=ga8v`jP#Q6D_j?d5 zq$4eDzBOT8Dr}Oz#jDj-n$7k&PcPM7C)pfoB=D}yg`;y1#=`F*cQfVXnf32?n5}U; zZjErAo|@u)ZMN93k#K*qUX8W#nGzB}i6?OwMX4z+5Ao08m-=6myDKjC!Sd8KRMs{( z^)LB&xMGKm;6wgnZVjXO4Bjr(K5+WMY^i@&OVH{M9nj*6Kp`Vm3GCn$+ z7JD#comUR(kmB==p097;V~c@|TfnLkv<6&()wk(}mdZjlp?@Af?2G0^NyyULNHGOb zsq^SK-+MFW#MxOc(I%cZ@$2`E_AGXgbd|zWJJ*P$>y=sHR0ChVJTIlIC*m`waH%UW zLNerEA~NtQ+I8Ko3xVjL2{K*I5qNr%T;R;cky?h>+ZO9dU3vITZn)+H4 z4nECC3Qy|guU!M)p2xc>op7kAu6Za#WTpWuv|VaRlMFA2$kp|qNktaPtwZwsW>?Ua ziHA2Q#iJ<57_4z-#Jj}sF_Rg{@}7~CA*$!b@opzw>h%0PT)wksl{s15WNJ#oz&Po< zzh-}N?gZ3yqT3L8XXp0kfKYkotGc+HW&VYV*TZPv-w76#H}H_N%(xyL@1*TdrK24m z%>rZq9C~vS+Pm(3Pk8?Bs;hTZYGG?I(|5ImpW*i39(M>)qJi>%pe{2vP^H|ZjvfFK zuaf%KLVI_hZ?EYNUNPMI>5Hk|1RKL;HaITi=BCHy=1IzWpPpvFi6Cpq1Cpv_etQc{ zT#1RNebuHE{@A>t2w{|}hzLunjIMTeojpDLUP3!Nz`X*+p@RS%0IDo}*Vi`2oF?!t zlcwGi*Zln05Q45Ha$v;NYUuQNdVlsOEF`+$Yo};r4yrj}+@%{ci&UYr*4Y|CxW;bz z@@A+cb3By`SOdgWp0#68AfClWCi7%<3v&?>&_s*me@~sF)iM z)KS$;7=W|@+dc1UUw-yPX<;TCA?tv>xw`LHfugnynjZjbd>ivd=7*+jLwvl~l0`F{ zCObw;-t&(P{esjokpsm9>Y6y#f#I(M8#Ml)c%$r1L;U|@h=dD$mj_iF4F=@}#g!*{p!^8;2|O zql%%PZ>rqll6isDH@Pj<MYqO@t zM4udi*gTyrpj@K<)sC#kZ8No7LOK~EI>sYOk%08%_;j1Z^C-X5eyB8yaVvK5Da?i3 z*|}p`HGfP(dWu721ks$=l~YrfgOIPYq}=7GaG(U0#I%)pa?WVZY>d_Gff^yon6R8G zv|ufIc0JFW0r6g9F$sPKoLRn7?odP|v;qK?#sCa1b$|$4wLt<}YosBpV zMfHaiW2M_=-;|nkcjvDZ=regb;NsIvQA6NHgqhV4aH5Jl%xPhxoJ(`7s?OF)O3C~} z#mHA*Ogs|=c^dHnr#bVpvGd!LRMYgl-^;ZZX~G)HG4+$3V(KD$tOvqQTOgM;XhpmT zN}@R0{WQnjTS|Nx-c7A_*;r%;z02>7El{r%wE_fVE;^$uYyUsh2_ zQt`v|s8g#1r5PaMp*AMb(B(xJim7bI)DM<*iA9NiCXQ}aDEl<2>u1r;G*wt!%$6t( z&P<4Yqx1c}`ulaEBf@|8$+PjFePXCqRJG40S)>W2kGT^(^(z)#uHB z{W|x&uE^d`@7i4v-_7tv3;QOOGikz1nx;*jLo^utIR7HqRS@$DMd6{lyv^%85}99G z_$kYn^JO;&uHcnKd|$Lej037fWwNPOX7F9bg*rTHWQ8Z|yG?+&++Y2_?xwl4z*&XcK%Sfkku~ zWs>LU<*SPb?crjdZ_MAWZ%FF5Jt%B(^+YEx6in|4O&fAs zs~8&vT!-4ZUJ0E~NfA=h*=ou|A~|jnsomx2-rNp5H4A?504xS_sciUtERAV*tywTm zM3cTfJp|@(_h-_?b42Z%evxEfCn<)ZDP|~=TVfnaUu6&ocPYfLN_d#%*m$>nwu_0U{?HkZ%8ch; zs}8WRfej5e%P(Yy=k!x#;b=Yv%a9QXKx7mw6!zGjIvG-{cSCq+BH!oqb}}Lwqs5!i z+9`hE4)q;*qemYU-Noce^h!fC+MhKQn3KG$G9z@HUQF1l7>Q5FP%|(?YLpKuqBKnz&Zn0 zoRK65d3AIgq3Zem{e|n~`?D$27SrXWrHlLfqaLP*!$$^XWF`XP+)I6d6epB?9~Anm zr9c(~Vs()DiRve6fqiHB2j!XqJReGSc9ro%nR5hCYWMI0f1D>WbDf@^%G@GEX^lEL zKzMSk*|SZtV4;eli6b?j=7W>;&*tp>a3X(`4Q9)Nm0pv=RmM7I3o)9KxMQYf)k^}rYiM3GJw|Zzfc&@t!W5< z&5+u6`?;-Lz*A0)+CAptky6Vb+tEy>QF8 zHG<)Z}Std5ccAAGJB?Q&SdxHI}eN2a3_)_=z)L|6NSV z`H7Zu0dLDG1l5U-unZyJ$Mr6ogiSWWH+9H!buP&82rCimSH4YG)9KzdPBa$%JAh@n z*}vm;={39a`2(P+YAaT})7RSDWYYC^+$8W;H=$<<2$YFopHu=e|}|D<31;O#uWzUzTtqoANL$sn(SUkY&C6gtET>GV{8i`6fMFZsc2vWdgc z02kp{6D))$6mt~9!Vp4k#4|wzE!ay+Z};Wishf%W8l!{7^=hl@#j%OI_rI<~00i@v zK4&AJDi$uY^!^h0zA=6Wa50b^dNmS>Z2y0xbdYFAuSTy!=n3O2<<;5DN}%4-lHRI| z#fdaA;~>QQ`}$M5#g2hdRpe1#Bswz?{6MVYj`Nnj1IK8XW-{95`qMN=50{$3#K+wa zeE)$eN|Mh2mT}mjc?LW1pFE56>du<->_+0EMZw zGT|Sa1}vk$yD;imZMFP z-h!(Eah(!57t+VOJQ_O~;}nC0+~u%CKMA|3`do)D+6jOQ?gj9aLgK$uLwMcPxBba} zKZ2m_%~PSm106K_1fGQ7R^DA8$nx})68z=>bHU$+edGLr^q)f?NUUPqMyMG{PdZad#a+A}#u^_#I>Ec&cKD|!e9){fLf!nI7T0LWQD!;?nr=?@ zktG>DcJB!)Q#2Ho83!nB8Jh!6E;qUnxy)n@)Wd*oJMuo1gT|`rLX$DL<(XvCW z1sR`XN?>vn)k=t}f|z?Kbx2#z1b}DD&)u>J=F!#`7q`LMRKxqL=U}-T0@P#5%YGyG zcgt%Gdx9|9`+rPC>q}mA=PnA#QUulTo-D9BTf3P?hA ziPEZ5uY_A^%a!9IO5|+~nwhOsyT8@|_AxRn_sqnvtyC=lt(*H?TjNSX zVj1G#kiFgyisOav(En=m#A~gpJf{_xK-^}sq!p~t-OlpN7n@Xg_|dDA>Sd?}u_%_A zA1QKnOu!i(;OsbXaN|wuDqZ1tQR&6$w!n%Bx`a^?eKcRRn3NPhCtXXK%c&&5<)ae& zn%Lqf?OYjNChS(#l7R-Qo{HPA?G}a)XIr|8^aB8=55oVSEEJcEgBC- z-^6NQN}$JU{iCu$&i~EtAbc zM#sjc+)2oO?{^x!H$4JCMeD{F{KN1a_0Kj~>^w0%IEY3-5P}vQ7G{n7hxAF#J=9VA z5bj`&V6#jnvAm~|l)InH@Os8iEW?N4@g=+lv^B+JYtj#Ko&j)sl~4>GZ7pq&8GrO` z*M}9tBIbxUH_JjxLDch_o^}Kg^5Ss*cy0v6TV*pRAC2@Q|mp>|!rYT{_r-jBKpd=xhpqRIWC+VZEIds=Fkt z<1gQ=s$~#RmG5Yj44EOZv;?369q!aV{sf1EmkSg`GpkzhywP)@n)Xj@M}YQsY)3OL zs88TtEAy+IDoP}SyJzo9QT$>2?SjNw(D1-Za%rQ_;*7%@Xo*Sg8wW<-{IDL^EN+(% zSr)b8>jh3SW)|{3O{)#TiinnFxzH*_od0HOZY4O%Fv_om3Rob_Xap+pv___;Z-SD{ zMByyMjh6J|$|XaM;@EodjJ4U!5?-$53gQ!LethPb{7O2u@TqsO(No%bS@qQxQruz{ zkIN(DyX_@vEF2t*N{yHz4+gEK{i9%nrXWn6`{n4u39nhmu5WO#BzPlht$+GrUd3;4 z$=_ZAR>9?V*AX_%|API5l?{4?=_;;fdwMQFlQB)V;)8 zN0X-GJrB6d!NngX+FTu_Gd^g5Rwu&1dbgs6zxq!7tP{gc;NA=9;m0I@q?aHw$B=j; zW~x5>GdQU4!{6eNx$mlUrO{0WM6 Date: Tue, 2 Jun 2020 16:28:46 -0400 Subject: [PATCH 298/469] Delete README.md --- src/qt/plugins/mrichtexteditor/README.md | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 src/qt/plugins/mrichtexteditor/README.md diff --git a/src/qt/plugins/mrichtexteditor/README.md b/src/qt/plugins/mrichtexteditor/README.md deleted file mode 100644 index f76d7e39..00000000 --- a/src/qt/plugins/mrichtexteditor/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# MRichTextEdit - -A simple Qt rich-text editor widget, easy to use in any Qt project. - -![Screenshot](https://github.com/Anchakor/MRichTextEditor/raw/master/example.png) - -The icons used are standard icons from theme as defined by [freedesktop.org Icon Naming Specification](http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html) (which lacks button/ordered list icons). - -The editor automatically converts plain text http(s) links and emails to html links in toHtml(). - -Courtesy of [Hobrasoft](http://www.hobrasoft.cz/). From 47f293ddf56ba45ed85915eb8a4d86a479e2660a Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:29:56 -0400 Subject: [PATCH 299/469] Delete allocators.h --- src/allocators.h | 259 ----------------------------------------------- 1 file changed, 259 deletions(-) delete mode 100644 src/allocators.h diff --git a/src/allocators.h b/src/allocators.h deleted file mode 100644 index 3d0637df..00000000 --- a/src/allocators.h +++ /dev/null @@ -1,259 +0,0 @@ -// Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2012 The Bitcoin developers -// Copyright (c) 2017-2018 The Swipp developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_ALLOCATORS_H -#define BITCOIN_ALLOCATORS_H - -#include -#include -#include -#include -#include - -#ifdef WIN32 -#ifdef _WIN32_WINNT -#undef _WIN32_WINNT -#endif -#define _WIN32_WINNT 0x0501 -#define WIN32_LEAN_AND_MEAN 1 -#ifndef NOMINMAX -#define NOMINMAX -#endif -#include -// This is used to attempt to keep keying material out of swap -// Note that VirtualLock does not provide this as a guarantee on Windows, -// but, in practice, memory that has been VirtualLock'd almost never gets written to -// the pagefile except in rare circumstances where memory is extremely low. -#else -#include -#include -#include -#endif - -// Thread-safe class to keep track of locked (ie, non-swappable) memory pages -// Memory locks do not stack, that is, pages which have been locked several times by calls to mlock(). -// will be unlocked by a single call to munlock(). This can result in keying material ending up in swap when -// those functions are used naively. This class simulates stacking memory locks by keeping a counter per page - -template class LockedPageManagerBase -{ -public: - LockedPageManagerBase(size_t page_size) : page_size(page_size) - { - // Determine bitmask for extracting page from address - assert(!(page_size & (page_size - 1))); // Size must be power of two - page_mask = ~(page_size - 1); - } - - // For all pages in affected range, increase lock count - void LockRange(void *p, size_t size) - { - boost::mutex::scoped_lock lock(mutex); - - if(!size) - return; - - const size_t base_addr = reinterpret_cast(p); - const size_t start_page = base_addr & page_mask; - const size_t end_page = (base_addr + size - 1) & page_mask; - - for(size_t page = start_page; page <= end_page; page += page_size) - { - Histogram::iterator it = histogram.find(page); - - if(it == histogram.end()) - { - locker.Lock(reinterpret_cast(page), page_size); - histogram.insert(std::make_pair(page, 1)); - } - else - it->second += 1; - } - } - - // For all pages in affected range, decrease lock count - void UnlockRange(void *p, size_t size) - { - boost::mutex::scoped_lock lock(mutex); - - if(!size) - return; - - const size_t base_addr = reinterpret_cast(p); - const size_t start_page = base_addr & page_mask; - const size_t end_page = (base_addr + size - 1) & page_mask; - - for(size_t page = start_page; page <= end_page; page += page_size) - { - Histogram::iterator it = histogram.find(page); - assert(it != histogram.end()); - it->second -= 1; - - if(it->second == 0) - { - locker.Unlock(reinterpret_cast(page), page_size); - histogram.erase(it); - } - } - } - - // Get number of locked pages for diagnostics - int GetLockedPageCount() - { - boost::mutex::scoped_lock lock(mutex); - return histogram.size(); - } - -private: - Locker locker; - boost::mutex mutex; - size_t page_size, page_mask; - typedef std::map Histogram; - Histogram histogram; -}; - -static inline size_t GetSystemPageSize() -{ - size_t page_size; -#if defined(WIN32) - SYSTEM_INFO sSysInfo; - GetSystemInfo(&sSysInfo); - page_size = sSysInfo.dwPageSize; -#elif defined(PAGESIZE) - page_size = PAGESIZE; -#else - page_size = sysconf(_SC_PAGESIZE); -#endif - return page_size; -} - -class MemoryPageLocker -{ -public: - bool Lock(const void *addr, size_t len) - { -#ifdef WIN32 - return VirtualLock(const_cast(addr), len); -#else - return mlock(addr, len) == 0; -#endif - } - - bool Unlock(const void *addr, size_t len) - { -#ifdef WIN32 - return VirtualUnlock(const_cast(addr), len); -#else - return munlock(addr, len) == 0; -#endif - } -}; - -// Singleton class to keep track of locked (ie, non-swappable) memory pages, for use in std::allocator templates -class LockedPageManager : public LockedPageManagerBase -{ -public: - static LockedPageManager instance; -private: - LockedPageManager() : LockedPageManagerBase(GetSystemPageSize()) { } -}; - -// Functions for directly locking/unlocking memory objects -// Intended for non-dynamically allocated structures - -template void LockObject(const T &t) -{ - LockedPageManager::instance.LockRange((void*)(&t), sizeof(T)); -} - -template void UnlockObject(const T &t) -{ - OPENSSL_cleanse((void*)(&t), sizeof(T)); - LockedPageManager::instance.UnlockRange((void*)(&t), sizeof(T)); -} - -// Allocator that locks its contents from being paged out of memory and clears its contents before deletion -template struct secure_allocator : public std::allocator -{ - // MSVC8 default copy constructor is broken - typedef std::allocator base; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::value_type value_type; - - secure_allocator() throw() { } - secure_allocator(const secure_allocator& a) throw() : base(a) { } - - template secure_allocator(const secure_allocator& a) throw() : base(a) { } - ~secure_allocator() throw() { } - - template struct rebind - { - typedef secure_allocator<_Other> other; - }; - - T* allocate(std::size_t n, const void *hint = 0) - { - T *p; - p = std::allocator::allocate(n, hint); - - if (p != NULL) - LockedPageManager::instance.LockRange(p, sizeof(T) * n); - - return p; - } - - void deallocate(T* p, std::size_t n) - { - if (p != NULL) - { - OPENSSL_cleanse(p, sizeof(T) * n); - LockedPageManager::instance.UnlockRange(p, sizeof(T) * n); - } - - std::allocator::deallocate(p, n); - } -}; - -// Allocator that clears its contents before deletion. -template struct zero_after_free_allocator : public std::allocator -{ - // MSVC8 default copy constructor is broken - typedef std::allocator base; - typedef typename base::size_type size_type; - typedef typename base::difference_type difference_type; - typedef typename base::pointer pointer; - typedef typename base::const_pointer const_pointer; - typedef typename base::reference reference; - typedef typename base::const_reference const_reference; - typedef typename base::value_type value_type; - - zero_after_free_allocator() throw() { } - zero_after_free_allocator(const zero_after_free_allocator& a) throw() : base(a) { } - template zero_after_free_allocator(const zero_after_free_allocator& a) throw() : base(a) { } - ~zero_after_free_allocator() throw() { } - - template struct rebind - { - typedef zero_after_free_allocator<_Other> other; - }; - - void deallocate(T* p, std::size_t n) - { - if (p != NULL) - OPENSSL_cleanse(p, sizeof(T) * n); - - std::allocator::deallocate(p, n); - } -}; - -typedef std::basic_string, secure_allocator > SecureString; - -#endif From 2797aaced4ee1ec8537d20a994ea83e2235240ee Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:30:21 -0400 Subject: [PATCH 300/469] Update Makefile.am --- src/Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index b5a08ed9..ac252b97 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -104,7 +104,6 @@ BITCOIN_CORE_H = \ addrdb.h \ activemasternode.h \ addressindex.h \ - allocators.h \ spentindex.h \ addrman.h \ alert.h \ From 6343af37dd5048563bfe08437dbcdc9e1448aed5 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:30:46 -0400 Subject: [PATCH 301/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 46e6cfad..fd4b57a2 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1037,23 +1037,6 @@ void BitcoinGUI::openClicked() } } -void BitcoinGUI::setMessageModel(MessageModel *messageModel) -{ - this->messageModel = messageModel; - if(messageModel) - { - // Report errors from message thread - connect(messageModel, SIGNAL(error(QString,QString,bool)), this, SLOT(error(QString,QString,bool))); - - // Put transaction list in tabs - messagePage->setModel(messageModel); - - // Balloon pop-up for new message - connect(messageModel, SIGNAL(rowsInserted(QModelIndex,int,int)), - this, SLOT(incomingMessage(QModelIndex,int,int))); - } -} - void BitcoinGUI::openDonate() { openExternalURL("https://helpthehomelessworldwide.org/donate"); From 42cdbaed697335051f2c401b5948cecabe7f415d Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:34:10 -0400 Subject: [PATCH 302/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index fd4b57a2..4b5c2fb1 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -493,7 +493,7 @@ void BitcoinGUI::createActions() connect(governanceAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(governanceAction, SIGNAL(triggered()), this, SLOT(gotoGovernancePage())); -} + } /* privatesendAction = new QAction(QIcon(":/icons/coinmix"), tr("&Private Send"), this); privatesendAction->setStatusTip(tr("Show Private Send of wallet")); @@ -600,7 +600,8 @@ void BitcoinGUI::createActions() // HTHW Donate externalDonate = new QAction(QIcon(":/icons/" + theme + "/about"), tr("Donate To HTHW"), this); externalDonate->setStatusTip(tr("Donate to Help The Homeless Worldwide")); - + + connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked())); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); @@ -612,7 +613,7 @@ void BitcoinGUI::createActions() // HTHW Donate connect(externalDonate, SIGNAL(triggered()), this, SLOT(openDonate())); - + // Jump directly to tabs in RPC-console connect(openInfoAction, SIGNAL(triggered()), this, SLOT(showInfo())); connect(openRPCConsoleAction, SIGNAL(triggered()), this, SLOT(showConsole())); @@ -711,7 +712,7 @@ void BitcoinGUI::createMenuBar() help->addAction(aboutQtAction); QMenu* donate = appMenuBar->addMenu(tr("&Donate")); - donate->addAction(externalDonate); + donate->addAction(externalDonate); } @@ -791,7 +792,7 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel) setNumConnections(_clientModel->getNumConnections()); connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, SLOT(setNetworkActive(bool))); - + modalOverlay->setKnownBestHeight(_clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(_clientModel->getHeaderTipTime())); setNumBlocks(_clientModel->getNumBlocks(), _clientModel->getLastBlockDate(), _clientModel->getVerificationProgress(NULL), false); connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,double,bool))); @@ -887,7 +888,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled) if (!fLiteMode && settings.value("fShowMasternodesTab").toBool() && masternodeAction) { masternodeAction->setEnabled(enabled); } - governanceAction->setEnabled(enabled); + governanceAction->setEnabled(enabled); encryptWalletAction->setEnabled(enabled); backupWalletAction->setEnabled(enabled); changePassphraseAction->setEnabled(enabled); @@ -1022,7 +1023,6 @@ void BitcoinGUI::showHelpMessageClicked() { if(!clientModel) return; - HelpMessageDialog dlg(this, HelpMessageDialog::pshelp); dlg.exec(); } */ @@ -1640,7 +1640,6 @@ void BitcoinGUI::detectShutdown() } } } - } */ From 3646cf800039f39970372196fb14db8e63a716e9 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 16:35:23 -0400 Subject: [PATCH 303/469] Update bitcoingui.h --- src/qt/bitcoingui.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index b3ad8e51..9011d71d 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -91,6 +91,7 @@ class BitcoinGUI : public QMainWindow private: ClientModel *clientModel; WalletFrame *walletFrame; + UnitDisplayStatusBarControl *unitDisplayControl; QLabel *labelWalletEncryptionIcon; QLabel *labelWalletHDStatusIcon; @@ -100,8 +101,8 @@ class BitcoinGUI : public QMainWindow QProgressBar *progressBar; QProgressDialog *progressDialog; - QMenuBar *appMenuBar; + QAction* externalDonate; QAction *governanceAction; /* QAction* privatesendAction; */ @@ -205,6 +206,7 @@ public Q_SLOTS: @see CClientUIInterface::MessageBoxFlags @param[in] ret pointer to a bool that will be modified to whether Ok was clicked (modal only) */ + void message(const QString &title, const QString &message, unsigned int style, bool *ret = NULL); #ifdef ENABLE_WALLET /** Set the hd-enabled status as shown in the UI. @@ -228,7 +230,7 @@ public Q_SLOTS: private Q_SLOTS: #ifdef ENABLE_WALLET - + /** Switch to masternode page */ void gotoGovernancePage(); /** Switch to private send page */ @@ -249,7 +251,6 @@ private Q_SLOTS: /** Show Sign/Verify Message dialog and switch to verify message tab */ void gotoVerifyMessageTab(QString addr = ""); - /** Show open dialog */ void openClicked(); #endif // ENABLE_WALLET From 74a671e11889f25edb057fdf6dde2974905c9623 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:01:21 -0400 Subject: [PATCH 304/469] Add files via upload --- src/qt/tradingdialog.cpp | 1390 ++++++++++++++++++++++++++++++++++++++ src/qt/tradingdialog.h | 117 ++++ 2 files changed, 1507 insertions(+) create mode 100644 src/qt/tradingdialog.cpp create mode 100644 src/qt/tradingdialog.h diff --git a/src/qt/tradingdialog.cpp b/src/qt/tradingdialog.cpp new file mode 100644 index 00000000..099df7b8 --- /dev/null +++ b/src/qt/tradingdialog.cpp @@ -0,0 +1,1390 @@ +#include "tradingdialog.h" +#include "ui_tradingdialog.h" +#include "clientmodel.h" +#include "walletmodel.h" +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace std; + +tradingDialog::tradingDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::tradingDialog), + model(0) +{ + ui->setupUi(this); + timerid = 0; + qDebug() << "Expected this"; + + ui->BtcAvailableLabel->setTextFormat(Qt::RichText); + ui->TXAvailableLabel->setTextFormat(Qt::RichText); + ui->BuyCostLabel->setTextFormat(Qt::RichText); + ui->SellCostLabel->setTextFormat(Qt::RichText); + ui->BittrexBTCLabel->setTextFormat(Qt::RichText); + ui->BittrexTXLabel->setTextFormat(Qt::RichText); + ui->CSDumpLabel->setTextFormat(Qt::RichText); + ui->CSTotalLabel->setTextFormat(Qt::RichText); + ui->CSReceiveLabel->setTextFormat(Qt::RichText); + + //Set tabs to inactive + ui->TradingTabWidget->setTabEnabled(0,false); + ui->TradingTabWidget->setTabEnabled(1,false); + ui->TradingTabWidget->setTabEnabled(3,false); + ui->TradingTabWidget->setTabEnabled(4,false); + ui->TradingTabWidget->setTabEnabled(5,false); + + // Listen for keypress + connect(ui->PasswordInput, SIGNAL(returnPressed()),ui->LoadKeys,SIGNAL(clicked())); + + /*OrderBook Table Init*/ + CreateOrderBookTables(*ui->BidsTable,QStringList() << "SUM(BTC)" << "TOTAL(BTC)" << "TX(SIZE)" << "BID(BTC)"); + CreateOrderBookTables(*ui->AsksTable,QStringList() << "ASK(BTC)" << "TX(SIZE)" << "TOTAL(BTC)" << "SUM(BTC)"); + /*OrderBook Table Init*/ + + /*Market History Table Init*/ + ui->MarketHistoryTable->setColumnCount(5); + ui->MarketHistoryTable->verticalHeader()->setVisible(false); + ui->MarketHistoryTable->setHorizontalHeaderLabels(QStringList()<<"DATE"<<"BUY/SELL"<<"BID/ASK"<<"TOTAL UNITS(EXCL)"<<"TOTAL COST(BTC)"); + ui->MarketHistoryTable->setRowCount(0); + int Cellwidth = ui->MarketHistoryTable->width() / 5; + ui->MarketHistoryTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(3,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(4,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->resizeSection(5,Cellwidth); + ui->MarketHistoryTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + ui->MarketHistoryTable->horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * {font-weight :bold;}"); + /*Market History Table Init*/ + + /*Account History Table Init*/ + ui->TradeHistoryTable->setColumnCount(9); + ui->TradeHistoryTable->verticalHeader()->setVisible(false); + ui->TradeHistoryTable->setHorizontalHeaderLabels(QStringList() << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "Closed"); + ui->TradeHistoryTable->setRowCount(0); + Cellwidth = ui->TradeHistoryTable->width() / 9; + ui->TradeHistoryTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(3,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(4,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(5,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(6,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(7,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(8,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->resizeSection(9,Cellwidth); + ui->TradeHistoryTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + ui->TradeHistoryTable->horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * {font-weight :bold;}"); + /*Account History Table Init*/ + + /*Open Orders Table*/ + ui->OpenOrdersTable->setColumnCount(10); + ui->OpenOrdersTable->verticalHeader()->setVisible(false); + ui->OpenOrdersTable->setHorizontalHeaderLabels(QStringList() << "OrderId" << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "Cancel Order"); + ui->OpenOrdersTable->setRowCount(0); + Cellwidth = ui->TradeHistoryTable->width() / 9; + ui->OpenOrdersTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(2,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(3,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(4,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(5,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(6,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(7,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(8,Cellwidth); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(9,Cellwidth); + ui->OpenOrdersTable->setColumnHidden(0,true); + ui->OpenOrdersTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + ui->OpenOrdersTable->horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * {font-weight :bold;}"); + + connect (ui->OpenOrdersTable, SIGNAL(cellClicked(int,int)), this, SLOT(CancelOrderSlot(int, int))); + /*Open Orders Table*/ +} + +void tradingDialog::InitTrading() +{ //todo - add internet connection/socket error checking. + + //Get default exchange info for the qlabels + UpdaterFunction(); + qDebug() << "Updater called"; + if(this->timerid == 0) + { + //Timer is not set,lets create one. + this->timer = new QTimer(this); + connect(timer, SIGNAL(timeout()), this, SLOT(UpdaterFunction())); + this->timer->start(5000); + this->timerid = this->timer->timerId(); + } + +} + +void tradingDialog::UpdaterFunction(){ + //TXst get the main exchange info in order to populate qLabels in maindialog. then get data + //required for the current tab. + + int Retval = SetExchangeInfoTextLabels(); + + if (Retval == 0){ + ActionsOnSwitch(-1); + } +} + +QString tradingDialog::GetMarketSummary(){ + + QString Response = sendRequest("https://bittrex.com/api/v1.1/public/GetMarketSummary?market=btc-EXCL"); + return Response; +} + +QString tradingDialog::GetOrderBook(){ + + QString Response = sendRequest("https://bittrex.com/api/v1.1/public/getorderbook?market=BTC-EXCL&type=both&depth=50"); + return Response; +} + +QString tradingDialog::GetMarketHistory(){ + QString Response = sendRequest("https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-EXCL&count=100"); + return Response; +} + +QString tradingDialog::CancelOrder(QString OrderId){ + + QString URL = "https://bittrex.com/api/v1.1/market/cancel?apikey="; + URL += this->ApiKey; + URL += "&nonce=12345434&uuid="; + URL += OrderId; + + QString Response = sendRequest(URL); + return Response; +} + +QString tradingDialog::BuyTX(QString OrderType, double Quantity, double Rate){ + + QString str = ""; + QString URL = "https://bittrex.com/api/v1.1/market/"; + URL += OrderType; + URL += "?apikey="; + URL += this->ApiKey; + URL += "&nonce=12345434&market=BTC-EXCL&quantity="; + URL += str.number(Quantity,'i',8); + URL += "&rate="; + URL += str.number(Rate,'i',8); + + QString Response = sendRequest(URL); + return Response; +} + +QString tradingDialog::SellTX(QString OrderType, double Quantity, double Rate){ + + QString str = ""; + QString URL = "https://bittrex.com/api/v1.1/market/"; + URL += OrderType; + URL += "?apikey="; + URL += this->ApiKey; + URL += "&nonce=12345434&market=BTC-EXCL&quantity="; + URL += str.number(Quantity,'i',8); + URL += "&rate="; + URL += str.number(Rate,'i',8); + + QString Response = sendRequest(URL); + return Response; +} + +QString tradingDialog::Withdraw(double Amount, QString Address, QString Coin){ + + QString str = ""; + QString URL = "https://bittrex.com/api/v1.1/account/withdraw?apikey="; + URL += this->ApiKey; + URL += "¤cy="; + URL += Coin; + URL += "&quantity="; + URL += str.number(Amount,'i',8); + URL += "&address="; + URL += Address; + URL += "&nonce=12345434"; + + QString Response = sendRequest(URL); + return Response; +} + +QString tradingDialog::GetOpenOrders(){ + QString URL = "https://bittrex.com/api/v1.1/market/getopenorders?apikey="; + URL += this->ApiKey; + URL += "&nonce=12345434&market=BTC-EXCL"; + + QString Response = sendRequest(URL); + return Response; +} + +QString tradingDialog::GetBalance(QString Currency){ + + QString URL = "https://bittrex.com/api/v1.1/account/getbalance?apikey="; + URL += this->ApiKey; + URL += "&nonce=12345434¤cy="; + URL += Currency; + + QString Response = sendRequest(URL); + return Response; +} + +QString tradingDialog::GetDepositAddress(){ + + QString URL = "https://bittrex.com/api/v1.1/account/getdepositaddress?apikey="; + URL += this->ApiKey; + URL += "&nonce=12345434¤cy=EXCL"; + + QString Response = sendRequest(URL); + return Response; +} + +QString tradingDialog::GetAccountHistory(){ + + QString URL = "https://bittrex.com/api/v1.1/account/getorderhistory?apikey="; + URL += this->ApiKey; + URL += "&nonce=12345434&market=BTC-EXCL&count=10"; + + QString Response = sendRequest(URL); + return Response; +} + +int tradingDialog::SetExchangeInfoTextLabels(){ + //Get the current exchange information + information for the current open tab if required. + QString str = ""; + QString Response = GetMarketSummary(); + + //Set the labels, parse the json result to get values. + QJsonObject obj = GetResultObjectFromJSONArray(Response); + + //set labels to richtext to use css. + ui->Bid->setTextFormat(Qt::RichText); + ui->Ask->setTextFormat(Qt::RichText); + ui->volumet->setTextFormat(Qt::RichText); + ui->volumebtc->setTextFormat(Qt::RichText); + + ui->Ask->setText("Ask: " + str.number(obj["Ask"].toDouble(),'i',8) + " BTC"); + + ui->Bid->setText("Bid: " + str.number(obj["Bid"].toDouble(),'i',8) + " BTC"); + + ui->volumet->setText("EXCL Volume: " + str.number(obj["Volume"].toDouble(),'i',8) + " EXCL"); + + ui->volumebtc->setText("BTC Volume: " + str.number(obj["BaseVolume"].toDouble(),'i',8) + " BTC"); + + obj.empty(); + +return 0; + } + +void tradingDialog::CreateOrderBookTables(QTableWidget& Table,QStringList TableHeader){ + + Table.setColumnCount(4); + Table.verticalHeader()->setVisible(false); + + Table.setHorizontalHeaderLabels(TableHeader); + + int Cellwidth = Table.width() / 4; + + Table.horizontalHeader()->resizeSection(1,Cellwidth); // column 1, width 50 + Table.horizontalHeader()->resizeSection(2,Cellwidth); + Table.horizontalHeader()->resizeSection(3,Cellwidth); + Table.horizontalHeader()->resizeSection(4,Cellwidth); + + Table.setRowCount(0); + + Table.horizontalHeader()->setResizeMode(QHeaderView::Stretch); + Table.horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + Table.horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * { font-weight :bold;}"); +} + +void tradingDialog::DisplayBalance(QLabel &BalanceLabel,QLabel &Available, QLabel &Pending, QString Currency,QString Response){ + + QString str; + + BalanceLabel.setTextFormat(Qt::RichText); + Available.setTextFormat(Qt::RichText); + Pending.setTextFormat(Qt::RichText); + + //Set the labels, parse the json result to get values. + QJsonObject ResultObject = GetResultObjectFromJSONObject(Response); + + BalanceLabel.setText("" + str.number( ResultObject["Balance"].toDouble(),'i',8) + " " + Currency); + Available.setText("" + str.number( ResultObject["Available"].toDouble(),'i',8) + " " +Currency); + Pending.setText("" + str.number( ResultObject["Pending"].toDouble(),'i',8) + " " +Currency); +} + +void tradingDialog::DisplayBalance(QLabel &BalanceLabel, QString Response){ + + QString str; + + //Set the labels, parse the json result to get values. + QJsonObject ResultObject = GetResultObjectFromJSONObject(Response); + + BalanceLabel.setText("" + str.number(ResultObject["Available"].toDouble(),'i',8) + ""); +} + +void tradingDialog::DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabel2, QString Response, QString Response2){ + + QString str; + QString str2; + + //Set the labels, parse the json result to get values. + QJsonObject ResultObject = GetResultObjectFromJSONObject(Response); + QJsonObject ResultObject2 = GetResultObjectFromJSONObject(Response2); + + BalanceLabel.setText("" + str.number(ResultObject["Available"].toDouble(),'i',8) + ""); + BalanceLabel2.setText("" + str2.number(ResultObject2["Available"].toDouble(),'i',8) + ""); +} + +void tradingDialog::ParseAndPopulateOpenOrdersTable(QString Response){ + + int itteration = 0, RowCount = 0; + + QJsonArray jsonArray = GetResultArrayFromJSONObject(Response); + QJsonObject obj; + + ui->OpenOrdersTable->setRowCount(0); + + foreach (const QJsonValue & value, jsonArray) + { + QString str = ""; + obj = value.toObject(); + + RowCount = ui->OpenOrdersTable->rowCount(); + + ui->OpenOrdersTable->insertRow(RowCount); + ui->OpenOrdersTable->setItem(itteration, 0, new QTableWidgetItem(obj["OrderUuid"].toString())); + ui->OpenOrdersTable->setItem(itteration, 1, new QTableWidgetItem(BittrexTimeStampToReadable(obj["Opened"].toString()))); + ui->OpenOrdersTable->setItem(itteration, 2, new QTableWidgetItem(obj["Exchange"].toString())); + ui->OpenOrdersTable->setItem(itteration, 3, new QTableWidgetItem(obj["OrderType"].toString())); + ui->OpenOrdersTable->setItem(itteration, 4, new QTableWidgetItem(str.number(obj["Limit"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 5, new QTableWidgetItem(str.number(obj["Quantity"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 6, new QTableWidgetItem(str.number(obj["QuantityRemaining"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 7, new QTableWidgetItem(str.number(obj["Price"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 8, new QTableWidgetItem(str.number(obj["PricePerUnit"].toDouble(),'i',8))); + ui->OpenOrdersTable->setItem(itteration, 9, new QTableWidgetItem(tr("Cancel Order"))); + + //Handle the cancel link in open orders table + QTableWidgetItem* CancelCell; + CancelCell= ui->OpenOrdersTable->item(itteration, 9); //Set the wtablewidget item to the cancel cell item. + CancelCell->setForeground(QColor::fromRgb(255,0,0)); //make this item red. + CancelCell->setTextAlignment(Qt::AlignCenter); + itteration++; + } + obj.empty(); +} + + +void tradingDialog::CancelOrderSlot(int row, int col){ + + QString OrderId = ui->OpenOrdersTable->model()->data(ui->OpenOrdersTable->model()->index(row,0)).toString(); + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Cancel Order","Are you sure you want to cancel the order?",QMessageBox::Yes|QMessageBox::No); + + if (reply == QMessageBox::Yes) { + + QString Response = CancelOrder(OrderId); + + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); + QJsonObject ResponseObject = jsonResponse.object(); + + if (ResponseObject["success"].toBool() == false){ + + QMessageBox::information(this,"Failed To Cancel Order",ResponseObject["message"].toString()); + + }else if (ResponseObject["success"].toBool() == true){ + ui->OpenOrdersTable->model()->removeRow(row); + QMessageBox::information(this,"Success","You're order was cancelled."); + } + } else { + qDebug() << "Do Nothing"; + } +} + +void tradingDialog::ParseAndPopulateAccountHistoryTable(QString Response){ + + int itteration = 0, RowCount = 0; + + QJsonArray jsonArray = GetResultArrayFromJSONObject(Response); + QJsonObject obj; + + ui->TradeHistoryTable->setRowCount(0); + + foreach (const QJsonValue & value, jsonArray) + { + QString str = ""; + obj = value.toObject(); + + RowCount = ui->TradeHistoryTable->rowCount(); + + ui->TradeHistoryTable->insertRow(RowCount); + ui->TradeHistoryTable->setItem(itteration, 0, new QTableWidgetItem(BittrexTimeStampToReadable(obj["TimeStamp"].toString()))); + ui->TradeHistoryTable->setItem(itteration, 1, new QTableWidgetItem(obj["Exchange"].toString())); + ui->TradeHistoryTable->setItem(itteration, 2, new QTableWidgetItem(obj["OrderType"].toString())); + ui->TradeHistoryTable->setItem(itteration, 3, new QTableWidgetItem(str.number(obj["Limit"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 4, new QTableWidgetItem(str.number(obj["Quantity"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 5, new QTableWidgetItem(str.number(obj["QuantityRemaining"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 6, new QTableWidgetItem(str.number(obj["Price"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 7, new QTableWidgetItem(str.number(obj["PricePerUnit"].toDouble(),'i',8))); + ui->TradeHistoryTable->setItem(itteration, 8, new QTableWidgetItem(obj["Closed"].toString())); + itteration++; + } + + obj.empty(); +} + + +void tradingDialog::ParseAndPopulateOrderBookTables(QString OrderBook){ + + QString str; + QJsonObject obj; + QJsonObject ResultObject = GetResultObjectFromJSONObject(OrderBook); + + int BuyItteration = 0,SellItteration = 0, BidRows = 0, AskRows = 0; + + QJsonArray BuyArray = ResultObject.value("buy").toArray(); //get buy/sell object from result object + QJsonArray SellArray = ResultObject.value("sell").toArray(); //get buy/sell object from result object + + double TXSupply = 0; + double TXDemand = 0; + double BtcSupply = 0; + double BtcDemand = 0; + + ui->AsksTable->setRowCount(0); + + foreach (const QJsonValue & value, SellArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + double a = (x * y); + + TXSupply += y; + BtcSupply += a; + + AskRows = ui->AsksTable->rowCount(); + ui->AsksTable->insertRow(AskRows); + ui->AsksTable->setItem(SellItteration, 0, new QTableWidgetItem(str.number(x,'i',8))); + ui->AsksTable->setItem(SellItteration, 1, new QTableWidgetItem(str.number(y,'i',8))); + ui->AsksTable->setItem(SellItteration, 2, new QTableWidgetItem(str.number(a,'i',8))); + ui->AsksTable->setItem(SellItteration, 3, new QTableWidgetItem(str.number(BtcSupply,'i',8))); + SellItteration++; + } + + ui->BidsTable->setRowCount(0); + + foreach (const QJsonValue & value, BuyArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + double a = (x * y); + + TXDemand += y; + BtcDemand += a; + + BidRows = ui->BidsTable->rowCount(); + ui->BidsTable->insertRow(BidRows); + ui->BidsTable->setItem(BuyItteration, 0, new QTableWidgetItem(str.number(BtcDemand,'i',8))); + ui->BidsTable->setItem(BuyItteration, 1, new QTableWidgetItem(str.number(a,'i',8))); + ui->BidsTable->setItem(BuyItteration, 2, new QTableWidgetItem(str.number(y,'i',8))); + ui->BidsTable->setItem(BuyItteration, 3, new QTableWidgetItem(str.number(x,'i',8))); + BuyItteration++; + } + + ui->TXSupply->setText("Supply: " + str.number(TXSupply,'i',8) + " EXCL"); + ui->BtcSupply->setText("" + str.number(BtcSupply,'i',8) + " BTC"); + ui->AsksCount->setText("Ask's : " + str.number(ui->AsksTable->rowCount()) + ""); + + ui->TXDemand->setText("Demand: " + str.number(TXDemand,'i',8) + " EXCL"); + ui->BtcDemand->setText("" + str.number(BtcDemand,'i',8) + " BTC"); + ui->BidsCount->setText("Bid's : " + str.number(ui->BidsTable->rowCount()) + ""); + obj.empty(); +} + + +void tradingDialog::ParseAndPopulateMarketHistoryTable(QString Response){ + + int itteration = 0, RowCount = 0; + QJsonArray jsonArray = GetResultArrayFromJSONObject(Response); + QJsonObject obj; + + ui->MarketHistoryTable->setRowCount(0); + + foreach (const QJsonValue & value, jsonArray) + { + QString str = ""; + obj = value.toObject(); + + RowCount = ui->MarketHistoryTable->rowCount(); + + ui->MarketHistoryTable->insertRow(RowCount); + ui->MarketHistoryTable->setItem(itteration, 0, new QTableWidgetItem(BittrexTimeStampToReadable(obj["TimeStamp"].toString()))); + ui->MarketHistoryTable->setItem(itteration, 1, new QTableWidgetItem(obj["OrderType"].toString())); + ui->MarketHistoryTable->setItem(itteration, 2, new QTableWidgetItem(str.number(obj["Price"].toDouble(),'i',8))); + ui->MarketHistoryTable->setItem(itteration, 3, new QTableWidgetItem(str.number(obj["Quantity"].toDouble(),'i',8))); + ui->MarketHistoryTable->setItem(itteration, 4, new QTableWidgetItem(str.number(obj["Total"].toDouble(),'i',8))); + ui->MarketHistoryTable->item(itteration,1)->setBackgroundColor((obj["OrderType"] == QStringLiteral("BUY")) ? (QColor (150, 191, 70,255)) : ( QColor (201, 119, 153,255))); + itteration++; + } + obj.empty(); +} + +void tradingDialog::ActionsOnSwitch(int index = -1){ + + QString Response = ""; + QString Response2 = ""; + QString Response3 = ""; + + if(index == -1){ + index = ui->TradingTabWidget->currentIndex(); + } + + switch (index){ + case 0: //buy tab is active + + Response = GetBalance("BTC"); + Response2 = GetBalance("EXCL"); + Response3 = GetOrderBook(); + + if((Response.size() > 0 && Response != "Error") && (Response2.size() > 0 && Response2 != "Error")){ + DisplayBalance(*ui->BtcAvailableLabel, *ui->TXAvailableLabel, Response, Response2); + } + if ((Response3.size() > 0 && Response3 != "Error")) { + ParseAndPopulateOrderBookTables(Response3); + } + + break; + + case 1: //Cross send tab active + Response = GetBalance("EXCL"); + Response2 = GetBalance("BTC"); + if((Response.size() > 0 && Response != "Error") && (Response2.size() > 0 && Response2 != "Error")){ + DisplayBalance(*ui->BittrexTXLabel, *ui->BittrexBTCLabel, Response, Response2); + } + + break; + + case 2://market history tab + Response = GetMarketHistory(); + if(Response.size() > 0 && Response != "Error"){ + ParseAndPopulateMarketHistoryTable(Response); + } + break; + + case 3: //open orders tab + Response = GetOpenOrders(); + if(Response.size() > 0 && Response != "Error"){ + ParseAndPopulateOpenOrdersTable(Response); + } + + break; + + case 4://account history tab + Response = GetAccountHistory(); + if(Response.size() > 0 && Response != "Error"){ + ParseAndPopulateAccountHistoryTable(Response); + } + break; + + case 5://show balance tab + Response = GetBalance("BTC"); + if(Response.size() > 0 && Response != "Error"){ + DisplayBalance(*ui->BitcoinBalanceLabel,*ui->BitcoinAvailableLabel,*ui->BitcoinPendingLabel, QString::fromUtf8("BTC"),Response); + } + + Response = GetBalance("EXCL"); + if(Response.size() > 0 && Response != "Error"){ + DisplayBalance(*ui->TXBalanceLabel,*ui->TXAvailableLabel_2,*ui->TXPendingLabel, QString::fromUtf8("EXCL"),Response); + } + break; + + case 6: + + break; + + } + +} + +void tradingDialog::on_TradingTabWidget_tabBarClicked(int index) +{ + //tab was clicked, interrupt the timer and restart after action completed. + + this->timer->stop(); + + ActionsOnSwitch(index); + + this->timer->start(); +} + + +QString tradingDialog::sendRequest(QString url){ + + QString Response = ""; + QString Secret = this->SecretKey; + + // create custom temporary event loop on stack + QEventLoop eventLoop; + + // "quit()" the event-loop, when the network request "finished()" + QNetworkAccessManager mgr; + QObject::connect(&mgr, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit())); + + // the HTTP request + QNetworkRequest req = QNetworkRequest(QUrl(url)); + + req.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); + + //make this conditional,depending if we are using private api call + req.setRawHeader("apisign",HMAC_SHA512_SIGNER(url,Secret).toStdString().c_str()); //set header for bittrex + + QNetworkReply *reply = mgr.get(req); + eventLoop.exec(); // blocks stack until "finished()" has been called + + if (reply->error() == QNetworkReply::NoError) { + //success + Response = reply->readAll(); + delete reply; + } + else{ + //failure + qDebug() << "Failure" <errorString(); + Response = "Error"; + //QMessageBox::information(this,"Error",reply->errorString()); + delete reply; + } + + return Response; +} + +QString tradingDialog::BittrexTimeStampToReadable(QString DateTime){ + //Seperate Time and date. + int TPos = DateTime.indexOf("T"); + int sPos = DateTime.indexOf("."); + QDateTime Date = QDateTime::fromString(DateTime.left(TPos),"yyyy-MM-dd"); //format to convert from + DateTime.remove(sPos,sizeof(DateTime)); + DateTime.remove(0,TPos+1); + QDateTime Time = QDateTime::fromString(DateTime.right(TPos),"hh:mm:ss"); + + //Reconstruct time and date in our own format, one that QDateTime will recognise. + QString DisplayDate = Date.toString("dd/MM/yyyy") + " " + Time.toString("hh:mm:ss A"); //formats to convert to + + return DisplayDate; +} + +void tradingDialog::CalculateBuyCostLabel(){ + + double price = ui->BuyBidPriceEdit->text().toDouble(); + double Quantity = ui->UnitsInput->text().toDouble(); + double cost = ((price * Quantity) + ((price * Quantity / 100) * 0.25)); + + QString Str = ""; + ui->BuyCostLabel->setText("" + Str.number(cost,'i',8) + ""); +} + +void tradingDialog::CalculateSellCostLabel(){ + + double price = ui->SellBidPriceEdit->text().toDouble(); + double Quantity = ui->UnitsInputTX->text().toDouble(); + double cost = ((price * Quantity) - ((price * Quantity / 100) * 0.25)); + + QString Str = ""; + ui->SellCostLabel->setText("" + Str.number(cost,'i',8) + ""); +} + +void tradingDialog::CalculateCSReceiveLabel(){ + + //calculate amount of currency than can be exclusivecoinred to bitcoin + QString balance = GetBalance("EXCL"); + QString buyorders = GetOrderBook(); + + QJsonObject BuyObject = GetResultObjectFromJSONObject(buyorders); + QJsonObject BalanceObject = GetResultObjectFromJSONObject(balance); + QJsonObject obj; + + double AvailableTX = BalanceObject["Available"].toDouble(); + double Quantity = ui->CSUnitsInput->text().toDouble(); + double Received = 0; + double Qty = 0; + double Price = 0; + QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object + + // For each buy order + foreach (const QJsonValue & value, BuyArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + // If + if ( ((Quantity / x) - y) > 0 ) + { + Price = x; + Received += ((Price * y) - ((Price * y / 100) * 0.25)); + Qty += y; + Quantity -= ((Price * y) - ((Price * y / 100) * 0.25)); + } else { + Price = x; + Received += ((Price * (Quantity / x)) - ((Price * (Quantity / x) / 100) * 0.25)); + Qty += (Quantity / x); + Quantity -= 0; + break; + } + } + + QString ReceiveStr = ""; + QString DumpStr = ""; + QString TotalStr = ""; + if ( Qty < AvailableTX ) + { + ui->CSReceiveLabel->setText("" + ReceiveStr.number((ui->CSUnitsInput->text().toDouble() - 0.0002),'i',8) + ""); + ui->CSDumpLabel->setText("" + DumpStr.number(Price,'i',8) + ""); + ui->CSTotalLabel->setText("" + TotalStr.number(Qty,'i',8) + ""); + } else { + ReceiveStr = "N/A"; + TotalStr = "N/A"; + DumpStr = "N/A"; + ui->CSReceiveLabel->setText("" + ReceiveStr + ""); + ui->CSDumpLabel->setText("" + DumpStr + ""); + ui->CSTotalLabel->setText("" + TotalStr + ""); + } +} + +void tradingDialog::on_UpdateKeys_clicked(bool Save, bool Load) +{ + this->ApiKey = ui->ApiKeyInput->text(); + this->SecretKey = ui->SecretKeyInput->text(); + + QJsonDocument jsonResponse = QJsonDocument::fromJson(GetAccountHistory().toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if ( ResponseObject.value("success").toBool() == false){ + QMessageBox::information(this,"API Configuration Failed","Api configuration was unsuccesful."); + + }else if ( ResponseObject.value("success").toBool() == true && Load){ + QMessageBox::information(this,"API Configuration Complete","Your API keys have been loaded and the connection has been successfully configured and tested."); + ui->ApiKeyInput->setEchoMode(QLineEdit::Password); + ui->SecretKeyInput->setEchoMode(QLineEdit::Password); + ui->PasswordInput->setText(""); + ui->TradingTabWidget->setTabEnabled(0,true); + ui->TradingTabWidget->setTabEnabled(1,true); + ui->TradingTabWidget->setTabEnabled(3,true); + ui->TradingTabWidget->setTabEnabled(4,true); + ui->TradingTabWidget->setTabEnabled(5,true); + }else if ( ResponseObject.value("success").toBool() == true && Save){ + QMessageBox::information(this,"API Configuration Complete","Your API keys have been saved and the connection has been successfully configured and tested."); + ui->ApiKeyInput->setEchoMode(QLineEdit::Password); + ui->SecretKeyInput->setEchoMode(QLineEdit::Password); + ui->PasswordInput->setText(""); + ui->TradingTabWidget->setTabEnabled(0,true); + ui->TradingTabWidget->setTabEnabled(1,true); + ui->TradingTabWidget->setTabEnabled(3,true); + ui->TradingTabWidget->setTabEnabled(4,true); + ui->TradingTabWidget->setTabEnabled(5,true); + }else{ + QMessageBox::information(this,"API Configuration Complete","Api connection has been successfully configured and tested."); + ui->ApiKeyInput->setEchoMode(QLineEdit::Password); + ui->SecretKeyInput->setEchoMode(QLineEdit::Password); + ui->PasswordInput->setText(""); + ui->TradingTabWidget->setTabEnabled(0,true); + ui->TradingTabWidget->setTabEnabled(1,true); + ui->TradingTabWidget->setTabEnabled(3,true); + ui->TradingTabWidget->setTabEnabled(4,true); + ui->TradingTabWidget->setTabEnabled(5,true); + } + +} + +string tradingDialog::encryptDecrypt(string toEncrypt, string password) { + + char * key = new char [password.size()+1]; + std::strcpy (key, password.c_str()); + key[password.size()] = '\0'; // don't forget the terminating 0 + + string output = toEncrypt; + + for (unsigned int i = 0; i < toEncrypt.size(); i++) + output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; + return output; +} + +void tradingDialog::on_SaveKeys_clicked() +{ + bool fSuccess = true; + boost::filesystem::path pathConfigFile = GetDataDir() / "APIcache.txt"; + boost::filesystem::ofstream stream (pathConfigFile.string(), ios::out | ios::trunc); + + // Qstring to string + string password = ui->PasswordInput->text().toUtf8().constData(); + + if (password.length() <= 6){ + QMessageBox::information(this,"Error !","Your password is too short !"); + fSuccess = false; + stream.close(); + } + + // qstrings to utf8, add to byteArray and convert to const char for stream + string Secret = ui->SecretKeyInput->text().toUtf8().constData(); + string Key = ui->ApiKeyInput->text().toUtf8().constData(); + string ESecret = ""; + string EKey = ""; + + if (stream.is_open() && fSuccess) + { + ESecret = encryptDecrypt(Secret, password); + EKey = encryptDecrypt(Key, password); + stream << ESecret << '\n'; + stream << EKey; + stream.close(); + } + if (fSuccess) { + bool Save = true; + on_UpdateKeys_clicked(Save); + } + +} + +void tradingDialog::on_LoadKeys_clicked() +{ + bool fSuccess = true; + boost::filesystem::path pathConfigFile = GetDataDir() / "APIcache.txt"; + boost::filesystem::ifstream stream (pathConfigFile.string()); + + // Qstring to string + string password = ui->PasswordInput->text().toUtf8().constData(); + + if (password.length() <= 6){ + QMessageBox::information(this,"Error !","Your password is too short !"); + fSuccess = false; + stream.close(); + } + + QString DSecret = ""; + QString DKey = ""; + + if (stream.is_open() && fSuccess) + { + int i =0; + for ( std::string line; std::getline(stream,line); ) + { + if (i == 0 ){ + DSecret = QString::fromUtf8(encryptDecrypt(line, password).c_str()); + ui->SecretKeyInput->setText(DSecret); + } else if (i == 1){ + DKey = QString::fromUtf8(encryptDecrypt(line, password).c_str()); + ui->ApiKeyInput->setText(DKey); + } + i++; + } + stream.close(); + } + if (fSuccess) { + bool Save = false; + bool Load = true; + on_UpdateKeys_clicked(Save, Load); + } + +} + +void tradingDialog::on_GenDepositBTN_clicked() +{ + QString response = GetDepositAddress(); + QJsonObject ResultObject = GetResultObjectFromJSONObject(response); + ui->DepositAddressLabel->setText(ResultObject["Address"].toString()); +} + +void tradingDialog::on_Sell_Max_Amount_clicked() +{ + //calculate amount of BTC that can be gained from selling EXCL available balance + QString responseA = GetBalance("EXCL"); + QString str; + QJsonObject ResultObject = GetResultObjectFromJSONObject(responseA); + + double AvailableTX = ResultObject["Available"].toDouble(); + + ui->UnitsInputTX->setText(str.number(AvailableTX,'i',8)); +} + +void tradingDialog::on_Buy_Max_Amount_clicked() +{ + //calculate amount of currency than can be brought with the BTC balance available + QString responseA = GetBalance("BTC"); + QString responseB = GetMarketSummary(); + QString str; + + QJsonObject ResultObject = GetResultObjectFromJSONObject(responseA); + QJsonObject ResultObj = GetResultObjectFromJSONArray(responseB); + + //Get the Bid ask or last value from combo + QString value = ui->BuyBidcomboBox->currentText(); + + double AvailableBTC = ResultObject["Available"].toDouble(); + double CurrentASK = ResultObj[value].toDouble(); + double Result = (AvailableBTC / CurrentASK); + double percentofnumber = (Result * 0.0025); + + Result = Result - percentofnumber; + ui->UnitsInput->setText(str.number(Result,'i',8)); +} + +void tradingDialog::on_CS_Max_Amount_clicked() +{ + double Quantity = ui->BittrexTXLabel->text().toDouble(); + double Received = 0; + double Qty = 0; + double Price = 0; + QString buyorders = GetOrderBook(); + QJsonObject BuyObject = GetResultObjectFromJSONObject(buyorders); + QJsonObject obj; + QString str; + + QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object + + // For each buy order + foreach (const QJsonValue & value, BuyArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + // If + if ( (Quantity - y) > 0 ) + { + Price = x; + Received += ((Price * y) - ((Price * y / 100) * 0.25)); + Qty += y; + Quantity -= y; + + } else { + Price = x; + Received += ((Price * Quantity) - ((Price * Quantity / 100) * 0.25)); + Qty += Quantity; + + if ((Quantity * x) < 0.00055){ + Quantity = (0.00055 / x); + } + + break; + } + } + + ui->CSUnitsInput->setText(str.number(Received,'i',8)); +} + +void tradingDialog::on_Withdraw_Max_Amount_clicked() +{ + //calculate amount of currency than can be brought with the BTC balance available + QString responseA = GetBalance("EXCL"); + QString str; + + QJsonObject ResultObject = GetResultObjectFromJSONObject(responseA); + + double AvailableTX = ResultObject["Available"].toDouble(); + + ui->WithdrawUnitsInput->setText(str.number(AvailableTX,'i',8)); +} + +QJsonObject tradingDialog::GetResultObjectFromJSONObject(QString response){ + + QJsonDocument jsonResponse = QJsonDocument::fromJson(response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + QJsonObject ResultObject = ResponseObject.value(QString("result")).toObject(); //get result object + + return ResultObject; +} + +QJsonObject tradingDialog::GetResultObjectFromJSONArray(QString response){ + + QJsonDocument jsonResponsea = QJsonDocument::fromJson(response.toUtf8()); + QJsonObject jsonObjecta = jsonResponsea.object(); + QJsonArray jsonArraya = jsonObjecta["result"].toArray(); + QJsonObject obj; + + foreach (const QJsonValue & value, jsonArraya) + { + obj = value.toObject(); + } + +return obj; +} + +QJsonArray tradingDialog::GetResultArrayFromJSONObject(QString response){ + + QJsonDocument jsonResponse = QJsonDocument::fromJson(response.toUtf8()); + QJsonObject jsonObject = jsonResponse.object(); + QJsonArray jsonArray = jsonObject["result"].toArray(); + +return jsonArray; +} + +QString tradingDialog::HMAC_SHA512_SIGNER(QString UrlToSign, QString Secret){ + + QString retval = ""; + + QByteArray byteArray = UrlToSign.toUtf8(); + const char* URL = byteArray.constData(); + + QByteArray byteArrayB = Secret.toUtf8(); + const char* Secretkey = byteArrayB.constData(); + + const EVP_MD *md = EVP_sha512(); + unsigned char* digest = NULL; + + // Using sha512 hash engine here. + digest = HMAC(md, Secretkey, strlen( Secretkey), (unsigned char*) URL, strlen( URL), NULL, NULL); + + // Be careful of the length of string with the choosen hash engine. SHA1 produces a 20-byte hash value which rendered as 40 characters. + // Change the length accordingly with your choosen hash engine + char mdString[129] = { 0 }; + + for(int i = 0; i < 64; i++){ + sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]); + } + retval = mdString; + //qDebug() << "HMAC digest:"<< retval; + + return retval; +} + +void tradingDialog::on_SellBidcomboBox_currentIndexChanged(const QString &arg1) +{ + QString response = GetMarketSummary(); + QJsonObject ResultObject = GetResultObjectFromJSONArray(response); + QString Str; + + //Get the Bid ask or last value from combo + ui->SellBidPriceEdit->setText(Str.number(ResultObject[arg1].toDouble(),'i',8)); + + CalculateSellCostLabel(); //update cost +} + +void tradingDialog::on_BuyBidcomboBox_currentIndexChanged(const QString &arg1) +{ + QString response = GetMarketSummary(); + QJsonObject ResultObject = GetResultObjectFromJSONArray(response); + QString Str; + + //Get the Bid ask or last value from combo + ui->BuyBidPriceEdit->setText(Str.number(ResultObject[arg1].toDouble(),'i',8)); + + CalculateBuyCostLabel(); //update cost +} + +void tradingDialog::on_BuyTX_clicked() +{ + double Rate; + double Quantity; + + Rate = ui->BuyBidPriceEdit->text().toDouble(); + Quantity = ui->UnitsInput->text().toDouble(); + + QString OrderType = "Limit"; + QString Order; + + if(OrderType == "Limit"){Order = "buylimit";}else if (OrderType == "Market"){ Order = "buymarket";} + + QString Msg = "Are you sure you want to buy "; + Msg += ui->UnitsInput->text(); + Msg += "EXCL @ "; + Msg += ui->BuyBidPriceEdit->text(); + Msg += " BTC Each"; + + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Buy Order",Msg,QMessageBox::Yes|QMessageBox::No); + + if (reply == QMessageBox::Yes) { + + QString Response = BuyTX(Order,Quantity,Rate); + + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if (ResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"Buy Order Failed",ResponseObject["message"].toString()); + + }else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Buy Order Initiated","You Placed an order"); + } + }else{ + //do nothing + } +} + +void tradingDialog::on_SellTXBTN_clicked() +{ + double Rate; + double Quantity; + + Rate = ui->SellBidPriceEdit->text().toDouble(); + Quantity = ui->UnitsInputTX->text().toDouble(); + + QString OrderType = "Limit"; + QString Order; + + if(OrderType == "Limit"){Order = "selllimit";}else if (OrderType == "Market"){ Order = "sellmarket";} + + QString Msg = "Are you sure you want to Sell "; + Msg += ui->UnitsInputTX->text(); + Msg += " EXCL @ "; + Msg += ui->SellBidPriceEdit->text(); + Msg += " BTC Each"; + + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Sell Order",Msg,QMessageBox::Yes|QMessageBox::No); + + if (reply == QMessageBox::Yes) { + + QString Response = SellTX(Order,Quantity,Rate); + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if (ResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"Sell Order Failed",ResponseObject["message"].toString()); + + }else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Sell Order Initiated","You Placed an order"); + } + }else{ + //do nothing + } +} + +void tradingDialog::on_CSUnitsBtn_clicked() +{ + double Quantity = ui->CSUnitsInput->text().toDouble(); + double Rate = ui->CSDumpLabel->text().toDouble(); + double Received = 0; + double Qty = 0; + double Price = 0; + double Add = 0; + + QString buyorders = GetOrderBook(); + QJsonObject BuyObject = GetResultObjectFromJSONObject(buyorders); + QJsonObject obj; + QString Astr; + QString Qstr; + QString Rstr; + QString Coin = "BTC"; + QString Msg = "Are you sure you want to Send "; + Msg += Qstr.number((Quantity - 0.0002),'i',8); + Msg += " BTC to "; + Msg += ui->CSUnitsAddress->text(); + Msg += ", DUMPING your coins at "; + Msg += Rstr.number(Rate,'i',8); + Msg += " satoshis ?"; + + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Cross-Send",Msg,QMessageBox::Yes|QMessageBox::No); + + if(reply != QMessageBox::Yes) + { + return; + } + + WalletModel::UnlockContext ctx(model->requestUnlock()); + if(!ctx.isValid()) + { + // Unlock wallet was cancelled + return; + } + + QString Order = "selllimit"; + QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object + + // For each buy order + foreach (const QJsonValue & value, BuyArray) + { + obj = value.toObject(); + + double x = obj["Rate"].toDouble(); //would like to use int64 here + double y = obj["Quantity"].toDouble(); + // If + if ( ((Quantity / x) - y) > 0 ) + { + Price = x; + Received += ((Price * y) - ((Price * y / 100) * 0.25)); + Qty += y; + Quantity -= ((Price * y) - ((Price * y / 100) * 0.25)); + + QString SellResponse = SellTX(Order,y,x); + QJsonDocument SelljsonResponse = QJsonDocument::fromJson(SellResponse.toUtf8()); //get json from str. + QJsonObject SellResponseObject = SelljsonResponse.object(); //get json obj + + if (SellResponseObject["success"].toBool() == false){ + if (SellResponseObject["message"].toString() == "DUST_TRADE_DISALLOWED_MIN_VALUE_50K_SAT"){ + Add += y; + continue; + } + QMessageBox::information(this,"sFailed",SellResponse); + break; + } + MilliSleep(100); + + } else { + Price = x; + Received += ((Price * (Quantity / x)) - ((Price * (Quantity / x) / 100) * 0.25)); + Qty += (Quantity / x); + if (Add > 0) + Quantity += (Add * x); + if (Quantity < 0.00051){ + Quantity = 0.00051; + } + QString SellResponse = SellTX(Order,(Quantity / x),x); + QJsonDocument SelljsonResponse = QJsonDocument::fromJson(SellResponse.toUtf8()); //get json from str. + QJsonObject SellResponseObject = SelljsonResponse.object(); //get json obj + + if (SellResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"sFailed",SellResponse); + + } else if (SellResponseObject["success"].toBool() == true){ + MilliSleep(5000); + QString Response = Withdraw(ui->CSUnitsInput->text().toDouble(),ui->CSUnitsAddress->text(),Coin); + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if (ResponseObject["success"].toBool() == false){ + MilliSleep(5000); + QString Response = Withdraw(ui->CSUnitsInput->text().toDouble(),ui->CSUnitsAddress->text(),Coin); + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); + + if (ResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"Failed",ResponseObject["message"].toString()); + } else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Success","
Cross-Send Successful
\n Sold "+Astr.number(Qty,'i',4)+" EXCL for "+Qstr.number((ui->CSUnitsInput->text().toDouble()-0.0002),'i',8)+" BTC"); + } + } else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Success","
Cross-Send Successful
\n Sold "+Astr.number(Qty,'i',4)+" EXCL for "+Qstr.number((ui->CSUnitsInput->text().toDouble()-0.0002),'i',8)+" BTC"); + } + } + break; + } + } +} + +void tradingDialog::on_WithdrawUnitsBtn_clicked() +{ + double Quantity = ui->WithdrawUnitsInput->text().toDouble(); + QString Qstr; + QString Coin = "EXCL"; + QString Msg = "Are you sure you want to Withdraw "; + Msg += Qstr.number((Quantity - 0.02),'i',8); + Msg += " EXCL to "; + Msg += ui->WithdrawAddress->text(); + Msg += " ?"; + + QMessageBox::StandardButton reply; + reply = QMessageBox::question(this,"Withdraw",Msg,QMessageBox::Yes|QMessageBox::No); + + if(reply != QMessageBox::Yes) + { + return; + } + + WalletModel::UnlockContext ctx(model->requestUnlock()); + if(!ctx.isValid()) + { + // Unlock wallet was cancelled + return; + } + + QString Response = Withdraw(Quantity, ui->WithdrawAddress->text(), Coin); + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj + + if (ResponseObject["success"].toBool() == false){ + QMessageBox::information(this,"Failed",ResponseObject["message"].toString()); + + }else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Success","Withdrawal Successful !"); + } +} + +void tradingDialog::on_UnitsInputTX_textChanged(const QString &arg1) +{ + CalculateSellCostLabel(); //update cost +} + +void tradingDialog::on_UnitsInput_textChanged(const QString &arg1) +{ + CalculateBuyCostLabel(); //update cost +} + +void tradingDialog::on_BuyBidPriceEdit_textChanged(const QString &arg1) +{ + CalculateBuyCostLabel(); //update cost +} + +void tradingDialog::on_SellBidPriceEdit_textChanged(const QString &arg1) +{ + CalculateSellCostLabel(); +} + +void tradingDialog::on_CSUnitsInput_textChanged(const QString &arg1) +{ + CalculateCSReceiveLabel(); //update cost +} + +void tradingDialog::on_CSPasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->CSUnitsAddress->setText(QApplication::clipboard()->text()); +} + +void tradingDialog::on_WithdrawPasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->WithdrawAddress->setText(QApplication::clipboard()->text()); +} + +void tradingDialog::on_SecretPasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->SecretKeyInput->setText(QApplication::clipboard()->text()); +} + +void tradingDialog::on_KeyPasteButton_clicked() +{ + // Paste text from clipboard into recipient field + ui->ApiKeyInput->setText(QApplication::clipboard()->text()); +} + +void setClipboard(const QString& str) +{ + QApplication::clipboard()->setText(str, QClipboard::Clipboard); + QApplication::clipboard()->setText(str, QClipboard::Selection); +} + +void tradingDialog::on_DepositCopyButton_clicked() +{ + setClipboard(ui->DepositAddressLabel->text()); +} + +void tradingDialog::setModel(WalletModel *model) +{ + this->model = model; +} + +tradingDialog::~tradingDialog() +{ + delete ui; +} diff --git a/src/qt/tradingdialog.h b/src/qt/tradingdialog.h new file mode 100644 index 00000000..6a4dbce9 --- /dev/null +++ b/src/qt/tradingdialog.h @@ -0,0 +1,117 @@ + +#ifndef TRADINGDIALOG_H +#define TRADINGDIALOG_H + +#include +#include +#include +#include "ui_tradingdialog.h" +#include "clientmodel.h" +#include "walletmodel.h" + +#include +#include + +#include +#include + +namespace Ui { +class tradingDialog; +} +class WalletModel; + +class tradingDialog : public QDialog +{ + Q_OBJECT + +public: + explicit tradingDialog(QWidget *parent = 0); + ~tradingDialog(); + + void setModel(WalletModel *model); + +private slots: + + void InitTrading(); + void on_TradingTabWidget_tabBarClicked(int index); + void ParseAndPopulateOrderBookTables(QString Response); + void ParseAndPopulateMarketHistoryTable(QString Response); + void ParseAndPopulateAccountHistoryTable(QString Response); + void ParseAndPopulateOpenOrdersTable(QString Response); + void UpdaterFunction(); + void CreateOrderBookTables(QTableWidget& Table,QStringList TableHeader); + void DisplayBalance(QLabel &BalanceLabel,QLabel &Available, QLabel &Pending, QString Currency,QString Response); + void DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabel2, QString Response, QString Response2); + void DisplayBalance(QLabel &BalanceLabel, QString Response); + void ActionsOnSwitch(int index); + void CancelOrderSlot(int row, int col); + void on_UpdateKeys_clicked(bool Save=false, bool Load=false); + void on_LoadKeys_clicked(); + void on_SaveKeys_clicked(); + void on_GenDepositBTN_clicked(); + + void CalculateBuyCostLabel(); + void on_Buy_Max_Amount_clicked(); + void on_BuyBidcomboBox_currentIndexChanged(const QString &arg1); + void on_UnitsInput_textChanged(const QString &arg1); + void on_BuyBidPriceEdit_textChanged(const QString &arg1); + void on_BuyTX_clicked(); + + void CalculateSellCostLabel(); + void on_Sell_Max_Amount_clicked(); + void on_SellBidcomboBox_currentIndexChanged(const QString &arg1); + void on_UnitsInputTX_textChanged(const QString &arg1); + void on_SellBidPriceEdit_textChanged(const QString &arg1); + void on_SellTXBTN_clicked(); + + void CalculateCSReceiveLabel(); + void on_CSUnitsInput_textChanged(const QString &arg1); + void on_CSUnitsBtn_clicked(); + void on_CS_Max_Amount_clicked(); + + void on_Withdraw_Max_Amount_clicked(); + void on_WithdrawUnitsBtn_clicked(); + + void on_KeyPasteButton_clicked(); + void on_SecretPasteButton_clicked(); + void on_CSPasteButton_clicked(); + void on_WithdrawPasteButton_clicked(); + void on_DepositCopyButton_clicked(); + + int SetExchangeInfoTextLabels(); + + QString BittrexTimeStampToReadable(QString DateTime); + QString CancelOrder(QString Orderid); + QString BuyTX(QString OrderType, double Quantity, double Rate); + QString SellTX(QString OrderType, double Quantity, double Rate); + QString Withdraw(double Amount, QString Address, QString Coin); + QString GetMarketHistory(); + QString GetMarketSummary(); + QString GetOrderBook(); + QString GetOpenOrders(); + QString GetAccountHistory(); + QString GetBalance(QString Currency); + QString GetDepositAddress(); + QString HMAC_SHA512_SIGNER(QString UrlToSign,QString Secretkey); + QString sendRequest(QString url); + string encryptDecrypt(string toEncrypt, string password); + QJsonObject GetResultObjectFromJSONObject(QString response); + QJsonObject GetResultObjectFromJSONArray(QString response); + QJsonArray GetResultArrayFromJSONObject(QString response); + +public slots: + + +private: + Ui::tradingDialog *ui; + //Socket *socket; + int timerid; + QTimer *timer; + QString ApiKey; + QString SecretKey; + WalletModel *model; + + +}; + +#endif // TRADINGDIALOG_H \ No newline at end of file From d5e29e32f989f3e27f420d4cd4ffb9311c4caea4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:01:41 -0400 Subject: [PATCH 305/469] Add files via upload --- src/qt/forms/tradingdialog.ui | 5595 +++++++++++++++++++++++++++++++++ 1 file changed, 5595 insertions(+) create mode 100644 src/qt/forms/tradingdialog.ui diff --git a/src/qt/forms/tradingdialog.ui b/src/qt/forms/tradingdialog.ui new file mode 100644 index 00000000..dc9e065b --- /dev/null +++ b/src/qt/forms/tradingdialog.ui @@ -0,0 +1,5595 @@ + + + tradingDialog + + + + 0 + 0 + 1031 + 594 + + + + Dialog + + + + + + + 0 + 0 + + + + + 849 + 40 + + + + + 16777215 + 220 + + + + QFrame::NoFrame + + + QFrame::Raised + + + 0 + + + + + + + + + 0 + 0 + + + + + 8 + 50 + false + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + + 8 + 50 + false + + + + 0.000000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + + 8 + 50 + false + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + + 8 + 50 + false + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + + + true + + + + 50 + false + + + + QTabWidget::North + + + QTabWidget::Rounded + + + 6 + + + + Trade + + + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 9 + 50 + false + + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + true + + + false + + + QAbstractItemView::NoSelection + + + + + + + + 75 + true + + + + Qt::LeftToRight + + + false + + + Units + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + + + + 75 + true + + + + BTC Available: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + BTC + + + + + + + + + + + + 75 + true + + + + TX Available: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + TX + + + + + + + + + + 10 + + + + Max + + + + + + + + 0 + 0 + + + + + 9 + 75 + true + + + + + + + + TX + + + + + + + + 10 + + + + Max + + + + + + + + 0 + 0 + + + + + 9 + 75 + true + + + + + + + + TX + + + + + + + + 75 + true + + + + Bid + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 10 + + + + + + + + + 0 + 0 + + + + + 9 + 75 + true + + + + + + + + BTC + + + + + + + + 10 + + + + + + + + + 0 + 0 + + + + + 9 + 75 + true + + + + + + + + BTC + + + + + + + + + + 75 + true + + + + Total w/ 0.25% Fee + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 50 + false + + + + BTC + + + + + + + + + + + + 75 + true + + + + Total w/ 0.25% Fee + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 50 + false + + + + BTC + + + + + + + + + Buy TX + + + + + + + Sell TX + + + + + + + + 0 + 0 + + + + + 9 + 50 + false + + + + QAbstractItemView::NoEditTriggers + + + false + + + false + + + true + + + false + + + QAbstractItemView::NoSelection + + + + + + + 0.00000000 BTC + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Asks: 0000 + + + + + + + 0.00000000 BTC + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 8 + + + + Demand: 0.00000000 TX + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Supply: 0.00000000 TX + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Bids: 0000 + + + + + + + + Send + + + + + + + + + 10 + 75 + true + + + + Lowest price: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + BTC + + + + + + + + + + + + 10 + 75 + true + + + + Amount in TX: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + TX + + + + + + + + + + + + 10 + 75 + true + + + + Total w/ Fees : + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + BTC + + + + + + + + + Send + + + + + + + + 10 + 50 + false + + + + + + + + + + + + 10 + 50 + false + + + + <html><head/><body><p><span style=" font-size:9pt; font-weight:600;">Warning:</span><span style=" font-size:9pt;"> This feature is in </span><span style=" font-size:9pt; font-weight:600;">ALPHA ! USE AT OWN RISK !</span></p></body></html> + + + + + + + + 10 + 50 + false + + + + <html><head/><body><p align="center"><span style=" font-weight:600; text-decoration: underline;">Instructions:</span></p><p align="center">To use the cross sending feature you need to have </p><p align="center">TX available to spend on Bittrex. If you don't have any </p><p align="center">you can find your deposit address on the &quot;Balance&quot; tab.</p><p align="center">1. Enter the amount you want to receive in Bitcoin.</p><p align="center">2. Enter the Bitcoin address you are sending to.</p><p align="center">3. Check that the Total with fee's is correct.</p><p align="center">4. Press send and watch the magic happen.</p><p align="center"><span style=" font-weight:600; text-decoration: underline;">Notes.</span></p><p align="center"><span style=" font-size:7pt;">Total w/ fees: N/A means you dont have enough EXCL to sell !</span></p><p align="center"><span style=" font-size:7pt;">All trades are done through Bittrex using your own balance and API keys.</span></p><p align="center"><span style=" font-size:7pt;">Encrypt and backup your wallet when using this feature.</span></p><p align="center"><span style=" font-size:7pt;">If you don't have a password you bittrex account will be accessible 24/7</span></p><p align="center"><span style=" font-size:7pt;">Withdrawal fee of 0.002 and 0.25% taken by Bittrex.</span></p></body></html> + + + + + + + + 10 + 75 + true + + + + Amount: + + + + + + + Qt::Horizontal + + + + 212 + 368 + + + + + + + + + 10 + 75 + true + + + + + + + + + 10 + 75 + true + + + + Address: + + + + + + + + + + 10 + 75 + true + + + + TX Balance: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + TX + + + + + + + + + + + + 10 + 75 + true + + + + BTC Balance: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 50 + false + + + + BTC + + + + + + + + + + 10 + + + + Max + + + + + + + + 10 + 75 + true + + + + + + + + Paste from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + + 18 + 75 + true + + + + Cross-Send + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 915 + 73 + + + + + + CSUnitsInput + label232_4 + CSUnitsAddress + label_8 + CSUnitsBtn + label232_8 + label_27 + label232_13 + label232_15 + CS_Max_Amount + verticalSpacer_3 + horizontalSpacer_6 + CSPasteButton + + + + Market History + + + + + + + + + + Open Orders + + + + + + + + + + Trade history + + + + + + + + + + Balance + + + + + + + 10 + 75 + true + + + + TX Balance: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 75 + true + + + + BTC Balance: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Qt::Horizontal + + + + 478 + 488 + + + + + + + + + 10 + 75 + true + + + + TX Available: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 75 + true + + + + BTC Available: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 75 + true + + + + TX Pending: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + 75 + true + + + + BTC Pending: + + + + + + + + 10 + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 10 + + + + Generate EXCL Coin Deposit Address + + + + + + + + 10 + 75 + true + + + + Deposit Address: + + + + + + + + 300 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + + + 120 + 120 + 120 + + + + + + + 120 + 120 + 120 + + + + + + + + + 10 + 75 + true + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + Copy to clipboard + + + + + + + :/icons/editcopy:/icons/editcopy + + + Alt+P + + + + + + + + 10 + 75 + true + + + + Withdraw TX: + + + + + + + + 10 + 75 + true + + + + Amount: + + + + + + + + 9 + 75 + true + + + + + + + + + + + + 10 + + + + Max + + + + + + + + 10 + 75 + true + + + + Address: + + + + + + + + 9 + 75 + true + + + + + + + + Paste from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + + 10 + + + + Withdraw + + + + + + + Qt::Vertical + + + + 428 + 262 + + + + + + label_31 + label_15 + label_12 + label_14 + label_13 + label_11 + BitcoinBalanceLabel + TXBalanceLabel + TXAvailableLabel_2 + TXPendingLabel + BitcoinAvailableLabel + BitcoinPendingLabel + label_33 + GenDepositBTN + DepositAddressLabel + Withdraw_Max_Amount + label_34 + WithdrawUnitsInput + label_10 + label_26 + WithdrawAddress + WithdrawUnitsBtn + horizontalSpacer_4 + verticalSpacer + WithdrawPasteButton + DepositCopyButton + + + + Settings + + + + + + + 75 + true + + + + API Key + + + + + + + + + + + + + + Paste from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + Qt::Horizontal + + + + 519 + 488 + + + + + + + + + 75 + true + + + + Secret Key + + + + + + + + + + Paste from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + + + + + + 75 + true + + + + Password + + + + + + + QLineEdit::Password + + + + + + + + 115 + 0 + + + + Load API Keys + + + + + + + + 125 + 0 + + + + Update API Keys + + + + + + + + 115 + 0 + + + + Save API Keys + + + + + + + Qt::Vertical + + + + 358 + 247 + + + + + + + + + 10 + 50 + false + + + + <html><head/><body><p>Loading keys:</p><p>1) Enter Password</p><p>2) Load API Keys</p><p>3) Start trading on Bittrex</p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 10 + 50 + false + + + + <html><head/><body><p>Saving keys:</p><p>1) Enter in API Keys found at <a href="https://bittrex.com/Account/ManageApiKey"><span style=" text-decoration: underline; color:#0000ff;">Bittrex</span></a></p><p>2) Enter Password</p><p>3) Save API Keys</p><p>4) Start trading on Bittrex</p></body></html> + + + + + label + ApiKeyInput + label_2 + SecretKeyInput + UpdateKeys + SaveKeys + LoadKeys + label232_16 + label232_17 + label_28 + PasswordInput + horizontalSpacer_3 + verticalSpacer_2 + KeyPasteButton + SecretPasteButton + + + + + + + + + + From 5ba7cbda306e051190f56ecb7e3d0b8bf3c46d7a Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:03:23 -0400 Subject: [PATCH 306/469] Update Makefile.qt.include --- src/Makefile.qt.include | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 49c453a9..28bbd937 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -52,6 +52,7 @@ QT_FORMS_UI = \ qt/forms/sendcoinsdialog.ui \ qt/forms/sendcoinsentry.ui \ qt/forms/signverifymessagedialog.ui \ + qt/forms/tradingdialog.ui \ qt/forms/transactiondescdialog.ui QT_MOC_CPP = \ @@ -95,6 +96,7 @@ QT_MOC_CPP = \ qt/moc_sendcoinsentry.cpp \ qt/moc_signverifymessagedialog.cpp \ qt/moc_splashscreen.cpp \ + qt/moc_tradingdialog.cpp \ qt/moc_trafficgraphwidget.cpp \ qt/moc_transactiondesc.cpp \ qt/moc_transactiondescdialog.cpp \ @@ -174,6 +176,7 @@ BITCOIN_QT_H = \ qt/sendcoinsentry.h \ qt/signverifymessagedialog.h \ qt/splashscreen.h \ + qt/tradingdialog.h \ qt/trafficgraphdata.h \ qt/trafficgraphwidget.h \ qt/transactiondesc.h \ @@ -516,6 +519,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/sendcoinsdialog.cpp \ qt/sendcoinsentry.cpp \ qt/signverifymessagedialog.cpp \ + qt/trading.cpp \ qt/transactiondesc.cpp \ qt/transactiondescdialog.cpp \ qt/transactionfilterproxy.cpp \ From 3eacfd02eedb1a278941b899ebf4ba4176516902 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:13:58 -0400 Subject: [PATCH 307/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 4b5c2fb1..1a2231b2 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -22,6 +22,7 @@ #include "platformstyle.h" #include "rpcconsole.h" #include "utilitydialog.h" +#include "tradingdialog.h" #ifdef ENABLE_WALLET #include "privatesend-client.h" @@ -494,7 +495,21 @@ void BitcoinGUI::createActions() connect(governanceAction, SIGNAL(triggered()), this, SLOT(gotoGovernancePage())); } - + { + tradingAction = new QAction(QIcon(":/icons/chat"), tr("&Trading"), this); + tradingAction->setStatusTip(tr("Trade HTH Today")); + tradingAction->setToolTip(tradingAction->statusTip()); + tradingAction->setCheckable(true); +#ifdef Q_OS_MAC + tradingAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_5)); +#else + tradingAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5)); +#endif + tabGroup->addAction(tradingAction); + connect(tradingAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(tradingAction, SIGNAL(triggered()), this, SLOT(gotoTradingDialogPage())); + + } /* privatesendAction = new QAction(QIcon(":/icons/coinmix"), tr("&Private Send"), this); privatesendAction->setStatusTip(tr("Show Private Send of wallet")); privatesendAction->setToolTip(privatesendAction->statusTip()); @@ -737,6 +752,9 @@ void BitcoinGUI::createToolBars() } toolbar->addAction(governanceAction); toolbar->addAction(unlockWalletAction); + + toolbar->addAction(tradingAction); + toolbar->addAction(unlockwalletAction); toolbar->setMovable(false); // remove unused icon in upper left corner overviewAction->setChecked(true); @@ -888,6 +906,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled) if (!fLiteMode && settings.value("fShowMasternodesTab").toBool() && masternodeAction) { masternodeAction->setEnabled(enabled); } + tradingAction->setEnabled(enabled); governanceAction->setEnabled(enabled); encryptWalletAction->setEnabled(enabled); backupWalletAction->setEnabled(enabled); @@ -1037,6 +1056,16 @@ void BitcoinGUI::openClicked() } } +void BitcoinGUI::gotoTradingPage() +{ + + TradingAction->setChecked(true); + centralStackedWidget->setCurrentWidget(tradingDialogPage); + + // exportAction->setEnabled(false); + // disconnect(exportAction, SIGNAL(triggered()), 0, 0); +} + void BitcoinGUI::openDonate() { openExternalURL("https://helpthehomelessworldwide.org/donate"); From 63139eb52d4929cd21a8a001ab12d902e728d026 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:15:44 -0400 Subject: [PATCH 308/469] Update bitcoingui.h --- src/qt/bitcoingui.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 9011d71d..1f352cbc 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -38,6 +38,7 @@ class HelpMessageDialog; class ModalOverlay; class QNetworkAccessManager; class QNetworkRequest; +class tradingDialog; class CWallet; @@ -105,6 +106,7 @@ class BitcoinGUI : public QMainWindow QAction* externalDonate; QAction *governanceAction; + QAction *tradingAction; /* QAction* privatesendAction; */ QAction *overviewAction; QAction *historyAction; @@ -230,11 +232,14 @@ public Q_SLOTS: private Q_SLOTS: #ifdef ENABLE_WALLET - + /** Switch to trading page */ + void gotoTradingPage(); /** Switch to masternode page */ void gotoGovernancePage(); + /** Switch to private send page */ - /* void gotoPrivateSendPage(); */ + /* void gotoPrivateSendPage(); */ + /** Switch to overview (home) page */ void gotoOverviewPage(); /** Switch to history (transactions) page */ From 6f5d739c6d0db4fd59d9371ef1d519793ce7dfc6 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:16:50 -0400 Subject: [PATCH 309/469] Update walletframe.cpp --- src/qt/walletframe.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index 6783019e..9834aea5 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -108,6 +108,16 @@ void WalletFrame::showOutOfSyncWarning(bool fShow) i.value()->showOutOfSyncWarning(fShow); } +void BitcoinGUI::gotoTradingPage() +{ + + TradingAction->setChecked(true); + centralStackedWidget->setCurrentWidget(tradingDialogPage); + + // exportAction->setEnabled(false); + // disconnect(exportAction, SIGNAL(triggered()), 0, 0); +} + void WalletFrame::gotoGovernancePage() { QMap::const_iterator i; From 5addd2c5131de46737eb255bdb842f1c6a32bf68 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:17:36 -0400 Subject: [PATCH 310/469] Update walletframe.h --- src/qt/walletframe.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qt/walletframe.h b/src/qt/walletframe.h index 54527997..7b23f5ac 100644 --- a/src/qt/walletframe.h +++ b/src/qt/walletframe.h @@ -63,6 +63,8 @@ class WalletFrame : public QFrame public Q_SLOTS: + /** Switch to trading page */ + void gotoTradingPage(); /** Switch to governance page */ void gotoGovernancePage(); /** Switch to private send page */ From 01be081f626624018b661e56e98bbf5fac8a6621 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:22:25 -0400 Subject: [PATCH 311/469] Update walletview.cpp --- src/qt/walletview.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index f503bccd..faf083c2 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -92,6 +92,9 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): } governanceListPage = new GovernanceList(platformStyle); addWidget(governanceListPage); + + tradingDialogPage = new tradingDialog(platformStyle); + addWidget(tradingDialogPage) // Clicking on a transaction on the overview pre-selects the transaction on the transaction history page connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex))); @@ -158,6 +161,7 @@ void WalletView::setClientModel(ClientModel *_clientModel) masternodeListPage->setClientModel(_clientModel); } governanceListPage->setClientModel(_clientModel); + tradingDialogPage->setClientModel(_clientModel); } void WalletView::setWalletModel(WalletModel *_walletModel) @@ -172,6 +176,7 @@ void WalletView::setWalletModel(WalletModel *_walletModel) if (!fLiteMode && settings.value("fShowMasternodesTab").toBool()) { masternodeListPage->setWalletModel(_walletModel); } + tradingDialogPage->setWalletModel(_walletModel); governanceListPage->setWalletModel(_walletModel); receiveCoinsPage->setModel(_walletModel); sendCoinsPage->setModel(_walletModel); @@ -232,6 +237,12 @@ void WalletView::processNewTransaction(const QModelIndex& parent, int start, int Q_EMIT incomingTransaction(date, walletModel->getOptionsModel()->getDisplayUnit(), amount, type, address, label); } +void WalletView::gotoGovernancePage() +{ + QSettings settings; + setCurrentWidget(tradingDialogPage); +} + void WalletView::gotoGovernancePage() { QSettings settings; From 9efda691bfa321c059f500fa94560eeee21fe6a9 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:25:33 -0400 Subject: [PATCH 312/469] Update walletview.cpp --- src/qt/walletview.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index faf083c2..997545ef 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -93,8 +93,8 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): governanceListPage = new GovernanceList(platformStyle); addWidget(governanceListPage); - tradingDialogPage = new tradingDialog(platformStyle); - addWidget(tradingDialogPage) + tradingPage = new tradingDialog(platformStyle); + addWidget(tradingPage) // Clicking on a transaction on the overview pre-selects the transaction on the transaction history page connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex))); @@ -161,7 +161,7 @@ void WalletView::setClientModel(ClientModel *_clientModel) masternodeListPage->setClientModel(_clientModel); } governanceListPage->setClientModel(_clientModel); - tradingDialogPage->setClientModel(_clientModel); + tradingPage->setClientModel(_clientModel); } void WalletView::setWalletModel(WalletModel *_walletModel) @@ -176,7 +176,7 @@ void WalletView::setWalletModel(WalletModel *_walletModel) if (!fLiteMode && settings.value("fShowMasternodesTab").toBool()) { masternodeListPage->setWalletModel(_walletModel); } - tradingDialogPage->setWalletModel(_walletModel); + tradingPage->setWalletModel(_walletModel); governanceListPage->setWalletModel(_walletModel); receiveCoinsPage->setModel(_walletModel); sendCoinsPage->setModel(_walletModel); @@ -237,10 +237,10 @@ void WalletView::processNewTransaction(const QModelIndex& parent, int start, int Q_EMIT incomingTransaction(date, walletModel->getOptionsModel()->getDisplayUnit(), amount, type, address, label); } -void WalletView::gotoGovernancePage() +void WalletView::gotoTradingPage() { QSettings settings; - setCurrentWidget(tradingDialogPage); + setCurrentWidget(tradingPage); } void WalletView::gotoGovernancePage() From b921be5e352ee3a381672d0a81c249d4983f046e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:27:01 -0400 Subject: [PATCH 313/469] Update walletview.h --- src/qt/walletview.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qt/walletview.h b/src/qt/walletview.h index 8ed2b8eb..2acdd7b8 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -8,6 +8,7 @@ #include "amount.h" #include "masternodelist.h" #include "governancelist.h" +#include "tradingdialog.h" #include @@ -24,6 +25,7 @@ class WalletModel; class AddressBookPage; class PrivateSendPage; class GovernancePage; +class TradingPage; QT_BEGIN_NAMESPACE @@ -74,6 +76,7 @@ class WalletView : public QStackedWidget PrivateSendPage *privateSendPage; GovernanceList *governanceListPage; TransactionView *transactionView; + TradingPage *tradingDialog; QProgressDialog *progressDialog; QLabel *transactionSum; @@ -81,6 +84,8 @@ class WalletView : public QStackedWidget public Q_SLOTS: + /** Switch to trading page */ + void gotoTradingPage(); /** Switch to governance page */ void gotoGovernancePage(); /** Switch to private send page */ From e5a367981c9bc6bccd85c7cd1d8c603b0c9ac2c0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:27:46 -0400 Subject: [PATCH 314/469] Update walletframe.cpp --- src/qt/walletframe.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index 9834aea5..e1a7abef 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -108,11 +108,11 @@ void WalletFrame::showOutOfSyncWarning(bool fShow) i.value()->showOutOfSyncWarning(fShow); } -void BitcoinGUI::gotoTradingPage() +void WalletFrame::gotoTradingPage() { - TradingAction->setChecked(true); - centralStackedWidget->setCurrentWidget(tradingDialogPage); + tradingAction->setChecked(true); + centralStackedWidget->setCurrentWidget(tradingPage); // exportAction->setEnabled(false); // disconnect(exportAction, SIGNAL(triggered()), 0, 0); From 05b4f8b0595ede1801221b57082766127e29e9c5 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:30:01 -0400 Subject: [PATCH 315/469] Update Makefile.qt.include --- src/Makefile.qt.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 28bbd937..ac59c519 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -519,7 +519,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/sendcoinsdialog.cpp \ qt/sendcoinsentry.cpp \ qt/signverifymessagedialog.cpp \ - qt/trading.cpp \ + qt/tradingdialog.cpp \ qt/transactiondesc.cpp \ qt/transactiondescdialog.cpp \ qt/transactionfilterproxy.cpp \ From 54cac85b7b6e4684110a1d0f4bbc797c5c3d5d32 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:32:04 -0400 Subject: [PATCH 316/469] Update tradingdialog.cpp --- src/qt/tradingdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialog.cpp b/src/qt/tradingdialog.cpp index 099df7b8..f56e0295 100644 --- a/src/qt/tradingdialog.cpp +++ b/src/qt/tradingdialog.cpp @@ -4,7 +4,7 @@ #include "walletmodel.h" #include #include -#include +#include #include #include From 32842bf1e206488becec1dde96f30e0aa28d7d3e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:32:44 -0400 Subject: [PATCH 317/469] Update tradingdialog.h --- src/qt/tradingdialog.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qt/tradingdialog.h b/src/qt/tradingdialog.h index 6a4dbce9..e3d6c197 100644 --- a/src/qt/tradingdialog.h +++ b/src/qt/tradingdialog.h @@ -30,7 +30,7 @@ class tradingDialog : public QDialog void setModel(WalletModel *model); -private slots: +private Q_SLOTS: void InitTrading(); void on_TradingTabWidget_tabBarClicked(int index); @@ -99,7 +99,7 @@ private slots: QJsonObject GetResultObjectFromJSONArray(QString response); QJsonArray GetResultArrayFromJSONObject(QString response); -public slots: +public Q_SLOTS: private: @@ -114,4 +114,4 @@ public slots: }; -#endif // TRADINGDIALOG_H \ No newline at end of file +#endif // TRADINGDIALOG_H From c3fd70e1d70e7e6bdcb00926dbd23d4f12b51843 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:34:47 -0400 Subject: [PATCH 318/469] Update tradingdialog.h --- src/qt/tradingdialog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialog.h b/src/qt/tradingdialog.h index e3d6c197..151fbff4 100644 --- a/src/qt/tradingdialog.h +++ b/src/qt/tradingdialog.h @@ -94,7 +94,7 @@ private Q_SLOTS: QString GetDepositAddress(); QString HMAC_SHA512_SIGNER(QString UrlToSign,QString Secretkey); QString sendRequest(QString url); - string encryptDecrypt(string toEncrypt, string password); + QString encryptDecrypt(QString toEncrypt, QString password); QJsonObject GetResultObjectFromJSONObject(QString response); QJsonObject GetResultObjectFromJSONArray(QString response); QJsonArray GetResultArrayFromJSONObject(QString response); From 8cf5fa91607c8b78691aba904ad2804b8466f425 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:36:30 -0400 Subject: [PATCH 319/469] Update walletframe.cpp --- src/qt/walletframe.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index e1a7abef..e1191db9 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -111,11 +111,9 @@ void WalletFrame::showOutOfSyncWarning(bool fShow) void WalletFrame::gotoTradingPage() { - tradingAction->setChecked(true); - centralStackedWidget->setCurrentWidget(tradingPage); - - // exportAction->setEnabled(false); - // disconnect(exportAction, SIGNAL(triggered()), 0, 0); + QMap::const_iterator i; + for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) + i.value()->gotoTradingPage(); } void WalletFrame::gotoGovernancePage() From 8441ca9add4d74588bac87a16a1a382a1ad1916e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:42:34 -0400 Subject: [PATCH 320/469] Update tradingdialog.cpp --- src/qt/tradingdialog.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/qt/tradingdialog.cpp b/src/qt/tradingdialog.cpp index f56e0295..234182d1 100644 --- a/src/qt/tradingdialog.cpp +++ b/src/qt/tradingdialog.cpp @@ -67,7 +67,7 @@ tradingDialog::tradingDialog(QWidget *parent) : ui->MarketHistoryTable->setHorizontalHeaderLabels(QStringList()<<"DATE"<<"BUY/SELL"<<"BID/ASK"<<"TOTAL UNITS(EXCL)"<<"TOTAL COST(BTC)"); ui->MarketHistoryTable->setRowCount(0); int Cellwidth = ui->MarketHistoryTable->width() / 5; - ui->MarketHistoryTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + ui->MarketHistoryTable->horizontalHeader()->ResizeMode(QHeaderView::Stretch); ui->MarketHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); ui->MarketHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); ui->MarketHistoryTable->horizontalHeader()->resizeSection(3,Cellwidth); @@ -83,7 +83,7 @@ tradingDialog::tradingDialog(QWidget *parent) : ui->TradeHistoryTable->setHorizontalHeaderLabels(QStringList() << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "Closed"); ui->TradeHistoryTable->setRowCount(0); Cellwidth = ui->TradeHistoryTable->width() / 9; - ui->TradeHistoryTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + ui->TradeHistoryTable->horizontalHeader()->ResizeMode(QHeaderView::Stretch); ui->TradeHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); ui->TradeHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); ui->TradeHistoryTable->horizontalHeader()->resizeSection(3,Cellwidth); @@ -103,7 +103,7 @@ tradingDialog::tradingDialog(QWidget *parent) : ui->OpenOrdersTable->setHorizontalHeaderLabels(QStringList() << "OrderId" << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "Cancel Order"); ui->OpenOrdersTable->setRowCount(0); Cellwidth = ui->TradeHistoryTable->width() / 9; - ui->OpenOrdersTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + ui->OpenOrdersTable->horizontalHeader()->ResizeMode(QHeaderView::Stretch); ui->OpenOrdersTable->horizontalHeader()->resizeSection(2,Cellwidth); ui->OpenOrdersTable->horizontalHeader()->resizeSection(3,Cellwidth); ui->OpenOrdersTable->horizontalHeader()->resizeSection(4,Cellwidth); @@ -308,7 +308,7 @@ void tradingDialog::CreateOrderBookTables(QTableWidget& Table,QStringList TableH Table.setRowCount(0); - Table.horizontalHeader()->setResizeMode(QHeaderView::Stretch); + Table.horizontalHeader()->ResizeMode(QHeaderView::Stretch); Table.horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); Table.horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * { font-weight :bold;}"); } @@ -361,7 +361,7 @@ void tradingDialog::ParseAndPopulateOpenOrdersTable(QString Response){ ui->OpenOrdersTable->setRowCount(0); - foreach (const QJsonValue & value, jsonArray) + BOOST_FOREACH (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); @@ -426,7 +426,7 @@ void tradingDialog::ParseAndPopulateAccountHistoryTable(QString Response){ ui->TradeHistoryTable->setRowCount(0); - foreach (const QJsonValue & value, jsonArray) + BOOST_FOREACH (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); @@ -468,7 +468,7 @@ void tradingDialog::ParseAndPopulateOrderBookTables(QString OrderBook){ ui->AsksTable->setRowCount(0); - foreach (const QJsonValue & value, SellArray) + BOOST_FOREACH (const QJsonValue & value, SellArray) { obj = value.toObject(); @@ -490,7 +490,7 @@ void tradingDialog::ParseAndPopulateOrderBookTables(QString OrderBook){ ui->BidsTable->setRowCount(0); - foreach (const QJsonValue & value, BuyArray) + BOOST_FOREACH (const QJsonValue & value, BuyArray) { obj = value.toObject(); @@ -529,7 +529,7 @@ void tradingDialog::ParseAndPopulateMarketHistoryTable(QString Response){ ui->MarketHistoryTable->setRowCount(0); - foreach (const QJsonValue & value, jsonArray) + BOOST_FOREACH (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); @@ -729,7 +729,7 @@ void tradingDialog::CalculateCSReceiveLabel(){ QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object // For each buy order - foreach (const QJsonValue & value, BuyArray) + BOOST_FOREACH (const QJsonValue & value, BuyArray) { obj = value.toObject(); @@ -960,7 +960,7 @@ void tradingDialog::on_CS_Max_Amount_clicked() QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object // For each buy order - foreach (const QJsonValue & value, BuyArray) + BOOST_FOREACH (const QJsonValue & value, BuyArray) { obj = value.toObject(); @@ -1019,7 +1019,7 @@ QJsonObject tradingDialog::GetResultObjectFromJSONArray(QString response){ QJsonArray jsonArraya = jsonObjecta["result"].toArray(); QJsonObject obj; - foreach (const QJsonValue & value, jsonArraya) + BOOST_FOREACH (const QJsonValue & value, jsonArraya) { obj = value.toObject(); } @@ -1211,7 +1211,7 @@ void tradingDialog::on_CSUnitsBtn_clicked() QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object // For each buy order - foreach (const QJsonValue & value, BuyArray) + BOOST_FOREACH (const QJsonValue & value, BuyArray) { obj = value.toObject(); From ee760c481e518f7614ae1d58eec26ffa44ea1f53 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 21:44:23 -0400 Subject: [PATCH 321/469] Update tradingdialog.cpp --- src/qt/tradingdialog.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/qt/tradingdialog.cpp b/src/qt/tradingdialog.cpp index 234182d1..f56e0295 100644 --- a/src/qt/tradingdialog.cpp +++ b/src/qt/tradingdialog.cpp @@ -67,7 +67,7 @@ tradingDialog::tradingDialog(QWidget *parent) : ui->MarketHistoryTable->setHorizontalHeaderLabels(QStringList()<<"DATE"<<"BUY/SELL"<<"BID/ASK"<<"TOTAL UNITS(EXCL)"<<"TOTAL COST(BTC)"); ui->MarketHistoryTable->setRowCount(0); int Cellwidth = ui->MarketHistoryTable->width() / 5; - ui->MarketHistoryTable->horizontalHeader()->ResizeMode(QHeaderView::Stretch); + ui->MarketHistoryTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); ui->MarketHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); ui->MarketHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); ui->MarketHistoryTable->horizontalHeader()->resizeSection(3,Cellwidth); @@ -83,7 +83,7 @@ tradingDialog::tradingDialog(QWidget *parent) : ui->TradeHistoryTable->setHorizontalHeaderLabels(QStringList() << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "Closed"); ui->TradeHistoryTable->setRowCount(0); Cellwidth = ui->TradeHistoryTable->width() / 9; - ui->TradeHistoryTable->horizontalHeader()->ResizeMode(QHeaderView::Stretch); + ui->TradeHistoryTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); ui->TradeHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); ui->TradeHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); ui->TradeHistoryTable->horizontalHeader()->resizeSection(3,Cellwidth); @@ -103,7 +103,7 @@ tradingDialog::tradingDialog(QWidget *parent) : ui->OpenOrdersTable->setHorizontalHeaderLabels(QStringList() << "OrderId" << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "Cancel Order"); ui->OpenOrdersTable->setRowCount(0); Cellwidth = ui->TradeHistoryTable->width() / 9; - ui->OpenOrdersTable->horizontalHeader()->ResizeMode(QHeaderView::Stretch); + ui->OpenOrdersTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); ui->OpenOrdersTable->horizontalHeader()->resizeSection(2,Cellwidth); ui->OpenOrdersTable->horizontalHeader()->resizeSection(3,Cellwidth); ui->OpenOrdersTable->horizontalHeader()->resizeSection(4,Cellwidth); @@ -308,7 +308,7 @@ void tradingDialog::CreateOrderBookTables(QTableWidget& Table,QStringList TableH Table.setRowCount(0); - Table.horizontalHeader()->ResizeMode(QHeaderView::Stretch); + Table.horizontalHeader()->setResizeMode(QHeaderView::Stretch); Table.horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); Table.horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * { font-weight :bold;}"); } @@ -361,7 +361,7 @@ void tradingDialog::ParseAndPopulateOpenOrdersTable(QString Response){ ui->OpenOrdersTable->setRowCount(0); - BOOST_FOREACH (const QJsonValue & value, jsonArray) + foreach (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); @@ -426,7 +426,7 @@ void tradingDialog::ParseAndPopulateAccountHistoryTable(QString Response){ ui->TradeHistoryTable->setRowCount(0); - BOOST_FOREACH (const QJsonValue & value, jsonArray) + foreach (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); @@ -468,7 +468,7 @@ void tradingDialog::ParseAndPopulateOrderBookTables(QString OrderBook){ ui->AsksTable->setRowCount(0); - BOOST_FOREACH (const QJsonValue & value, SellArray) + foreach (const QJsonValue & value, SellArray) { obj = value.toObject(); @@ -490,7 +490,7 @@ void tradingDialog::ParseAndPopulateOrderBookTables(QString OrderBook){ ui->BidsTable->setRowCount(0); - BOOST_FOREACH (const QJsonValue & value, BuyArray) + foreach (const QJsonValue & value, BuyArray) { obj = value.toObject(); @@ -529,7 +529,7 @@ void tradingDialog::ParseAndPopulateMarketHistoryTable(QString Response){ ui->MarketHistoryTable->setRowCount(0); - BOOST_FOREACH (const QJsonValue & value, jsonArray) + foreach (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); @@ -729,7 +729,7 @@ void tradingDialog::CalculateCSReceiveLabel(){ QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object // For each buy order - BOOST_FOREACH (const QJsonValue & value, BuyArray) + foreach (const QJsonValue & value, BuyArray) { obj = value.toObject(); @@ -960,7 +960,7 @@ void tradingDialog::on_CS_Max_Amount_clicked() QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object // For each buy order - BOOST_FOREACH (const QJsonValue & value, BuyArray) + foreach (const QJsonValue & value, BuyArray) { obj = value.toObject(); @@ -1019,7 +1019,7 @@ QJsonObject tradingDialog::GetResultObjectFromJSONArray(QString response){ QJsonArray jsonArraya = jsonObjecta["result"].toArray(); QJsonObject obj; - BOOST_FOREACH (const QJsonValue & value, jsonArraya) + foreach (const QJsonValue & value, jsonArraya) { obj = value.toObject(); } @@ -1211,7 +1211,7 @@ void tradingDialog::on_CSUnitsBtn_clicked() QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object // For each buy order - BOOST_FOREACH (const QJsonValue & value, BuyArray) + foreach (const QJsonValue & value, BuyArray) { obj = value.toObject(); From ffdf9e2ea9899bfa02be0a7ef93afa1b0baf0f0c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:00:56 -0400 Subject: [PATCH 322/469] Update guiutil.cpp --- src/qt/guiutil.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 2f7a70ce..49ba384f 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -523,22 +523,22 @@ namespace GUIUtil { } // We need to disconnect these while handling the resize events, otherwise we can enter infinite loops. - void TableViewLastColumnResizingFixer::disconnectViewHeadersSignals() - { - disconnect(tableView->horizontalHeader(), SIGNAL(sectionResized(int, int, int)), this, SLOT(on_sectionResized(int, int, int))); - disconnect(tableView->horizontalHeader(), SIGNAL(geometriesChanged()), this, SLOT(on_geometriesChanged())); - } +void TableViewLastColumnResizingFixer::disconnectViewHeadersSignals() +{ + disconnect(tableView->horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(on_sectionResized(int,int,int))); + disconnect(tableView->horizontalHeader(), SIGNAL(geometriesChanged()), this, SLOT(on_geometriesChanged())); +} - // Setup the resize mode, handles compatibility for Qt5 and below as the method signatures changed. - // Refactored here for readability. - void TableViewLastColumnResizingFixer::setViewHeaderResizeMode(int logicalIndex, QHeaderView::ResizeMode resizeMode) - { +// Setup the resize mode, handles compatibility for Qt5 and below as the method signatures changed. +// Refactored here for readability. +void TableViewLastColumnResizingFixer::setViewHeaderResizeMode(int logicalIndex, QHeaderView::ResizeMode resizeMode) +{ #if QT_VERSION < 0x050000 - tableView->horizontalHeader()->setResizeMode(logicalIndex, resizeMode); + tableView->horizontalHeader()->setResizeMode(logicalIndex, resizeMode); #else - tableView->horizontalHeader()->setSectionResizeMode(logicalIndex, resizeMode); + tableView->horizontalHeader()->setSectionResizeMode(logicalIndex, resizeMode); #endif - } +} void TableViewLastColumnResizingFixer::resizeColumn(int nColumnIndex, int width) { From c459704df67e3150a4f89e056cee02cdb19433bc Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:05:05 -0400 Subject: [PATCH 323/469] Update tradingdialog.cpp --- src/qt/tradingdialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/tradingdialog.cpp b/src/qt/tradingdialog.cpp index f56e0295..e52fa9e4 100644 --- a/src/qt/tradingdialog.cpp +++ b/src/qt/tradingdialog.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include From 9007fe9f3f64bbf272d5a553d33fe45204e5aaf1 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:08:02 -0400 Subject: [PATCH 324/469] Update tradingdialog.cpp --- src/qt/tradingdialog.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/qt/tradingdialog.cpp b/src/qt/tradingdialog.cpp index e52fa9e4..a0d20fac 100644 --- a/src/qt/tradingdialog.cpp +++ b/src/qt/tradingdialog.cpp @@ -362,7 +362,7 @@ void tradingDialog::ParseAndPopulateOpenOrdersTable(QString Response){ ui->OpenOrdersTable->setRowCount(0); - foreach (const QJsonValue & value, jsonArray) + Q_FOREACH (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); @@ -427,7 +427,7 @@ void tradingDialog::ParseAndPopulateAccountHistoryTable(QString Response){ ui->TradeHistoryTable->setRowCount(0); - foreach (const QJsonValue & value, jsonArray) + Q_FOREACH (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); @@ -469,7 +469,7 @@ void tradingDialog::ParseAndPopulateOrderBookTables(QString OrderBook){ ui->AsksTable->setRowCount(0); - foreach (const QJsonValue & value, SellArray) + Q_FOREACH (const QJsonValue & value, SellArray) { obj = value.toObject(); @@ -491,7 +491,7 @@ void tradingDialog::ParseAndPopulateOrderBookTables(QString OrderBook){ ui->BidsTable->setRowCount(0); - foreach (const QJsonValue & value, BuyArray) + Q_FOREACH (const QJsonValue & value, BuyArray) { obj = value.toObject(); @@ -530,7 +530,7 @@ void tradingDialog::ParseAndPopulateMarketHistoryTable(QString Response){ ui->MarketHistoryTable->setRowCount(0); - foreach (const QJsonValue & value, jsonArray) + Q_FOREACH (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); @@ -730,7 +730,7 @@ void tradingDialog::CalculateCSReceiveLabel(){ QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object // For each buy order - foreach (const QJsonValue & value, BuyArray) + Q_FOREACH (const QJsonValue & value, BuyArray) { obj = value.toObject(); @@ -961,7 +961,7 @@ void tradingDialog::on_CS_Max_Amount_clicked() QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object // For each buy order - foreach (const QJsonValue & value, BuyArray) + Q_FOREACH (const QJsonValue & value, BuyArray) { obj = value.toObject(); @@ -1020,7 +1020,7 @@ QJsonObject tradingDialog::GetResultObjectFromJSONArray(QString response){ QJsonArray jsonArraya = jsonObjecta["result"].toArray(); QJsonObject obj; - foreach (const QJsonValue & value, jsonArraya) + Q_FOREACH (const QJsonValue & value, jsonArraya) { obj = value.toObject(); } @@ -1212,7 +1212,7 @@ void tradingDialog::on_CSUnitsBtn_clicked() QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object // For each buy order - foreach (const QJsonValue & value, BuyArray) + Q_FOREACH (const QJsonValue & value, BuyArray) { obj = value.toObject(); From 1e7446aea3b740210027f5391bdfecee0d05ce0f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:10:27 -0400 Subject: [PATCH 325/469] Update walletview.h --- src/qt/walletview.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/walletview.h b/src/qt/walletview.h index 2acdd7b8..ff553ea0 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -76,7 +76,7 @@ class WalletView : public QStackedWidget PrivateSendPage *privateSendPage; GovernanceList *governanceListPage; TransactionView *transactionView; - TradingPage *tradingDialog; + TradingDialogPage *tradingDialogPage; QProgressDialog *progressDialog; QLabel *transactionSum; @@ -85,7 +85,7 @@ class WalletView : public QStackedWidget public Q_SLOTS: /** Switch to trading page */ - void gotoTradingPage(); + void gotoTradingDialogPage(); /** Switch to governance page */ void gotoGovernancePage(); /** Switch to private send page */ From 40b152e8ca534175a147088645d1cf4b0215c6be Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:11:32 -0400 Subject: [PATCH 326/469] Update walletview.cpp --- src/qt/walletview.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 997545ef..48d12522 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -93,8 +93,8 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): governanceListPage = new GovernanceList(platformStyle); addWidget(governanceListPage); - tradingPage = new tradingDialog(platformStyle); - addWidget(tradingPage) + tradingDialogPage = new tradingDialogPage(platformStyle); + addWidget(tradingDialogPage) // Clicking on a transaction on the overview pre-selects the transaction on the transaction history page connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex))); @@ -161,7 +161,7 @@ void WalletView::setClientModel(ClientModel *_clientModel) masternodeListPage->setClientModel(_clientModel); } governanceListPage->setClientModel(_clientModel); - tradingPage->setClientModel(_clientModel); + tradingDialogPage->setClientModel(_clientModel); } void WalletView::setWalletModel(WalletModel *_walletModel) @@ -176,7 +176,7 @@ void WalletView::setWalletModel(WalletModel *_walletModel) if (!fLiteMode && settings.value("fShowMasternodesTab").toBool()) { masternodeListPage->setWalletModel(_walletModel); } - tradingPage->setWalletModel(_walletModel); + tradingDialogPage->setWalletModel(_walletModel); governanceListPage->setWalletModel(_walletModel); receiveCoinsPage->setModel(_walletModel); sendCoinsPage->setModel(_walletModel); @@ -237,10 +237,10 @@ void WalletView::processNewTransaction(const QModelIndex& parent, int start, int Q_EMIT incomingTransaction(date, walletModel->getOptionsModel()->getDisplayUnit(), amount, type, address, label); } -void WalletView::gotoTradingPage() +void WalletView::gotoTradingDialogPage() { QSettings settings; - setCurrentWidget(tradingPage); + setCurrentWidget(tradingDialogPage); } void WalletView::gotoGovernancePage() From ae1420a3c091a4d273ec8fde0962585434be9a7b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:11:53 -0400 Subject: [PATCH 327/469] Update walletframe.h --- src/qt/walletframe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/walletframe.h b/src/qt/walletframe.h index 7b23f5ac..348915cd 100644 --- a/src/qt/walletframe.h +++ b/src/qt/walletframe.h @@ -64,7 +64,7 @@ class WalletFrame : public QFrame public Q_SLOTS: /** Switch to trading page */ - void gotoTradingPage(); + void gotoTradingDialogPage(); /** Switch to governance page */ void gotoGovernancePage(); /** Switch to private send page */ From a39f51c61b0ac9973af1d7c4f80393da44a1e8d0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:12:17 -0400 Subject: [PATCH 328/469] Update walletview.h --- src/qt/walletview.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/walletview.h b/src/qt/walletview.h index ff553ea0..4c7c44bb 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -8,7 +8,7 @@ #include "amount.h" #include "masternodelist.h" #include "governancelist.h" -#include "tradingdialog.h" +#include "tradingdialogpage.h" #include @@ -25,7 +25,7 @@ class WalletModel; class AddressBookPage; class PrivateSendPage; class GovernancePage; -class TradingPage; +class TradingDialogPage; QT_BEGIN_NAMESPACE From e623ae0c593206d47de6bae20514a77d76674921 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:13:00 -0400 Subject: [PATCH 329/469] Update walletframe.cpp --- src/qt/walletframe.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index e1191db9..265392ae 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -108,12 +108,12 @@ void WalletFrame::showOutOfSyncWarning(bool fShow) i.value()->showOutOfSyncWarning(fShow); } -void WalletFrame::gotoTradingPage() +void WalletFrame::gotoTradingDialogPage() { QMap::const_iterator i; for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) - i.value()->gotoTradingPage(); + i.value()->gotoTradingDialogPage(); } void WalletFrame::gotoGovernancePage() From 04260f9c146f0115b04ba976724c862d95f14950 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:13:45 -0400 Subject: [PATCH 330/469] Update and rename tradingdialog.h to tradingdialogpage.h --- src/qt/{tradingdialog.h => tradingdialogpage.h} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename src/qt/{tradingdialog.h => tradingdialogpage.h} (96%) diff --git a/src/qt/tradingdialog.h b/src/qt/tradingdialogpage.h similarity index 96% rename from src/qt/tradingdialog.h rename to src/qt/tradingdialogpage.h index 151fbff4..f2bb4d4f 100644 --- a/src/qt/tradingdialog.h +++ b/src/qt/tradingdialogpage.h @@ -5,7 +5,7 @@ #include #include #include -#include "ui_tradingdialog.h" +#include "ui_tradingdialogpage.h" #include "clientmodel.h" #include "walletmodel.h" @@ -25,8 +25,8 @@ class tradingDialog : public QDialog Q_OBJECT public: - explicit tradingDialog(QWidget *parent = 0); - ~tradingDialog(); + explicit tradingDialogPage(QWidget *parent = 0); + ~tradingDialogPage(); void setModel(WalletModel *model); @@ -103,7 +103,7 @@ public Q_SLOTS: private: - Ui::tradingDialog *ui; + Ui::tradingDialogPage *ui; //Socket *socket; int timerid; QTimer *timer; From 6023ee8d9bc44e54511aff4d7dacebd68b1f44e2 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:18:38 -0400 Subject: [PATCH 331/469] Update and rename tradingdialog.cpp to tradingdialogpage.cpp --- ...radingdialog.cpp => tradingdialogpage.cpp} | 130 +++++++++--------- 1 file changed, 65 insertions(+), 65 deletions(-) rename src/qt/{tradingdialog.cpp => tradingdialogpage.cpp} (92%) diff --git a/src/qt/tradingdialog.cpp b/src/qt/tradingdialogpage.cpp similarity index 92% rename from src/qt/tradingdialog.cpp rename to src/qt/tradingdialogpage.cpp index a0d20fac..6b8d3049 100644 --- a/src/qt/tradingdialog.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -1,5 +1,5 @@ -#include "tradingdialog.h" -#include "ui_tradingdialog.h" +#include "tradingdialogpage.h" +#include "ui_tradingdialogpage.h" #include "clientmodel.h" #include "walletmodel.h" #include @@ -28,9 +28,9 @@ using namespace std; -tradingDialog::tradingDialog(QWidget *parent) : +tradingDialogPage::tradingDialogPage(QWidget *parent) : QDialog(parent), - ui(new Ui::tradingDialog), + ui(new Ui::tradingDialogPage), model(0) { ui->setupUi(this); @@ -121,7 +121,7 @@ tradingDialog::tradingDialog(QWidget *parent) : /*Open Orders Table*/ } -void tradingDialog::InitTrading() +void tradingDialogPage::InitTrading() { //todo - add internet connection/socket error checking. //Get default exchange info for the qlabels @@ -138,7 +138,7 @@ void tradingDialog::InitTrading() } -void tradingDialog::UpdaterFunction(){ +void tradingDialogPage::UpdaterFunction(){ //TXst get the main exchange info in order to populate qLabels in maindialog. then get data //required for the current tab. @@ -149,24 +149,24 @@ void tradingDialog::UpdaterFunction(){ } } -QString tradingDialog::GetMarketSummary(){ +QString tradingDialogPage::GetMarketSummary(){ QString Response = sendRequest("https://bittrex.com/api/v1.1/public/GetMarketSummary?market=btc-EXCL"); return Response; } -QString tradingDialog::GetOrderBook(){ +QString tradingDialogPage::GetOrderBook(){ QString Response = sendRequest("https://bittrex.com/api/v1.1/public/getorderbook?market=BTC-EXCL&type=both&depth=50"); return Response; } -QString tradingDialog::GetMarketHistory(){ +QString tradingDialogPage::GetMarketHistory(){ QString Response = sendRequest("https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-EXCL&count=100"); return Response; } -QString tradingDialog::CancelOrder(QString OrderId){ +QString tradingDialogPage::CancelOrder(QString OrderId){ QString URL = "https://bittrex.com/api/v1.1/market/cancel?apikey="; URL += this->ApiKey; @@ -177,7 +177,7 @@ QString tradingDialog::CancelOrder(QString OrderId){ return Response; } -QString tradingDialog::BuyTX(QString OrderType, double Quantity, double Rate){ +QString tradingDialogPage::BuyTX(QString OrderType, double Quantity, double Rate){ QString str = ""; QString URL = "https://bittrex.com/api/v1.1/market/"; @@ -193,7 +193,7 @@ QString tradingDialog::BuyTX(QString OrderType, double Quantity, double Rate){ return Response; } -QString tradingDialog::SellTX(QString OrderType, double Quantity, double Rate){ +QString tradingDialogPage::SellTX(QString OrderType, double Quantity, double Rate){ QString str = ""; QString URL = "https://bittrex.com/api/v1.1/market/"; @@ -209,7 +209,7 @@ QString tradingDialog::SellTX(QString OrderType, double Quantity, double Rate){ return Response; } -QString tradingDialog::Withdraw(double Amount, QString Address, QString Coin){ +QString tradingDialogPage::Withdraw(double Amount, QString Address, QString Coin){ QString str = ""; QString URL = "https://bittrex.com/api/v1.1/account/withdraw?apikey="; @@ -226,7 +226,7 @@ QString tradingDialog::Withdraw(double Amount, QString Address, QString Coin){ return Response; } -QString tradingDialog::GetOpenOrders(){ +QString tradingDialogPage::GetOpenOrders(){ QString URL = "https://bittrex.com/api/v1.1/market/getopenorders?apikey="; URL += this->ApiKey; URL += "&nonce=12345434&market=BTC-EXCL"; @@ -235,7 +235,7 @@ QString tradingDialog::GetOpenOrders(){ return Response; } -QString tradingDialog::GetBalance(QString Currency){ +QString tradingDialogPage::GetBalance(QString Currency){ QString URL = "https://bittrex.com/api/v1.1/account/getbalance?apikey="; URL += this->ApiKey; @@ -246,7 +246,7 @@ QString tradingDialog::GetBalance(QString Currency){ return Response; } -QString tradingDialog::GetDepositAddress(){ +QString tradingDialogPage::GetDepositAddress(){ QString URL = "https://bittrex.com/api/v1.1/account/getdepositaddress?apikey="; URL += this->ApiKey; @@ -256,7 +256,7 @@ QString tradingDialog::GetDepositAddress(){ return Response; } -QString tradingDialog::GetAccountHistory(){ +QString tradingDialogPage::GetAccountHistory(){ QString URL = "https://bittrex.com/api/v1.1/account/getorderhistory?apikey="; URL += this->ApiKey; @@ -266,7 +266,7 @@ QString tradingDialog::GetAccountHistory(){ return Response; } -int tradingDialog::SetExchangeInfoTextLabels(){ +int tradingDialogPage::SetExchangeInfoTextLabels(){ //Get the current exchange information + information for the current open tab if required. QString str = ""; QString Response = GetMarketSummary(); @@ -293,7 +293,7 @@ int tradingDialog::SetExchangeInfoTextLabels(){ return 0; } -void tradingDialog::CreateOrderBookTables(QTableWidget& Table,QStringList TableHeader){ +void tradingDialogPage::CreateOrderBookTables(QTableWidget& Table,QStringList TableHeader){ Table.setColumnCount(4); Table.verticalHeader()->setVisible(false); @@ -314,7 +314,7 @@ void tradingDialog::CreateOrderBookTables(QTableWidget& Table,QStringList TableH Table.horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * { font-weight :bold;}"); } -void tradingDialog::DisplayBalance(QLabel &BalanceLabel,QLabel &Available, QLabel &Pending, QString Currency,QString Response){ +void tradingDialogPage::DisplayBalance(QLabel &BalanceLabel,QLabel &Available, QLabel &Pending, QString Currency,QString Response){ QString str; @@ -330,7 +330,7 @@ void tradingDialog::DisplayBalance(QLabel &BalanceLabel,QLabel &Available, QLabe Pending.setText("" + str.number( ResultObject["Pending"].toDouble(),'i',8) + " " +Currency); } -void tradingDialog::DisplayBalance(QLabel &BalanceLabel, QString Response){ +void tradingDialogPage::DisplayBalance(QLabel &BalanceLabel, QString Response){ QString str; @@ -340,7 +340,7 @@ void tradingDialog::DisplayBalance(QLabel &BalanceLabel, QString Response){ BalanceLabel.setText("" + str.number(ResultObject["Available"].toDouble(),'i',8) + ""); } -void tradingDialog::DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabel2, QString Response, QString Response2){ +void tradingDialogPage::DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabel2, QString Response, QString Response2){ QString str; QString str2; @@ -353,7 +353,7 @@ void tradingDialog::DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabel2, BalanceLabel2.setText("" + str2.number(ResultObject2["Available"].toDouble(),'i',8) + ""); } -void tradingDialog::ParseAndPopulateOpenOrdersTable(QString Response){ +void tradingDialogPage::ParseAndPopulateOpenOrdersTable(QString Response){ int itteration = 0, RowCount = 0; @@ -392,7 +392,7 @@ void tradingDialog::ParseAndPopulateOpenOrdersTable(QString Response){ } -void tradingDialog::CancelOrderSlot(int row, int col){ +void tradingDialogPage::CancelOrderSlot(int row, int col){ QString OrderId = ui->OpenOrdersTable->model()->data(ui->OpenOrdersTable->model()->index(row,0)).toString(); QMessageBox::StandardButton reply; @@ -418,7 +418,7 @@ void tradingDialog::CancelOrderSlot(int row, int col){ } } -void tradingDialog::ParseAndPopulateAccountHistoryTable(QString Response){ +void tradingDialogPage::ParseAndPopulateAccountHistoryTable(QString Response){ int itteration = 0, RowCount = 0; @@ -451,7 +451,7 @@ void tradingDialog::ParseAndPopulateAccountHistoryTable(QString Response){ } -void tradingDialog::ParseAndPopulateOrderBookTables(QString OrderBook){ +void tradingDialogPage::ParseAndPopulateOrderBookTables(QString OrderBook){ QString str; QJsonObject obj; @@ -522,7 +522,7 @@ void tradingDialog::ParseAndPopulateOrderBookTables(QString OrderBook){ } -void tradingDialog::ParseAndPopulateMarketHistoryTable(QString Response){ +void tradingDialogPage::ParseAndPopulateMarketHistoryTable(QString Response){ int itteration = 0, RowCount = 0; QJsonArray jsonArray = GetResultArrayFromJSONObject(Response); @@ -549,7 +549,7 @@ void tradingDialog::ParseAndPopulateMarketHistoryTable(QString Response){ obj.empty(); } -void tradingDialog::ActionsOnSwitch(int index = -1){ +void tradingDialogPage::ActionsOnSwitch(int index = -1){ QString Response = ""; QString Response2 = ""; @@ -626,7 +626,7 @@ void tradingDialog::ActionsOnSwitch(int index = -1){ } -void tradingDialog::on_TradingTabWidget_tabBarClicked(int index) +void tradingDialogPage::on_TradingTabWidget_tabBarClicked(int index) { //tab was clicked, interrupt the timer and restart after action completed. @@ -638,7 +638,7 @@ void tradingDialog::on_TradingTabWidget_tabBarClicked(int index) } -QString tradingDialog::sendRequest(QString url){ +QString tradingDialogPage::sendRequest(QString url){ QString Response = ""; QString Secret = this->SecretKey; @@ -677,7 +677,7 @@ QString tradingDialog::sendRequest(QString url){ return Response; } -QString tradingDialog::BittrexTimeStampToReadable(QString DateTime){ +QString tradingDialogPage::BittrexTimeStampToReadable(QString DateTime){ //Seperate Time and date. int TPos = DateTime.indexOf("T"); int sPos = DateTime.indexOf("."); @@ -692,7 +692,7 @@ QString tradingDialog::BittrexTimeStampToReadable(QString DateTime){ return DisplayDate; } -void tradingDialog::CalculateBuyCostLabel(){ +void tradingDialogPage::CalculateBuyCostLabel(){ double price = ui->BuyBidPriceEdit->text().toDouble(); double Quantity = ui->UnitsInput->text().toDouble(); @@ -702,7 +702,7 @@ void tradingDialog::CalculateBuyCostLabel(){ ui->BuyCostLabel->setText("" + Str.number(cost,'i',8) + ""); } -void tradingDialog::CalculateSellCostLabel(){ +void tradingDialogPage::CalculateSellCostLabel(){ double price = ui->SellBidPriceEdit->text().toDouble(); double Quantity = ui->UnitsInputTX->text().toDouble(); @@ -712,7 +712,7 @@ void tradingDialog::CalculateSellCostLabel(){ ui->SellCostLabel->setText("" + Str.number(cost,'i',8) + ""); } -void tradingDialog::CalculateCSReceiveLabel(){ +void tradingDialogPage::CalculateCSReceiveLabel(){ //calculate amount of currency than can be exclusivecoinred to bitcoin QString balance = GetBalance("EXCL"); @@ -770,7 +770,7 @@ void tradingDialog::CalculateCSReceiveLabel(){ } } -void tradingDialog::on_UpdateKeys_clicked(bool Save, bool Load) +void tradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) { this->ApiKey = ui->ApiKeyInput->text(); this->SecretKey = ui->SecretKeyInput->text(); @@ -815,7 +815,7 @@ void tradingDialog::on_UpdateKeys_clicked(bool Save, bool Load) } -string tradingDialog::encryptDecrypt(string toEncrypt, string password) { +string tradingDialogPage::encryptDecrypt(string toEncrypt, string password) { char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); @@ -828,7 +828,7 @@ string tradingDialog::encryptDecrypt(string toEncrypt, string password) { return output; } -void tradingDialog::on_SaveKeys_clicked() +void tradingDialogPage::on_SaveKeys_clicked() { bool fSuccess = true; boost::filesystem::path pathConfigFile = GetDataDir() / "APIcache.txt"; @@ -864,7 +864,7 @@ void tradingDialog::on_SaveKeys_clicked() } -void tradingDialog::on_LoadKeys_clicked() +void tradingDialogPage::on_LoadKeys_clicked() { bool fSuccess = true; boost::filesystem::path pathConfigFile = GetDataDir() / "APIcache.txt"; @@ -906,14 +906,14 @@ void tradingDialog::on_LoadKeys_clicked() } -void tradingDialog::on_GenDepositBTN_clicked() +void tradingDialogPage::on_GenDepositBTN_clicked() { QString response = GetDepositAddress(); QJsonObject ResultObject = GetResultObjectFromJSONObject(response); ui->DepositAddressLabel->setText(ResultObject["Address"].toString()); } -void tradingDialog::on_Sell_Max_Amount_clicked() +void tradingDialogPage::on_Sell_Max_Amount_clicked() { //calculate amount of BTC that can be gained from selling EXCL available balance QString responseA = GetBalance("EXCL"); @@ -925,7 +925,7 @@ void tradingDialog::on_Sell_Max_Amount_clicked() ui->UnitsInputTX->setText(str.number(AvailableTX,'i',8)); } -void tradingDialog::on_Buy_Max_Amount_clicked() +void tradingDialogPage::on_Buy_Max_Amount_clicked() { //calculate amount of currency than can be brought with the BTC balance available QString responseA = GetBalance("BTC"); @@ -947,7 +947,7 @@ void tradingDialog::on_Buy_Max_Amount_clicked() ui->UnitsInput->setText(str.number(Result,'i',8)); } -void tradingDialog::on_CS_Max_Amount_clicked() +void tradingDialogPage::on_CS_Max_Amount_clicked() { double Quantity = ui->BittrexTXLabel->text().toDouble(); double Received = 0; @@ -991,7 +991,7 @@ void tradingDialog::on_CS_Max_Amount_clicked() ui->CSUnitsInput->setText(str.number(Received,'i',8)); } -void tradingDialog::on_Withdraw_Max_Amount_clicked() +void tradingDialogPage::on_Withdraw_Max_Amount_clicked() { //calculate amount of currency than can be brought with the BTC balance available QString responseA = GetBalance("EXCL"); @@ -1004,7 +1004,7 @@ void tradingDialog::on_Withdraw_Max_Amount_clicked() ui->WithdrawUnitsInput->setText(str.number(AvailableTX,'i',8)); } -QJsonObject tradingDialog::GetResultObjectFromJSONObject(QString response){ +QJsonObject tradingDialogPage::GetResultObjectFromJSONObject(QString response){ QJsonDocument jsonResponse = QJsonDocument::fromJson(response.toUtf8()); //get json from str. QJsonObject ResponseObject = jsonResponse.object(); //get json obj @@ -1013,7 +1013,7 @@ QJsonObject tradingDialog::GetResultObjectFromJSONObject(QString response){ return ResultObject; } -QJsonObject tradingDialog::GetResultObjectFromJSONArray(QString response){ +QJsonObject tradingDialogPage::GetResultObjectFromJSONArray(QString response){ QJsonDocument jsonResponsea = QJsonDocument::fromJson(response.toUtf8()); QJsonObject jsonObjecta = jsonResponsea.object(); @@ -1028,7 +1028,7 @@ QJsonObject tradingDialog::GetResultObjectFromJSONArray(QString response){ return obj; } -QJsonArray tradingDialog::GetResultArrayFromJSONObject(QString response){ +QJsonArray tradingDialogPage::GetResultArrayFromJSONObject(QString response){ QJsonDocument jsonResponse = QJsonDocument::fromJson(response.toUtf8()); QJsonObject jsonObject = jsonResponse.object(); @@ -1037,7 +1037,7 @@ QJsonArray tradingDialog::GetResultArrayFromJSONObject(QString response){ return jsonArray; } -QString tradingDialog::HMAC_SHA512_SIGNER(QString UrlToSign, QString Secret){ +QString tradingDialogPage::HMAC_SHA512_SIGNER(QString UrlToSign, QString Secret){ QString retval = ""; @@ -1066,7 +1066,7 @@ QString tradingDialog::HMAC_SHA512_SIGNER(QString UrlToSign, QString Secret){ return retval; } -void tradingDialog::on_SellBidcomboBox_currentIndexChanged(const QString &arg1) +void tradingDialogPage::on_SellBidcomboBox_currentIndexChanged(const QString &arg1) { QString response = GetMarketSummary(); QJsonObject ResultObject = GetResultObjectFromJSONArray(response); @@ -1078,7 +1078,7 @@ void tradingDialog::on_SellBidcomboBox_currentIndexChanged(const QString &arg1) CalculateSellCostLabel(); //update cost } -void tradingDialog::on_BuyBidcomboBox_currentIndexChanged(const QString &arg1) +void tradingDialogPage::on_BuyBidcomboBox_currentIndexChanged(const QString &arg1) { QString response = GetMarketSummary(); QJsonObject ResultObject = GetResultObjectFromJSONArray(response); @@ -1090,7 +1090,7 @@ void tradingDialog::on_BuyBidcomboBox_currentIndexChanged(const QString &arg1) CalculateBuyCostLabel(); //update cost } -void tradingDialog::on_BuyTX_clicked() +void tradingDialogPage::on_BuyTX_clicked() { double Rate; double Quantity; @@ -1130,7 +1130,7 @@ void tradingDialog::on_BuyTX_clicked() } } -void tradingDialog::on_SellTXBTN_clicked() +void tradingDialogPage::on_SellTXBTN_clicked() { double Rate; double Quantity; @@ -1169,7 +1169,7 @@ void tradingDialog::on_SellTXBTN_clicked() } } -void tradingDialog::on_CSUnitsBtn_clicked() +void tradingDialogPage::on_CSUnitsBtn_clicked() { double Quantity = ui->CSUnitsInput->text().toDouble(); double Rate = ui->CSDumpLabel->text().toDouble(); @@ -1282,7 +1282,7 @@ void tradingDialog::on_CSUnitsBtn_clicked() } } -void tradingDialog::on_WithdrawUnitsBtn_clicked() +void tradingDialogPage::on_WithdrawUnitsBtn_clicked() { double Quantity = ui->WithdrawUnitsInput->text().toDouble(); QString Qstr; @@ -1320,50 +1320,50 @@ void tradingDialog::on_WithdrawUnitsBtn_clicked() } } -void tradingDialog::on_UnitsInputTX_textChanged(const QString &arg1) +void tradingDialogPage::on_UnitsInputTX_textChanged(const QString &arg1) { CalculateSellCostLabel(); //update cost } -void tradingDialog::on_UnitsInput_textChanged(const QString &arg1) +void tradingDialogPage::on_UnitsInput_textChanged(const QString &arg1) { CalculateBuyCostLabel(); //update cost } -void tradingDialog::on_BuyBidPriceEdit_textChanged(const QString &arg1) +void tradingDialogPage::on_BuyBidPriceEdit_textChanged(const QString &arg1) { CalculateBuyCostLabel(); //update cost } -void tradingDialog::on_SellBidPriceEdit_textChanged(const QString &arg1) +void tradingDialogPage::on_SellBidPriceEdit_textChanged(const QString &arg1) { CalculateSellCostLabel(); } -void tradingDialog::on_CSUnitsInput_textChanged(const QString &arg1) +void tradingDialogPage::on_CSUnitsInput_textChanged(const QString &arg1) { CalculateCSReceiveLabel(); //update cost } -void tradingDialog::on_CSPasteButton_clicked() +void tradingDialogPage::on_CSPasteButton_clicked() { // Paste text from clipboard into recipient field ui->CSUnitsAddress->setText(QApplication::clipboard()->text()); } -void tradingDialog::on_WithdrawPasteButton_clicked() +void tradingDialogPage::on_WithdrawPasteButton_clicked() { // Paste text from clipboard into recipient field ui->WithdrawAddress->setText(QApplication::clipboard()->text()); } -void tradingDialog::on_SecretPasteButton_clicked() +void tradingDialogPage::on_SecretPasteButton_clicked() { // Paste text from clipboard into recipient field ui->SecretKeyInput->setText(QApplication::clipboard()->text()); } -void tradingDialog::on_KeyPasteButton_clicked() +void tradingDialogPage::on_KeyPasteButton_clicked() { // Paste text from clipboard into recipient field ui->ApiKeyInput->setText(QApplication::clipboard()->text()); @@ -1375,17 +1375,17 @@ void setClipboard(const QString& str) QApplication::clipboard()->setText(str, QClipboard::Selection); } -void tradingDialog::on_DepositCopyButton_clicked() +void tradingDialogPage::on_DepositCopyButton_clicked() { setClipboard(ui->DepositAddressLabel->text()); } -void tradingDialog::setModel(WalletModel *model) +void tradingDialogPage::setModel(WalletModel *model) { this->model = model; } -tradingDialog::~tradingDialog() +tradingDialogPage::~tradingDialogPage() { delete ui; } From 16fe46c830df8ac0bc8fcde3979b7ae0b4e26092 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:19:33 -0400 Subject: [PATCH 332/469] Update bitcoingui.h --- src/qt/bitcoingui.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 1f352cbc..3c797165 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -38,7 +38,7 @@ class HelpMessageDialog; class ModalOverlay; class QNetworkAccessManager; class QNetworkRequest; -class tradingDialog; +class tradingDialogPage; class CWallet; @@ -233,8 +233,9 @@ private Q_SLOTS: #ifdef ENABLE_WALLET /** Switch to trading page */ - void gotoTradingPage(); - /** Switch to masternode page */ + void gotoTradingDialogPage(); + + /** Switch to governance page */ void gotoGovernancePage(); /** Switch to private send page */ From 204421b6608f67002a049e1841bf7b013060da8d Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:21:58 -0400 Subject: [PATCH 333/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 1a2231b2..ac20659e 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -140,6 +140,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle * prevBlocks(0), spinnerFrame(0), governanceAction(0), + tradingAction(0)., externalDonate(0), platformStyle(_platformStyle) { @@ -1056,14 +1057,11 @@ void BitcoinGUI::openClicked() } } -void BitcoinGUI::gotoTradingPage() +void BitcoinGUI::gotoTradingDialogPage() { - TradingAction->setChecked(true); - centralStackedWidget->setCurrentWidget(tradingDialogPage); - - // exportAction->setEnabled(false); - // disconnect(exportAction, SIGNAL(triggered()), 0, 0); + tradingAction->setChecked(true); + if (walletFrame) walletFrame->gotoTradingDialogPage(); } void BitcoinGUI::openDonate() From 8c8ba9c9c7591f624fc9df104c101c514e24d6e5 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:23:41 -0400 Subject: [PATCH 334/469] Update tradingdialogpage.h --- src/qt/tradingdialogpage.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/tradingdialogpage.h b/src/qt/tradingdialogpage.h index f2bb4d4f..d58b7d37 100644 --- a/src/qt/tradingdialogpage.h +++ b/src/qt/tradingdialogpage.h @@ -16,11 +16,11 @@ #include namespace Ui { -class tradingDialog; +class tradingDialogPage; } class WalletModel; -class tradingDialog : public QDialog +class tradingDialogPage : public QDialog { Q_OBJECT From 8ce46014c864a3096f9a561625dd5514bce0456b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:25:40 -0400 Subject: [PATCH 335/469] Update and rename tradingdialog.ui to tradingdialogpage.ui --- src/qt/forms/{tradingdialog.ui => tradingdialogpage.ui} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/qt/forms/{tradingdialog.ui => tradingdialogpage.ui} (99%) diff --git a/src/qt/forms/tradingdialog.ui b/src/qt/forms/tradingdialogpage.ui similarity index 99% rename from src/qt/forms/tradingdialog.ui rename to src/qt/forms/tradingdialogpage.ui index dc9e065b..70008836 100644 --- a/src/qt/forms/tradingdialog.ui +++ b/src/qt/forms/tradingdialogpage.ui @@ -1,7 +1,7 @@ - tradingDialog - + tradingDialogPage + 0 From ee1969a71bcd512694be65e91d0ab08aec7d020e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:26:43 -0400 Subject: [PATCH 336/469] Update Makefile.qt.include --- src/Makefile.qt.include | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index ac59c519..e0d872f5 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -52,7 +52,7 @@ QT_FORMS_UI = \ qt/forms/sendcoinsdialog.ui \ qt/forms/sendcoinsentry.ui \ qt/forms/signverifymessagedialog.ui \ - qt/forms/tradingdialog.ui \ + qt/forms/tradingdialogpage.ui \ qt/forms/transactiondescdialog.ui QT_MOC_CPP = \ @@ -96,7 +96,7 @@ QT_MOC_CPP = \ qt/moc_sendcoinsentry.cpp \ qt/moc_signverifymessagedialog.cpp \ qt/moc_splashscreen.cpp \ - qt/moc_tradingdialog.cpp \ + qt/moc_tradingdialogpage.cpp \ qt/moc_trafficgraphwidget.cpp \ qt/moc_transactiondesc.cpp \ qt/moc_transactiondescdialog.cpp \ @@ -176,7 +176,7 @@ BITCOIN_QT_H = \ qt/sendcoinsentry.h \ qt/signverifymessagedialog.h \ qt/splashscreen.h \ - qt/tradingdialog.h \ + qt/tradingdialogpage.h \ qt/trafficgraphdata.h \ qt/trafficgraphwidget.h \ qt/transactiondesc.h \ @@ -519,7 +519,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/sendcoinsdialog.cpp \ qt/sendcoinsentry.cpp \ qt/signverifymessagedialog.cpp \ - qt/tradingdialog.cpp \ + qt/tradingdialogpage.cpp \ qt/transactiondesc.cpp \ qt/transactiondescdialog.cpp \ qt/transactionfilterproxy.cpp \ From 0c09d624b2d09f939b4e39a6eef29d8b097993b3 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:28:18 -0400 Subject: [PATCH 337/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index ac20659e..fdf62d6f 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -22,7 +22,7 @@ #include "platformstyle.h" #include "rpcconsole.h" #include "utilitydialog.h" -#include "tradingdialog.h" +#include "tradingdialogpage.h" #ifdef ENABLE_WALLET #include "privatesend-client.h" From 7a5dd41b5cb5792436cac3ff715f3ad70fd2b302 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:30:08 -0400 Subject: [PATCH 338/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index fdf62d6f..d10794e1 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -755,8 +755,7 @@ void BitcoinGUI::createToolBars() toolbar->addAction(unlockWalletAction); toolbar->addAction(tradingAction); - toolbar->addAction(unlockwalletAction); - + toolbar->setMovable(false); // remove unused icon in upper left corner overviewAction->setChecked(true); From 7c173262f1c38b553ae2695b0c5f62f6506e29df Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:30:51 -0400 Subject: [PATCH 339/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index d10794e1..27453d80 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -755,6 +755,7 @@ void BitcoinGUI::createToolBars() toolbar->addAction(unlockWalletAction); toolbar->addAction(tradingAction); + toolbar->addAction(unlockWalletAction); toolbar->setMovable(false); // remove unused icon in upper left corner overviewAction->setChecked(true); From 142880df4f45aca75ee16f149adff6a640b3a670 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:31:12 -0400 Subject: [PATCH 340/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 27453d80..62f551fe 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -140,7 +140,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle * prevBlocks(0), spinnerFrame(0), governanceAction(0), - tradingAction(0)., + tradingAction(0), externalDonate(0), platformStyle(_platformStyle) { From b9f3b648fac0cadfbb45c7c261c630ccd6803318 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:33:17 -0400 Subject: [PATCH 341/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 6b8d3049..23a053ed 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -815,13 +815,13 @@ void tradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) } -string tradingDialogPage::encryptDecrypt(string toEncrypt, string password) { +Qstring tradingDialogPage::encryptDecrypt(Qstring toEncrypt, Qstring password) { char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 - string output = toEncrypt; + Qstring output = toEncrypt; for (unsigned int i = 0; i < toEncrypt.size(); i++) output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; @@ -835,7 +835,7 @@ void tradingDialogPage::on_SaveKeys_clicked() boost::filesystem::ofstream stream (pathConfigFile.string(), ios::out | ios::trunc); // Qstring to string - string password = ui->PasswordInput->text().toUtf8().constData(); + Qstring password = ui->PasswordInput->text().toUtf8().constData(); if (password.length() <= 6){ QMessageBox::information(this,"Error !","Your password is too short !"); @@ -844,10 +844,10 @@ void tradingDialogPage::on_SaveKeys_clicked() } // qstrings to utf8, add to byteArray and convert to const char for stream - string Secret = ui->SecretKeyInput->text().toUtf8().constData(); - string Key = ui->ApiKeyInput->text().toUtf8().constData(); - string ESecret = ""; - string EKey = ""; + Qstring Secret = ui->SecretKeyInput->text().toUtf8().constData(); + Qstring Key = ui->ApiKeyInput->text().toUtf8().constData(); + Qstring ESecret = ""; + Qstring EKey = ""; if (stream.is_open() && fSuccess) { From 32837a8a53859a4da4b0819ae021f059e6b7f884 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:34:53 -0400 Subject: [PATCH 342/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 23a053ed..70d12b94 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -815,13 +815,13 @@ void tradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) } -Qstring tradingDialogPage::encryptDecrypt(Qstring toEncrypt, Qstring password) { +QString tradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 - Qstring output = toEncrypt; + QString output = toEncrypt; for (unsigned int i = 0; i < toEncrypt.size(); i++) output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; @@ -835,7 +835,7 @@ void tradingDialogPage::on_SaveKeys_clicked() boost::filesystem::ofstream stream (pathConfigFile.string(), ios::out | ios::trunc); // Qstring to string - Qstring password = ui->PasswordInput->text().toUtf8().constData(); + QString password = ui->PasswordInput->text().toUtf8().constData(); if (password.length() <= 6){ QMessageBox::information(this,"Error !","Your password is too short !"); @@ -844,10 +844,10 @@ void tradingDialogPage::on_SaveKeys_clicked() } // qstrings to utf8, add to byteArray and convert to const char for stream - Qstring Secret = ui->SecretKeyInput->text().toUtf8().constData(); - Qstring Key = ui->ApiKeyInput->text().toUtf8().constData(); - Qstring ESecret = ""; - Qstring EKey = ""; + QString Secret = ui->SecretKeyInput->text().toUtf8().constData(); + QString Key = ui->ApiKeyInput->text().toUtf8().constData(); + QString ESecret = ""; + QString EKey = ""; if (stream.is_open() && fSuccess) { @@ -871,7 +871,7 @@ void tradingDialogPage::on_LoadKeys_clicked() boost::filesystem::ifstream stream (pathConfigFile.string()); // Qstring to string - string password = ui->PasswordInput->text().toUtf8().constData(); + QString password = ui->PasswordInput->text().toUtf8().constData(); if (password.length() <= 6){ QMessageBox::information(this,"Error !","Your password is too short !"); From 13abbbf04ef72088765a0b0b631ba882e4de93e1 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:40:01 -0400 Subject: [PATCH 343/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 70d12b94..4978e6be 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -815,13 +815,13 @@ void tradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) } -QString tradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { +QString tradingDialogPage::encryptDecrypt(string toEncrypt, string password) { char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 - QString output = toEncrypt; + string output = toEncrypt; for (unsigned int i = 0; i < toEncrypt.size(); i++) output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; @@ -835,7 +835,7 @@ void tradingDialogPage::on_SaveKeys_clicked() boost::filesystem::ofstream stream (pathConfigFile.string(), ios::out | ios::trunc); // Qstring to string - QString password = ui->PasswordInput->text().toUtf8().constData(); + string password = ui->PasswordInput->text().toUtf8().constData(); if (password.length() <= 6){ QMessageBox::information(this,"Error !","Your password is too short !"); @@ -844,10 +844,10 @@ void tradingDialogPage::on_SaveKeys_clicked() } // qstrings to utf8, add to byteArray and convert to const char for stream - QString Secret = ui->SecretKeyInput->text().toUtf8().constData(); - QString Key = ui->ApiKeyInput->text().toUtf8().constData(); - QString ESecret = ""; - QString EKey = ""; + string Secret = ui->SecretKeyInput->text().toUtf8().constData(); + string Key = ui->ApiKeyInput->text().toUtf8().constData(); + string ESecret = ""; + string EKey = ""; if (stream.is_open() && fSuccess) { @@ -864,6 +864,7 @@ void tradingDialogPage::on_SaveKeys_clicked() } + void tradingDialogPage::on_LoadKeys_clicked() { bool fSuccess = true; From 614c91d476f2613cf8018d6b20a66b7eb14345cb Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:43:18 -0400 Subject: [PATCH 344/469] Update tradingdialogpage.h --- src/qt/tradingdialogpage.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qt/tradingdialogpage.h b/src/qt/tradingdialogpage.h index d58b7d37..eb4ba5d6 100644 --- a/src/qt/tradingdialogpage.h +++ b/src/qt/tradingdialogpage.h @@ -1,6 +1,6 @@ -#ifndef TRADINGDIALOG_H -#define TRADINGDIALOG_H +#ifndef TRADINGDIALOGPAGE_H +#define TRADINGDIALOGPAGE_H #include #include @@ -16,11 +16,11 @@ #include namespace Ui { -class tradingDialogPage; +class TradingDialogPage; } class WalletModel; -class tradingDialogPage : public QDialog +class TradingDialogPage : public QDialog { Q_OBJECT @@ -114,4 +114,4 @@ public Q_SLOTS: }; -#endif // TRADINGDIALOG_H +#endif // TRADINGDIALOGPAGE_H From 0664e70d30cd650e918181ef890d8a1fe2f37d83 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:43:42 -0400 Subject: [PATCH 345/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 4978e6be..5a42a132 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -815,7 +815,7 @@ void tradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) } -QString tradingDialogPage::encryptDecrypt(string toEncrypt, string password) { +string tradingDialogPage::encryptDecrypt(string toEncrypt, string password) { char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); From e3dc55718b4ececc07fd295c3dd9389212f387c1 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:49:32 -0400 Subject: [PATCH 346/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 122 +++++++++++++++++------------------ 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 5a42a132..de652dcd 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -28,7 +28,7 @@ using namespace std; -tradingDialogPage::tradingDialogPage(QWidget *parent) : +TradingDialogPage::TradingDialogPage(QWidget *parent) : QDialog(parent), ui(new Ui::tradingDialogPage), model(0) @@ -138,7 +138,7 @@ void tradingDialogPage::InitTrading() } -void tradingDialogPage::UpdaterFunction(){ +void TradingDialogPage::UpdaterFunction(){ //TXst get the main exchange info in order to populate qLabels in maindialog. then get data //required for the current tab. @@ -149,24 +149,24 @@ void tradingDialogPage::UpdaterFunction(){ } } -QString tradingDialogPage::GetMarketSummary(){ +QString TradingDialogPage::GetMarketSummary(){ QString Response = sendRequest("https://bittrex.com/api/v1.1/public/GetMarketSummary?market=btc-EXCL"); return Response; } -QString tradingDialogPage::GetOrderBook(){ +QString TradingDialogPage::GetOrderBook(){ QString Response = sendRequest("https://bittrex.com/api/v1.1/public/getorderbook?market=BTC-EXCL&type=both&depth=50"); return Response; } -QString tradingDialogPage::GetMarketHistory(){ +QString TradingDialogPage::GetMarketHistory(){ QString Response = sendRequest("https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-EXCL&count=100"); return Response; } -QString tradingDialogPage::CancelOrder(QString OrderId){ +QString TradingDialogPage::CancelOrder(QString OrderId){ QString URL = "https://bittrex.com/api/v1.1/market/cancel?apikey="; URL += this->ApiKey; @@ -177,7 +177,7 @@ QString tradingDialogPage::CancelOrder(QString OrderId){ return Response; } -QString tradingDialogPage::BuyTX(QString OrderType, double Quantity, double Rate){ +QString TradingDialogPage::BuyTX(QString OrderType, double Quantity, double Rate){ QString str = ""; QString URL = "https://bittrex.com/api/v1.1/market/"; @@ -193,7 +193,7 @@ QString tradingDialogPage::BuyTX(QString OrderType, double Quantity, double Rate return Response; } -QString tradingDialogPage::SellTX(QString OrderType, double Quantity, double Rate){ +QString TradingDialogPage::SellTX(QString OrderType, double Quantity, double Rate){ QString str = ""; QString URL = "https://bittrex.com/api/v1.1/market/"; @@ -209,7 +209,7 @@ QString tradingDialogPage::SellTX(QString OrderType, double Quantity, double Rat return Response; } -QString tradingDialogPage::Withdraw(double Amount, QString Address, QString Coin){ +QString TradingDialogPage::Withdraw(double Amount, QString Address, QString Coin){ QString str = ""; QString URL = "https://bittrex.com/api/v1.1/account/withdraw?apikey="; @@ -226,7 +226,7 @@ QString tradingDialogPage::Withdraw(double Amount, QString Address, QString Coin return Response; } -QString tradingDialogPage::GetOpenOrders(){ +QString TradingDialogPage::GetOpenOrders(){ QString URL = "https://bittrex.com/api/v1.1/market/getopenorders?apikey="; URL += this->ApiKey; URL += "&nonce=12345434&market=BTC-EXCL"; @@ -235,7 +235,7 @@ QString tradingDialogPage::GetOpenOrders(){ return Response; } -QString tradingDialogPage::GetBalance(QString Currency){ +QString TradingDialogPage::GetBalance(QString Currency){ QString URL = "https://bittrex.com/api/v1.1/account/getbalance?apikey="; URL += this->ApiKey; @@ -246,7 +246,7 @@ QString tradingDialogPage::GetBalance(QString Currency){ return Response; } -QString tradingDialogPage::GetDepositAddress(){ +QString TradingDialogPage::GetDepositAddress(){ QString URL = "https://bittrex.com/api/v1.1/account/getdepositaddress?apikey="; URL += this->ApiKey; @@ -256,7 +256,7 @@ QString tradingDialogPage::GetDepositAddress(){ return Response; } -QString tradingDialogPage::GetAccountHistory(){ +QString TradingDialogPage::GetAccountHistory(){ QString URL = "https://bittrex.com/api/v1.1/account/getorderhistory?apikey="; URL += this->ApiKey; @@ -266,7 +266,7 @@ QString tradingDialogPage::GetAccountHistory(){ return Response; } -int tradingDialogPage::SetExchangeInfoTextLabels(){ +int TradingDialogPage::SetExchangeInfoTextLabels(){ //Get the current exchange information + information for the current open tab if required. QString str = ""; QString Response = GetMarketSummary(); @@ -293,7 +293,7 @@ int tradingDialogPage::SetExchangeInfoTextLabels(){ return 0; } -void tradingDialogPage::CreateOrderBookTables(QTableWidget& Table,QStringList TableHeader){ +void TradingDialogPage::CreateOrderBookTables(QTableWidget& Table,QStringList TableHeader){ Table.setColumnCount(4); Table.verticalHeader()->setVisible(false); @@ -314,7 +314,7 @@ void tradingDialogPage::CreateOrderBookTables(QTableWidget& Table,QStringList Ta Table.horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * { font-weight :bold;}"); } -void tradingDialogPage::DisplayBalance(QLabel &BalanceLabel,QLabel &Available, QLabel &Pending, QString Currency,QString Response){ +void TradingDialogPage::DisplayBalance(QLabel &BalanceLabel,QLabel &Available, QLabel &Pending, QString Currency,QString Response){ QString str; @@ -330,7 +330,7 @@ void tradingDialogPage::DisplayBalance(QLabel &BalanceLabel,QLabel &Available, Q Pending.setText("" + str.number( ResultObject["Pending"].toDouble(),'i',8) + " " +Currency); } -void tradingDialogPage::DisplayBalance(QLabel &BalanceLabel, QString Response){ +void TradingDialogPage::DisplayBalance(QLabel &BalanceLabel, QString Response){ QString str; @@ -340,7 +340,7 @@ void tradingDialogPage::DisplayBalance(QLabel &BalanceLabel, QString Response){ BalanceLabel.setText("" + str.number(ResultObject["Available"].toDouble(),'i',8) + ""); } -void tradingDialogPage::DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabel2, QString Response, QString Response2){ +void TradingDialogPage::DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabel2, QString Response, QString Response2){ QString str; QString str2; @@ -353,7 +353,7 @@ void tradingDialogPage::DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabe BalanceLabel2.setText("" + str2.number(ResultObject2["Available"].toDouble(),'i',8) + ""); } -void tradingDialogPage::ParseAndPopulateOpenOrdersTable(QString Response){ +void TradingDialogPage::ParseAndPopulateOpenOrdersTable(QString Response){ int itteration = 0, RowCount = 0; @@ -392,7 +392,7 @@ void tradingDialogPage::ParseAndPopulateOpenOrdersTable(QString Response){ } -void tradingDialogPage::CancelOrderSlot(int row, int col){ +void TradingDialogPage::CancelOrderSlot(int row, int col){ QString OrderId = ui->OpenOrdersTable->model()->data(ui->OpenOrdersTable->model()->index(row,0)).toString(); QMessageBox::StandardButton reply; @@ -418,7 +418,7 @@ void tradingDialogPage::CancelOrderSlot(int row, int col){ } } -void tradingDialogPage::ParseAndPopulateAccountHistoryTable(QString Response){ +void TradingDialogPage::ParseAndPopulateAccountHistoryTable(QString Response){ int itteration = 0, RowCount = 0; @@ -451,7 +451,7 @@ void tradingDialogPage::ParseAndPopulateAccountHistoryTable(QString Response){ } -void tradingDialogPage::ParseAndPopulateOrderBookTables(QString OrderBook){ +void TradingDialogPage::ParseAndPopulateOrderBookTables(QString OrderBook){ QString str; QJsonObject obj; @@ -522,7 +522,7 @@ void tradingDialogPage::ParseAndPopulateOrderBookTables(QString OrderBook){ } -void tradingDialogPage::ParseAndPopulateMarketHistoryTable(QString Response){ +void TradingDialogPage::ParseAndPopulateMarketHistoryTable(QString Response){ int itteration = 0, RowCount = 0; QJsonArray jsonArray = GetResultArrayFromJSONObject(Response); @@ -549,7 +549,7 @@ void tradingDialogPage::ParseAndPopulateMarketHistoryTable(QString Response){ obj.empty(); } -void tradingDialogPage::ActionsOnSwitch(int index = -1){ +void TradingDialogPage::ActionsOnSwitch(int index = -1){ QString Response = ""; QString Response2 = ""; @@ -626,7 +626,7 @@ void tradingDialogPage::ActionsOnSwitch(int index = -1){ } -void tradingDialogPage::on_TradingTabWidget_tabBarClicked(int index) +void TradingDialogPage::on_TradingTabWidget_tabBarClicked(int index) { //tab was clicked, interrupt the timer and restart after action completed. @@ -638,7 +638,7 @@ void tradingDialogPage::on_TradingTabWidget_tabBarClicked(int index) } -QString tradingDialogPage::sendRequest(QString url){ +QString TradingDialogPage::sendRequest(QString url){ QString Response = ""; QString Secret = this->SecretKey; @@ -677,7 +677,7 @@ QString tradingDialogPage::sendRequest(QString url){ return Response; } -QString tradingDialogPage::BittrexTimeStampToReadable(QString DateTime){ +QString TradingDialogPage::BittrexTimeStampToReadable(QString DateTime){ //Seperate Time and date. int TPos = DateTime.indexOf("T"); int sPos = DateTime.indexOf("."); @@ -692,7 +692,7 @@ QString tradingDialogPage::BittrexTimeStampToReadable(QString DateTime){ return DisplayDate; } -void tradingDialogPage::CalculateBuyCostLabel(){ +void TradingDialogPage::CalculateBuyCostLabel(){ double price = ui->BuyBidPriceEdit->text().toDouble(); double Quantity = ui->UnitsInput->text().toDouble(); @@ -702,7 +702,7 @@ void tradingDialogPage::CalculateBuyCostLabel(){ ui->BuyCostLabel->setText("" + Str.number(cost,'i',8) + ""); } -void tradingDialogPage::CalculateSellCostLabel(){ +void TradingDialogPage::CalculateSellCostLabel(){ double price = ui->SellBidPriceEdit->text().toDouble(); double Quantity = ui->UnitsInputTX->text().toDouble(); @@ -712,7 +712,7 @@ void tradingDialogPage::CalculateSellCostLabel(){ ui->SellCostLabel->setText("" + Str.number(cost,'i',8) + ""); } -void tradingDialogPage::CalculateCSReceiveLabel(){ +void TradingDialogPage::CalculateCSReceiveLabel(){ //calculate amount of currency than can be exclusivecoinred to bitcoin QString balance = GetBalance("EXCL"); @@ -770,7 +770,7 @@ void tradingDialogPage::CalculateCSReceiveLabel(){ } } -void tradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) +void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) { this->ApiKey = ui->ApiKeyInput->text(); this->SecretKey = ui->SecretKeyInput->text(); @@ -815,7 +815,7 @@ void tradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) } -string tradingDialogPage::encryptDecrypt(string toEncrypt, string password) { +string TradingDialogPage::encryptDecrypt(string toEncrypt, string password) { char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); @@ -828,7 +828,7 @@ string tradingDialogPage::encryptDecrypt(string toEncrypt, string password) { return output; } -void tradingDialogPage::on_SaveKeys_clicked() +void TradingDialogPage::on_SaveKeys_clicked() { bool fSuccess = true; boost::filesystem::path pathConfigFile = GetDataDir() / "APIcache.txt"; @@ -865,7 +865,7 @@ void tradingDialogPage::on_SaveKeys_clicked() } -void tradingDialogPage::on_LoadKeys_clicked() +void TradingDialogPage::on_LoadKeys_clicked() { bool fSuccess = true; boost::filesystem::path pathConfigFile = GetDataDir() / "APIcache.txt"; @@ -907,14 +907,14 @@ void tradingDialogPage::on_LoadKeys_clicked() } -void tradingDialogPage::on_GenDepositBTN_clicked() +void TradingDialogPage::on_GenDepositBTN_clicked() { QString response = GetDepositAddress(); QJsonObject ResultObject = GetResultObjectFromJSONObject(response); ui->DepositAddressLabel->setText(ResultObject["Address"].toString()); } -void tradingDialogPage::on_Sell_Max_Amount_clicked() +void TradingDialogPage::on_Sell_Max_Amount_clicked() { //calculate amount of BTC that can be gained from selling EXCL available balance QString responseA = GetBalance("EXCL"); @@ -926,7 +926,7 @@ void tradingDialogPage::on_Sell_Max_Amount_clicked() ui->UnitsInputTX->setText(str.number(AvailableTX,'i',8)); } -void tradingDialogPage::on_Buy_Max_Amount_clicked() +void TradingDialogPage::on_Buy_Max_Amount_clicked() { //calculate amount of currency than can be brought with the BTC balance available QString responseA = GetBalance("BTC"); @@ -948,7 +948,7 @@ void tradingDialogPage::on_Buy_Max_Amount_clicked() ui->UnitsInput->setText(str.number(Result,'i',8)); } -void tradingDialogPage::on_CS_Max_Amount_clicked() +void TradingDialogPage::on_CS_Max_Amount_clicked() { double Quantity = ui->BittrexTXLabel->text().toDouble(); double Received = 0; @@ -992,7 +992,7 @@ void tradingDialogPage::on_CS_Max_Amount_clicked() ui->CSUnitsInput->setText(str.number(Received,'i',8)); } -void tradingDialogPage::on_Withdraw_Max_Amount_clicked() +void TradingDialogPage::on_Withdraw_Max_Amount_clicked() { //calculate amount of currency than can be brought with the BTC balance available QString responseA = GetBalance("EXCL"); @@ -1005,7 +1005,7 @@ void tradingDialogPage::on_Withdraw_Max_Amount_clicked() ui->WithdrawUnitsInput->setText(str.number(AvailableTX,'i',8)); } -QJsonObject tradingDialogPage::GetResultObjectFromJSONObject(QString response){ +QJsonObject TradingDialogPage::GetResultObjectFromJSONObject(QString response){ QJsonDocument jsonResponse = QJsonDocument::fromJson(response.toUtf8()); //get json from str. QJsonObject ResponseObject = jsonResponse.object(); //get json obj @@ -1014,7 +1014,7 @@ QJsonObject tradingDialogPage::GetResultObjectFromJSONObject(QString response){ return ResultObject; } -QJsonObject tradingDialogPage::GetResultObjectFromJSONArray(QString response){ +QJsonObject TradingDialogPage::GetResultObjectFromJSONArray(QString response){ QJsonDocument jsonResponsea = QJsonDocument::fromJson(response.toUtf8()); QJsonObject jsonObjecta = jsonResponsea.object(); @@ -1029,7 +1029,7 @@ QJsonObject tradingDialogPage::GetResultObjectFromJSONArray(QString response){ return obj; } -QJsonArray tradingDialogPage::GetResultArrayFromJSONObject(QString response){ +QJsonArray TradingDialogPage::GetResultArrayFromJSONObject(QString response){ QJsonDocument jsonResponse = QJsonDocument::fromJson(response.toUtf8()); QJsonObject jsonObject = jsonResponse.object(); @@ -1038,7 +1038,7 @@ QJsonArray tradingDialogPage::GetResultArrayFromJSONObject(QString response){ return jsonArray; } -QString tradingDialogPage::HMAC_SHA512_SIGNER(QString UrlToSign, QString Secret){ +QString TradingDialogPage::HMAC_SHA512_SIGNER(QString UrlToSign, QString Secret){ QString retval = ""; @@ -1067,7 +1067,7 @@ QString tradingDialogPage::HMAC_SHA512_SIGNER(QString UrlToSign, QString Secret) return retval; } -void tradingDialogPage::on_SellBidcomboBox_currentIndexChanged(const QString &arg1) +void TradingDialogPage::on_SellBidcomboBox_currentIndexChanged(const QString &arg1) { QString response = GetMarketSummary(); QJsonObject ResultObject = GetResultObjectFromJSONArray(response); @@ -1079,7 +1079,7 @@ void tradingDialogPage::on_SellBidcomboBox_currentIndexChanged(const QString &ar CalculateSellCostLabel(); //update cost } -void tradingDialogPage::on_BuyBidcomboBox_currentIndexChanged(const QString &arg1) +void TradingDialogPage::on_BuyBidcomboBox_currentIndexChanged(const QString &arg1) { QString response = GetMarketSummary(); QJsonObject ResultObject = GetResultObjectFromJSONArray(response); @@ -1091,7 +1091,7 @@ void tradingDialogPage::on_BuyBidcomboBox_currentIndexChanged(const QString &arg CalculateBuyCostLabel(); //update cost } -void tradingDialogPage::on_BuyTX_clicked() +void TradingDialogPage::on_BuyTX_clicked() { double Rate; double Quantity; @@ -1131,7 +1131,7 @@ void tradingDialogPage::on_BuyTX_clicked() } } -void tradingDialogPage::on_SellTXBTN_clicked() +void TradingDialogPage::on_SellTXBTN_clicked() { double Rate; double Quantity; @@ -1170,7 +1170,7 @@ void tradingDialogPage::on_SellTXBTN_clicked() } } -void tradingDialogPage::on_CSUnitsBtn_clicked() +void TradingDialogPage::on_CSUnitsBtn_clicked() { double Quantity = ui->CSUnitsInput->text().toDouble(); double Rate = ui->CSDumpLabel->text().toDouble(); @@ -1283,7 +1283,7 @@ void tradingDialogPage::on_CSUnitsBtn_clicked() } } -void tradingDialogPage::on_WithdrawUnitsBtn_clicked() +void TradingDialogPage::on_WithdrawUnitsBtn_clicked() { double Quantity = ui->WithdrawUnitsInput->text().toDouble(); QString Qstr; @@ -1321,50 +1321,50 @@ void tradingDialogPage::on_WithdrawUnitsBtn_clicked() } } -void tradingDialogPage::on_UnitsInputTX_textChanged(const QString &arg1) +void TradingDialogPage::on_UnitsInputTX_textChanged(const QString &arg1) { CalculateSellCostLabel(); //update cost } -void tradingDialogPage::on_UnitsInput_textChanged(const QString &arg1) +void TradingDialogPage::on_UnitsInput_textChanged(const QString &arg1) { CalculateBuyCostLabel(); //update cost } -void tradingDialogPage::on_BuyBidPriceEdit_textChanged(const QString &arg1) +void TradingDialogPage::on_BuyBidPriceEdit_textChanged(const QString &arg1) { CalculateBuyCostLabel(); //update cost } -void tradingDialogPage::on_SellBidPriceEdit_textChanged(const QString &arg1) +void TradingDialogPage::on_SellBidPriceEdit_textChanged(const QString &arg1) { CalculateSellCostLabel(); } -void tradingDialogPage::on_CSUnitsInput_textChanged(const QString &arg1) +void TradingDialogPage::on_CSUnitsInput_textChanged(const QString &arg1) { CalculateCSReceiveLabel(); //update cost } -void tradingDialogPage::on_CSPasteButton_clicked() +void TradingDialogPage::on_CSPasteButton_clicked() { // Paste text from clipboard into recipient field ui->CSUnitsAddress->setText(QApplication::clipboard()->text()); } -void tradingDialogPage::on_WithdrawPasteButton_clicked() +void TradingDialogPage::on_WithdrawPasteButton_clicked() { // Paste text from clipboard into recipient field ui->WithdrawAddress->setText(QApplication::clipboard()->text()); } -void tradingDialogPage::on_SecretPasteButton_clicked() +void TradingDialogPage::on_SecretPasteButton_clicked() { // Paste text from clipboard into recipient field ui->SecretKeyInput->setText(QApplication::clipboard()->text()); } -void tradingDialogPage::on_KeyPasteButton_clicked() +void TradingDialogPage::on_KeyPasteButton_clicked() { // Paste text from clipboard into recipient field ui->ApiKeyInput->setText(QApplication::clipboard()->text()); @@ -1376,17 +1376,17 @@ void setClipboard(const QString& str) QApplication::clipboard()->setText(str, QClipboard::Selection); } -void tradingDialogPage::on_DepositCopyButton_clicked() +void TradingDialogPage::on_DepositCopyButton_clicked() { setClipboard(ui->DepositAddressLabel->text()); } -void tradingDialogPage::setModel(WalletModel *model) +void TradingDialogPage::setModel(WalletModel *model) { this->model = model; } -tradingDialogPage::~tradingDialogPage() +TradingDialogPage::~TradingDialogPage() { delete ui; } From 129e276bd0e40215ef83770d5b26980e65fb5519 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:50:30 -0400 Subject: [PATCH 347/469] Update tradingdialogpage.h --- src/qt/tradingdialogpage.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qt/tradingdialogpage.h b/src/qt/tradingdialogpage.h index eb4ba5d6..d31d432b 100644 --- a/src/qt/tradingdialogpage.h +++ b/src/qt/tradingdialogpage.h @@ -25,8 +25,8 @@ class TradingDialogPage : public QDialog Q_OBJECT public: - explicit tradingDialogPage(QWidget *parent = 0); - ~tradingDialogPage(); + explicit TradingDialogPage(QWidget *parent = 0); + ~TradingDialogPage(); void setModel(WalletModel *model); @@ -103,7 +103,7 @@ public Q_SLOTS: private: - Ui::tradingDialogPage *ui; + Ui::TradingDialogPage *ui; //Socket *socket; int timerid; QTimer *timer; From a1c2214008723d954130018ae1ae8514d841962f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 22:57:18 -0400 Subject: [PATCH 348/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index de652dcd..b605faa8 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -30,7 +30,7 @@ using namespace std; TradingDialogPage::TradingDialogPage(QWidget *parent) : QDialog(parent), - ui(new Ui::tradingDialogPage), + ui(new Ui::TradingDialogPage), model(0) { ui->setupUi(this); From 6af0b3216f5063299e76be31ff01babee983652b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:01:43 -0400 Subject: [PATCH 349/469] Update tradingdialogpage.h --- src/qt/tradingdialogpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.h b/src/qt/tradingdialogpage.h index d31d432b..837f4db5 100644 --- a/src/qt/tradingdialogpage.h +++ b/src/qt/tradingdialogpage.h @@ -16,7 +16,7 @@ #include namespace Ui { -class TradingDialogPage; +class tradingDialogPage; } class WalletModel; From 49154a401d17245c117adc7e3242b512f8842d18 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:02:00 -0400 Subject: [PATCH 350/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index b605faa8..de652dcd 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -30,7 +30,7 @@ using namespace std; TradingDialogPage::TradingDialogPage(QWidget *parent) : QDialog(parent), - ui(new Ui::TradingDialogPage), + ui(new Ui::tradingDialogPage), model(0) { ui->setupUi(this); From b2352d51b133c945b9442658a73daf02daf5ccca Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:12:40 -0400 Subject: [PATCH 351/469] Update tradingdialogpage.ui --- src/qt/forms/tradingdialogpage.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/forms/tradingdialogpage.ui b/src/qt/forms/tradingdialogpage.ui index 70008836..bfbece85 100644 --- a/src/qt/forms/tradingdialogpage.ui +++ b/src/qt/forms/tradingdialogpage.ui @@ -1,7 +1,7 @@ - tradingDialogPage - + TradingDialogPage + 0 From 02e1366791b11f43d77bb381e14feef807753ad9 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:15:20 -0400 Subject: [PATCH 352/469] Update walletview.cpp --- src/qt/walletview.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 48d12522..6cce2e8a 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -93,8 +93,8 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): governanceListPage = new GovernanceList(platformStyle); addWidget(governanceListPage); - tradingDialogPage = new tradingDialogPage(platformStyle); - addWidget(tradingDialogPage) + TradingDialogPage = new TradingDialogPage(platformStyle); + addWidget(TradingDialogPage) // Clicking on a transaction on the overview pre-selects the transaction on the transaction history page connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex))); @@ -161,7 +161,7 @@ void WalletView::setClientModel(ClientModel *_clientModel) masternodeListPage->setClientModel(_clientModel); } governanceListPage->setClientModel(_clientModel); - tradingDialogPage->setClientModel(_clientModel); + TradingDialogPage->setClientModel(_clientModel); } void WalletView::setWalletModel(WalletModel *_walletModel) @@ -176,7 +176,7 @@ void WalletView::setWalletModel(WalletModel *_walletModel) if (!fLiteMode && settings.value("fShowMasternodesTab").toBool()) { masternodeListPage->setWalletModel(_walletModel); } - tradingDialogPage->setWalletModel(_walletModel); + TradingDialogPage->setWalletModel(_walletModel); governanceListPage->setWalletModel(_walletModel); receiveCoinsPage->setModel(_walletModel); sendCoinsPage->setModel(_walletModel); @@ -240,7 +240,7 @@ void WalletView::processNewTransaction(const QModelIndex& parent, int start, int void WalletView::gotoTradingDialogPage() { QSettings settings; - setCurrentWidget(tradingDialogPage); + setCurrentWidget(TradingDialogPage); } void WalletView::gotoGovernancePage() From b843ba846c0bfc66633a21f68c48242364578511 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:15:44 -0400 Subject: [PATCH 353/469] Update walletview.h --- src/qt/walletview.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/walletview.h b/src/qt/walletview.h index 4c7c44bb..732586d4 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -76,7 +76,7 @@ class WalletView : public QStackedWidget PrivateSendPage *privateSendPage; GovernanceList *governanceListPage; TransactionView *transactionView; - TradingDialogPage *tradingDialogPage; + TradingDialogPage *TradingDialogPage; QProgressDialog *progressDialog; QLabel *transactionSum; From 02dfe5243a07ba51cd9f9524529f38a4764aa53b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:17:36 -0400 Subject: [PATCH 354/469] Update walletview.cpp --- src/qt/walletview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 6cce2e8a..5e1ff216 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -94,7 +94,7 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): addWidget(governanceListPage); TradingDialogPage = new TradingDialogPage(platformStyle); - addWidget(TradingDialogPage) + addWidget(TradingDialogPage); // Clicking on a transaction on the overview pre-selects the transaction on the transaction history page connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex))); From 0b55a92a6ec33ae8f8a65124e142feee2be3950d Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:20:00 -0400 Subject: [PATCH 355/469] Update walletview.cpp --- src/qt/walletview.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 5e1ff216..535ad24c 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -93,7 +93,7 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): governanceListPage = new GovernanceList(platformStyle); addWidget(governanceListPage); - TradingDialogPage = new TradingDialogPage(platformStyle); + tradingDialogPage = new TradingDialogPage(platformStyle); addWidget(TradingDialogPage); // Clicking on a transaction on the overview pre-selects the transaction on the transaction history page @@ -161,7 +161,7 @@ void WalletView::setClientModel(ClientModel *_clientModel) masternodeListPage->setClientModel(_clientModel); } governanceListPage->setClientModel(_clientModel); - TradingDialogPage->setClientModel(_clientModel); + tradingDialogPage->setClientModel(_clientModel); } void WalletView::setWalletModel(WalletModel *_walletModel) @@ -176,7 +176,7 @@ void WalletView::setWalletModel(WalletModel *_walletModel) if (!fLiteMode && settings.value("fShowMasternodesTab").toBool()) { masternodeListPage->setWalletModel(_walletModel); } - TradingDialogPage->setWalletModel(_walletModel); + tradingDialogPage->setWalletModel(_walletModel); governanceListPage->setWalletModel(_walletModel); receiveCoinsPage->setModel(_walletModel); sendCoinsPage->setModel(_walletModel); @@ -240,7 +240,7 @@ void WalletView::processNewTransaction(const QModelIndex& parent, int start, int void WalletView::gotoTradingDialogPage() { QSettings settings; - setCurrentWidget(TradingDialogPage); + setCurrentWidget(tradingDialogPage); } void WalletView::gotoGovernancePage() From 358ed5a895a75efc8bf5aec63acf3fa0a7d4df08 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:23:19 -0400 Subject: [PATCH 356/469] Update walletview.h --- src/qt/walletview.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/walletview.h b/src/qt/walletview.h index 732586d4..4c7c44bb 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -76,7 +76,7 @@ class WalletView : public QStackedWidget PrivateSendPage *privateSendPage; GovernanceList *governanceListPage; TransactionView *transactionView; - TradingDialogPage *TradingDialogPage; + TradingDialogPage *tradingDialogPage; QProgressDialog *progressDialog; QLabel *transactionSum; From 3c2a9bd6877431e5a078ebc7ef4154e6952224ed Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:24:19 -0400 Subject: [PATCH 357/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index de652dcd..b605faa8 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -30,7 +30,7 @@ using namespace std; TradingDialogPage::TradingDialogPage(QWidget *parent) : QDialog(parent), - ui(new Ui::tradingDialogPage), + ui(new Ui::TradingDialogPage), model(0) { ui->setupUi(this); From f780f478e7e4275145f82abf704d0f28040a14e6 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:24:51 -0400 Subject: [PATCH 358/469] Update tradingdialogpage.h --- src/qt/tradingdialogpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.h b/src/qt/tradingdialogpage.h index 837f4db5..d31d432b 100644 --- a/src/qt/tradingdialogpage.h +++ b/src/qt/tradingdialogpage.h @@ -16,7 +16,7 @@ #include namespace Ui { -class tradingDialogPage; +class TradingDialogPage; } class WalletModel; From 2fb3f346eb736500a74b5f77935c6830350e3a07 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:26:14 -0400 Subject: [PATCH 359/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index b605faa8..2610755c 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -121,7 +121,7 @@ TradingDialogPage::TradingDialogPage(QWidget *parent) : /*Open Orders Table*/ } -void tradingDialogPage::InitTrading() +void TradingDialogPage::InitTrading() { //todo - add internet connection/socket error checking. //Get default exchange info for the qlabels From 811ab986a4cc86e26cd8e61924b50f8ecdf84f83 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:27:50 -0400 Subject: [PATCH 360/469] Update walletview.cpp --- src/qt/walletview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 535ad24c..a263d5bf 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -94,7 +94,7 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): addWidget(governanceListPage); tradingDialogPage = new TradingDialogPage(platformStyle); - addWidget(TradingDialogPage); + addWidget(tradingDialogPage); // Clicking on a transaction on the overview pre-selects the transaction on the transaction history page connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex))); From 7d993498089d565071ed96e5a2fab319d9896de0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:34:01 -0400 Subject: [PATCH 361/469] Update walletview.cpp --- src/qt/walletview.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index a263d5bf..de91851a 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -84,17 +84,18 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): addWidget(receiveCoinsPage); addWidget(sendCoinsPage); addWidget(privateSendPage); + + tradingDialogPage = new TradingDialogPage(platformStyle); + addWidget(tradingDialogPage); QSettings settings; if (!fLiteMode && settings.value("fShowMasternodesTab").toBool()) { masternodeListPage = new MasternodeList(platformStyle); addWidget(masternodeListPage); } - governanceListPage = new GovernanceList(platformStyle); + governanceListPage = new GovernanceList(platformStyle); addWidget(governanceListPage); - tradingDialogPage = new TradingDialogPage(platformStyle); - addWidget(tradingDialogPage); // Clicking on a transaction on the overview pre-selects the transaction on the transaction history page connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex))); @@ -239,8 +240,7 @@ void WalletView::processNewTransaction(const QModelIndex& parent, int start, int void WalletView::gotoTradingDialogPage() { - QSettings settings; - setCurrentWidget(tradingDialogPage); + setCurrentWidget(tradingDialogPage); } void WalletView::gotoGovernancePage() From 2b2c6b580be01ee8948c38e5b5c60aec37394909 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:36:24 -0400 Subject: [PATCH 362/469] Update walletview.cpp --- src/qt/walletview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index de91851a..e3e2bb74 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -85,7 +85,7 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): addWidget(sendCoinsPage); addWidget(privateSendPage); - tradingDialogPage = new TradingDialogPage(platformStyle); + tradingDialogPage = new TradingDialogPage(); addWidget(tradingDialogPage); QSettings settings; From 57020daad202d114ac7c1bca5fb81fc01f491aa5 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:37:23 -0400 Subject: [PATCH 363/469] Update walletview.cpp --- src/qt/walletview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index e3e2bb74..f4a19b6d 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -162,7 +162,7 @@ void WalletView::setClientModel(ClientModel *_clientModel) masternodeListPage->setClientModel(_clientModel); } governanceListPage->setClientModel(_clientModel); - tradingDialogPage->setClientModel(_clientModel); + } void WalletView::setWalletModel(WalletModel *_walletModel) @@ -177,7 +177,7 @@ void WalletView::setWalletModel(WalletModel *_walletModel) if (!fLiteMode && settings.value("fShowMasternodesTab").toBool()) { masternodeListPage->setWalletModel(_walletModel); } - tradingDialogPage->setWalletModel(_walletModel); + governanceListPage->setWalletModel(_walletModel); receiveCoinsPage->setModel(_walletModel); sendCoinsPage->setModel(_walletModel); From 99ed0f70ff48eb45e0f7dc28313de04c279f0baf Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:39:37 -0400 Subject: [PATCH 364/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 2610755c..7bc45bad 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -815,7 +815,7 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) } -string TradingDialogPage::encryptDecrypt(string toEncrypt, string password) { +int TradingDialogPage::encryptDecrypt(string toEncrypt, string password) { char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); From 445054a885904f3babe5f20d9154f52185bfd737 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:40:49 -0400 Subject: [PATCH 365/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 7bc45bad..810f21f6 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -815,7 +815,7 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) } -int TradingDialogPage::encryptDecrypt(string toEncrypt, string password) { +QString TradingDialogPage::encryptDecrypt(string toEncrypt, string password) { char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); From ce3de51fa26fefacf2c45b0d4c5944f3db50e026 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:43:37 -0400 Subject: [PATCH 366/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 810f21f6..39e8b02e 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -815,7 +815,7 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) } -QString TradingDialogPage::encryptDecrypt(string toEncrypt, string password) { +QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); From fff4d5cf5e5c4e19aa5a854c33fb9e5020b8a521 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:51:06 -0400 Subject: [PATCH 367/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 39e8b02e..af800e10 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -821,7 +822,7 @@ QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { std::strcpy (key, password.c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 - string output = toEncrypt; + QString output = toEncrypt; for (unsigned int i = 0; i < toEncrypt.size(); i++) output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; @@ -835,7 +836,7 @@ void TradingDialogPage::on_SaveKeys_clicked() boost::filesystem::ofstream stream (pathConfigFile.string(), ios::out | ios::trunc); // Qstring to string - string password = ui->PasswordInput->text().toUtf8().constData(); + QString password = ui->PasswordInput->text().toUtf8().constData(); if (password.length() <= 6){ QMessageBox::information(this,"Error !","Your password is too short !"); From 4185c85dbe8ee4edd1d5c19dd26ff568d465eb6f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:55:56 -0400 Subject: [PATCH 368/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index af800e10..ec257390 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -816,7 +816,7 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) } -QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { +string TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); From 3fd38adab339263e1739064d1e1d49da65c5ca60 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:56:16 -0400 Subject: [PATCH 369/469] Update tradingdialogpage.h --- src/qt/tradingdialogpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.h b/src/qt/tradingdialogpage.h index d31d432b..cf855bef 100644 --- a/src/qt/tradingdialogpage.h +++ b/src/qt/tradingdialogpage.h @@ -94,7 +94,7 @@ private Q_SLOTS: QString GetDepositAddress(); QString HMAC_SHA512_SIGNER(QString UrlToSign,QString Secretkey); QString sendRequest(QString url); - QString encryptDecrypt(QString toEncrypt, QString password); + string encryptDecrypt(QString toEncrypt, QString password); QJsonObject GetResultObjectFromJSONObject(QString response); QJsonObject GetResultObjectFromJSONArray(QString response); QJsonArray GetResultArrayFromJSONObject(QString response); From 0412a508821cd5c50f34c7ea5dcbae4a55448196 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:58:31 -0400 Subject: [PATCH 370/469] Update tradingdialogpage.h --- src/qt/tradingdialogpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.h b/src/qt/tradingdialogpage.h index cf855bef..d31d432b 100644 --- a/src/qt/tradingdialogpage.h +++ b/src/qt/tradingdialogpage.h @@ -94,7 +94,7 @@ private Q_SLOTS: QString GetDepositAddress(); QString HMAC_SHA512_SIGNER(QString UrlToSign,QString Secretkey); QString sendRequest(QString url); - string encryptDecrypt(QString toEncrypt, QString password); + QString encryptDecrypt(QString toEncrypt, QString password); QJsonObject GetResultObjectFromJSONObject(QString response); QJsonObject GetResultObjectFromJSONArray(QString response); QJsonArray GetResultArrayFromJSONObject(QString response); From 23f81896ff5a947f305ca510f76be13731b3f6de Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Tue, 2 Jun 2020 23:59:44 -0400 Subject: [PATCH 371/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index ec257390..af800e10 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -816,7 +816,7 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) } -string TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { +QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); From 4982662cf4764552e62c8e4cbae3c31882341749 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 00:04:29 -0400 Subject: [PATCH 372/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index af800e10..5c910743 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -69,7 +69,7 @@ TradingDialogPage::TradingDialogPage(QWidget *parent) : ui->MarketHistoryTable->setHorizontalHeaderLabels(QStringList()<<"DATE"<<"BUY/SELL"<<"BID/ASK"<<"TOTAL UNITS(EXCL)"<<"TOTAL COST(BTC)"); ui->MarketHistoryTable->setRowCount(0); int Cellwidth = ui->MarketHistoryTable->width() / 5; - ui->MarketHistoryTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + ui->MarketHistoryTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); ui->MarketHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); ui->MarketHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); ui->MarketHistoryTable->horizontalHeader()->resizeSection(3,Cellwidth); @@ -85,7 +85,7 @@ TradingDialogPage::TradingDialogPage(QWidget *parent) : ui->TradeHistoryTable->setHorizontalHeaderLabels(QStringList() << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "Closed"); ui->TradeHistoryTable->setRowCount(0); Cellwidth = ui->TradeHistoryTable->width() / 9; - ui->TradeHistoryTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + ui->TradeHistoryTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); ui->TradeHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); ui->TradeHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); ui->TradeHistoryTable->horizontalHeader()->resizeSection(3,Cellwidth); @@ -105,7 +105,7 @@ TradingDialogPage::TradingDialogPage(QWidget *parent) : ui->OpenOrdersTable->setHorizontalHeaderLabels(QStringList() << "OrderId" << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "Cancel Order"); ui->OpenOrdersTable->setRowCount(0); Cellwidth = ui->TradeHistoryTable->width() / 9; - ui->OpenOrdersTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + ui->OpenOrdersTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); ui->OpenOrdersTable->horizontalHeader()->resizeSection(2,Cellwidth); ui->OpenOrdersTable->horizontalHeader()->resizeSection(3,Cellwidth); ui->OpenOrdersTable->horizontalHeader()->resizeSection(4,Cellwidth); @@ -310,7 +310,7 @@ void TradingDialogPage::CreateOrderBookTables(QTableWidget& Table,QStringList Ta Table.setRowCount(0); - Table.horizontalHeader()->setResizeMode(QHeaderView::Stretch); + Table.horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); Table.horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); Table.horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * { font-weight :bold;}"); } From b8390be90309d11200d7f3205fb9235819f010cc Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 00:06:29 -0400 Subject: [PATCH 373/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 5c910743..3f85dd1b 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -845,10 +845,10 @@ void TradingDialogPage::on_SaveKeys_clicked() } // qstrings to utf8, add to byteArray and convert to const char for stream - string Secret = ui->SecretKeyInput->text().toUtf8().constData(); - string Key = ui->ApiKeyInput->text().toUtf8().constData(); - string ESecret = ""; - string EKey = ""; + QString Secret = ui->SecretKeyInput->text().toUtf8().constData(); + QString Key = ui->ApiKeyInput->text().toUtf8().constData(); + QString ESecret = ""; + QString EKey = ""; if (stream.is_open() && fSuccess) { From c031706aa934693bce74913d3dbb3c353ad6ec77 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 00:07:49 -0400 Subject: [PATCH 374/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 3f85dd1b..7897bec4 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -836,7 +836,7 @@ void TradingDialogPage::on_SaveKeys_clicked() boost::filesystem::ofstream stream (pathConfigFile.string(), ios::out | ios::trunc); // Qstring to string - QString password = ui->PasswordInput->text().toUtf8().constData(); + string password = ui->PasswordInput->text().toUtf8().constData(); if (password.length() <= 6){ QMessageBox::information(this,"Error !","Your password is too short !"); @@ -845,10 +845,10 @@ void TradingDialogPage::on_SaveKeys_clicked() } // qstrings to utf8, add to byteArray and convert to const char for stream - QString Secret = ui->SecretKeyInput->text().toUtf8().constData(); - QString Key = ui->ApiKeyInput->text().toUtf8().constData(); - QString ESecret = ""; - QString EKey = ""; + string Secret = ui->SecretKeyInput->text().toUtf8().constData(); + string Key = ui->ApiKeyInput->text().toUtf8().constData(); + string ESecret = ""; + string EKey = ""; if (stream.is_open() && fSuccess) { From 0509eaeda33e8030532027369ce2e2d31fe8705a Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 00:20:36 -0400 Subject: [PATCH 375/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 7897bec4..ebcb1ac3 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -818,14 +818,14 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { - char * key = new char [password.size()+1]; + QChar * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 QString output = toEncrypt; for (unsigned int i = 0; i < toEncrypt.size(); i++) - output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; + output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(QChar))]; return output; } From 77b61158b454d29014bf053489367df8c32dd81e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 00:22:26 -0400 Subject: [PATCH 376/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index ebcb1ac3..7897bec4 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -818,14 +818,14 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { - QChar * key = new char [password.size()+1]; + char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 QString output = toEncrypt; for (unsigned int i = 0; i < toEncrypt.size(); i++) - output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(QChar))]; + output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; return output; } From 66419e85329576296a8236c91d9cedf3ad0e5f4c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 00:55:28 -0400 Subject: [PATCH 377/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 7897bec4..2ce6c09b 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -816,13 +816,13 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) } -QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { +string TradingDialogPage::encryptDecrypt(string toEncrypt, string password) { char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 - QString output = toEncrypt; + string output = toEncrypt; for (unsigned int i = 0; i < toEncrypt.size(); i++) output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; @@ -865,7 +865,6 @@ void TradingDialogPage::on_SaveKeys_clicked() } - void TradingDialogPage::on_LoadKeys_clicked() { bool fSuccess = true; @@ -873,7 +872,7 @@ void TradingDialogPage::on_LoadKeys_clicked() boost::filesystem::ifstream stream (pathConfigFile.string()); // Qstring to string - QString password = ui->PasswordInput->text().toUtf8().constData(); + string password = ui->PasswordInput->text().toUtf8().constData(); if (password.length() <= 6){ QMessageBox::information(this,"Error !","Your password is too short !"); @@ -917,14 +916,14 @@ void TradingDialogPage::on_GenDepositBTN_clicked() void TradingDialogPage::on_Sell_Max_Amount_clicked() { - //calculate amount of BTC that can be gained from selling EXCL available balance - QString responseA = GetBalance("EXCL"); + //calculate amount of BTC that can be gained from selling IC available balance + QString responseA = GetBalance("KONJ"); QString str; QJsonObject ResultObject = GetResultObjectFromJSONObject(responseA); - double AvailableTX = ResultObject["Available"].toDouble(); + double AvailableHM = ResultObject["Available"].toDouble(); - ui->UnitsInputTX->setText(str.number(AvailableTX,'i',8)); + ui->UnitsInputHM->setText(str.number(AvailableHM,'i',8)); } void TradingDialogPage::on_Buy_Max_Amount_clicked() @@ -951,7 +950,7 @@ void TradingDialogPage::on_Buy_Max_Amount_clicked() void TradingDialogPage::on_CS_Max_Amount_clicked() { - double Quantity = ui->BittrexTXLabel->text().toDouble(); + double Quantity = ui->BittrexHMLabel->text().toDouble(); double Received = 0; double Qty = 0; double Price = 0; @@ -963,7 +962,7 @@ void TradingDialogPage::on_CS_Max_Amount_clicked() QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object // For each buy order - Q_FOREACH (const QJsonValue & value, BuyArray) + foreach (const QJsonValue & value, BuyArray) { obj = value.toObject(); From 9862a5f0d65ecd144a75ba116866a3270efb2143 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 00:57:07 -0400 Subject: [PATCH 378/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 2ce6c09b..a1fe043a 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -962,7 +962,7 @@ void TradingDialogPage::on_CS_Max_Amount_clicked() QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object // For each buy order - foreach (const QJsonValue & value, BuyArray) + Q_FOREACH (const QJsonValue & value, BuyArray) { obj = value.toObject(); From 04a9d295aa7085a16704beb099e8d20ec97eb923 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 00:59:04 -0400 Subject: [PATCH 379/469] Update tradingdialogpage.h --- src/qt/tradingdialogpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.h b/src/qt/tradingdialogpage.h index d31d432b..c7a9d17b 100644 --- a/src/qt/tradingdialogpage.h +++ b/src/qt/tradingdialogpage.h @@ -94,7 +94,7 @@ private Q_SLOTS: QString GetDepositAddress(); QString HMAC_SHA512_SIGNER(QString UrlToSign,QString Secretkey); QString sendRequest(QString url); - QString encryptDecrypt(QString toEncrypt, QString password); + string encryptDecrypt(string toEncrypt, string password); QJsonObject GetResultObjectFromJSONObject(QString response); QJsonObject GetResultObjectFromJSONArray(QString response); QJsonArray GetResultArrayFromJSONObject(QString response); From 8cda4185c522dcbb8d1c00f26d4e8460c2f26b3e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:06:47 -0400 Subject: [PATCH 380/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index a1fe043a..c716b1bc 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -950,7 +950,7 @@ void TradingDialogPage::on_Buy_Max_Amount_clicked() void TradingDialogPage::on_CS_Max_Amount_clicked() { - double Quantity = ui->BittrexHMLabel->text().toDouble(); + double Quantity = ui->BittrexTXLabel->text().toDouble(); double Received = 0; double Qty = 0; double Price = 0; From 0a4ea1313d902d7f9ff79e1e0f5d40d5e9ffa976 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:09:25 -0400 Subject: [PATCH 381/469] Update tradingdialogpage.h --- src/qt/tradingdialogpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.h b/src/qt/tradingdialogpage.h index c7a9d17b..0cd9b7a4 100644 --- a/src/qt/tradingdialogpage.h +++ b/src/qt/tradingdialogpage.h @@ -94,7 +94,7 @@ private Q_SLOTS: QString GetDepositAddress(); QString HMAC_SHA512_SIGNER(QString UrlToSign,QString Secretkey); QString sendRequest(QString url); - string encryptDecrypt(string toEncrypt, string password); + QString encryptDecrypt(string toEncrypt, string password); QJsonObject GetResultObjectFromJSONObject(QString response); QJsonObject GetResultObjectFromJSONArray(QString response); QJsonArray GetResultArrayFromJSONObject(QString response); From fd90ddc0f94f25be48d70933cac93cd679cc83da Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:09:58 -0400 Subject: [PATCH 382/469] Update tradingdialogpage.h --- src/qt/tradingdialogpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.h b/src/qt/tradingdialogpage.h index 0cd9b7a4..d31d432b 100644 --- a/src/qt/tradingdialogpage.h +++ b/src/qt/tradingdialogpage.h @@ -94,7 +94,7 @@ private Q_SLOTS: QString GetDepositAddress(); QString HMAC_SHA512_SIGNER(QString UrlToSign,QString Secretkey); QString sendRequest(QString url); - QString encryptDecrypt(string toEncrypt, string password); + QString encryptDecrypt(QString toEncrypt, QString password); QJsonObject GetResultObjectFromJSONObject(QString response); QJsonObject GetResultObjectFromJSONArray(QString response); QJsonArray GetResultArrayFromJSONObject(QString response); From 98fb71de0b3f9b630cf66f61d8d6ab3d62e20094 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:11:42 -0400 Subject: [PATCH 383/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index c716b1bc..926cda0d 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -921,9 +921,9 @@ void TradingDialogPage::on_Sell_Max_Amount_clicked() QString str; QJsonObject ResultObject = GetResultObjectFromJSONObject(responseA); - double AvailableHM = ResultObject["Available"].toDouble(); + double AvailableTX = ResultObject["Available"].toDouble(); - ui->UnitsInputHM->setText(str.number(AvailableHM,'i',8)); + ui->UnitsInputTX->setText(str.number(AvailableTX,'i',8)); } void TradingDialogPage::on_Buy_Max_Amount_clicked() From af59754078f3721a27f01e99d11ca7b044959833 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:13:45 -0400 Subject: [PATCH 384/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 926cda0d..88889157 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -816,7 +816,7 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) } -string TradingDialogPage::encryptDecrypt(string toEncrypt, string password) { +QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); From b9c3b67e25f463a4eeb3fed3b7c89e23e6852b04 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:16:34 -0400 Subject: [PATCH 385/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 88889157..acceb65d 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -26,6 +26,7 @@ #include #include +#include using namespace std; From ca20b32ec9e601f98039e19afd2832068ff124e8 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:18:53 -0400 Subject: [PATCH 386/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index acceb65d..eea53882 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -820,7 +820,7 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; - std::strcpy (key, password.c_str()); + std::strcpy (key, password->c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 string output = toEncrypt; From 5dc536419c9b2d7941e8cfd1b38117f4899054cf Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:20:17 -0400 Subject: [PATCH 387/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index eea53882..acceb65d 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -820,7 +820,7 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; - std::strcpy (key, password->c_str()); + std::strcpy (key, password.c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 string output = toEncrypt; From 0456ecb3ca7b18246984e97afc42951ac79ff576 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:33:09 -0400 Subject: [PATCH 388/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index acceb65d..a9dd7dd6 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -27,6 +27,7 @@ #include #include #include +#include using namespace std; @@ -817,7 +818,7 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) } -QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { +string TradingDialogPage::encryptDecrypt(string toEncrypt, string password) { char * key = new char [password.size()+1]; std::strcpy (key, password.c_str()); From 21f0a23b24507c7d70daaf4638c1c2e32f6b4b13 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:34:34 -0400 Subject: [PATCH 389/469] Update tradingdialogpage.h --- src/qt/tradingdialogpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.h b/src/qt/tradingdialogpage.h index d31d432b..c7a9d17b 100644 --- a/src/qt/tradingdialogpage.h +++ b/src/qt/tradingdialogpage.h @@ -94,7 +94,7 @@ private Q_SLOTS: QString GetDepositAddress(); QString HMAC_SHA512_SIGNER(QString UrlToSign,QString Secretkey); QString sendRequest(QString url); - QString encryptDecrypt(QString toEncrypt, QString password); + string encryptDecrypt(string toEncrypt, string password); QJsonObject GetResultObjectFromJSONObject(QString response); QJsonObject GetResultObjectFromJSONArray(QString response); QJsonArray GetResultArrayFromJSONObject(QString response); From e664e1859179c93978514a0ddf5cd78896d35a41 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:36:57 -0400 Subject: [PATCH 390/469] Update tradingdialogpage.h --- src/qt/tradingdialogpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.h b/src/qt/tradingdialogpage.h index c7a9d17b..d31d432b 100644 --- a/src/qt/tradingdialogpage.h +++ b/src/qt/tradingdialogpage.h @@ -94,7 +94,7 @@ private Q_SLOTS: QString GetDepositAddress(); QString HMAC_SHA512_SIGNER(QString UrlToSign,QString Secretkey); QString sendRequest(QString url); - string encryptDecrypt(string toEncrypt, string password); + QString encryptDecrypt(QString toEncrypt, QString password); QJsonObject GetResultObjectFromJSONObject(QString response); QJsonObject GetResultObjectFromJSONArray(QString response); QJsonArray GetResultArrayFromJSONObject(QString response); From cc9ebf350738932a2384f578410d52f51a2abe31 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:38:09 -0400 Subject: [PATCH 391/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index a9dd7dd6..d56f7614 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -818,10 +818,10 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) } -string TradingDialogPage::encryptDecrypt(string toEncrypt, string password) { +QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; - std::strcpy (key, password.c_str()); + std::strcpy (key, password.toStdString().c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 string output = toEncrypt; From 960ac5ba4a0c1654ae965d0dbd88d3251744bf4c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:40:07 -0400 Subject: [PATCH 392/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index d56f7614..acf79b91 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -824,7 +824,7 @@ QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { std::strcpy (key, password.toStdString().c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 - string output = toEncrypt; + QString output = toEncrypt; for (unsigned int i = 0; i < toEncrypt.size(); i++) output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; From 597278dd275b174178f6680ed317eed0f9fcf7ea Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:48:44 -0400 Subject: [PATCH 393/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index acf79b91..9f877d56 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -827,7 +827,7 @@ QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { QString output = toEncrypt; for (unsigned int i = 0; i < toEncrypt.size(); i++) - output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; + output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char *))]; return output; } From 2ca1e2e980391fd9f922cb9935009d0cdbaac0d9 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:54:32 -0400 Subject: [PATCH 394/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 9f877d56..52533a64 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -821,13 +821,17 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; + char * encryptDecrypt(char * toEncrypt); + char key[] = "DSIHKGDSHIGOK$%#%45434etG34th8349ty"; + int string_size = std::strlen(toEncrypt); std::strcpy (key, password.toStdString().c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 QString output = toEncrypt; for (unsigned int i = 0; i < toEncrypt.size(); i++) - output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char *))]; + output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; + return output; } From 78246e79ff254465b0919165fbdb6b05e13051bc Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:55:09 -0400 Subject: [PATCH 395/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 52533a64..d5fb8827 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -822,7 +822,6 @@ QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; char * encryptDecrypt(char * toEncrypt); - char key[] = "DSIHKGDSHIGOK$%#%45434etG34th8349ty"; int string_size = std::strlen(toEncrypt); std::strcpy (key, password.toStdString().c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 From ecac01f65f589ce70d82bce0ab46d08365f7d512 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:56:09 -0400 Subject: [PATCH 396/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index d5fb8827..0d67ef7a 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -822,7 +822,7 @@ QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; char * encryptDecrypt(char * toEncrypt); - int string_size = std::strlen(toEncrypt); + int password_size = std::strlen(toEncrypt); std::strcpy (key, password.toStdString().c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 From c788794b9ae5d9d0b6762c65182d180aa320e781 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 01:58:09 -0400 Subject: [PATCH 397/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 0d67ef7a..853bf25d 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -821,16 +821,13 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; - char * encryptDecrypt(char * toEncrypt); - int password_size = std::strlen(toEncrypt); - std::strcpy (key, password.toStdString().c_str()); + std::strcpy (key, password.c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 - QString output = toEncrypt; + string output = toEncrypt; for (unsigned int i = 0; i < toEncrypt.size(); i++) output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; - return output; } From 56ecf969089e29847de85c6e909dfc55cf7dd267 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 02:00:17 -0400 Subject: [PATCH 398/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 853bf25d..d56f7614 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -821,7 +821,7 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; - std::strcpy (key, password.c_str()); + std::strcpy (key, password.toStdString().c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 string output = toEncrypt; From c82100eeca37bfb5c1dfe4a4b0ccbe2a576241d4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 02:00:45 -0400 Subject: [PATCH 399/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index d56f7614..acf79b91 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -824,7 +824,7 @@ QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { std::strcpy (key, password.toStdString().c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 - string output = toEncrypt; + QString output = toEncrypt; for (unsigned int i = 0; i < toEncrypt.size(); i++) output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; From 5e4cc855985917d3e41d05b449d039a4bbd470bc Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 02:04:27 -0400 Subject: [PATCH 400/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index acf79b91..55d06fb7 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -821,7 +821,7 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; - std::strcpy (key, password.toStdString().c_str()); + std::strcpy (key, password.toStdString()).c_str(); key[password.size()] = '\0'; // don't forget the terminating 0 QString output = toEncrypt; From f34d3401fe10f7d36569d3a81433ef803d50b7db Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 02:05:16 -0400 Subject: [PATCH 401/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 55d06fb7..91754031 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -821,7 +821,7 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { char * key = new char [password.size()+1]; - std::strcpy (key, password.toStdString()).c_str(); + std::strcpy (key, password.c_str()); key[password.size()] = '\0'; // don't forget the terminating 0 QString output = toEncrypt; From 940dddd87880824563e07968d05ca94da6f6ad86 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 02:39:25 -0400 Subject: [PATCH 402/469] Update tradingdialogpage.ui --- src/qt/forms/tradingdialogpage.ui | 8538 ++++++++++------------------- 1 file changed, 2978 insertions(+), 5560 deletions(-) diff --git a/src/qt/forms/tradingdialogpage.ui b/src/qt/forms/tradingdialogpage.ui index bfbece85..a7b8a4d3 100644 --- a/src/qt/forms/tradingdialogpage.ui +++ b/src/qt/forms/tradingdialogpage.ui @@ -6,16 +6,2892 @@ 0 0 - 1031 - 594 + 849 + 480 Dialog - - - + + + true + + + + 10 + 40 + 831 + 431 + + + + + 50 + false + + + + QTabWidget::North + + + QTabWidget::Rounded + + + 6 + + + + Buy + + + + + 30 + 330 + 75 + 23 + + + + Buy MACRON + + + + + + 10 + 110 + 46 + 23 + + + + + 75 + true + + + + Units + + + + + + 330 + 110 + 451 + 23 + + + + + 9 + 75 + true + + + + + + + 330 + 140 + 451 + 23 + + + + + 9 + 75 + true + + + + + + + 790 + 110 + 31 + 23 + + + + MACRON + + + + + + 790 + 140 + 21 + 23 + + + + BTC + + + + + + 10 + 140 + 46 + 23 + + + + + 75 + true + + + + Bid + + + + + + 10 + 170 + 71 + 16 + + + + + 75 + true + + + + Order Type + + + + + + 129 + 110 + 191 + 23 + + + + + 10 + + + + Max + + + + + + 129 + 140 + 191 + 23 + + + + + 10 + + + + + + + 129 + 170 + 191 + 23 + + + + + 10 + + + + + + + 21 + 11 + 180 + 15 + + + + + + + + 75 + true + + + + BTC Available: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + BTC + + + + + + + + + 11 + 301 + 209 + 15 + + + + + + + + 75 + true + + + + Total w/ 0.25% Fee + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 50 + false + + + + BTC + + + + + + + + + Sell + + + + + 790 + 140 + 21 + 23 + + + + BTC + + + + + + 129 + 140 + 191 + 23 + + + + + 10 + + + + + + + 10 + 110 + 46 + 23 + + + + + 75 + true + + + + Units + + + + + + 129 + 110 + 191 + 23 + + + + + 10 + + + + Max + + + + + + 10 + 170 + 71 + 16 + + + + + 75 + true + + + + Order Type + + + + + + 129 + 170 + 191 + 23 + + + + + 10 + + + + + + + 10 + 140 + 46 + 23 + + + + + 75 + true + + + + Bid + + + + + + 790 + 110 + 31 + 23 + + + + MACRON + + + + + + 330 + 110 + 451 + 23 + + + + + 9 + 75 + true + + + + + + + 330 + 140 + 451 + 23 + + + + + 9 + 75 + true + + + + + + + 30 + 330 + 75 + 23 + + + + Sell MACRON + + + + + + 22 + 12 + 200 + 15 + + + + + + + + 75 + true + + + + MACRON Available: + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + 75 + true + + + + MACRON + + + + + + + + + 10 + 300 + 218 + 15 + + + + + + + + 75 + true + + + + Total w/ 0.25% Fee + + + + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 127 + 212 + 127 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 255 + 0 + + + + + + + 0 + 212 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 113 + 0 + + + + + + + 0 + 85 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 85 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 170 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + 0.00000000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 50 + false + + + + BTC + + + + + + + + + Order Book + + + + + 10 + 60 + 391 + 321 + + + + + 9 + 50 + false + + + + + + + 420 + 60 + 391 + 321 + + + + + 9 + 50 + false + + + + + + + 10 + 10 + 91 + 16 + + + + Bids + + + + + + 420 + 10 + 91 + 16 + + + + Asks + + + + + + 570 + 10 + 241 + 16 + + + + label + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 160 + 10 + 241 + 16 + + + + label + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 220 + 30 + 181 + 16 + + + + TextLabel + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 630 + 30 + 181 + 16 + + + + TextLabel + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 400 + 60 + 20 + 321 + + + + Qt::Vertical + + + + + + Market History + + + + + 10 + 10 + 801 + 371 + + + + + + + Open Orders + + + + + 10 + 40 + 801 + 341 + + + + + + + 10 + 10 + 101 + 17 + + + + Advanced View + + + + + + Trade history + + + + + 0 + 10 + 821 + 361 + + + + + + + Balance + + + + + 357 + 30 + 150 + 16 + + + + TextLabel + + + + + + 120 + 30 + 150 + 16 + + + + TextLabel + + + + + + 30 + 30 + 75 + 16 + + + + + 75 + true + + + + MACRON Balance: + + + + + + 270 + 30 + 71 + 16 + + + + + 75 + true + + + + BTC Balance: + + + + + + 120 + 70 + 150 + 16 + + + + TextLabel + + + + + + 30 + 70 + 83 + 16 + + + + + 75 + true + + + + MACRON Available: + + + + + + 30 + 110 + 76 + 16 + + + + + 75 + true + + + + MACRON Pending: + + + + + + 120 + 110 + 150 + 16 + + + + TextLabel + + + + + + 270 + 70 + 81 + 16 + + + + + 75 + true + + + + BTC Available + + + + + + 357 + 70 + 150 + 16 + + + + TextLabel + + + + + + 270 + 110 + 69 + 16 + + + + + 75 + true + + + + BTC Pending + + + + + + 357 + 110 + 150 + 16 + + + + TextLabel + + + + + + 30 + 200 + 171 + 16 + + + + + 75 + true + + + + Bittrex MACRON Deposit Address: + + + + + + 30 + 160 + 411 + 23 + + + + Generate MACRON Coin Deposit Address + + + + + + 200 + 200 + 261 + 16 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 255 + + + + + + + + + 120 + 120 + 120 + + + + + + + 120 + 120 + 120 + + + + + + + + + 75 + true + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + Settings + + + + + 200 + 50 + 300 + 23 + + + + + + + + + + 30 + 90 + 71 + 20 + + + + + 75 + true + + + + Secret Key + + + + + + 30 + 50 + 51 + 20 + + + + + 75 + true + + + + API Key + + + + + + 200 + 90 + 300 + 23 + + + + + + + 560 + 90 + 191 + 23 + + + + Update API Keys + + + label + ApiKeyInput + label_2 + SecretKeyInput + UpdateKeys + + + 0 @@ -23,11 +2899,11 @@ - - 849 - 40 - - + + 849 + 30 + + 16777215 @@ -35,5561 +2911,103 @@ - QFrame::NoFrame + QFrame::StyledPanel QFrame::Raised - - 0 - - - + + - - - - - 0 - 0 - - - - - 8 - 50 - false - - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 0 - 0 - - - - - 8 - 50 - false - - - - 0.000000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 0 - 0 - - - - - 8 - 50 - false - - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 0 - 0 - - - - - 8 - 50 - false - - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - - - - - true - - - - 50 - false - - - - QTabWidget::North - - - QTabWidget::Rounded - - - 6 - - - - Trade - - - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - - 9 - 50 - false - - - - QAbstractItemView::NoEditTriggers - - - false - - - false - - - true - - - false - - - QAbstractItemView::NoSelection - - - - - - - - 75 - true - - - - Qt::LeftToRight - - - false - - - Units - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - - - - - - - - 75 - true - - - - BTC Available: - - - - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - 75 - true - - - - BTC - - - - - - - - - - - - 75 - true - - - - TX Available: - - - - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - 75 - true - - - - TX - - - - - - - - - - 10 - - - - Max - - - - - - - - 0 - 0 - - - - - 9 - 75 - true - - - - - - - - TX - - - - - - - - 10 - - - - Max - - - - - - - - 0 - 0 - - - - - 9 - 75 - true - - - - - - - - TX - - - - - - - - 75 - true - - - - Bid - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 10 - - - - - - - - - 0 - 0 - - - - - 9 - 75 - true - - - - - - - - BTC - - - - - - - - 10 - - - - - - - - - 0 - 0 - - - - - 9 - 75 - true - - - - - - - - BTC - - - - - - - - - - 75 - true - - - - Total w/ 0.25% Fee - - - - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 50 - false - - - - BTC - - - - - - - - - - - - 75 - true - - - - Total w/ 0.25% Fee - - - - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 50 - false - - - - BTC - - - - - - - - - Buy TX - - - - - - - Sell TX - - - - - - - - 0 - 0 - - - - - 9 - 50 - false - - - - QAbstractItemView::NoEditTriggers - - - false - - - false - - - true - - - false - - - QAbstractItemView::NoSelection - - - - - - - 0.00000000 BTC - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Asks: 0000 - - - - - - - 0.00000000 BTC - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 8 - - - - Demand: 0.00000000 TX - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Supply: 0.00000000 TX - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Bids: 0000 - - - - - - - - Send - - - - - - - - - 10 - 75 - true - - - - Lowest price: - - - - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 10 - 75 - true - - - - false - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 10 - 50 - false - - - - BTC - - - - - - - - - - - - 10 - 75 - true - - - - Amount in TX: - - - - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 10 - 75 - true - - - - false - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 10 - 50 - false - - - - TX - - - - - - - - - - - - 10 - 75 - true - - - - Total w/ Fees : - - - - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 10 - 75 - true - - - - false - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 10 - 50 - false - - - - BTC - - - - - - - - - Send - - - - - - - - 10 - 50 - false - - - - - - - - - - - - 10 - 50 - false - - - - <html><head/><body><p><span style=" font-size:9pt; font-weight:600;">Warning:</span><span style=" font-size:9pt;"> This feature is in </span><span style=" font-size:9pt; font-weight:600;">ALPHA ! USE AT OWN RISK !</span></p></body></html> - - - - - - - - 10 - 50 - false - - - - <html><head/><body><p align="center"><span style=" font-weight:600; text-decoration: underline;">Instructions:</span></p><p align="center">To use the cross sending feature you need to have </p><p align="center">TX available to spend on Bittrex. If you don't have any </p><p align="center">you can find your deposit address on the &quot;Balance&quot; tab.</p><p align="center">1. Enter the amount you want to receive in Bitcoin.</p><p align="center">2. Enter the Bitcoin address you are sending to.</p><p align="center">3. Check that the Total with fee's is correct.</p><p align="center">4. Press send and watch the magic happen.</p><p align="center"><span style=" font-weight:600; text-decoration: underline;">Notes.</span></p><p align="center"><span style=" font-size:7pt;">Total w/ fees: N/A means you dont have enough EXCL to sell !</span></p><p align="center"><span style=" font-size:7pt;">All trades are done through Bittrex using your own balance and API keys.</span></p><p align="center"><span style=" font-size:7pt;">Encrypt and backup your wallet when using this feature.</span></p><p align="center"><span style=" font-size:7pt;">If you don't have a password you bittrex account will be accessible 24/7</span></p><p align="center"><span style=" font-size:7pt;">Withdrawal fee of 0.002 and 0.25% taken by Bittrex.</span></p></body></html> - - - - - - - - 10 - 75 - true - - - - Amount: - - - - - - - Qt::Horizontal - - - - 212 - 368 - - - - - - - - - 10 - 75 - true - - - - - - - - - 10 - 75 - true - - - - Address: - - - - - - - - - - 10 - 75 - true - - - - TX Balance: - - - - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 10 - 75 - true - - - - false - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 10 - 50 - false - - - - TX - - - - - - - - - - - - 10 - 75 - true - - - - BTC Balance: - - - - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 127 - 212 - 127 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 255 - 0 - - - - - - - 0 - 212 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 113 - 0 - - - - - - - 0 - 85 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 85 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 170 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 10 - 75 - true - - - - false - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 10 - 50 - false - - - - BTC - - - - - - - - - - 10 - - - - Max - - - - - - - - 10 - 75 - true - - - - - - - - Paste from clipboard - - - - - - - :/icons/editpaste:/icons/editpaste - - - Alt+P - - - - - - - - 18 - 75 - true - - - - Cross-Send - - - Qt::AlignCenter - - - - - - - Qt::Vertical - - - - 915 - 73 - - - - - - CSUnitsInput - label232_4 - CSUnitsAddress - label_8 - CSUnitsBtn - label232_8 - label_27 - label232_13 - label232_15 - CS_Max_Amount - verticalSpacer_3 - horizontalSpacer_6 - CSPasteButton - - - - Market History - - - - - - - - - - Open Orders - - - - - - - - - - Trade history - - - - - - - - - - Balance - - - - - - - 10 - 75 - true - - - - TX Balance: - - - - - - - - 10 - - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 10 - 75 - true - - - - BTC Balance: - - - - - - - - 10 - - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - Qt::Horizontal - - - - 478 - 488 - - - - - - - - - 10 - 75 - true - - - - TX Available: - - - - - - - - 10 - - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 10 - 75 - true - - - - BTC Available: - - - - - - - - 10 - - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 10 - 75 - true - - - - TX Pending: - - - - - - - - 10 - - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 10 - 75 - true - - - - BTC Pending: - - - - - - - - 10 - - - - 0.00000000 - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - - 10 - - - - Generate EXCL Coin Deposit Address - - - - - - - - 10 - 75 - true - - - - Deposit Address: - - - - - - - - 300 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 255 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 255 - - - - - - - - - 120 - 120 - 120 - - - - - - - 120 - 120 - 120 - - - - - - - - - 10 - 75 - true - - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - Copy to clipboard - - - - - - - :/icons/editcopy:/icons/editcopy - - - Alt+P - - - - - - - - 10 - 75 - true - - - - Withdraw TX: - - - - - - - - 10 - 75 - true - - - - Amount: - - - - - - - - 9 - 75 - true - - - - - - - - - - - - 10 - - - - Max - - - - - - - - 10 - 75 - true - - - - Address: - - - - - - - - 9 - 75 - true - - - - - - - - Paste from clipboard - - - - - - - :/icons/editpaste:/icons/editpaste - - - Alt+P - - - - - - - - 10 - - - - Withdraw - - - - - - - Qt::Vertical - - - - 428 - 262 - - - - - - label_31 - label_15 - label_12 - label_14 - label_13 - label_11 - BitcoinBalanceLabel - TXBalanceLabel - TXAvailableLabel_2 - TXPendingLabel - BitcoinAvailableLabel - BitcoinPendingLabel - label_33 - GenDepositBTN - DepositAddressLabel - Withdraw_Max_Amount - label_34 - WithdrawUnitsInput - label_10 - label_26 - WithdrawAddress - WithdrawUnitsBtn - horizontalSpacer_4 - verticalSpacer - WithdrawPasteButton - DepositCopyButton - - - - Settings - - - - - - - 75 - true - - - - API Key - - - - - - - - - - - - - - Paste from clipboard - - - - - - - :/icons/editpaste:/icons/editpaste - - - Alt+P - - - - - - - Qt::Horizontal - - - - 519 - 488 - - - - - - - - - 75 - true - - - - Secret Key - - - - - - - - - - Paste from clipboard - - - - - - - :/icons/editpaste:/icons/editpaste - - - Alt+P - - - - - - - - 75 - true - - - - Password - - - - - - - QLineEdit::Password - - - - - - - - 115 - 0 - - - - Load API Keys - - - - - - - - 125 - 0 - - - - Update API Keys - - - - - - - - 115 - 0 - - - - Save API Keys - - - - - - - Qt::Vertical - - - - 358 - 247 - - - - - - - - - 10 - 50 - false - - - - <html><head/><body><p>Loading keys:</p><p>1) Enter Password</p><p>2) Load API Keys</p><p>3) Start trading on Bittrex</p></body></html> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 10 - 50 - false - - - - <html><head/><body><p>Saving keys:</p><p>1) Enter in API Keys found at <a href="https://bittrex.com/Account/ManageApiKey"><span style=" text-decoration: underline; color:#0000ff;">Bittrex</span></a></p><p>2) Enter Password</p><p>3) Save API Keys</p><p>4) Start trading on Bittrex</p></body></html> - - - - - label - ApiKeyInput - label_2 - SecretKeyInput - UpdateKeys - SaveKeys - LoadKeys - label232_16 - label232_17 - label_28 - PasswordInput - horizontalSpacer_3 - verticalSpacer_2 - KeyPasteButton - SecretPasteButton - - - - + + + + + 11 + 11 + 151 + 16 + + + + + 151 + 0 + + + + 0.00000000 + + + + + + + + 532 + 11 + 201 + 16 + + + + + 201 + 0 + + + + 0.000000000 + + + + + + + + 168 + 11 + 181 + 16 + + + + + 181 + 0 + + + + 0.00000000 + + + + + + + + 355 + 11 + 171 + 16 + + + + + 171 + 0 + + + + 0.00000000 + + + + + + + - - - + From 493912b87dca00a9e30b41ffdf7d2d272b3e7b87 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 02:42:47 -0400 Subject: [PATCH 403/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 922 ++++++++++------------------------- 1 file changed, 265 insertions(+), 657 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 91754031..048673f1 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -1,18 +1,12 @@ -#include "tradingdialogpage.h" -#include "ui_tradingdialogpage.h" -#include "clientmodel.h" -#include "walletmodel.h" +#include "tradingdialog.h" +#include "ui_tradingdialog.h" #include #include -#include -#include #include #include #include #include -#include -#include #include #include @@ -22,57 +16,51 @@ #include #include #include -#include #include -#include -#include -#include using namespace std; TradingDialogPage::TradingDialogPage(QWidget *parent) : QDialog(parent), - ui(new Ui::TradingDialogPage), - model(0) + ui(new Ui::TradingDialogPage) { ui->setupUi(this); timerid = 0; qDebug() << "Expected this"; - - ui->BtcAvailableLabel->setTextFormat(Qt::RichText); - ui->TXAvailableLabel->setTextFormat(Qt::RichText); - ui->BuyCostLabel->setTextFormat(Qt::RichText); - ui->SellCostLabel->setTextFormat(Qt::RichText); - ui->BittrexBTCLabel->setTextFormat(Qt::RichText); - ui->BittrexTXLabel->setTextFormat(Qt::RichText); - ui->CSDumpLabel->setTextFormat(Qt::RichText); - ui->CSTotalLabel->setTextFormat(Qt::RichText); - ui->CSReceiveLabel->setTextFormat(Qt::RichText); + QPalette sample_palette; + sample_palette.setColor(QPalette::Window, Qt::green); + + ui->BuyCostLabel->setPalette(sample_palette); + ui->SellCostLabel->setPalette(sample_palette); + ui->MACRONAvailableLabel->setPalette(sample_palette); + ui->BtcAvailableLbl_2->setPalette(sample_palette); //Set tabs to inactive ui->TradingTabWidget->setTabEnabled(0,false); ui->TradingTabWidget->setTabEnabled(1,false); - ui->TradingTabWidget->setTabEnabled(3,false); ui->TradingTabWidget->setTabEnabled(4,false); ui->TradingTabWidget->setTabEnabled(5,false); + ui->TradingTabWidget->setTabEnabled(6,false); - // Listen for keypress - connect(ui->PasswordInput, SIGNAL(returnPressed()),ui->LoadKeys,SIGNAL(clicked())); /*OrderBook Table Init*/ - CreateOrderBookTables(*ui->BidsTable,QStringList() << "SUM(BTC)" << "TOTAL(BTC)" << "TX(SIZE)" << "BID(BTC)"); - CreateOrderBookTables(*ui->AsksTable,QStringList() << "ASK(BTC)" << "TX(SIZE)" << "TOTAL(BTC)" << "SUM(BTC)"); + CreateOrderBookTables(*ui->BidsTable,QStringList() << "TOTAL(BTC)"<< "MACRON(SIZE)" << "BID(BTC)"); + CreateOrderBookTables(*ui->AsksTable,QStringList() << "ASK(BTC)" << "MACRON(SIZE)" << "TOTAL(BTC)"); /*OrderBook Table Init*/ /*Market History Table Init*/ ui->MarketHistoryTable->setColumnCount(5); ui->MarketHistoryTable->verticalHeader()->setVisible(false); - ui->MarketHistoryTable->setHorizontalHeaderLabels(QStringList()<<"DATE"<<"BUY/SELL"<<"BID/ASK"<<"TOTAL UNITS(EXCL)"<<"TOTAL COST(BTC)"); + + ui->MarketHistoryTable->setHorizontalHeaderLabels(QStringList()<<"DATE"<<"BUY/SELL"<<"BID/ASK"<<"TOTAL UNITS(MACRON)"<<"TOTAL COST(BTC"); ui->MarketHistoryTable->setRowCount(0); + int Cellwidth = ui->MarketHistoryTable->width() / 5; - ui->MarketHistoryTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); - ui->MarketHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); + + ui->MarketHistoryTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + + ui->MarketHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); // column 1, width 50 ui->MarketHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); ui->MarketHistoryTable->horizontalHeader()->resizeSection(3,Cellwidth); ui->MarketHistoryTable->horizontalHeader()->resizeSection(4,Cellwidth); @@ -82,46 +70,53 @@ TradingDialogPage::TradingDialogPage(QWidget *parent) : /*Market History Table Init*/ /*Account History Table Init*/ - ui->TradeHistoryTable->setColumnCount(9); - ui->TradeHistoryTable->verticalHeader()->setVisible(false); - ui->TradeHistoryTable->setHorizontalHeaderLabels(QStringList() << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "Closed"); + ui->TradeHistoryTable->setColumnCount(13); + + ui->TradeHistoryTable->setHorizontalHeaderLabels(QStringList() << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << + "Conditional" << "Condition" << "Condition Target" << "ImmediateOrCancel" << "Closed"); ui->TradeHistoryTable->setRowCount(0); - Cellwidth = ui->TradeHistoryTable->width() / 9; - ui->TradeHistoryTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); - ui->TradeHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); - ui->TradeHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); - ui->TradeHistoryTable->horizontalHeader()->resizeSection(3,Cellwidth); - ui->TradeHistoryTable->horizontalHeader()->resizeSection(4,Cellwidth); - ui->TradeHistoryTable->horizontalHeader()->resizeSection(5,Cellwidth); - ui->TradeHistoryTable->horizontalHeader()->resizeSection(6,Cellwidth); - ui->TradeHistoryTable->horizontalHeader()->resizeSection(7,Cellwidth); - ui->TradeHistoryTable->horizontalHeader()->resizeSection(8,Cellwidth); - ui->TradeHistoryTable->horizontalHeader()->resizeSection(9,Cellwidth); ui->TradeHistoryTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); ui->TradeHistoryTable->horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * {font-weight :bold;}"); + ui->TradeHistoryTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); /*Account History Table Init*/ /*Open Orders Table*/ - ui->OpenOrdersTable->setColumnCount(10); - ui->OpenOrdersTable->verticalHeader()->setVisible(false); - ui->OpenOrdersTable->setHorizontalHeaderLabels(QStringList() << "OrderId" << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "Cancel Order"); + ui->OpenOrdersTable->setColumnCount(15); + ui->OpenOrdersTable->setHorizontalHeaderLabels(QStringList() << "OrderId" << "Date Time" << "Exchange" << "OrderType" << "Limit" << "QTY" << "QTY_Rem" << "Price" << "PricePerUnit" << "CancelInitiated" << + "Conditional" << "Condition" << "Condition Target" << "ImmediateOrCancel" << "Cancel Order"); ui->OpenOrdersTable->setRowCount(0); - Cellwidth = ui->TradeHistoryTable->width() / 9; - ui->OpenOrdersTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); - ui->OpenOrdersTable->horizontalHeader()->resizeSection(2,Cellwidth); - ui->OpenOrdersTable->horizontalHeader()->resizeSection(3,Cellwidth); - ui->OpenOrdersTable->horizontalHeader()->resizeSection(4,Cellwidth); - ui->OpenOrdersTable->horizontalHeader()->resizeSection(5,Cellwidth); - ui->OpenOrdersTable->horizontalHeader()->resizeSection(6,Cellwidth); - ui->OpenOrdersTable->horizontalHeader()->resizeSection(7,Cellwidth); - ui->OpenOrdersTable->horizontalHeader()->resizeSection(8,Cellwidth); - ui->OpenOrdersTable->horizontalHeader()->resizeSection(9,Cellwidth); ui->OpenOrdersTable->setColumnHidden(0,true); ui->OpenOrdersTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); ui->OpenOrdersTable->horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * {font-weight :bold;}"); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(1,120); // column 1, width 50 + ui->OpenOrdersTable->horizontalHeader()->resizeSection(2,70); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(3,70); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(4,70); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(5,70); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(6,70); + ui->OpenOrdersTable->horizontalHeader()->resizeSection(7,70); + + ui->OpenOrdersTable->setColumnHidden(9,true); + ui->OpenOrdersTable->setColumnHidden(10,true); + ui->OpenOrdersTable->setColumnHidden(11,true); + ui->OpenOrdersTable->setColumnHidden(12,true); + ui->OpenOrdersTable->setColumnHidden(13,true); + connect (ui->OpenOrdersTable, SIGNAL(cellClicked(int,int)), this, SLOT(CancelOrderSlot(int, int))); /*Open Orders Table*/ + + /*populate static combo values*/ + ui->BuyBidcomboBox -> addItems(QStringList()<<"Last"<<"Bid"<<"Ask"); + ui->buyOrdertypeCombo-> addItems(QStringList()<<"Limit"<<"Market"); + ui->SellBidcomboBox -> addItems(QStringList()<<"Last"<<"Bid"<<"Ask"); + ui->SellOrdertypeCombo-> addItems(QStringList()<<"Limit"<<"Market"); + //ui->BuyTimeInForceCombo-> addItems(QStringList()<<"Good 'Til Cancelled"<<"Immediate Or Cancel"); + //ui->BuyConditionCombo-> addItems(QStringList()<<"Greater Than Or Equal To"<<"Less Than Or Equal To"); + //ui->BuyConditionCombo->hide(); + //ui->BuyWhenPriceLabel->hide(); + //ui->ConditionLineEdit->hide(); + /*populate static combo values*/ } void TradingDialogPage::InitTrading() @@ -142,7 +137,7 @@ void TradingDialogPage::InitTrading() } void TradingDialogPage::UpdaterFunction(){ - //TXst get the main exchange info in order to populate qLabels in maindialog. then get data + //MACRONst get the main exchange info in order to populate qLabels in maindialog. then get data //required for the current tab. int Retval = SetExchangeInfoTextLabels(); @@ -154,18 +149,18 @@ void TradingDialogPage::UpdaterFunction(){ QString TradingDialogPage::GetMarketSummary(){ - QString Response = sendRequest("https://bittrex.com/api/v1.1/public/GetMarketSummary?market=btc-EXCL"); + QString Response = sendRequest("https://bittrex.com/api/v1.1/public/GetMarketSummary?market=BTC-MACRON"); return Response; } QString TradingDialogPage::GetOrderBook(){ - QString Response = sendRequest("https://bittrex.com/api/v1.1/public/getorderbook?market=BTC-EXCL&type=both&depth=50"); + QString Response = sendRequest("https://bittrex.com/api/v1.1/public/getorderbook?market=BTC-MACRON&type=both&depth=50"); return Response; } QString TradingDialogPage::GetMarketHistory(){ - QString Response = sendRequest("https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-EXCL&count=100"); + QString Response = sendRequest("https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-MACRON&count=100"); return Response; } @@ -180,14 +175,14 @@ QString TradingDialogPage::CancelOrder(QString OrderId){ return Response; } -QString TradingDialogPage::BuyTX(QString OrderType, double Quantity, double Rate){ +QString TradingDialogPage::BuyMACRON(QString OrderType, double Quantity, double Rate){ QString str = ""; QString URL = "https://bittrex.com/api/v1.1/market/"; URL += OrderType; URL += "?apikey="; URL += this->ApiKey; - URL += "&nonce=12345434&market=BTC-EXCL&quantity="; + URL += "&nonce=12345434&market=BTC-MACRON&quantity="; URL += str.number(Quantity,'i',8); URL += "&rate="; URL += str.number(Rate,'i',8); @@ -196,14 +191,14 @@ QString TradingDialogPage::BuyTX(QString OrderType, double Quantity, double Rate return Response; } -QString TradingDialogPage::SellTX(QString OrderType, double Quantity, double Rate){ +QString TradingDialogPage::SellMACRON(QString OrderType, double Quantity, double Rate){ QString str = ""; QString URL = "https://bittrex.com/api/v1.1/market/"; URL += OrderType; URL += "?apikey="; URL += this->ApiKey; - URL += "&nonce=12345434&market=BTC-EXCL&quantity="; + URL += "&nonce=12345434&market=BTC-MACRON&quantity="; URL += str.number(Quantity,'i',8); URL += "&rate="; URL += str.number(Rate,'i',8); @@ -212,27 +207,10 @@ QString TradingDialogPage::SellTX(QString OrderType, double Quantity, double Rat return Response; } -QString TradingDialogPage::Withdraw(double Amount, QString Address, QString Coin){ - - QString str = ""; - QString URL = "https://bittrex.com/api/v1.1/account/withdraw?apikey="; - URL += this->ApiKey; - URL += "¤cy="; - URL += Coin; - URL += "&quantity="; - URL += str.number(Amount,'i',8); - URL += "&address="; - URL += Address; - URL += "&nonce=12345434"; - - QString Response = sendRequest(URL); - return Response; -} - QString TradingDialogPage::GetOpenOrders(){ QString URL = "https://bittrex.com/api/v1.1/market/getopenorders?apikey="; URL += this->ApiKey; - URL += "&nonce=12345434&market=BTC-EXCL"; + URL += "&nonce=12345434&market=MACRON-BTC"; QString Response = sendRequest(URL); return Response; @@ -242,7 +220,7 @@ QString TradingDialogPage::GetBalance(QString Currency){ QString URL = "https://bittrex.com/api/v1.1/account/getbalance?apikey="; URL += this->ApiKey; - URL += "&nonce=12345434¤cy="; + URL += "&nonce=12345434¤cy=MACRON"; URL += Currency; QString Response = sendRequest(URL); @@ -253,7 +231,7 @@ QString TradingDialogPage::GetDepositAddress(){ QString URL = "https://bittrex.com/api/v1.1/account/getdepositaddress?apikey="; URL += this->ApiKey; - URL += "&nonce=12345434¤cy=EXCL"; + URL += "&nonce=12345434¤cy=MACRON"; QString Response = sendRequest(URL); return Response; @@ -263,7 +241,7 @@ QString TradingDialogPage::GetAccountHistory(){ QString URL = "https://bittrex.com/api/v1.1/account/getorderhistory?apikey="; URL += this->ApiKey; - URL += "&nonce=12345434&market=BTC-EXCL&count=10"; + URL += "&nonce=12345434&market=MACRON-BTC&count=10"; QString Response = sendRequest(URL); return Response; @@ -283,13 +261,13 @@ int TradingDialogPage::SetExchangeInfoTextLabels(){ ui->volumet->setTextFormat(Qt::RichText); ui->volumebtc->setTextFormat(Qt::RichText); - ui->Ask->setText("Ask: " + str.number(obj["Ask"].toDouble(),'i',8) + " BTC"); + ui->Ask->setText("Ask: " + str.number(obj["Ask"].toDouble(),'i',8) + " BTC"); - ui->Bid->setText("Bid: " + str.number(obj["Bid"].toDouble(),'i',8) + " BTC"); + ui->Bid->setText("Bid: " + str.number(obj["Bid"].toDouble(),'i',8) + " BTC"); - ui->volumet->setText("EXCL Volume: " + str.number(obj["Volume"].toDouble(),'i',8) + " EXCL"); + ui->volumet->setText("MACRON Volume: " + str.number(obj["Volume"].toDouble(),'i',8) + " MACRON"); - ui->volumebtc->setText("BTC Volume: " + str.number(obj["BaseVolume"].toDouble(),'i',8) + " BTC"); + ui->volumebtc->setText("BTC Volume: " + str.number(obj["BaseVolume"].toDouble(),'i',8) + " BTC"); obj.empty(); @@ -298,21 +276,20 @@ return 0; void TradingDialogPage::CreateOrderBookTables(QTableWidget& Table,QStringList TableHeader){ - Table.setColumnCount(4); + Table.setColumnCount(3); Table.verticalHeader()->setVisible(false); Table.setHorizontalHeaderLabels(TableHeader); - int Cellwidth = Table.width() / 4; + int Cellwidth = Table.width() / 3; Table.horizontalHeader()->resizeSection(1,Cellwidth); // column 1, width 50 Table.horizontalHeader()->resizeSection(2,Cellwidth); Table.horizontalHeader()->resizeSection(3,Cellwidth); - Table.horizontalHeader()->resizeSection(4,Cellwidth); Table.setRowCount(0); - Table.horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); + Table.horizontalHeader()->setResizeMode(QHeaderView::Stretch); Table.horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); Table.horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * { font-weight :bold;}"); } @@ -333,29 +310,6 @@ void TradingDialogPage::DisplayBalance(QLabel &BalanceLabel,QLabel &Available, Q Pending.setText("" + str.number( ResultObject["Pending"].toDouble(),'i',8) + " " +Currency); } -void TradingDialogPage::DisplayBalance(QLabel &BalanceLabel, QString Response){ - - QString str; - - //Set the labels, parse the json result to get values. - QJsonObject ResultObject = GetResultObjectFromJSONObject(Response); - - BalanceLabel.setText("" + str.number(ResultObject["Available"].toDouble(),'i',8) + ""); -} - -void TradingDialogPage::DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabel2, QString Response, QString Response2){ - - QString str; - QString str2; - - //Set the labels, parse the json result to get values. - QJsonObject ResultObject = GetResultObjectFromJSONObject(Response); - QJsonObject ResultObject2 = GetResultObjectFromJSONObject(Response2); - - BalanceLabel.setText("" + str.number(ResultObject["Available"].toDouble(),'i',8) + ""); - BalanceLabel2.setText("" + str2.number(ResultObject2["Available"].toDouble(),'i',8) + ""); -} - void TradingDialogPage::ParseAndPopulateOpenOrdersTable(QString Response){ int itteration = 0, RowCount = 0; @@ -365,13 +319,23 @@ void TradingDialogPage::ParseAndPopulateOpenOrdersTable(QString Response){ ui->OpenOrdersTable->setRowCount(0); - Q_FOREACH (const QJsonValue & value, jsonArray) + foreach (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); RowCount = ui->OpenOrdersTable->rowCount(); + QString ios; + QString IsConditional; + QString ConditionTarget; + QString CancelInitiated; + + obj["ImmediateOrCancel"].toBool() == true ? (ios = "true") : ( ios = "false"); + obj["IsConditional"].toBool() == true ? (IsConditional = "true") : ( IsConditional = "false"); + obj["ConditionTarget"].toBool() == true ? (ConditionTarget = "true") : ( ConditionTarget = "false"); + obj["CancelInitiated"].toBool() == true ? (CancelInitiated = "true") : ( CancelInitiated = "false"); + ui->OpenOrdersTable->insertRow(RowCount); ui->OpenOrdersTable->setItem(itteration, 0, new QTableWidgetItem(obj["OrderUuid"].toString())); ui->OpenOrdersTable->setItem(itteration, 1, new QTableWidgetItem(BittrexTimeStampToReadable(obj["Opened"].toString()))); @@ -382,16 +346,19 @@ void TradingDialogPage::ParseAndPopulateOpenOrdersTable(QString Response){ ui->OpenOrdersTable->setItem(itteration, 6, new QTableWidgetItem(str.number(obj["QuantityRemaining"].toDouble(),'i',8))); ui->OpenOrdersTable->setItem(itteration, 7, new QTableWidgetItem(str.number(obj["Price"].toDouble(),'i',8))); ui->OpenOrdersTable->setItem(itteration, 8, new QTableWidgetItem(str.number(obj["PricePerUnit"].toDouble(),'i',8))); - ui->OpenOrdersTable->setItem(itteration, 9, new QTableWidgetItem(tr("Cancel Order"))); + ui->OpenOrdersTable->setItem(itteration, 9, new QTableWidgetItem(CancelInitiated)); + ui->OpenOrdersTable->setItem(itteration, 10, new QTableWidgetItem(IsConditional)); + ui->OpenOrdersTable->setItem(itteration, 11, new QTableWidgetItem(obj["Condition"].toString())); + ui->OpenOrdersTable->setItem(itteration, 12, new QTableWidgetItem(ConditionTarget)); + ui->OpenOrdersTable->setItem(itteration, 13, new QTableWidgetItem(ios)); + ui->OpenOrdersTable->setItem(itteration, 14, new QTableWidgetItem(tr("Cancel Order"))); //Handle the cancel link in open orders table QTableWidgetItem* CancelCell; - CancelCell= ui->OpenOrdersTable->item(itteration, 9); //Set the wtablewidget item to the cancel cell item. + CancelCell= ui->OpenOrdersTable->item(itteration, 14); //Set the wtablewidget item to the cancel cell item. CancelCell->setForeground(QColor::fromRgb(255,0,0)); //make this item red. CancelCell->setTextAlignment(Qt::AlignCenter); - itteration++; - } - obj.empty(); + } } @@ -430,13 +397,21 @@ void TradingDialogPage::ParseAndPopulateAccountHistoryTable(QString Response){ ui->TradeHistoryTable->setRowCount(0); - Q_FOREACH (const QJsonValue & value, jsonArray) + foreach (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); RowCount = ui->TradeHistoryTable->rowCount(); + QString ios; + QString IsConditional; + QString ConditionTarget; + + obj["ImmediateOrCancel"].toBool() == true ? (ios = "true") : ( ios = "false"); + obj["IsConditional"].toBool() == true ? (IsConditional = "true") : ( IsConditional = "false"); + obj["ConditionTarget"].toBool() == true ? (ConditionTarget = "true") : ( ConditionTarget = "false"); + ui->TradeHistoryTable->insertRow(RowCount); ui->TradeHistoryTable->setItem(itteration, 0, new QTableWidgetItem(BittrexTimeStampToReadable(obj["TimeStamp"].toString()))); ui->TradeHistoryTable->setItem(itteration, 1, new QTableWidgetItem(obj["Exchange"].toString())); @@ -446,7 +421,11 @@ void TradingDialogPage::ParseAndPopulateAccountHistoryTable(QString Response){ ui->TradeHistoryTable->setItem(itteration, 5, new QTableWidgetItem(str.number(obj["QuantityRemaining"].toDouble(),'i',8))); ui->TradeHistoryTable->setItem(itteration, 6, new QTableWidgetItem(str.number(obj["Price"].toDouble(),'i',8))); ui->TradeHistoryTable->setItem(itteration, 7, new QTableWidgetItem(str.number(obj["PricePerUnit"].toDouble(),'i',8))); - ui->TradeHistoryTable->setItem(itteration, 8, new QTableWidgetItem(obj["Closed"].toString())); + ui->TradeHistoryTable->setItem(itteration, 8, new QTableWidgetItem(IsConditional)); + ui->TradeHistoryTable->setItem(itteration, 9, new QTableWidgetItem(obj["Condition"].toString())); + ui->TradeHistoryTable->setItem(itteration, 10, new QTableWidgetItem(ConditionTarget)); + ui->TradeHistoryTable->setItem(itteration, 11, new QTableWidgetItem(ios)); + ui->TradeHistoryTable->setItem(itteration, 12, new QTableWidgetItem(obj["Closed"].toString())); itteration++; } @@ -465,14 +444,14 @@ void TradingDialogPage::ParseAndPopulateOrderBookTables(QString OrderBook){ QJsonArray BuyArray = ResultObject.value("buy").toArray(); //get buy/sell object from result object QJsonArray SellArray = ResultObject.value("sell").toArray(); //get buy/sell object from result object - double TXSupply = 0; - double TXDemand = 0; - double BtcSupply = 0; - double BtcDemand = 0; + double MACRONSupply = 0; + double MACRONDemand = 0; + double BtcSupply = 0; + double BtcDemand = 0; ui->AsksTable->setRowCount(0); - Q_FOREACH (const QJsonValue & value, SellArray) + foreach (const QJsonValue & value, SellArray) { obj = value.toObject(); @@ -480,21 +459,21 @@ void TradingDialogPage::ParseAndPopulateOrderBookTables(QString OrderBook){ double y = obj["Quantity"].toDouble(); double a = (x * y); - TXSupply += y; - BtcSupply += a; + MACRONSupply = MACRONSupply + y; + BtcSupply = BtcSupply + a; AskRows = ui->AsksTable->rowCount(); ui->AsksTable->insertRow(AskRows); + ui->AsksTable->setItem(SellItteration, 0, new QTableWidgetItem(str.number(x,'i',8))); ui->AsksTable->setItem(SellItteration, 1, new QTableWidgetItem(str.number(y,'i',8))); ui->AsksTable->setItem(SellItteration, 2, new QTableWidgetItem(str.number(a,'i',8))); - ui->AsksTable->setItem(SellItteration, 3, new QTableWidgetItem(str.number(BtcSupply,'i',8))); SellItteration++; - } + } ui->BidsTable->setRowCount(0); - Q_FOREACH (const QJsonValue & value, BuyArray) + foreach (const QJsonValue & value, BuyArray) { obj = value.toObject(); @@ -502,26 +481,26 @@ void TradingDialogPage::ParseAndPopulateOrderBookTables(QString OrderBook){ double y = obj["Quantity"].toDouble(); double a = (x * y); - TXDemand += y; - BtcDemand += a; + MACRONDemand = MACRONDemand + y; + BtcDemand = BtcDemand + a; BidRows = ui->BidsTable->rowCount(); ui->BidsTable->insertRow(BidRows); - ui->BidsTable->setItem(BuyItteration, 0, new QTableWidgetItem(str.number(BtcDemand,'i',8))); - ui->BidsTable->setItem(BuyItteration, 1, new QTableWidgetItem(str.number(a,'i',8))); - ui->BidsTable->setItem(BuyItteration, 2, new QTableWidgetItem(str.number(y,'i',8))); - ui->BidsTable->setItem(BuyItteration, 3, new QTableWidgetItem(str.number(x,'i',8))); + ui->BidsTable->setItem(BuyItteration, 0, new QTableWidgetItem(str.number(a,'i',8))); + ui->BidsTable->setItem(BuyItteration, 1, new QTableWidgetItem(str.number(y,'i',8))); + ui->BidsTable->setItem(BuyItteration, 2, new QTableWidgetItem(str.number(x,'i',8))); BuyItteration++; - } + } - ui->TXSupply->setText("Supply: " + str.number(TXSupply,'i',8) + " EXCL"); - ui->BtcSupply->setText("" + str.number(BtcSupply,'i',8) + " BTC"); - ui->AsksCount->setText("Ask's : " + str.number(ui->AsksTable->rowCount()) + ""); + ui->MACRONSupply->setText("Supply: " + str.number(MACRONSupply,'i',8) + " MACRON"); + ui->BtcSupply->setText("" + str.number(BtcSupply,'i',8) + " BTC"); + ui->AsksCount->setText("Ask's : " + str.number(ui->AsksTable->rowCount()) + ""); - ui->TXDemand->setText("Demand: " + str.number(TXDemand,'i',8) + " EXCL"); - ui->BtcDemand->setText("" + str.number(BtcDemand,'i',8) + " BTC"); - ui->BidsCount->setText("Bid's : " + str.number(ui->BidsTable->rowCount()) + ""); - obj.empty(); + + ui->MACRONDemand->setText("Demand: " + str.number(MACRONDemand,'i',8) + " MACRON"); + ui->BtcDemand->setText("" + str.number(BtcDemand,'i',8) + " BTC"); + ui->BidsCount->setText("Bid's : " + str.number(ui->BidsTable->rowCount()) + ""); + obj.empty(); } @@ -533,7 +512,7 @@ void TradingDialogPage::ParseAndPopulateMarketHistoryTable(QString Response){ ui->MarketHistoryTable->setRowCount(0); - Q_FOREACH (const QJsonValue & value, jsonArray) + foreach (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); @@ -546,7 +525,7 @@ void TradingDialogPage::ParseAndPopulateMarketHistoryTable(QString Response){ ui->MarketHistoryTable->setItem(itteration, 2, new QTableWidgetItem(str.number(obj["Price"].toDouble(),'i',8))); ui->MarketHistoryTable->setItem(itteration, 3, new QTableWidgetItem(str.number(obj["Quantity"].toDouble(),'i',8))); ui->MarketHistoryTable->setItem(itteration, 4, new QTableWidgetItem(str.number(obj["Total"].toDouble(),'i',8))); - ui->MarketHistoryTable->item(itteration,1)->setBackgroundColor((obj["OrderType"] == QStringLiteral("BUY")) ? (QColor (150, 191, 70,255)) : ( QColor (201, 119, 153,255))); + ui->MarketHistoryTable->item(itteration,1)->setBackgroundColor((obj["OrderType"] == "BUY") ? (QColor (150, 191, 70,255)) : ( QColor (201, 119, 153,255))); itteration++; } obj.empty(); @@ -555,8 +534,6 @@ void TradingDialogPage::ParseAndPopulateMarketHistoryTable(QString Response){ void TradingDialogPage::ActionsOnSwitch(int index = -1){ QString Response = ""; - QString Response2 = ""; - QString Response3 = ""; if(index == -1){ index = ui->TradingTabWidget->currentIndex(); @@ -564,64 +541,77 @@ void TradingDialogPage::ActionsOnSwitch(int index = -1){ switch (index){ case 0: //buy tab is active + Response = GetMarketSummary(); + if(Response.size() > 0 && Response != "Error"){ + + QString balance = GetBalance("BTC"); - Response = GetBalance("BTC"); - Response2 = GetBalance("EXCL"); - Response3 = GetOrderBook(); + QString str; + QJsonObject ResultObject = GetResultObjectFromJSONObject(balance); - if((Response.size() > 0 && Response != "Error") && (Response2.size() > 0 && Response2 != "Error")){ - DisplayBalance(*ui->BtcAvailableLabel, *ui->TXAvailableLabel, Response, Response2); - } - if ((Response3.size() > 0 && Response3 != "Error")) { - ParseAndPopulateOrderBookTables(Response3); - } + ui->BtcAvailableLbl->setText(str.number(ResultObject["Available"].toDouble(),'i',8)); + } break; - case 1: //Cross send tab active - Response = GetBalance("EXCL"); - Response2 = GetBalance("BTC"); - if((Response.size() > 0 && Response != "Error") && (Response2.size() > 0 && Response2 != "Error")){ - DisplayBalance(*ui->BittrexTXLabel, *ui->BittrexBTCLabel, Response, Response2); - } + case 1: //sell tab active + //Sell tab is active + Response = GetMarketSummary(); + if(Response.size() > 0 && Response != "Error"){ + + QString balance = GetBalance("MACRON"); + QString str; + QJsonObject ResultObject = GetResultObjectFromJSONObject(balance); + + ui->MACRONAvailableLabel->setText(str.number(ResultObject["Available"].toDouble(),'i',8)); + } break; - case 2://market history tab - Response = GetMarketHistory(); - if(Response.size() > 0 && Response != "Error"){ - ParseAndPopulateMarketHistoryTable(Response); - } + case 2: //Order book tab is the current tab - update the info + Response = GetOrderBook(); + if(Response.size() > 0 && Response != "Error"){ + ParseAndPopulateOrderBookTables(Response); + } + break; - case 3: //open orders tab - Response = GetOpenOrders(); - if(Response.size() > 0 && Response != "Error"){ - ParseAndPopulateOpenOrdersTable(Response); - } + case 3://market history tab + Response = GetMarketHistory(); + if(Response.size() > 0 && Response != "Error"){ + ParseAndPopulateMarketHistoryTable(Response); + } + break; + + case 4: //open orders tab + Response = GetOpenOrders(); + if(Response.size() > 0 && Response != "Error"){ + ParseAndPopulateOpenOrdersTable(Response); + } break; - case 4://account history tab - Response = GetAccountHistory(); - if(Response.size() > 0 && Response != "Error"){ - ParseAndPopulateAccountHistoryTable(Response); - } + case 5://account history tab + Response = GetAccountHistory(); + if(Response.size() > 0 && Response != "Error"){ + ParseAndPopulateAccountHistoryTable(Response); + } break; - case 5://show balance tab - Response = GetBalance("BTC"); - if(Response.size() > 0 && Response != "Error"){ - DisplayBalance(*ui->BitcoinBalanceLabel,*ui->BitcoinAvailableLabel,*ui->BitcoinPendingLabel, QString::fromUtf8("BTC"),Response); - } + case 6://show balance tab + Response = GetBalance("BTC"); + if(Response.size() > 0 && Response != "Error"){ + DisplayBalance(*ui->BitcoinBalanceLabel,*ui->BitcoinAvailableLabel,*ui->BitcoinPendingLabel, QString::fromUtf8("BTC"),Response); + } + + Response = GetBalance("MACRON"); - Response = GetBalance("EXCL"); - if(Response.size() > 0 && Response != "Error"){ - DisplayBalance(*ui->TXBalanceLabel,*ui->TXAvailableLabel_2,*ui->TXPendingLabel, QString::fromUtf8("EXCL"),Response); - } + if(Response.size() > 0 && Response != "Error"){ + DisplayBalance(*ui->MACRONBalanceLabel,*ui->MACRONAvailableLabel,*ui->MACRONPendingLabel, QString::fromUtf8("MACRON"),Response); + } break; - case 6: + case 7: break; @@ -702,78 +692,20 @@ void TradingDialogPage::CalculateBuyCostLabel(){ double cost = ((price * Quantity) + ((price * Quantity / 100) * 0.25)); QString Str = ""; - ui->BuyCostLabel->setText("" + Str.number(cost,'i',8) + ""); + ui->BuyCostLabel->setText(Str.number(cost,'i',8)); } void TradingDialogPage::CalculateSellCostLabel(){ double price = ui->SellBidPriceEdit->text().toDouble(); - double Quantity = ui->UnitsInputTX->text().toDouble(); + double Quantity = ui->UnitsInputMACRON->text().toDouble(); double cost = ((price * Quantity) - ((price * Quantity / 100) * 0.25)); QString Str = ""; - ui->SellCostLabel->setText("" + Str.number(cost,'i',8) + ""); + ui->SellCostLabel->setText(Str.number(cost,'i',8)); } -void TradingDialogPage::CalculateCSReceiveLabel(){ - - //calculate amount of currency than can be exclusivecoinred to bitcoin - QString balance = GetBalance("EXCL"); - QString buyorders = GetOrderBook(); - - QJsonObject BuyObject = GetResultObjectFromJSONObject(buyorders); - QJsonObject BalanceObject = GetResultObjectFromJSONObject(balance); - QJsonObject obj; - - double AvailableTX = BalanceObject["Available"].toDouble(); - double Quantity = ui->CSUnitsInput->text().toDouble(); - double Received = 0; - double Qty = 0; - double Price = 0; - QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object - - // For each buy order - Q_FOREACH (const QJsonValue & value, BuyArray) - { - obj = value.toObject(); - - double x = obj["Rate"].toDouble(); //would like to use int64 here - double y = obj["Quantity"].toDouble(); - // If - if ( ((Quantity / x) - y) > 0 ) - { - Price = x; - Received += ((Price * y) - ((Price * y / 100) * 0.25)); - Qty += y; - Quantity -= ((Price * y) - ((Price * y / 100) * 0.25)); - } else { - Price = x; - Received += ((Price * (Quantity / x)) - ((Price * (Quantity / x) / 100) * 0.25)); - Qty += (Quantity / x); - Quantity -= 0; - break; - } - } - - QString ReceiveStr = ""; - QString DumpStr = ""; - QString TotalStr = ""; - if ( Qty < AvailableTX ) - { - ui->CSReceiveLabel->setText("" + ReceiveStr.number((ui->CSUnitsInput->text().toDouble() - 0.0002),'i',8) + ""); - ui->CSDumpLabel->setText("" + DumpStr.number(Price,'i',8) + ""); - ui->CSTotalLabel->setText("" + TotalStr.number(Qty,'i',8) + ""); - } else { - ReceiveStr = "N/A"; - TotalStr = "N/A"; - DumpStr = "N/A"; - ui->CSReceiveLabel->setText("" + ReceiveStr + ""); - ui->CSDumpLabel->setText("" + DumpStr + ""); - ui->CSTotalLabel->setText("" + TotalStr + ""); - } -} - -void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) +void TradingDialogPage::on_UpdateKeys_clicked() { this->ApiKey = ui->ApiKeyInput->text(); this->SecretKey = ui->SecretKeyInput->text(); @@ -784,131 +716,20 @@ void TradingDialogPage::on_UpdateKeys_clicked(bool Save, bool Load) if ( ResponseObject.value("success").toBool() == false){ QMessageBox::information(this,"API Configuration Failed","Api configuration was unsuccesful."); - }else if ( ResponseObject.value("success").toBool() == true && Load){ - QMessageBox::information(this,"API Configuration Complete","Your API keys have been loaded and the connection has been successfully configured and tested."); - ui->ApiKeyInput->setEchoMode(QLineEdit::Password); - ui->SecretKeyInput->setEchoMode(QLineEdit::Password); - ui->PasswordInput->setText(""); - ui->TradingTabWidget->setTabEnabled(0,true); - ui->TradingTabWidget->setTabEnabled(1,true); - ui->TradingTabWidget->setTabEnabled(3,true); - ui->TradingTabWidget->setTabEnabled(4,true); - ui->TradingTabWidget->setTabEnabled(5,true); - }else if ( ResponseObject.value("success").toBool() == true && Save){ - QMessageBox::information(this,"API Configuration Complete","Your API keys have been saved and the connection has been successfully configured and tested."); - ui->ApiKeyInput->setEchoMode(QLineEdit::Password); - ui->SecretKeyInput->setEchoMode(QLineEdit::Password); - ui->PasswordInput->setText(""); - ui->TradingTabWidget->setTabEnabled(0,true); - ui->TradingTabWidget->setTabEnabled(1,true); - ui->TradingTabWidget->setTabEnabled(3,true); - ui->TradingTabWidget->setTabEnabled(4,true); - ui->TradingTabWidget->setTabEnabled(5,true); - }else{ + }else if ( ResponseObject.value("success").toBool() == true){ QMessageBox::information(this,"API Configuration Complete","Api connection has been successfully configured and tested."); ui->ApiKeyInput->setEchoMode(QLineEdit::Password); ui->SecretKeyInput->setEchoMode(QLineEdit::Password); - ui->PasswordInput->setText(""); ui->TradingTabWidget->setTabEnabled(0,true); ui->TradingTabWidget->setTabEnabled(1,true); ui->TradingTabWidget->setTabEnabled(3,true); ui->TradingTabWidget->setTabEnabled(4,true); ui->TradingTabWidget->setTabEnabled(5,true); + ui->TradingTabWidget->setTabEnabled(6,true); } } -QString TradingDialogPage::encryptDecrypt(QString toEncrypt, QString password) { - - char * key = new char [password.size()+1]; - std::strcpy (key, password.c_str()); - key[password.size()] = '\0'; // don't forget the terminating 0 - - QString output = toEncrypt; - - for (unsigned int i = 0; i < toEncrypt.size(); i++) - output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; - return output; -} - -void TradingDialogPage::on_SaveKeys_clicked() -{ - bool fSuccess = true; - boost::filesystem::path pathConfigFile = GetDataDir() / "APIcache.txt"; - boost::filesystem::ofstream stream (pathConfigFile.string(), ios::out | ios::trunc); - - // Qstring to string - string password = ui->PasswordInput->text().toUtf8().constData(); - - if (password.length() <= 6){ - QMessageBox::information(this,"Error !","Your password is too short !"); - fSuccess = false; - stream.close(); - } - - // qstrings to utf8, add to byteArray and convert to const char for stream - string Secret = ui->SecretKeyInput->text().toUtf8().constData(); - string Key = ui->ApiKeyInput->text().toUtf8().constData(); - string ESecret = ""; - string EKey = ""; - - if (stream.is_open() && fSuccess) - { - ESecret = encryptDecrypt(Secret, password); - EKey = encryptDecrypt(Key, password); - stream << ESecret << '\n'; - stream << EKey; - stream.close(); - } - if (fSuccess) { - bool Save = true; - on_UpdateKeys_clicked(Save); - } - -} - -void TradingDialogPage::on_LoadKeys_clicked() -{ - bool fSuccess = true; - boost::filesystem::path pathConfigFile = GetDataDir() / "APIcache.txt"; - boost::filesystem::ifstream stream (pathConfigFile.string()); - - // Qstring to string - string password = ui->PasswordInput->text().toUtf8().constData(); - - if (password.length() <= 6){ - QMessageBox::information(this,"Error !","Your password is too short !"); - fSuccess = false; - stream.close(); - } - - QString DSecret = ""; - QString DKey = ""; - - if (stream.is_open() && fSuccess) - { - int i =0; - for ( std::string line; std::getline(stream,line); ) - { - if (i == 0 ){ - DSecret = QString::fromUtf8(encryptDecrypt(line, password).c_str()); - ui->SecretKeyInput->setText(DSecret); - } else if (i == 1){ - DKey = QString::fromUtf8(encryptDecrypt(line, password).c_str()); - ui->ApiKeyInput->setText(DKey); - } - i++; - } - stream.close(); - } - if (fSuccess) { - bool Save = false; - bool Load = true; - on_UpdateKeys_clicked(Save, Load); - } - -} - void TradingDialogPage::on_GenDepositBTN_clicked() { QString response = GetDepositAddress(); @@ -916,16 +737,17 @@ void TradingDialogPage::on_GenDepositBTN_clicked() ui->DepositAddressLabel->setText(ResultObject["Address"].toString()); } + void TradingDialogPage::on_Sell_Max_Amount_clicked() { - //calculate amount of BTC that can be gained from selling IC available balance - QString responseA = GetBalance("KONJ"); + //calculate amount of BTC that can be gained from selling MACRON available balance + QString responseA = GetBalance("MACRON"); QString str; QJsonObject ResultObject = GetResultObjectFromJSONObject(responseA); - double AvailableTX = ResultObject["Available"].toDouble(); + double AvailableMACRON = ResultObject["Available"].toDouble(); - ui->UnitsInputTX->setText(str.number(AvailableTX,'i',8)); + ui->UnitsInputMACRON->setText(str.number(AvailableMACRON,'i',8)); } void TradingDialogPage::on_Buy_Max_Amount_clicked() @@ -950,62 +772,21 @@ void TradingDialogPage::on_Buy_Max_Amount_clicked() ui->UnitsInput->setText(str.number(Result,'i',8)); } -void TradingDialogPage::on_CS_Max_Amount_clicked() +void TradingDialogPage::on_buyOrdertypeCombo_activated(const QString &arg1) { - double Quantity = ui->BittrexTXLabel->text().toDouble(); - double Received = 0; - double Qty = 0; - double Price = 0; - QString buyorders = GetOrderBook(); - QJsonObject BuyObject = GetResultObjectFromJSONObject(buyorders); - QJsonObject obj; - QString str; - - QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object - - // For each buy order - Q_FOREACH (const QJsonValue & value, BuyArray) - { - obj = value.toObject(); - - double x = obj["Rate"].toDouble(); //would like to use int64 here - double y = obj["Quantity"].toDouble(); - // If - if ( (Quantity - y) > 0 ) - { - Price = x; - Received += ((Price * y) - ((Price * y / 100) * 0.25)); - Qty += y; - Quantity -= y; - - } else { - Price = x; - Received += ((Price * Quantity) - ((Price * Quantity / 100) * 0.25)); - Qty += Quantity; - - if ((Quantity * x) < 0.00055){ - Quantity = (0.00055 / x); - } - - break; - } - } - - ui->CSUnitsInput->setText(str.number(Received,'i',8)); + if(arg1 == "Conditional"){ + //ui->BuyWhenPriceLabel->show(); + //ui->BuyConditionCombo->show(); + //ui->ConditionLineEdit->show(); + //ui->Conditionlabel->show(); + }else if (arg1 == "Limit"){ + // ui->BuyWhenPriceLabel->hide(); + // ui->BuyConditionCombo->hide(); + // ui->ConditionLineEdit->hide(); + // ui->Conditionlabel->hide(); + } } -void TradingDialogPage::on_Withdraw_Max_Amount_clicked() -{ - //calculate amount of currency than can be brought with the BTC balance available - QString responseA = GetBalance("EXCL"); - QString str; - - QJsonObject ResultObject = GetResultObjectFromJSONObject(responseA); - - double AvailableTX = ResultObject["Available"].toDouble(); - - ui->WithdrawUnitsInput->setText(str.number(AvailableTX,'i',8)); -} QJsonObject TradingDialogPage::GetResultObjectFromJSONObject(QString response){ @@ -1023,7 +804,7 @@ QJsonObject TradingDialogPage::GetResultObjectFromJSONArray(QString response){ QJsonArray jsonArraya = jsonObjecta["result"].toArray(); QJsonObject obj; - Q_FOREACH (const QJsonValue & value, jsonArraya) + foreach (const QJsonValue & value, jsonArraya) { obj = value.toObject(); } @@ -1050,15 +831,14 @@ QString TradingDialogPage::HMAC_SHA512_SIGNER(QString UrlToSign, QString Secret) QByteArray byteArrayB = Secret.toUtf8(); const char* Secretkey = byteArrayB.constData(); - const EVP_MD *md = EVP_sha512(); - unsigned char* digest = NULL; + unsigned char* digest; // Using sha512 hash engine here. - digest = HMAC(md, Secretkey, strlen( Secretkey), (unsigned char*) URL, strlen( URL), NULL, NULL); + digest = HMAC(EVP_sha512(), Secretkey, strlen( Secretkey), (unsigned char*) URL, strlen( URL), NULL, NULL); // Be careful of the length of string with the choosen hash engine. SHA1 produces a 20-byte hash value which rendered as 40 characters. // Change the length accordingly with your choosen hash engine - char mdString[129] = { 0 }; + char mdString[128]; for(int i = 0; i < 64; i++){ sprintf(&mdString[i*2], "%02x", (unsigned int)digest[i]); @@ -1093,7 +873,7 @@ void TradingDialogPage::on_BuyBidcomboBox_currentIndexChanged(const QString &arg CalculateBuyCostLabel(); //update cost } -void TradingDialogPage::on_BuyTX_clicked() +void TradingDialogPage::on_BuyMACRON_clicked() { double Rate; double Quantity; @@ -1101,229 +881,102 @@ void TradingDialogPage::on_BuyTX_clicked() Rate = ui->BuyBidPriceEdit->text().toDouble(); Quantity = ui->UnitsInput->text().toDouble(); - QString OrderType = "Limit"; + QString OrderType = ui->buyOrdertypeCombo->currentText(); QString Order; if(OrderType == "Limit"){Order = "buylimit";}else if (OrderType == "Market"){ Order = "buymarket";} QString Msg = "Are you sure you want to buy "; Msg += ui->UnitsInput->text(); - Msg += "EXCL @ "; + Msg += "MACRON @ "; Msg += ui->BuyBidPriceEdit->text(); Msg += " BTC Each"; - QMessageBox::StandardButton reply; + QMessageBox::StandardButton reply; reply = QMessageBox::question(this,"Buy Order",Msg,QMessageBox::Yes|QMessageBox::No); - if (reply == QMessageBox::Yes) { + if (reply == QMessageBox::Yes) { - QString Response = BuyTX(Order,Quantity,Rate); + QString Response = BuyMACRON(Order,Quantity,Rate); - QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. - QJsonObject ResponseObject = jsonResponse.object(); //get json obj + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj - if (ResponseObject["success"].toBool() == false){ - QMessageBox::information(this,"Buy Order Failed",ResponseObject["message"].toString()); + if (ResponseObject["success"].toBool() == false){ - }else if (ResponseObject["success"].toBool() == true){ - QMessageBox::information(this,"Buy Order Initiated","You Placed an order"); - } - }else{ - //do nothing - } + QMessageBox::information(this,"Buy Order Failed",ResponseObject["message"].toString()); + + }else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Buy Order Initiated","You Placed an order"); + } + }else{ + + //do nothing + } } -void TradingDialogPage::on_SellTXBTN_clicked() +void TradingDialogPage::on_SellMACRONBTN_clicked() { double Rate; double Quantity; Rate = ui->SellBidPriceEdit->text().toDouble(); - Quantity = ui->UnitsInputTX->text().toDouble(); + Quantity = ui->UnitsInputMACRON->text().toDouble(); - QString OrderType = "Limit"; + QString OrderType = ui->SellOrdertypeCombo->currentText(); QString Order; if(OrderType == "Limit"){Order = "selllimit";}else if (OrderType == "Market"){ Order = "sellmarket";} QString Msg = "Are you sure you want to Sell "; - Msg += ui->UnitsInputTX->text(); - Msg += " EXCL @ "; + Msg += ui->UnitsInputMACRON->text(); + Msg += " MACRON @ "; Msg += ui->SellBidPriceEdit->text(); Msg += " BTC Each"; - QMessageBox::StandardButton reply; + QMessageBox::StandardButton reply; reply = QMessageBox::question(this,"Sell Order",Msg,QMessageBox::Yes|QMessageBox::No); - if (reply == QMessageBox::Yes) { - - QString Response = SellTX(Order,Quantity,Rate); - QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. - QJsonObject ResponseObject = jsonResponse.object(); //get json obj - - if (ResponseObject["success"].toBool() == false){ - QMessageBox::information(this,"Sell Order Failed",ResponseObject["message"].toString()); - - }else if (ResponseObject["success"].toBool() == true){ - QMessageBox::information(this,"Sell Order Initiated","You Placed an order"); - } - }else{ - //do nothing - } -} + if (reply == QMessageBox::Yes) { -void TradingDialogPage::on_CSUnitsBtn_clicked() -{ - double Quantity = ui->CSUnitsInput->text().toDouble(); - double Rate = ui->CSDumpLabel->text().toDouble(); - double Received = 0; - double Qty = 0; - double Price = 0; - double Add = 0; - - QString buyorders = GetOrderBook(); - QJsonObject BuyObject = GetResultObjectFromJSONObject(buyorders); - QJsonObject obj; - QString Astr; - QString Qstr; - QString Rstr; - QString Coin = "BTC"; - QString Msg = "Are you sure you want to Send "; - Msg += Qstr.number((Quantity - 0.0002),'i',8); - Msg += " BTC to "; - Msg += ui->CSUnitsAddress->text(); - Msg += ", DUMPING your coins at "; - Msg += Rstr.number(Rate,'i',8); - Msg += " satoshis ?"; - - QMessageBox::StandardButton reply; - reply = QMessageBox::question(this,"Cross-Send",Msg,QMessageBox::Yes|QMessageBox::No); - - if(reply != QMessageBox::Yes) - { - return; - } + QString Response = SellMACRON(Order,Quantity,Rate); + QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. + QJsonObject ResponseObject = jsonResponse.object(); //get json obj - WalletModel::UnlockContext ctx(model->requestUnlock()); - if(!ctx.isValid()) - { - // Unlock wallet was cancelled - return; - } + if (ResponseObject["success"].toBool() == false){ - QString Order = "selllimit"; - QJsonArray BuyArray = BuyObject.value("buy").toArray(); //get buy/sell object from result object + QMessageBox::information(this,"Sell Order Failed",ResponseObject["message"].toString()); - // For each buy order - Q_FOREACH (const QJsonValue & value, BuyArray) - { - obj = value.toObject(); + }else if (ResponseObject["success"].toBool() == true){ + QMessageBox::information(this,"Sell Order Initiated","You Placed an order"); + } +}else{ - double x = obj["Rate"].toDouble(); //would like to use int64 here - double y = obj["Quantity"].toDouble(); - // If - if ( ((Quantity / x) - y) > 0 ) - { - Price = x; - Received += ((Price * y) - ((Price * y / 100) * 0.25)); - Qty += y; - Quantity -= ((Price * y) - ((Price * y / 100) * 0.25)); - - QString SellResponse = SellTX(Order,y,x); - QJsonDocument SelljsonResponse = QJsonDocument::fromJson(SellResponse.toUtf8()); //get json from str. - QJsonObject SellResponseObject = SelljsonResponse.object(); //get json obj - - if (SellResponseObject["success"].toBool() == false){ - if (SellResponseObject["message"].toString() == "DUST_TRADE_DISALLOWED_MIN_VALUE_50K_SAT"){ - Add += y; - continue; - } - QMessageBox::information(this,"sFailed",SellResponse); - break; - } - MilliSleep(100); - - } else { - Price = x; - Received += ((Price * (Quantity / x)) - ((Price * (Quantity / x) / 100) * 0.25)); - Qty += (Quantity / x); - if (Add > 0) - Quantity += (Add * x); - if (Quantity < 0.00051){ - Quantity = 0.00051; - } - QString SellResponse = SellTX(Order,(Quantity / x),x); - QJsonDocument SelljsonResponse = QJsonDocument::fromJson(SellResponse.toUtf8()); //get json from str. - QJsonObject SellResponseObject = SelljsonResponse.object(); //get json obj - - if (SellResponseObject["success"].toBool() == false){ - QMessageBox::information(this,"sFailed",SellResponse); - - } else if (SellResponseObject["success"].toBool() == true){ - MilliSleep(5000); - QString Response = Withdraw(ui->CSUnitsInput->text().toDouble(),ui->CSUnitsAddress->text(),Coin); - QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. - QJsonObject ResponseObject = jsonResponse.object(); //get json obj - - if (ResponseObject["success"].toBool() == false){ - MilliSleep(5000); - QString Response = Withdraw(ui->CSUnitsInput->text().toDouble(),ui->CSUnitsAddress->text(),Coin); - QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. - QJsonObject ResponseObject = jsonResponse.object(); - - if (ResponseObject["success"].toBool() == false){ - QMessageBox::information(this,"Failed",ResponseObject["message"].toString()); - } else if (ResponseObject["success"].toBool() == true){ - QMessageBox::information(this,"Success","
Cross-Send Successful
\n Sold "+Astr.number(Qty,'i',4)+" EXCL for "+Qstr.number((ui->CSUnitsInput->text().toDouble()-0.0002),'i',8)+" BTC"); - } - } else if (ResponseObject["success"].toBool() == true){ - QMessageBox::information(this,"Success","
Cross-Send Successful
\n Sold "+Astr.number(Qty,'i',4)+" EXCL for "+Qstr.number((ui->CSUnitsInput->text().toDouble()-0.0002),'i',8)+" BTC"); - } - } - break; - } - } + //do nothing + } } -void TradingDialogPage::on_WithdrawUnitsBtn_clicked() -{ - double Quantity = ui->WithdrawUnitsInput->text().toDouble(); - QString Qstr; - QString Coin = "EXCL"; - QString Msg = "Are you sure you want to Withdraw "; - Msg += Qstr.number((Quantity - 0.02),'i',8); - Msg += " EXCL to "; - Msg += ui->WithdrawAddress->text(); - Msg += " ?"; - - QMessageBox::StandardButton reply; - reply = QMessageBox::question(this,"Withdraw",Msg,QMessageBox::Yes|QMessageBox::No); - - if(reply != QMessageBox::Yes) - { - return; - } - - WalletModel::UnlockContext ctx(model->requestUnlock()); - if(!ctx.isValid()) - { - // Unlock wallet was cancelled - return; - } - - QString Response = Withdraw(Quantity, ui->WithdrawAddress->text(), Coin); - QJsonDocument jsonResponse = QJsonDocument::fromJson(Response.toUtf8()); //get json from str. - QJsonObject ResponseObject = jsonResponse.object(); //get json obj - if (ResponseObject["success"].toBool() == false){ - QMessageBox::information(this,"Failed",ResponseObject["message"].toString()); +void TradingDialogPage::on_AdvancedView_stateChanged(int arg1) +{ + //Show or hide columns in OpenOrders Table depending on checkbox state + if(arg1 == 2){ + ui->OpenOrdersTable->setColumnHidden(9,false); + ui->OpenOrdersTable->setColumnHidden(10,false); + ui->OpenOrdersTable->setColumnHidden(11,false); + ui->OpenOrdersTable->setColumnHidden(12,false); + ui->OpenOrdersTable->setColumnHidden(13,false); + }else if(arg1 == 0) { + ui->OpenOrdersTable->setColumnHidden(9,true); + ui->OpenOrdersTable->setColumnHidden(10,true); + ui->OpenOrdersTable->setColumnHidden(11,true); + ui->OpenOrdersTable->setColumnHidden(12,true); + ui->OpenOrdersTable->setColumnHidden(13,true); - }else if (ResponseObject["success"].toBool() == true){ - QMessageBox::information(this,"Success","Withdrawal Successful !"); - } + } } -void TradingDialogPage::on_UnitsInputTX_textChanged(const QString &arg1) +void TradingDialogPage::on_UnitsInputMACRON_textChanged(const QString &arg1) { CalculateSellCostLabel(); //update cost } @@ -1343,51 +996,6 @@ void TradingDialogPage::on_SellBidPriceEdit_textChanged(const QString &arg1) CalculateSellCostLabel(); } -void TradingDialogPage::on_CSUnitsInput_textChanged(const QString &arg1) -{ - CalculateCSReceiveLabel(); //update cost -} - -void TradingDialogPage::on_CSPasteButton_clicked() -{ - // Paste text from clipboard into recipient field - ui->CSUnitsAddress->setText(QApplication::clipboard()->text()); -} - -void TradingDialogPage::on_WithdrawPasteButton_clicked() -{ - // Paste text from clipboard into recipient field - ui->WithdrawAddress->setText(QApplication::clipboard()->text()); -} - -void TradingDialogPage::on_SecretPasteButton_clicked() -{ - // Paste text from clipboard into recipient field - ui->SecretKeyInput->setText(QApplication::clipboard()->text()); -} - -void TradingDialogPage::on_KeyPasteButton_clicked() -{ - // Paste text from clipboard into recipient field - ui->ApiKeyInput->setText(QApplication::clipboard()->text()); -} - -void setClipboard(const QString& str) -{ - QApplication::clipboard()->setText(str, QClipboard::Clipboard); - QApplication::clipboard()->setText(str, QClipboard::Selection); -} - -void TradingDialogPage::on_DepositCopyButton_clicked() -{ - setClipboard(ui->DepositAddressLabel->text()); -} - -void TradingDialogPage::setModel(WalletModel *model) -{ - this->model = model; -} - TradingDialogPage::~TradingDialogPage() { delete ui; From 37584f43ae30cfd1b4741020fa0888eca6406a81 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 02:44:35 -0400 Subject: [PATCH 404/469] Update tradingdialogpage.h --- src/qt/tradingdialogpage.h | 54 +++++++++----------------------------- 1 file changed, 12 insertions(+), 42 deletions(-) diff --git a/src/qt/tradingdialogpage.h b/src/qt/tradingdialogpage.h index d31d432b..a86110bd 100644 --- a/src/qt/tradingdialogpage.h +++ b/src/qt/tradingdialogpage.h @@ -1,4 +1,3 @@ - #ifndef TRADINGDIALOGPAGE_H #define TRADINGDIALOGPAGE_H @@ -6,11 +5,6 @@ #include #include #include "ui_tradingdialogpage.h" -#include "clientmodel.h" -#include "walletmodel.h" - -#include -#include #include #include @@ -18,7 +12,6 @@ namespace Ui { class TradingDialogPage; } -class WalletModel; class TradingDialogPage : public QDialog { @@ -27,9 +20,7 @@ class TradingDialogPage : public QDialog public: explicit TradingDialogPage(QWidget *parent = 0); ~TradingDialogPage(); - - void setModel(WalletModel *model); - + private Q_SLOTS: void InitTrading(); @@ -40,51 +31,32 @@ private Q_SLOTS: void ParseAndPopulateOpenOrdersTable(QString Response); void UpdaterFunction(); void CreateOrderBookTables(QTableWidget& Table,QStringList TableHeader); + void CalculateBuyCostLabel(); + void CalculateSellCostLabel(); void DisplayBalance(QLabel &BalanceLabel,QLabel &Available, QLabel &Pending, QString Currency,QString Response); - void DisplayBalance(QLabel &BalanceLabel, QLabel &BalanceLabel2, QString Response, QString Response2); - void DisplayBalance(QLabel &BalanceLabel, QString Response); void ActionsOnSwitch(int index); void CancelOrderSlot(int row, int col); - void on_UpdateKeys_clicked(bool Save=false, bool Load=false); - void on_LoadKeys_clicked(); - void on_SaveKeys_clicked(); + void on_UpdateKeys_clicked(); void on_GenDepositBTN_clicked(); - - void CalculateBuyCostLabel(); void on_Buy_Max_Amount_clicked(); + void on_buyOrdertypeCombo_activated(const QString &arg1); void on_BuyBidcomboBox_currentIndexChanged(const QString &arg1); void on_UnitsInput_textChanged(const QString &arg1); void on_BuyBidPriceEdit_textChanged(const QString &arg1); - void on_BuyTX_clicked(); - - void CalculateSellCostLabel(); - void on_Sell_Max_Amount_clicked(); + void on_BuyMACRON_clicked(); + void on_SellMACRONBTN_clicked(); void on_SellBidcomboBox_currentIndexChanged(const QString &arg1); - void on_UnitsInputTX_textChanged(const QString &arg1); + void on_Sell_Max_Amount_clicked(); + void on_UnitsInputMACRON_textChanged(const QString &arg1); void on_SellBidPriceEdit_textChanged(const QString &arg1); - void on_SellTXBTN_clicked(); - - void CalculateCSReceiveLabel(); - void on_CSUnitsInput_textChanged(const QString &arg1); - void on_CSUnitsBtn_clicked(); - void on_CS_Max_Amount_clicked(); - - void on_Withdraw_Max_Amount_clicked(); - void on_WithdrawUnitsBtn_clicked(); - - void on_KeyPasteButton_clicked(); - void on_SecretPasteButton_clicked(); - void on_CSPasteButton_clicked(); - void on_WithdrawPasteButton_clicked(); - void on_DepositCopyButton_clicked(); + void on_AdvancedView_stateChanged(int arg1); int SetExchangeInfoTextLabels(); QString BittrexTimeStampToReadable(QString DateTime); QString CancelOrder(QString Orderid); - QString BuyTX(QString OrderType, double Quantity, double Rate); - QString SellTX(QString OrderType, double Quantity, double Rate); - QString Withdraw(double Amount, QString Address, QString Coin); + QString BuyMACRON(QString OrderType, double Quantity, double Rate); + QString SellMACRON(QString OrderType, double Quantity, double Rate); QString GetMarketHistory(); QString GetMarketSummary(); QString GetOrderBook(); @@ -94,7 +66,6 @@ private Q_SLOTS: QString GetDepositAddress(); QString HMAC_SHA512_SIGNER(QString UrlToSign,QString Secretkey); QString sendRequest(QString url); - QString encryptDecrypt(QString toEncrypt, QString password); QJsonObject GetResultObjectFromJSONObject(QString response); QJsonObject GetResultObjectFromJSONArray(QString response); QJsonArray GetResultArrayFromJSONObject(QString response); @@ -109,7 +80,6 @@ public Q_SLOTS: QTimer *timer; QString ApiKey; QString SecretKey; - WalletModel *model; }; From 54169743465561681a3ce5d79e82c80bd315ae8c Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 02:45:26 -0400 Subject: [PATCH 405/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index 048673f1..dd7967da 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -1,5 +1,5 @@ -#include "tradingdialog.h" -#include "ui_tradingdialog.h" +#include "tradingdialogpage.h" +#include "ui_tradingdialogpage.h" #include #include From aca419b0d9a1696ebd301c37e8cb3a8c4c4c5e12 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 02:48:37 -0400 Subject: [PATCH 406/469] Update tradingdialogpage.cpp --- src/qt/tradingdialogpage.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qt/tradingdialogpage.cpp b/src/qt/tradingdialogpage.cpp index dd7967da..d0bdca29 100644 --- a/src/qt/tradingdialogpage.cpp +++ b/src/qt/tradingdialogpage.cpp @@ -58,7 +58,7 @@ TradingDialogPage::TradingDialogPage(QWidget *parent) : int Cellwidth = ui->MarketHistoryTable->width() / 5; - ui->MarketHistoryTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + ui->MarketHistoryTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); ui->MarketHistoryTable->horizontalHeader()->resizeSection(1,Cellwidth); // column 1, width 50 ui->MarketHistoryTable->horizontalHeader()->resizeSection(2,Cellwidth); @@ -289,7 +289,7 @@ void TradingDialogPage::CreateOrderBookTables(QTableWidget& Table,QStringList Ta Table.setRowCount(0); - Table.horizontalHeader()->setResizeMode(QHeaderView::Stretch); + Table.horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); Table.horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); Table.horizontalHeader()->setStyleSheet("QHeaderView::section, QHeaderView::section * { font-weight :bold;}"); } @@ -319,7 +319,7 @@ void TradingDialogPage::ParseAndPopulateOpenOrdersTable(QString Response){ ui->OpenOrdersTable->setRowCount(0); - foreach (const QJsonValue & value, jsonArray) + Q_FOREACH (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); @@ -397,7 +397,7 @@ void TradingDialogPage::ParseAndPopulateAccountHistoryTable(QString Response){ ui->TradeHistoryTable->setRowCount(0); - foreach (const QJsonValue & value, jsonArray) + Q_FOREACH (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); @@ -451,7 +451,7 @@ void TradingDialogPage::ParseAndPopulateOrderBookTables(QString OrderBook){ ui->AsksTable->setRowCount(0); - foreach (const QJsonValue & value, SellArray) + Q_FOREACH (const QJsonValue & value, SellArray) { obj = value.toObject(); @@ -473,7 +473,7 @@ void TradingDialogPage::ParseAndPopulateOrderBookTables(QString OrderBook){ ui->BidsTable->setRowCount(0); - foreach (const QJsonValue & value, BuyArray) + Q_FOREACH (const QJsonValue & value, BuyArray) { obj = value.toObject(); @@ -512,7 +512,7 @@ void TradingDialogPage::ParseAndPopulateMarketHistoryTable(QString Response){ ui->MarketHistoryTable->setRowCount(0); - foreach (const QJsonValue & value, jsonArray) + Q_FOREACH (const QJsonValue & value, jsonArray) { QString str = ""; obj = value.toObject(); @@ -804,7 +804,7 @@ QJsonObject TradingDialogPage::GetResultObjectFromJSONArray(QString response){ QJsonArray jsonArraya = jsonObjecta["result"].toArray(); QJsonObject obj; - foreach (const QJsonValue & value, jsonArraya) + Q_FOREACH (const QJsonValue & value, jsonArraya) { obj = value.toObject(); } From 1f8586aa74992b0919df7cee911a0875e69abdcb Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:08:19 -0400 Subject: [PATCH 407/469] Create chatwindow.cpp --- src/qt/chatwindow.cpp | 215 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 src/qt/chatwindow.cpp diff --git a/src/qt/chatwindow.cpp b/src/qt/chatwindow.cpp new file mode 100644 index 00000000..d00e2407 --- /dev/null +++ b/src/qt/chatwindow.cpp @@ -0,0 +1,215 @@ +/*Copyright (C) 2009 Cleriot Simon +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ + +#include "chatwindow.h" +#include "ui_chatwindow.h" + +ChatWindow::ChatWindow(QWidget *parent) + : QWidget(parent), ui(new Ui::ChatWindowClass) +{ + ui->setupUi(this); + setFixedSize(750,600); + ui->splitter->hide(); + + connect(ui->buttonConnect, SIGNAL(clicked()), this, SLOT(connecte())); + + connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close())); + connect(ui->actionCloseTab, SIGNAL(triggered()), this, SLOT(closeTab())); + + connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(sendCommande())); + + + + + + connect(ui->disconnect, SIGNAL(clicked()), this, SLOT(disconnectFromServer())); + connect(ui->tab, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)) ); + connect(ui->tab, SIGNAL(tabCloseRequested(int)), this, SLOT(tabClosing(int)) ); + +} + + + +void ChatWindow::tabChanged(int index) +{ + if(index!=0 && joining == false) + currentTab()->updateUsersList(ui->tab->tabText(index)); +} + +void ChatWindow::tabClosing(int index) +{ + currentTab()->leave(ui->tab->tabText(index)); +} +/*void ChatWindow::tabRemoved(int index) +{ + currentTab()->leave(ui->tab->tabText(index)); +}*/ + +void ChatWindow::disconnectFromServer() { + + QMapIterator i(serveurs); + + while(i.hasNext()) + { + i.next(); + QMapIterator i2(i.value()->conversations); + while(i2.hasNext()) + { + i2.next(); + i.value()->sendData("QUIT "+i2.key() + " "); + } + } + + + ui->splitter->hide(); + ui->hide3->show(); + +} + +Serveur *ChatWindow::currentTab() +{ + QString tooltip=ui->tab->tabToolTip(ui->tab->currentIndex()); + return serveurs[tooltip]; + //return ui->tab->currentWidget()->findChild(); +} + +void ChatWindow::closeTab() +{ + QString tooltip=ui->tab->tabToolTip(ui->tab->currentIndex()); + QString txt=ui->tab->tabText(ui->tab->currentIndex()); + + if(txt==tooltip) + { + QMapIterator i(serveurs[tooltip]->conversations); + + int count=ui->tab->currentIndex()+1; + + while(i.hasNext()) + { + i.next(); + ui->tab->removeTab(count); + } + + currentTab()->abort(); + ui->tab->removeTab(ui->tab->currentIndex()); + } + else + { + + ui->tab->removeTab(ui->tab->currentIndex()); + currentTab()->conversations.remove(txt); + } +} + +void ChatWindow::sendCommande() +{ + QString tooltip=ui->tab->tabToolTip(ui->tab->currentIndex()); + QString txt=ui->tab->tabText(ui->tab->currentIndex()); + if(txt==tooltip) + { + currentTab()->sendData(currentTab()->parseCommande(ui->lineEdit->text(),true) ); + } + else + { + currentTab()->sendData(currentTab()->parseCommande(ui->lineEdit->text()) ); + } + ui->lineEdit->clear(); + ui->lineEdit->setFocus(); +} + +void ChatWindow::tabJoined() +{ + joining=true; +} +void ChatWindow::tabJoining() +{ + joining=false; +} + +void ChatWindow::connecte() +{ + + ui->splitter->show(); + Serveur *serveur=new Serveur; + QTextEdit *textEdit=new QTextEdit; + ui->hide3->hide(); + + ui->tab->addTab(textEdit,"Console/PM"); + ui->tab->setTabToolTip(ui->tab->count()-1,"irc.freenode.net"); + // current tab is now the last, therefore remove all but the last + for (int i = ui->tab->count(); i > 1; --i) { + ui->tab->removeTab(0); + } + + serveurs.insert("irc.freenode.net",serveur); + + serveur->pseudo=ui->editPseudo->text(); + serveur->serveur="irc.freenode.net"; + serveur->port=6667; + serveur->affichage=textEdit; + serveur->tab=ui->tab; + serveur->userList=ui->userView; + serveur->parent=this; + + textEdit->setReadOnly(true); + + connect(serveur, SIGNAL(joinTab()),this, SLOT(tabJoined() )); + connect(serveur, SIGNAL(tabJoined()),this, SLOT(tabJoining() )); + + serveur->connectToHost("irc.freenode.net",6667); + + ui->tab->setCurrentIndex(ui->tab->count()-1); +} + +void ChatWindow::closeEvent(QCloseEvent *event) +{ + (void) event; + + QMapIterator i(serveurs); + + while(i.hasNext()) + { + i.next(); + QMapIterator i2(i.value()->conversations); + while(i2.hasNext()) + { + i2.next(); + i.value()->sendData("QUIT "+i2.key() + " "); + } + } +} +void ChatWindow ::setModel(ClientModel *model) +{ + this->model = model; +} + + +ChatWindow::~ChatWindow() +{ + delete ui; + QMapIterator i(serveurs); + + while(i.hasNext()) + { + i.next(); + QMapIterator i2(i.value()->conversations); + while(i2.hasNext()) + { + i2.next(); + i.value()->sendData("QUIT "+i2.key() + " "); + } + } +} From 98069465c8972e3d3a1158c85726ce37ff62ac41 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:08:45 -0400 Subject: [PATCH 408/469] Create chatwindow.h --- src/qt/chatwindow.h | 66 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/qt/chatwindow.h diff --git a/src/qt/chatwindow.h b/src/qt/chatwindow.h new file mode 100644 index 00000000..c6dada4c --- /dev/null +++ b/src/qt/chatwindow.h @@ -0,0 +1,66 @@ +/*Copyright (C) 2009 Cleriot Simon +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ + +#ifndef CHATWINDOW_H +#define CHATWINDOW_H + +#include +#include +#include "clientmodel.h" +#include "serveur.h" + + + +namespace Ui +{ + class ChatWindowClass; +} + +class ChatWindow : public QWidget +{ + Q_OBJECT + +public: + ChatWindow(QWidget *parent = 0); + ~ChatWindow(); + void setModel(ClientModel *model); + Serveur * currentTab(); + signals: + void changeTab(); + + public slots: + void sendCommande(); + void connecte(); + void closeTab(); + + void tabChanged(int index); + + void tabJoined(); + void tabJoining(); + void disconnectFromServer(); + void tabClosing(int index); + + +private: + Ui::ChatWindowClass *ui; + ClientModel *model; + QMap serveurs; + bool joining; + void closeEvent(QCloseEvent *event); + +}; + +#endif // CHATWINDOW_H From 1b18c096a43ac24be4992b7bb80664fde6c184f1 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:10:22 -0400 Subject: [PATCH 409/469] Create serveur.cpp --- src/qt/serveur.cpp | 359 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 359 insertions(+) create mode 100644 src/qt/serveur.cpp diff --git a/src/qt/serveur.cpp b/src/qt/serveur.cpp new file mode 100644 index 00000000..d077b4d3 --- /dev/null +++ b/src/qt/serveur.cpp @@ -0,0 +1,359 @@ +/*Copyright (C) 2009 Cleriot Simon +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ +#include +#include "serveur.h" + QStringList users; + bool delist = true; +Serveur::Serveur() +{ + connect(this, SIGNAL(readyRead()), this, SLOT(readServeur())); + connect(this, SIGNAL(connected()), this, SLOT(connected())); + connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(errorSocket(QAbstractSocket::SocketError))); + + updateUsers=false; +} + + + + +void Serveur::errorSocket(QAbstractSocket::SocketError error) +{ + switch(error) + { + case QAbstractSocket::HostNotFoundError: + affichage->append(tr("ERROR : can't find HTHWorld server.")); + break; + case QAbstractSocket::ConnectionRefusedError: + affichage->append(tr("ERROR : server refused connection")); + break; + case QAbstractSocket::RemoteHostClosedError: + affichage->append(tr("ERROR : server cut connection")); + break; + default: + affichage->append(tr("ERROR : ") + this->errorString() + tr("")); + } +} + +void Serveur::connected() +{ + affichage->append("Connecting... to HTHWorld IRC. Please wait."); + + sendData("USER "+pseudo+" localhost "+serveur+" :"+pseudo); + sendData("NICK "+pseudo); + affichage->append("Connected to HTHWorld IRC."); + +} + +void Serveur::joins() +{ + join("#HTHWorld"); +} + +void Serveur::readServeur() +{ + QString message=QString::fromUtf8(this->readAll()); + + + QString currentChan=tab->tabText(tab->currentIndex()); + + if(message.startsWith("PING :")) + { + QStringList liste=message.split(" "); + QString msg="PONG "+liste.at(1); + sendData(msg); + } + else if(message.contains("Nickname is already in use.")) + { + pseudo=pseudo+"_2"; + pseudo.remove("\r\n"); + sendData("NICK "+pseudo); + emit pseudoChanged(pseudo); + ecrire("-> Name changed to "+pseudo); + } + else if(updateUsers==true) + { + updateUsersList("",message); + } + + QStringList list=message.split("\r\n"); + foreach(QString msg,list) + { + if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ PRIVMSG ([a-zA-Z0-9\\#]+) :(.+)"))) + { + QRegExp reg(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ PRIVMSG ([a-zA-Z0-9\\#]+) :(.+)"); + QString msg2=msg; + ecrire(msg.replace(reg,"\\2 <\\1> \\3"),"",msg2.replace(reg,"\\2 <\\1> \\3")); + } + else if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ JOIN ([a-zA-Z0-9\\#]+)"))) + { + QRegExp reg(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ JOIN ([a-zA-Z0-9\\#]+)"); + QString msg2=msg; + ecrire(msg.replace(reg,"\\2 -> \\1 join \\2
"),"",msg2.replace(reg,"-> \\1 join \\2")); + updateUsersList(msg.replace(reg,"\\2")); + } + else if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ PART ([a-zA-Z0-9\\#]+)"))) + { + QRegExp reg(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ PART ([a-zA-Z0-9\\#]+) :(.+)"); + QString msg2=msg; + ecrire(msg.replace(reg,"\\2 -> \\1 quit \\2 (\\3)
"),"",msg2.replace(reg,"-> \\1 quit \\2")); + updateUsersList(msg.replace(reg,"\\2")); + } + else if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ QUIT (.+)"))) + { + QRegExp reg(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ QUIT (.+)"); + QString msg2=msg; + ecrire(msg.replace(reg,"\\2 -> \\1 quit this server (\\2)
"),"",msg2.replace(reg,"-> \\1 left")); + updateUsersList(msg.replace(reg,"\\2")); + } + else if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NICK :(.+)"))) + { + QRegExp reg(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NICK :(.+)"); + QString msg2=msg; + ecrire(msg.replace(reg,"\\1 is now called \\2
"),"",msg2.replace(reg,"-> \\1 is now called \\2")); + updateUsersList(currentChan); + } + else if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ KICK ([a-zA-Z0-9\\#]+) ([a-zA-Z0-9]+) :(.+)"))) + { + QRegExp reg(":([a-zA-Z0-9]+)\\!~[a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ KICK ([a-zA-Z0-9\\#]+) ([a-zA-Z0-9]+) :(.+)"); + QString msg2=msg; + ecrire(msg.replace(reg,"\\2 -> \\1 kicked \\3 (\\4)
"),"",msg2.replace(reg,"-> \\1 quit \\3")); + updateUsersList(msg.replace(reg,"\\2")); + } + else if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NOTICE ([a-zA-Z0-9]+) :(.+)"))) + { + if(conversations.contains(currentChan)) + { + QRegExp reg(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NOTICE [a-zA-Z0-9]+ :(.+)"); + ecrire(msg.replace(reg,"[NOTICE] \\1 : \\2
"),currentChan); + } + else if(currentChan==serveur) + { + QRegExp reg(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ NOTICE [a-zA-Z0-9]+ :(.+)"); + ecrire(msg.replace(reg,"[NOTICE] \\1 : \\2
")); + } + } + else if(msg.contains("/MOTD command.")) + { + joins(); + + + } + + + + } + + //} +} + +void Serveur::sendData(QString txt) +{ + if(this->state()==QAbstractSocket::ConnectedState) + { + this->write((txt+"\r\n").toUtf8()); + } +} + +QString Serveur::parseCommande(QString comm,bool serveur) +{ + if(comm.startsWith("/")) + { + comm.remove(0,1); + QString pref=comm.split(" ").first(); + QStringList args=comm.split(" "); + args.removeFirst(); + QString destChan=tab->tabText(tab->currentIndex()); + QString msg=args.join(" "); + + if(pref=="me") + return "PRIVMSG "+destChan+" ACTION " + msg + ""; + else if(pref=="msg") + return "MSG "+destChan+" ACTION " + msg + ""; + else if(pref=="join") + { + join(msg); + return " "; + } + else if(pref=="quit") + { + if(msg == "") + return "QUIT "+msgQuit; + else + return "QUIT "+msg; + } + else if(pref=="part") + { + tab->removeTab(tab->currentIndex()); + + if(msg == "") + { + if(msg.startsWith("#")) + destChan=msg.split(" ").first(); + + if(msgQuit=="") + return "PART "+destChan+" using IrcLightClient"; + else + return "PART "+destChan+" "+msgQuit; + } + else + return "PART "+destChan+" "+msg; + + conversations.remove(destChan); + } + else if(pref=="kick") + { + QStringList tableau=msg.split(" "); + QString c1,c2,c3; + if(tableau.count() > 0) c1=" "+tableau.first(); + else c1=""; + if(tableau.count() > 1) c2=" "+tableau.at(1); + else c2=""; + if(tableau.count() > 2) c3=" "+tableau.at(2); + else c3=""; + + if(c1.startsWith("#")) + return "KICK"+c1+c2+c3; + else + return "KICK "+destChan+c1+c2; + } + else if(pref=="update") + { + updateUsers=true; + return "WHO "+destChan; + } + else if(pref=="ns") + { + return "NICKSERV "+msg; + } + else if(pref=="nick") + { + emit pseudoChanged(msg); + ecrire("-> Nickname changed to "+msg); + return "NICK "+msg; + } + else if(pref=="msg") + { + return "MSG "+msg; + } + + else + return pref+" "+msg; + } + else if(!serveur) + { + QString destChan=tab->tabText(tab->currentIndex()); + if(comm.endsWith("
")) + comm=comm.remove(QRegExp("
$")); + ecrire("<"+pseudo+"> "+comm,destChan); + + if(comm.startsWith(":")) + comm.insert(0,":"); + + return "PRIVMSG "+destChan+" "+comm.replace(" ","\t"); + } + else + { + return ""; + } +} + +void Serveur::join(QString chan) +{ + affichage->append("Joining "+ chan +" channel"); + emit joinTab(); + QTextEdit *textEdit=new QTextEdit; + int index=tab->insertTab(tab->currentIndex()+1,textEdit,chan); + tab->setTabToolTip(index,serveur); + tab->setCurrentIndex(index); + + textEdit->setReadOnly(true); + + conversations.insert(chan,textEdit); + + sendData("JOIN "+chan); + + emit tabJoined(); +} +void Serveur::leave(QString chan) +{ + sendData(parseCommande("/part "+chan+ " "+msgQuit)); +} + +void Serveur::ecrire(QString txt,QString destChan,QString msgTray) +{ + if(destChan!="") + { + conversations[destChan]->setHtml(conversations[destChan]->toHtml()+txt); + QScrollBar *sb = conversations[destChan]->verticalScrollBar(); + sb->setValue(sb->maximum()); + } + else if(txt.startsWith("#")) + { + QString dest=txt.split(" ").first(); + QStringList list=txt.split(" "); + list.removeFirst(); + txt=list.join(" "); + conversations[dest]->setHtml(conversations[dest]->toHtml()+txt); + QScrollBar *sb = conversations[dest]->verticalScrollBar(); + sb->setValue(sb->maximum()); } + else + { + txt.replace("\r\n","
"); + affichage->setHtml(affichage->toHtml()+txt+"
"); + QScrollBar *sb = affichage->verticalScrollBar(); + sb->setValue(sb->maximum()); + } + + +} + +void Serveur::updateUsersList(QString chan,QString message) +{ + message = message.replace("\r\n",""); + message = message.replace("\r",""); + if(chan!=serveur) + { + if(updateUsers==true || message != "") + { + QString liste2=message.replace(":",""); + QStringList liste=liste2.split(" "); + + if (delist == true) users.clear(); + + for(int i=5; i < liste.count(); i++) + { + users.append(liste.at(i)); + } + updateUsers=false; + if (liste.count() < 53) delist = true; + else delist = false; + QStringListModel *model = new QStringListModel(users); + userList->setModel(model); + userList->update(); + } + else + { + updateUsers=true; + sendData("NAMES "+chan); + } + } + else + { + QStringListModel model; + userList->setModel(&model); + userList->update(); + } +} From 8752ab23476db4aef0f05c0950f866f6ec634202 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:10:42 -0400 Subject: [PATCH 410/469] Create serveur.h --- src/qt/serveur.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/qt/serveur.h diff --git a/src/qt/serveur.h b/src/qt/serveur.h new file mode 100644 index 00000000..2a6d296d --- /dev/null +++ b/src/qt/serveur.h @@ -0,0 +1,67 @@ +/*Copyright (C) 2009 Cleriot Simon +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ + +#ifndef SERVEUR_H +#define SERVEUR_H + +#include +#include +#include +#include +#include +#include + +class Serveur : public QTcpSocket +{ + Q_OBJECT + + public: + Serveur(); + QTextEdit *affichage; + QListView *userList; + QString pseudo,serveur,msgQuit; + int port; + QTabWidget *tab; + QMap conversations; + QSystemTrayIcon *tray; + + bool updateUsers; + + QString parseCommande(QString comm,bool serveur=false); + + QWidget *parent; + + + signals: + void pseudoChanged(QString newPseudo); + void joinTab(); + void tabJoined(); + + public slots: + void readServeur(); + void errorSocket(QAbstractSocket::SocketError); + void connected(); + void joins(); + void sendData(QString txt); + void join(QString chan); + void leave(QString chan); + void ecrire(QString txt,QString destChan="",QString msgTray=""); + void updateUsersList(QString chan="",QString message=""); + + //void tabChanged(int index); +}; + +#endif // SERVEUR_H From 2b27a3b7428085fecf21fee6cbd6894436622b68 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:11:08 -0400 Subject: [PATCH 411/469] Create chatwindow.ui --- src/qt/forms/chatwindow.ui | 300 +++++++++++++++++++++++++++++++++++++ 1 file changed, 300 insertions(+) create mode 100644 src/qt/forms/chatwindow.ui diff --git a/src/qt/forms/chatwindow.ui b/src/qt/forms/chatwindow.ui new file mode 100644 index 00000000..bc38d860 --- /dev/null +++ b/src/qt/forms/chatwindow.ui @@ -0,0 +1,300 @@ + + + ChatWindowClass + + + + 0 + 0 + 747 + 514 + + + + + + 0 + 0 + 741 + 511 + + + + + true + + + + 10 + 10 + 721 + 501 + + + + + + + + + 10 + 0 + 541 + 451 + + + + + + + QTabWidget::Rounded + + + 0 + + + false + + + + Tab 1 + + hide3 + hide3 + + + + Tab 2 + + + + + + + 10 + 460 + 701 + 30 + + + + + 0 + 0 + + + + + 16777215 + 30 + + + + + + + 560 + 20 + 161 + 391 + + + + + 0 + 300 + + + + border-radius:10px; + + + + + + 642 + 420 + 71 + 28 + + + + Disconnect + + + + + + + 10 + 10 + 731 + 501 + + + + + + 10 + 20 + 250 + 27 + + + + + 7 + + + + + + Open Sans,sans-serif + + + + <html><head/><body><p align="center"><span style=" font-size:20px; font-weight:600; color:#000000;">MACRON Chat</span></p></body></html> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 130 + 280 + 71 + 51 + + + + <html><head/><body><p align="center"><a href="https://twitter.com/MACRON_Team"><span style=" text-decoration: underline; color:#0000ff;"><img src=":/icons/twitter.png"/></span></a></p></body></html> + + + 5 + + + true + + + + + + 220 + 280 + 53 + 51 + + + + <html><head/><body><p><a href="https://bitcointalk.org/index.php?topic=1083744.0"><span style=" text-decoration: underline; color:#0000ff;"><img src=":/icons/bct.png"/></span></a></p></body></html> + + + true + + + + + + 290 + 280 + 41 + 51 + + + + <html><head/><body><p><a href="https://bittrex.com/Market/Index?MarketName=BTC-MACRON"><span style=" text-decoration: underline; color:#0000ff;"><img src=":/icons/yob.png"/></span></a></p></body></html> + + + true + + + + + + 160 + 160 + 151 + 22 + + + + + + + + + + 100 + 160 + 61 + 21 + + + + Nickname + + + + + + 160 + 200 + 151 + 41 + + + + border-radius:40px;border:1px solid grey + + + Click to connect + + + + + + 100 + 130 + 121 + 16 + + + + <html><head/><body><p><span style=" font-weight:600;">Connect to Trollbox :</span></p></body></html> + + + + + + + Quitter + + + Ctrl+Q + + + + + Fermer l'onglet + + + + + + + From 59a4dbd59a30835c41bd537e234337ca30dab48a Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:13:53 -0400 Subject: [PATCH 412/469] Update Makefile.qt.include --- src/Makefile.qt.include | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index e0d872f5..fb9c259b 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -33,6 +33,7 @@ QT_TS = \ QT_FORMS_UI = \ qt/forms/addressbookpage.ui \ qt/forms/askpassphrasedialog.ui \ + qt/forms/chatwindow.ui \ qt/forms/coincontroldialog.ui \ qt/forms/editaddressdialog.ui \ qt/forms/governancelist.ui \ @@ -64,6 +65,7 @@ QT_MOC_CPP = \ qt/moc_bitcoinamountfield.cpp \ qt/moc_bitcoingui.cpp \ qt/moc_bitcoinunits.cpp \ + qt/moc_chatwindow.cpp \ qt/moc_clientmodel.cpp \ qt/moc_coincontroldialog.cpp \ qt/moc_coincontroltreewidget.cpp \ @@ -94,6 +96,7 @@ QT_MOC_CPP = \ qt/moc_rpcconsole.cpp \ qt/moc_sendcoinsdialog.cpp \ qt/moc_sendcoinsentry.cpp \ + qt/moc_serveur.cpp \ qt/moc_signverifymessagedialog.cpp \ qt/moc_splashscreen.cpp \ qt/moc_tradingdialogpage.cpp \ @@ -139,6 +142,7 @@ BITCOIN_QT_H = \ qt/bitcoinamountfield.h \ qt/bitcoingui.h \ qt/bitcoinunits.h \ + qt/chatwindow.h \ qt/clientmodel.h \ qt/coincontroldialog.h \ qt/coincontroltreewidget.h \ @@ -174,6 +178,7 @@ BITCOIN_QT_H = \ qt/rpcconsole.h \ qt/sendcoinsdialog.h \ qt/sendcoinsentry.h \ + qt/serveur.h \ qt/signverifymessagedialog.h \ qt/splashscreen.h \ qt/tradingdialogpage.h \ @@ -501,6 +506,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/addressbookpage.cpp \ qt/addresstablemodel.cpp \ qt/askpassphrasedialog.cpp \ + qt/chatwindow.cpp \ qt/coincontroldialog.cpp \ qt/coincontroltreewidget.cpp \ qt/editaddressdialog.cpp \ @@ -518,6 +524,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/recentrequeststablemodel.cpp \ qt/sendcoinsdialog.cpp \ qt/sendcoinsentry.cpp \ + qt/serveur.cpp \ qt/signverifymessagedialog.cpp \ qt/tradingdialogpage.cpp \ qt/transactiondesc.cpp \ From 45767e51e34b6549d8bc0a631cdf4a6e332c1f1e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:20:51 -0400 Subject: [PATCH 413/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 62f551fe..e1b19264 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -23,6 +23,7 @@ #include "rpcconsole.h" #include "utilitydialog.h" #include "tradingdialogpage.h" +#include "chatwindow.h" #ifdef ENABLE_WALLET #include "privatesend-client.h" @@ -142,6 +143,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle * governanceAction(0), tradingAction(0), externalDonate(0), + chatWindow(0), platformStyle(_platformStyle) { /* Open CSS when configured */ @@ -616,6 +618,10 @@ void BitcoinGUI::createActions() // HTHW Donate externalDonate = new QAction(QIcon(":/icons/" + theme + "/about"), tr("Donate To HTHW"), this); externalDonate->setStatusTip(tr("Donate to Help The Homeless Worldwide")); + + // HTH Chat + chatWindow = new QAction(QIcon(":/icons/" + theme + "/chat"), tr("HTH Chat"), this); + chatWindow->setStatusTip(tr("HTH World IRC Chat")); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); @@ -630,6 +636,9 @@ void BitcoinGUI::createActions() // HTHW Donate connect(externalDonate, SIGNAL(triggered()), this, SLOT(openDonate())); + // HTHW Chat + connect(chatWindow, SIGNAL(triggered()), this, SLOT(gotoChatPage())); + // Jump directly to tabs in RPC-console connect(openInfoAction, SIGNAL(triggered()), this, SLOT(showInfo())); connect(openRPCConsoleAction, SIGNAL(triggered()), this, SLOT(showConsole())); @@ -730,6 +739,9 @@ void BitcoinGUI::createMenuBar() QMenu* donate = appMenuBar->addMenu(tr("&Donate")); donate->addAction(externalDonate); + QMenu* chat = appMenuBar->addMenu(tr("&HTH Chat")); + chat->addAction(chatWindow); + } void BitcoinGUI::createToolBars() @@ -1057,6 +1069,12 @@ void BitcoinGUI::openClicked() } } +void BitcoinGUI::gotoChatPage() +{ + chatWindow->setChecked(true); + if (walletFrame) walletFrame->gotoChatPage(); +} + void BitcoinGUI::gotoTradingDialogPage() { From 9f319f0ce86b147c17e406aed0c51f21b6097835 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:22:49 -0400 Subject: [PATCH 414/469] Update bitcoingui.h --- src/qt/bitcoingui.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 3c797165..b520b203 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -39,6 +39,7 @@ class ModalOverlay; class QNetworkAccessManager; class QNetworkRequest; class tradingDialogPage; +class ChatWindow; class CWallet; @@ -104,6 +105,7 @@ class BitcoinGUI : public QMainWindow QMenuBar *appMenuBar; + QAction* chatWindow; QAction* externalDonate; QAction *governanceAction; QAction *tradingAction; @@ -232,15 +234,15 @@ public Q_SLOTS: private Q_SLOTS: #ifdef ENABLE_WALLET + + /** Switch to chat page */ + void gotoChatPage(); /** Switch to trading page */ void gotoTradingDialogPage(); - /** Switch to governance page */ void gotoGovernancePage(); - /** Switch to private send page */ /* void gotoPrivateSendPage(); */ - /** Switch to overview (home) page */ void gotoOverviewPage(); /** Switch to history (transactions) page */ From 779b661eebf44c5f23bf11622257c9dcab8d28a7 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:26:34 -0400 Subject: [PATCH 415/469] Update chatwindow.h --- src/qt/chatwindow.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/chatwindow.h b/src/qt/chatwindow.h index c6dada4c..d02f5f8a 100644 --- a/src/qt/chatwindow.h +++ b/src/qt/chatwindow.h @@ -38,10 +38,10 @@ class ChatWindow : public QWidget ~ChatWindow(); void setModel(ClientModel *model); Serveur * currentTab(); - signals: + Q_SIGNALS: void changeTab(); - public slots: + public Q_SLOTS: void sendCommande(); void connecte(); void closeTab(); From 822ecd0704cdeecca7c05285d9e960e821973de0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:27:28 -0400 Subject: [PATCH 416/469] Update serveur.h --- src/qt/serveur.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/serveur.h b/src/qt/serveur.h index 2a6d296d..9d2f6270 100644 --- a/src/qt/serveur.h +++ b/src/qt/serveur.h @@ -45,12 +45,12 @@ class Serveur : public QTcpSocket QWidget *parent; - signals: + Q_SIGNALS: void pseudoChanged(QString newPseudo); void joinTab(); void tabJoined(); - public slots: + public Q_SLOTS: void readServeur(); void errorSocket(QAbstractSocket::SocketError); void connected(); From ca4b3322ebc1c720ba940af94048a6e8c9247626 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:28:36 -0400 Subject: [PATCH 417/469] Update walletframe.cpp --- src/qt/walletframe.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index 265392ae..3f004d86 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -108,6 +108,14 @@ void WalletFrame::showOutOfSyncWarning(bool fShow) i.value()->showOutOfSyncWarning(fShow); } +void WalletFrame::gotoChatPage() +{ + + QMap::const_iterator i; + for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) + i.value()->gotoChatPage(); +} + void WalletFrame::gotoTradingDialogPage() { From 5284a1d12a5af884baf48be99b8f3bae785e449b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:29:08 -0400 Subject: [PATCH 418/469] Update walletframe.h --- src/qt/walletframe.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qt/walletframe.h b/src/qt/walletframe.h index 348915cd..5413a4a0 100644 --- a/src/qt/walletframe.h +++ b/src/qt/walletframe.h @@ -63,6 +63,8 @@ class WalletFrame : public QFrame public Q_SLOTS: + /** Switch to chat page */ + void gotoChatPage(); /** Switch to trading page */ void gotoTradingDialogPage(); /** Switch to governance page */ From 543a9f7dba24f08ae3aa96edf327f7793bd91759 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:31:40 -0400 Subject: [PATCH 419/469] Update walletview.cpp --- src/qt/walletview.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index f4a19b6d..08399263 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -87,6 +87,9 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): tradingDialogPage = new TradingDialogPage(); addWidget(tradingDialogPage); + + chatWindow = new ChatPage(); + addWidget(chatWindow); QSettings settings; if (!fLiteMode && settings.value("fShowMasternodesTab").toBool()) { @@ -238,6 +241,11 @@ void WalletView::processNewTransaction(const QModelIndex& parent, int start, int Q_EMIT incomingTransaction(date, walletModel->getOptionsModel()->getDisplayUnit(), amount, type, address, label); } +void WalletView::gotoChatPage() +{ + setCurrentWidget(chatWindow); +} + void WalletView::gotoTradingDialogPage() { setCurrentWidget(tradingDialogPage); From 1f4f82cdf78f0e5e4c0b6628567ef34314a90a60 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:33:03 -0400 Subject: [PATCH 420/469] Update walletview.h --- src/qt/walletview.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/qt/walletview.h b/src/qt/walletview.h index 4c7c44bb..1adc1905 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -9,6 +9,7 @@ #include "masternodelist.h" #include "governancelist.h" #include "tradingdialogpage.h" +#include "chatwindow.h" #include @@ -26,6 +27,7 @@ class AddressBookPage; class PrivateSendPage; class GovernancePage; class TradingDialogPage; +class ChatWindow; QT_BEGIN_NAMESPACE @@ -77,6 +79,7 @@ class WalletView : public QStackedWidget GovernanceList *governanceListPage; TransactionView *transactionView; TradingDialogPage *tradingDialogPage; + ChatPage *chatWindow; QProgressDialog *progressDialog; QLabel *transactionSum; @@ -84,6 +87,8 @@ class WalletView : public QStackedWidget public Q_SLOTS: + /** Switch to chat page */ + void gotoChatPage(); /** Switch to trading page */ void gotoTradingDialogPage(); /** Switch to governance page */ From 313d2d1b4dd59fc40266bc31163ad63c7ef6ddc5 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:34:27 -0400 Subject: [PATCH 421/469] Update walletview.h --- src/qt/walletview.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qt/walletview.h b/src/qt/walletview.h index 1adc1905..bf4188fb 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -9,7 +9,7 @@ #include "masternodelist.h" #include "governancelist.h" #include "tradingdialogpage.h" -#include "chatwindow.h" +#include "chatwindowpage.h" #include @@ -27,7 +27,7 @@ class AddressBookPage; class PrivateSendPage; class GovernancePage; class TradingDialogPage; -class ChatWindow; +class ChatWindowPage; QT_BEGIN_NAMESPACE @@ -79,7 +79,7 @@ class WalletView : public QStackedWidget GovernanceList *governanceListPage; TransactionView *transactionView; TradingDialogPage *tradingDialogPage; - ChatPage *chatWindow; + ChatWindowPage *chatWindowPage; QProgressDialog *progressDialog; QLabel *transactionSum; @@ -88,7 +88,7 @@ class WalletView : public QStackedWidget public Q_SLOTS: /** Switch to chat page */ - void gotoChatPage(); + void gotoChatWindowPage(); /** Switch to trading page */ void gotoTradingDialogPage(); /** Switch to governance page */ From da4651b3ba4002a8f164b3d921305a3067118e9b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:35:12 -0400 Subject: [PATCH 422/469] Update walletview.cpp --- src/qt/walletview.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 08399263..8bb78d2b 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -88,8 +88,8 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): tradingDialogPage = new TradingDialogPage(); addWidget(tradingDialogPage); - chatWindow = new ChatPage(); - addWidget(chatWindow); + chatWindowPage = new ChatWindowPage(); + addWidget(chatWindowPage); QSettings settings; if (!fLiteMode && settings.value("fShowMasternodesTab").toBool()) { @@ -241,9 +241,9 @@ void WalletView::processNewTransaction(const QModelIndex& parent, int start, int Q_EMIT incomingTransaction(date, walletModel->getOptionsModel()->getDisplayUnit(), amount, type, address, label); } -void WalletView::gotoChatPage() +void WalletView::gotoChatWindowPage() { - setCurrentWidget(chatWindow); + setCurrentWidget(chatWindowPage); } void WalletView::gotoTradingDialogPage() From 600d2fc3d71769398d20502e97b39eb75bb2b923 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:35:33 -0400 Subject: [PATCH 423/469] Update walletframe.h --- src/qt/walletframe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/walletframe.h b/src/qt/walletframe.h index 5413a4a0..dbdc174d 100644 --- a/src/qt/walletframe.h +++ b/src/qt/walletframe.h @@ -64,7 +64,7 @@ class WalletFrame : public QFrame public Q_SLOTS: /** Switch to chat page */ - void gotoChatPage(); + void gotoChatWindowPage(); /** Switch to trading page */ void gotoTradingDialogPage(); /** Switch to governance page */ From 6e601fddca2c69d5294046779d87f04c4a8bc36b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:36:02 -0400 Subject: [PATCH 424/469] Update walletframe.cpp --- src/qt/walletframe.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index 3f004d86..f2eae939 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -108,12 +108,12 @@ void WalletFrame::showOutOfSyncWarning(bool fShow) i.value()->showOutOfSyncWarning(fShow); } -void WalletFrame::gotoChatPage() +void WalletFrame::gotoChatWindowPage() { QMap::const_iterator i; for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) - i.value()->gotoChatPage(); + i.value()->gotoChatWindowPage(); } void WalletFrame::gotoTradingDialogPage() From d208673e9aa42441cb7b3e264cbbfa8e516530e7 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:36:37 -0400 Subject: [PATCH 425/469] Update bitcoingui.h --- src/qt/bitcoingui.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index b520b203..25561564 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -39,7 +39,7 @@ class ModalOverlay; class QNetworkAccessManager; class QNetworkRequest; class tradingDialogPage; -class ChatWindow; +class ChatWindowPage; class CWallet; @@ -105,7 +105,7 @@ class BitcoinGUI : public QMainWindow QMenuBar *appMenuBar; - QAction* chatWindow; + QAction* chatWindowPage; QAction* externalDonate; QAction *governanceAction; QAction *tradingAction; @@ -236,7 +236,7 @@ private Q_SLOTS: /** Switch to chat page */ - void gotoChatPage(); + void gotoChatWindowPage(); /** Switch to trading page */ void gotoTradingDialogPage(); /** Switch to governance page */ From e59626852f66995a3a854924eabe79cf119a1cd9 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:39:23 -0400 Subject: [PATCH 426/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index e1b19264..a07b3f1a 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -23,7 +23,7 @@ #include "rpcconsole.h" #include "utilitydialog.h" #include "tradingdialogpage.h" -#include "chatwindow.h" +#include "chatwindowpage.h" #ifdef ENABLE_WALLET #include "privatesend-client.h" @@ -143,7 +143,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle * governanceAction(0), tradingAction(0), externalDonate(0), - chatWindow(0), + chatWindowPage(0), platformStyle(_platformStyle) { /* Open CSS when configured */ @@ -489,9 +489,9 @@ void BitcoinGUI::createActions() governanceAction->setToolTip(governanceAction->statusTip()); governanceAction->setCheckable(true); #ifdef Q_OS_MAC - governanceAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_5)); + governanceAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_6)); #else - governanceAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5)); + governanceAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6)); #endif tabGroup->addAction(governanceAction); connect(governanceAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); @@ -504,9 +504,9 @@ void BitcoinGUI::createActions() tradingAction->setToolTip(tradingAction->statusTip()); tradingAction->setCheckable(true); #ifdef Q_OS_MAC - tradingAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_5)); + tradingAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_7)); #else - tradingAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5)); + tradingAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_7)); #endif tabGroup->addAction(tradingAction); connect(tradingAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); @@ -620,8 +620,8 @@ void BitcoinGUI::createActions() externalDonate->setStatusTip(tr("Donate to Help The Homeless Worldwide")); // HTH Chat - chatWindow = new QAction(QIcon(":/icons/" + theme + "/chat"), tr("HTH Chat"), this); - chatWindow->setStatusTip(tr("HTH World IRC Chat")); + chatWindowPage = new QAction(QIcon(":/icons/" + theme + "/chat"), tr("HTH Chat"), this); + chatWindowPage->setStatusTip(tr("HTH World IRC Chat")); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); @@ -637,7 +637,7 @@ void BitcoinGUI::createActions() connect(externalDonate, SIGNAL(triggered()), this, SLOT(openDonate())); // HTHW Chat - connect(chatWindow, SIGNAL(triggered()), this, SLOT(gotoChatPage())); + connect(chatWindowPage, SIGNAL(triggered()), this, SLOT(gotoChatWindowPage())); // Jump directly to tabs in RPC-console connect(openInfoAction, SIGNAL(triggered()), this, SLOT(showInfo())); @@ -740,7 +740,7 @@ void BitcoinGUI::createMenuBar() donate->addAction(externalDonate); QMenu* chat = appMenuBar->addMenu(tr("&HTH Chat")); - chat->addAction(chatWindow); + chat->addAction(chatWindowPage); } @@ -1069,10 +1069,10 @@ void BitcoinGUI::openClicked() } } -void BitcoinGUI::gotoChatPage() +void BitcoinGUI::gotoChatWindowPage() { - chatWindow->setChecked(true); - if (walletFrame) walletFrame->gotoChatPage(); + chatWindowPage->setChecked(true); + if (walletFrame) walletFrame->gotoChatWindowPage(); } void BitcoinGUI::gotoTradingDialogPage() From c725335d3140b1eedffad4f014899586c256bde4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:39:47 -0400 Subject: [PATCH 427/469] Update and rename chatwindow.ui to chatwindowPage.ui --- src/qt/forms/{chatwindow.ui => chatwindowPage.ui} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/qt/forms/{chatwindow.ui => chatwindowPage.ui} (99%) diff --git a/src/qt/forms/chatwindow.ui b/src/qt/forms/chatwindowPage.ui similarity index 99% rename from src/qt/forms/chatwindow.ui rename to src/qt/forms/chatwindowPage.ui index bc38d860..9b70968a 100644 --- a/src/qt/forms/chatwindow.ui +++ b/src/qt/forms/chatwindowPage.ui @@ -1,7 +1,7 @@ - ChatWindowClass - + ChatWindowPage + 0 From 836d3099457bcaf5aef51a34ce7ea2eb4cd566ee Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:41:09 -0400 Subject: [PATCH 428/469] Update and rename chatwindow.cpp to chatwindowpage.cpp --- src/qt/{chatwindow.cpp => chatwindowpage.cpp} | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) rename src/qt/{chatwindow.cpp => chatwindowpage.cpp} (88%) diff --git a/src/qt/chatwindow.cpp b/src/qt/chatwindowpage.cpp similarity index 88% rename from src/qt/chatwindow.cpp rename to src/qt/chatwindowpage.cpp index d00e2407..8cd62adc 100644 --- a/src/qt/chatwindow.cpp +++ b/src/qt/chatwindowpage.cpp @@ -14,11 +14,11 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ -#include "chatwindow.h" -#include "ui_chatwindow.h" +#include "chatwindowpage.h" +#include "ui_chatwindowpage.h" -ChatWindow::ChatWindow(QWidget *parent) - : QWidget(parent), ui(new Ui::ChatWindowClass) +ChatWindowPage::ChatWindowPage(QWidget *parent) + : QWidget(parent), ui(new Ui::ChatWindowPage) { ui->setupUi(this); setFixedSize(750,600); @@ -43,13 +43,13 @@ ChatWindow::ChatWindow(QWidget *parent) -void ChatWindow::tabChanged(int index) +void ChatWindowPage::tabChanged(int index) { if(index!=0 && joining == false) currentTab()->updateUsersList(ui->tab->tabText(index)); } -void ChatWindow::tabClosing(int index) +void ChatWindowPage::tabClosing(int index) { currentTab()->leave(ui->tab->tabText(index)); } @@ -58,7 +58,7 @@ void ChatWindow::tabClosing(int index) currentTab()->leave(ui->tab->tabText(index)); }*/ -void ChatWindow::disconnectFromServer() { +void ChatWindowPage::disconnectFromServer() { QMapIterator i(serveurs); @@ -79,14 +79,14 @@ void ChatWindow::disconnectFromServer() { } -Serveur *ChatWindow::currentTab() +Serveur *ChatWindowPage::currentTab() { QString tooltip=ui->tab->tabToolTip(ui->tab->currentIndex()); return serveurs[tooltip]; //return ui->tab->currentWidget()->findChild(); } -void ChatWindow::closeTab() +void ChatWindowPage::closeTab() { QString tooltip=ui->tab->tabToolTip(ui->tab->currentIndex()); QString txt=ui->tab->tabText(ui->tab->currentIndex()); @@ -114,7 +114,7 @@ void ChatWindow::closeTab() } } -void ChatWindow::sendCommande() +void ChatWindowPage::sendCommande() { QString tooltip=ui->tab->tabToolTip(ui->tab->currentIndex()); QString txt=ui->tab->tabText(ui->tab->currentIndex()); @@ -130,16 +130,16 @@ void ChatWindow::sendCommande() ui->lineEdit->setFocus(); } -void ChatWindow::tabJoined() +void ChatWindowPage::tabJoined() { joining=true; } -void ChatWindow::tabJoining() +void ChatWindowPage::tabJoining() { joining=false; } -void ChatWindow::connecte() +void ChatWindowPage::connecte() { ui->splitter->show(); @@ -174,7 +174,7 @@ void ChatWindow::connecte() ui->tab->setCurrentIndex(ui->tab->count()-1); } -void ChatWindow::closeEvent(QCloseEvent *event) +void ChatWindowPage::closeEvent(QCloseEvent *event) { (void) event; @@ -191,13 +191,13 @@ void ChatWindow::closeEvent(QCloseEvent *event) } } } -void ChatWindow ::setModel(ClientModel *model) +void ChatWindowPage ::setModel(ClientModel *model) { this->model = model; } -ChatWindow::~ChatWindow() +ChatWindowPage::~ChatWindowPage() { delete ui; QMapIterator i(serveurs); From aa4738d3887ac6d0674a40e673ca986f9624d215 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:41:48 -0400 Subject: [PATCH 429/469] Update and rename chatwindow.h to chatwindowpage.h --- src/qt/{chatwindow.h => chatwindowpage.h} | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename src/qt/{chatwindow.h => chatwindowpage.h} (87%) diff --git a/src/qt/chatwindow.h b/src/qt/chatwindowpage.h similarity index 87% rename from src/qt/chatwindow.h rename to src/qt/chatwindowpage.h index d02f5f8a..bd21242d 100644 --- a/src/qt/chatwindow.h +++ b/src/qt/chatwindowpage.h @@ -14,8 +14,8 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA*/ -#ifndef CHATWINDOW_H -#define CHATWINDOW_H +#ifndef CHATWINDOWPAGE_H +#define CHATWINDOWPAGE_H #include #include @@ -26,7 +26,7 @@ namespace Ui { - class ChatWindowClass; + class ChatWindowPage; } class ChatWindow : public QWidget @@ -34,8 +34,8 @@ class ChatWindow : public QWidget Q_OBJECT public: - ChatWindow(QWidget *parent = 0); - ~ChatWindow(); + ChatWindowPage(QWidget *parent = 0); + ~ChatWindowPage(); void setModel(ClientModel *model); Serveur * currentTab(); Q_SIGNALS: @@ -55,7 +55,7 @@ class ChatWindow : public QWidget private: - Ui::ChatWindowClass *ui; + Ui::ChatWindowPage *ui; ClientModel *model; QMap serveurs; bool joining; @@ -63,4 +63,4 @@ class ChatWindow : public QWidget }; -#endif // CHATWINDOW_H +#endif // CHATWINDOWPAGE_H From 20c368688aa34d4aae6298e0d408934aa78b05cf Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:43:07 -0400 Subject: [PATCH 430/469] Update serveur.cpp --- src/qt/serveur.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/serveur.cpp b/src/qt/serveur.cpp index d077b4d3..0252edc4 100644 --- a/src/qt/serveur.cpp +++ b/src/qt/serveur.cpp @@ -89,7 +89,7 @@ void Serveur::readServeur() } QStringList list=message.split("\r\n"); - foreach(QString msg,list) + Q_FOREACH(QString msg,list) { if(msg.contains(QRegExp(":([a-zA-Z0-9]+)\\![~a-zA-Z0-9]+@[a-zA-Z0-9\\/\\.-]+ PRIVMSG ([a-zA-Z0-9\\#]+) :(.+)"))) { From 7c65f4a998e0e0c7ea5599dd9018d25b74fcdf45 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:44:10 -0400 Subject: [PATCH 431/469] Update Makefile.qt.include --- src/Makefile.qt.include | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index fb9c259b..0d1aa4d7 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -33,7 +33,7 @@ QT_TS = \ QT_FORMS_UI = \ qt/forms/addressbookpage.ui \ qt/forms/askpassphrasedialog.ui \ - qt/forms/chatwindow.ui \ + qt/forms/chatwindowpage.ui \ qt/forms/coincontroldialog.ui \ qt/forms/editaddressdialog.ui \ qt/forms/governancelist.ui \ @@ -65,7 +65,7 @@ QT_MOC_CPP = \ qt/moc_bitcoinamountfield.cpp \ qt/moc_bitcoingui.cpp \ qt/moc_bitcoinunits.cpp \ - qt/moc_chatwindow.cpp \ + qt/moc_chatwindowpage.cpp \ qt/moc_clientmodel.cpp \ qt/moc_coincontroldialog.cpp \ qt/moc_coincontroltreewidget.cpp \ @@ -142,7 +142,7 @@ BITCOIN_QT_H = \ qt/bitcoinamountfield.h \ qt/bitcoingui.h \ qt/bitcoinunits.h \ - qt/chatwindow.h \ + qt/chatwindowpage.h \ qt/clientmodel.h \ qt/coincontroldialog.h \ qt/coincontroltreewidget.h \ @@ -506,7 +506,7 @@ BITCOIN_QT_WALLET_CPP = \ qt/addressbookpage.cpp \ qt/addresstablemodel.cpp \ qt/askpassphrasedialog.cpp \ - qt/chatwindow.cpp \ + qt/chatwindowpage.cpp \ qt/coincontroldialog.cpp \ qt/coincontroltreewidget.cpp \ qt/editaddressdialog.cpp \ From 4bf7236a0e4423f6e02ae560d7ac7d3765164916 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:47:01 -0400 Subject: [PATCH 432/469] Rename chatwindowPage.ui to chatwindowpage.ui --- src/qt/forms/{chatwindowPage.ui => chatwindowpage.ui} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/qt/forms/{chatwindowPage.ui => chatwindowpage.ui} (100%) diff --git a/src/qt/forms/chatwindowPage.ui b/src/qt/forms/chatwindowpage.ui similarity index 100% rename from src/qt/forms/chatwindowPage.ui rename to src/qt/forms/chatwindowpage.ui From aaf69fb18960e7fb21f81cb15023b1ffc4c957cc Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:48:47 -0400 Subject: [PATCH 433/469] Update chatwindowpage.h --- src/qt/chatwindowpage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/chatwindowpage.h b/src/qt/chatwindowpage.h index bd21242d..4414e067 100644 --- a/src/qt/chatwindowpage.h +++ b/src/qt/chatwindowpage.h @@ -29,7 +29,7 @@ namespace Ui class ChatWindowPage; } -class ChatWindow : public QWidget +class ChatWindowPage : public QWidget { Q_OBJECT From a7b92f3c36b430b95e89cbd27d7a2e5ea7afba4e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:51:47 -0400 Subject: [PATCH 434/469] Update serveur.cpp --- src/qt/serveur.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qt/serveur.cpp b/src/qt/serveur.cpp index 0252edc4..8178aec1 100644 --- a/src/qt/serveur.cpp +++ b/src/qt/serveur.cpp @@ -80,7 +80,7 @@ void Serveur::readServeur() pseudo=pseudo+"_2"; pseudo.remove("\r\n"); sendData("NICK "+pseudo); - emit pseudoChanged(pseudo); + Q_EMIT pseudoChanged(pseudo); ecrire("-> Name changed to "+pseudo); } else if(updateUsers==true) @@ -240,7 +240,7 @@ QString Serveur::parseCommande(QString comm,bool serveur) } else if(pref=="nick") { - emit pseudoChanged(msg); + Q_EMIT pseudoChanged(msg); ecrire("-> Nickname changed to "+msg); return "NICK "+msg; } @@ -273,7 +273,7 @@ QString Serveur::parseCommande(QString comm,bool serveur) void Serveur::join(QString chan) { affichage->append("Joining "+ chan +" channel"); - emit joinTab(); + Q_EMIT joinTab(); QTextEdit *textEdit=new QTextEdit; int index=tab->insertTab(tab->currentIndex()+1,textEdit,chan); tab->setTabToolTip(index,serveur); @@ -285,7 +285,7 @@ void Serveur::join(QString chan) sendData("JOIN "+chan); - emit tabJoined(); + Q_EMIT tabJoined(); } void Serveur::leave(QString chan) { From 97c78a3c8c0733278b102aa123c3a69c29fd078d Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:11:12 -0400 Subject: [PATCH 435/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index a07b3f1a..7dd51b3d 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -141,7 +141,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle * prevBlocks(0), spinnerFrame(0), governanceAction(0), - tradingAction(0), + /* tradingAction(0), */ externalDonate(0), chatWindowPage(0), platformStyle(_platformStyle) @@ -498,7 +498,7 @@ void BitcoinGUI::createActions() connect(governanceAction, SIGNAL(triggered()), this, SLOT(gotoGovernancePage())); } - { + /* { tradingAction = new QAction(QIcon(":/icons/chat"), tr("&Trading"), this); tradingAction->setStatusTip(tr("Trade HTH Today")); tradingAction->setToolTip(tradingAction->statusTip()); @@ -512,7 +512,7 @@ void BitcoinGUI::createActions() connect(tradingAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(tradingAction, SIGNAL(triggered()), this, SLOT(gotoTradingDialogPage())); - } + } */ /* privatesendAction = new QAction(QIcon(":/icons/coinmix"), tr("&Private Send"), this); privatesendAction->setStatusTip(tr("Show Private Send of wallet")); privatesendAction->setToolTip(privatesendAction->statusTip()); @@ -766,8 +766,8 @@ void BitcoinGUI::createToolBars() toolbar->addAction(governanceAction); toolbar->addAction(unlockWalletAction); - toolbar->addAction(tradingAction); - toolbar->addAction(unlockWalletAction); + /* toolbar->addAction(tradingAction); + toolbar->addAction(unlockWalletAction); */ toolbar->setMovable(false); // remove unused icon in upper left corner overviewAction->setChecked(true); @@ -919,7 +919,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled) if (!fLiteMode && settings.value("fShowMasternodesTab").toBool() && masternodeAction) { masternodeAction->setEnabled(enabled); } - tradingAction->setEnabled(enabled); + /*tradingAction->setEnabled(enabled); */ governanceAction->setEnabled(enabled); encryptWalletAction->setEnabled(enabled); backupWalletAction->setEnabled(enabled); @@ -1075,12 +1075,12 @@ void BitcoinGUI::gotoChatWindowPage() if (walletFrame) walletFrame->gotoChatWindowPage(); } -void BitcoinGUI::gotoTradingDialogPage() +/*void BitcoinGUI::gotoTradingDialogPage() { tradingAction->setChecked(true); if (walletFrame) walletFrame->gotoTradingDialogPage(); -} +} */ void BitcoinGUI::openDonate() { From 9e42056ddd0cf0e562d9bcf658694948dcae5408 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:12:23 -0400 Subject: [PATCH 436/469] Update bitcoingui.h --- src/qt/bitcoingui.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 25561564..055119d2 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -38,7 +38,7 @@ class HelpMessageDialog; class ModalOverlay; class QNetworkAccessManager; class QNetworkRequest; -class tradingDialogPage; +/*class tradingDialogPage; */ class ChatWindowPage; class CWallet; @@ -108,7 +108,7 @@ class BitcoinGUI : public QMainWindow QAction* chatWindowPage; QAction* externalDonate; QAction *governanceAction; - QAction *tradingAction; + /* QAction *tradingAction; */ /* QAction* privatesendAction; */ QAction *overviewAction; QAction *historyAction; @@ -238,7 +238,7 @@ private Q_SLOTS: /** Switch to chat page */ void gotoChatWindowPage(); /** Switch to trading page */ - void gotoTradingDialogPage(); + /* void gotoTradingDialogPage(); */ /** Switch to governance page */ void gotoGovernancePage(); /** Switch to private send page */ From 83b4227127fd118240257507cb9aa33a7abe0c01 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:13:01 -0400 Subject: [PATCH 437/469] Update walletframe.cpp --- src/qt/walletframe.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index f2eae939..1389bb79 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -116,13 +116,13 @@ void WalletFrame::gotoChatWindowPage() i.value()->gotoChatWindowPage(); } -void WalletFrame::gotoTradingDialogPage() +/*void WalletFrame::gotoTradingDialogPage() { QMap::const_iterator i; for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) i.value()->gotoTradingDialogPage(); -} +} */ void WalletFrame::gotoGovernancePage() { From 88c0777f1ee8519e7bc87eb8e2b3d546de197277 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:13:23 -0400 Subject: [PATCH 438/469] Update walletframe.h --- src/qt/walletframe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/walletframe.h b/src/qt/walletframe.h index dbdc174d..866caea5 100644 --- a/src/qt/walletframe.h +++ b/src/qt/walletframe.h @@ -66,7 +66,7 @@ public Q_SLOTS: /** Switch to chat page */ void gotoChatWindowPage(); /** Switch to trading page */ - void gotoTradingDialogPage(); + /* void gotoTradingDialogPage(); */ /** Switch to governance page */ void gotoGovernancePage(); /** Switch to private send page */ From 2746967d47298eb51e08f1083566399392fdc75b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:14:18 -0400 Subject: [PATCH 439/469] Update walletview.cpp --- src/qt/walletview.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 8bb78d2b..fb6e2527 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -85,8 +85,8 @@ WalletView::WalletView(const PlatformStyle *_platformStyle, QWidget *parent): addWidget(sendCoinsPage); addWidget(privateSendPage); - tradingDialogPage = new TradingDialogPage(); - addWidget(tradingDialogPage); + /* tradingDialogPage = new TradingDialogPage(); + addWidget(tradingDialogPage); */ chatWindowPage = new ChatWindowPage(); addWidget(chatWindowPage); @@ -246,10 +246,10 @@ void WalletView::gotoChatWindowPage() setCurrentWidget(chatWindowPage); } -void WalletView::gotoTradingDialogPage() +/*void WalletView::gotoTradingDialogPage() { setCurrentWidget(tradingDialogPage); -} +} */ void WalletView::gotoGovernancePage() { From 92d1d7d29955493198ccdce06008e338afe85864 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:14:58 -0400 Subject: [PATCH 440/469] Update walletview.h --- src/qt/walletview.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qt/walletview.h b/src/qt/walletview.h index bf4188fb..d1fc4313 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -8,7 +8,7 @@ #include "amount.h" #include "masternodelist.h" #include "governancelist.h" -#include "tradingdialogpage.h" +/* #include "tradingdialogpage.h" */ #include "chatwindowpage.h" @@ -26,7 +26,7 @@ class WalletModel; class AddressBookPage; class PrivateSendPage; class GovernancePage; -class TradingDialogPage; +/* class TradingDialogPage; */ class ChatWindowPage; @@ -78,7 +78,7 @@ class WalletView : public QStackedWidget PrivateSendPage *privateSendPage; GovernanceList *governanceListPage; TransactionView *transactionView; - TradingDialogPage *tradingDialogPage; + /* TradingDialogPage *tradingDialogPage; */ ChatWindowPage *chatWindowPage; QProgressDialog *progressDialog; @@ -90,7 +90,7 @@ public Q_SLOTS: /** Switch to chat page */ void gotoChatWindowPage(); /** Switch to trading page */ - void gotoTradingDialogPage(); + /* void gotoTradingDialogPage(); */ /** Switch to governance page */ void gotoGovernancePage(); /** Switch to private send page */ From baff4704ef663dfe7303f1334e402a87675ae3a7 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:15:22 -0400 Subject: [PATCH 441/469] Update bitcoingui.cpp --- src/qt/bitcoingui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 7dd51b3d..1e1e9bca 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -22,7 +22,7 @@ #include "platformstyle.h" #include "rpcconsole.h" #include "utilitydialog.h" -#include "tradingdialogpage.h" +/* #include "tradingdialogpage.h" */ #include "chatwindowpage.h" #ifdef ENABLE_WALLET From 2077aac557fcf8ff1347da0647382a270a37db64 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:28:16 -0400 Subject: [PATCH 442/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index 9b70968a..a3d0168c 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -50,7 +50,7 @@ QTabWidget::Rounded - 0 + 1 false @@ -59,8 +59,6 @@ Tab 1 - hide3 - hide3 @@ -114,10 +112,22 @@ 642 420 - 71 - 28 + 100 + 30 + + + 100 + 30 + + + + + 100 + 30 + + Disconnect @@ -138,7 +148,7 @@ 10 20 250 - 27 + 29 @@ -153,7 +163,7 @@ - <html><head/><body><p align="center"><span style=" font-size:20px; font-weight:600; color:#000000;">MACRON Chat</span></p></body></html> + <html><head/><body><p align="center"><span style=" font-size:20px; font-weight:600; color:#34bcaa;">HTH World Chat</span></p></body></html> From e7e2413745008c9ce5e866bac69ed42a9ba6af74 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:34:36 -0400 Subject: [PATCH 443/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index a3d0168c..620dc081 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -110,7 +110,7 @@ - 642 + 595 420 100 30 From 462fee55fd01d29811e242503e7b61e9c481b558 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:36:45 -0400 Subject: [PATCH 444/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index 620dc081..218bc683 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -129,7 +129,7 @@ - Disconnect + Leave From b58bc863a40b8396fd7811a6524694fac4e6d4f5 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:39:43 -0400 Subject: [PATCH 445/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index 218bc683..a46dd02f 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -236,7 +236,7 @@ - 160 + 170 160 151 22 From f6eb4d827619dba48ff9bb20e57675322d94d393 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:52:22 -0400 Subject: [PATCH 446/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 92 +++++++++------------------------- 1 file changed, 25 insertions(+), 67 deletions(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index a46dd02f..e90fb464 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -128,6 +128,13 @@ 30 + + border-style: solid; +border-width: 2px; +border-color: #34bcaa; +border-radius: 10px; +font-size: 11px; + Leave @@ -145,8 +152,8 @@ - 10 - 20 + 130 + 40 250 29 @@ -155,15 +162,10 @@ 7 - - - - - Open Sans,sans-serif - - + + - <html><head/><body><p align="center"><span style=" font-size:20px; font-weight:600; color:#34bcaa;">HTH World Chat</span></p></body></html> + HTH Chat @@ -172,9 +174,12 @@ Qt::Horizontal + + QSizePolicy::Fixed + - 40 + 60 20 @@ -182,57 +187,6 @@ - - - - 130 - 280 - 71 - 51 - - - - <html><head/><body><p align="center"><a href="https://twitter.com/MACRON_Team"><span style=" text-decoration: underline; color:#0000ff;"><img src=":/icons/twitter.png"/></span></a></p></body></html> - - - 5 - - - true - - - - - - 220 - 280 - 53 - 51 - - - - <html><head/><body><p><a href="https://bitcointalk.org/index.php?topic=1083744.0"><span style=" text-decoration: underline; color:#0000ff;"><img src=":/icons/bct.png"/></span></a></p></body></html> - - - true - - - - - - 290 - 280 - 41 - 51 - - - - <html><head/><body><p><a href="https://bittrex.com/Market/Index?MarketName=BTC-MACRON"><span style=" text-decoration: underline; color:#0000ff;"><img src=":/icons/yob.png"/></span></a></p></body></html> - - - true - - @@ -262,14 +216,18 @@ - 160 - 200 + 170 + 225 151 41 - border-radius:40px;border:1px solid grey + border-style: solid; +border-width: 2px; +border-color: #34bcaa; +border-radius: 10px; +font-size: 11px; Click to connect @@ -278,8 +236,8 @@ - 100 - 130 + 183 + 114 121 16 From de84f9403dff7197e5a0ac38a2a933e459238de9 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:55:17 -0400 Subject: [PATCH 447/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index e90fb464..daecc771 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -152,7 +152,7 @@ font-size: 11px;
- 130 + 160 40 250 29 From a578cc5da48d1f02c5c9cacb45177a51e861681b Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:56:52 -0400 Subject: [PATCH 448/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index daecc771..445ddabb 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -152,7 +152,7 @@ font-size: 11px;
- 160 + 150 40 250 29 From 8f8daa0cd52a40980cc6b02a4fe3019fb6dd14c0 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 12:58:32 -0400 Subject: [PATCH 449/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index 445ddabb..1ff3c76d 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -210,7 +210,7 @@ font-size: 11px;
- Nickname + Nickname: @@ -230,7 +230,7 @@ border-radius: 10px; font-size: 11px;
- Click to connect + Click to Connect From f3dccd9d20bad29759d3fa5b496c1cc7e89e8625 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:02:48 -0400 Subject: [PATCH 450/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index 1ff3c76d..e187939e 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -164,8 +164,12 @@ font-size: 11px;
+ + font-weight: bold; +font-size: 20px; + - HTH Chat + HTH World Chat @@ -203,7 +207,7 @@ font-size: 11px;
- 100 + 80 160 61 21 @@ -236,14 +240,14 @@ font-size: 11px;
- 183 - 114 - 121 - 16 + 160 + 110 + 191 + 20 - <html><head/><body><p><span style=" font-weight:600;">Connect to Trollbox :</span></p></body></html> + <html><head/><body><p><span style=" font-weight:600;">Connect to #HTHWorld Trollbox:</span></p></body></html> From 3b6fe516b879e8a408a8c16e95a5521bcb4459e8 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:04:53 -0400 Subject: [PATCH 451/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index e187939e..a037e671 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -209,7 +209,7 @@ font-size: 20px;
80 160 - 61 + 81 21 @@ -240,14 +240,14 @@ font-size: 11px;
- 160 + 180 110 - 191 + 151 20 - <html><head/><body><p><span style=" font-weight:600;">Connect to #HTHWorld Trollbox:</span></p></body></html> + <html><head/><body><p><span style=" font-weight:600;">Connect to #HTHWorld</span></p></body></html> From 2f3215f8071d677afb2eee59cd0a2afea4a70eb8 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:09:00 -0400 Subject: [PATCH 452/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index a037e671..ae84a300 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -152,7 +152,7 @@ font-size: 11px;
- 150 + 170 40 250 29 @@ -162,7 +162,7 @@ font-size: 11px;
7 - + font-weight: bold; @@ -240,14 +240,14 @@ font-size: 11px; - 180 + 160 110 - 151 + 251 20 - <html><head/><body><p><span style=" font-weight:600;">Connect to #HTHWorld</span></p></body></html> + <html><head/><body><p><span style=" font-weight:600;">Connect to #HTHWorld TrollBox</span></p></body></html> From d1d49ba6210412e98ffb5e5b0d604d61c9efd0f4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:10:18 -0400 Subject: [PATCH 453/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index ae84a300..62131e49 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -240,7 +240,7 @@ font-size: 11px;
- 160 + 140 110 251 20 From 40b471854f53e7083d4a8b53ab23d9379a2d8654 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:14:10 -0400 Subject: [PATCH 454/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index 62131e49..c3c220ac 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -152,9 +152,9 @@ font-size: 11px;
- 170 + 149 40 - 250 + 271 29 @@ -194,8 +194,8 @@ font-size: 20px;
- 170 - 160 + 185 + 210 151 22 @@ -208,7 +208,7 @@ font-size: 20px;
80 - 160 + 210 81 21 @@ -220,8 +220,8 @@ font-size: 20px;
- 170 - 225 + 185 + 330 151 41 @@ -241,14 +241,17 @@ font-size: 11px;
140 - 110 + 142 251 - 20 + 25 <html><head/><body><p><span style=" font-weight:600;">Connect to #HTHWorld TrollBox</span></p></body></html> + + Qt::AlignCenter + From 6140b9b6d20c4c2bf6ccd6fa2048e1d4a2dc9828 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:15:54 -0400 Subject: [PATCH 455/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index c3c220ac..91afa6c8 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -152,9 +152,9 @@ font-size: 11px;
- 149 + 169 40 - 271 + 251 29 From 82e5b7e9b9950af33d62d8b5f5a49d4529075da1 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:17:32 -0400 Subject: [PATCH 456/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index 91afa6c8..b1dc9f11 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -152,9 +152,9 @@ font-size: 11px;
- 169 + 179 40 - 251 + 241 29 From b05bc61a210aac3b905f8507abcd0126ee967d3e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:19:54 -0400 Subject: [PATCH 457/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index b1dc9f11..9269e5cb 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -6,17 +6,17 @@ 0 0 - 747 - 514 + 878 + 692 0 - 0 - 741 - 511 + 50 + 851 + 611 @@ -145,8 +145,8 @@ font-size: 11px; 10 10 - 731 - 501 + 851 + 671 From d212a7dab232d70f2058f8473e26f11ac9dde822 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:32:36 -0400 Subject: [PATCH 458/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index 9269e5cb..2e037a3c 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -221,7 +221,7 @@ font-size: 20px; 185 - 330 + 275 151 41 @@ -253,6 +253,19 @@ font-size: 11px; Qt::AlignCenter + + + + 20 + 350 + 521 + 81 + + + + <html><head/><body><p>To Chat on Web, Go to <a href="https://webchat.freenode.net/"><span style=" text-decoration: underline; color:#0000ff;">https://webchat.freenode.net/</span></a></p><p>Enter your Nick</p><p>Enter#HTHWorld as Channel</p></body></html> + + From 39b010828dc9fd142575fa1fa2d9013c29876cf7 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:34:37 -0400 Subject: [PATCH 459/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index 2e037a3c..f21b2a07 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -263,7 +263,7 @@ font-size: 11px; - <html><head/><body><p>To Chat on Web, Go to <a href="https://webchat.freenode.net/"><span style=" text-decoration: underline; color:#0000ff;">https://webchat.freenode.net/</span></a></p><p>Enter your Nick</p><p>Enter#HTHWorld as Channel</p></body></html> + <html><head/><body><p>To Chat on Web, Go to <a href="https://webchat.freenode.net/"><span style=" text-decoration: underline; color:#0000ff;">https://webchat.freenode.net/</span></a></p><p>Enter your Nick</p><p>Enter #HTHWorld as Channel</p></body></html> From 3c85169d4628732de3d86902ce1367910e66883e Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:40:20 -0400 Subject: [PATCH 460/469] Update chatwindowpage.cpp --- src/qt/chatwindowpage.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qt/chatwindowpage.cpp b/src/qt/chatwindowpage.cpp index 8cd62adc..d2f55016 100644 --- a/src/qt/chatwindowpage.cpp +++ b/src/qt/chatwindowpage.cpp @@ -213,3 +213,10 @@ ChatWindowPage::~ChatWindowPage() } } } + + +void ChatWindowPage::on_pushButton_WebChat_clicked() { // #HTHWorld Chat + + QDesktopServices::openUrl(QUrl("https://webchat.freenode.net//", QUrl::TolerantMode)); + +} From 8c973e7187034a2fb3c19825a4844bf7e520dbb6 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:41:29 -0400 Subject: [PATCH 461/469] Update chatwindowpage.h --- src/qt/chatwindowpage.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/chatwindowpage.h b/src/qt/chatwindowpage.h index 4414e067..a29d2424 100644 --- a/src/qt/chatwindowpage.h +++ b/src/qt/chatwindowpage.h @@ -60,6 +60,7 @@ class ChatWindowPage : public QWidget QMap serveurs; bool joining; void closeEvent(QCloseEvent *event); + void on_pushButton_WebChat_clicked(); }; From df92554efeec6607bc0080aef34f474755a2f3f2 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 13:42:48 -0400 Subject: [PATCH 462/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index f21b2a07..91646076 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -256,14 +256,49 @@ font-size: 11px; - 20 - 350 - 521 - 81 + 200 + 380 + 181 + 61 - <html><head/><body><p>To Chat on Web, Go to <a href="https://webchat.freenode.net/"><span style=" text-decoration: underline; color:#0000ff;">https://webchat.freenode.net/</span></a></p><p>Enter your Nick</p><p>Enter #HTHWorld as Channel</p></body></html> + <html><head/><body><p>Enter your Nick</p><p>Enter #HTHWorld as Channel</p></body></html> + + + + + + 30 + 390 + 120 + 30 + + + + + 100 + 30 + + + + + 120 + 30 + + + + Visit HTH Partners and Donate Today!!!!!!!! + + + border-style: solid; +border-width: 2px; +border-color: #34bcaa; +border-radius: 10px; +font-size: 11px; + + + #HTHWorld From 4fc4890978cad7dc7226c7f4b7cd38661c3acc40 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 14:03:43 -0400 Subject: [PATCH 463/469] Update chatwindowpage.ui From 01e41e0d006f6c51ff0dec47a5f8a3e81d345ea9 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 14:08:19 -0400 Subject: [PATCH 464/469] Update chatwindowpage.cpp --- src/qt/chatwindowpage.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/qt/chatwindowpage.cpp b/src/qt/chatwindowpage.cpp index d2f55016..e4b3ee5c 100644 --- a/src/qt/chatwindowpage.cpp +++ b/src/qt/chatwindowpage.cpp @@ -196,6 +196,12 @@ void ChatWindowPage ::setModel(ClientModel *model) this->model = model; } +void ChatWindowPage::on_pushButton_WebChat_clicked() { // #HTHWorld Chat + + QDesktopServices::openUrl(QUrl("https://webchat.freenode.net//", QUrl::TolerantMode)); + +} + ChatWindowPage::~ChatWindowPage() { @@ -213,10 +219,3 @@ ChatWindowPage::~ChatWindowPage() } } } - - -void ChatWindowPage::on_pushButton_WebChat_clicked() { // #HTHWorld Chat - - QDesktopServices::openUrl(QUrl("https://webchat.freenode.net//", QUrl::TolerantMode)); - -} From 8ea4a961757d9a86da568fb7c83a1340bbd79898 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 14:09:34 -0400 Subject: [PATCH 465/469] Update chatwindowpage.cpp --- src/qt/chatwindowpage.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qt/chatwindowpage.cpp b/src/qt/chatwindowpage.cpp index e4b3ee5c..2791a83f 100644 --- a/src/qt/chatwindowpage.cpp +++ b/src/qt/chatwindowpage.cpp @@ -30,6 +30,9 @@ ChatWindowPage::ChatWindowPage(QWidget *parent) connect(ui->actionCloseTab, SIGNAL(triggered()), this, SLOT(closeTab())); connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(sendCommande())); + + + ui->pushButton_WebChat->setStatusTip(tr("Visit Help The Homeless Worldwide Web Chat")); From 3ef8171053b387572c211f1f47a12d149e8d29e4 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 14:13:23 -0400 Subject: [PATCH 466/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index 91646076..4c061627 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -270,7 +270,7 @@ font-size: 11px; 30 - 390 + 400 120 30 @@ -288,7 +288,7 @@ font-size: 11px; - Visit HTH Partners and Donate Today!!!!!!!! + Visit HTH World Web Chat border-style: solid; From d2c1c12dc869499c81ea752a66e982b8cebe293f Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 14:15:33 -0400 Subject: [PATCH 467/469] Update chatwindowpage.cpp --- src/qt/chatwindowpage.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/qt/chatwindowpage.cpp b/src/qt/chatwindowpage.cpp index 2791a83f..87bff742 100644 --- a/src/qt/chatwindowpage.cpp +++ b/src/qt/chatwindowpage.cpp @@ -17,6 +17,13 @@ #include "chatwindowpage.h" #include "ui_chatwindowpage.h" +#include +#include +#include +#include +#include +#include + ChatWindowPage::ChatWindowPage(QWidget *parent) : QWidget(parent), ui(new Ui::ChatWindowPage) { From 0e7fa5451a1dd19d007f948dc2cc088b770fd195 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 14:17:15 -0400 Subject: [PATCH 468/469] Update chatwindowpage.h --- src/qt/chatwindowpage.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qt/chatwindowpage.h b/src/qt/chatwindowpage.h index a29d2424..2beba14b 100644 --- a/src/qt/chatwindowpage.h +++ b/src/qt/chatwindowpage.h @@ -22,6 +22,10 @@ #include "clientmodel.h" #include "serveur.h" +#include +#include +#include + namespace Ui @@ -60,6 +64,8 @@ class ChatWindowPage : public QWidget QMap serveurs; bool joining; void closeEvent(QCloseEvent *event); + +private Q_SLOTS: void on_pushButton_WebChat_clicked(); }; From a0165b255399d321b184eaef6234d17745dbd502 Mon Sep 17 00:00:00 2001 From: devilking6105 <43361618+devilking6105@users.noreply.github.com> Date: Thu, 4 Jun 2020 14:20:02 -0400 Subject: [PATCH 469/469] Update chatwindowpage.ui --- src/qt/forms/chatwindowpage.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/forms/chatwindowpage.ui b/src/qt/forms/chatwindowpage.ui index 4c061627..663f0ba3 100644 --- a/src/qt/forms/chatwindowpage.ui +++ b/src/qt/forms/chatwindowpage.ui @@ -258,7 +258,7 @@ font-size: 11px; 200 380 - 181 + 231 61